Repository navigation
refactor(native-chat): give each structured dispatch state exactly one meaning - #20133
Merged
Merged
Conversation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ELI5
When a message can't be sent, Orca now says which of two things happened — "it definitely didn't go" or "I genuinely can't tell" — instead of saying "I can't tell" for both. That matters because Retry is safe in the first case and dangerous in the second.
The critical change, in one sentence
Retry's safety stops depending on a list being correct, and starts depending on the state itself.
Before, every failed send landed in one state —
unknown, "delivery in doubt" — and Retry consulted a lookup of reasons to decide whether re-delivering that particularunknownwas safe:That is a runtime judgement call standing in front of a duplicate-delivery hazard. It is only safe while the list is right, and nothing fails when somebody adds a new reason and forgets it.
After, the one case that was provably safe is not an
unknownat all — a write the agent's input pump never took resolvesrejected, because "provably did not happen" is whatrejectedalready means. With that case gone, the allowlist has no entries left and is deleted. Retry's rule becomes unconditional:Re-sending after a
rejectedis safe by construction rather than by permission: it goes out under a fresh client message id, so it is a new message and cannot duplicate an old one.That is the whole change. A judgement call became a structural invariant. Everything below — the copy fixes, the mobile fixes — follows from the states now meaning one thing each.
What you see today vs after
Case A — the agent's input pipe breaks (agent crashed, was killed, restarted). The message provably never left your machine.
provider_write_failed: broken pipein redToday that red line is an internal identifier on your screen. There is nothing you can do with it, and the Retry button next to it is inert.
Case B — Orca genuinely can't tell (host restarted mid-send, ack lost). The agent may or may not have it.
Unchanged on purpose: still "Message delivery is unconfirmed.", still refuses to re-deliver. That refusal is the point — see Why.
On mobile. Today, a send whose outcome is unknown reports as sent: the composer clears your draft and the message looks delivered. After: it reports unknown, keeps your draft, and says "Delivery unconfirmed — check chat before retrying."
Why
Retry used to re-deliver messages that had already reached the model. In one measured session a single message reached the model five times. The root cause was fixed in #19863 (a 10-second timer that declared healthy sends "unconfirmed" — 25% of all sends tripped it). This PR fixes the state model underneath it.
unknownmeant five different things, only one of which was real ambiguity. A one-entry allowlist then existed to teach Retry that one particularunknownwas safe. That is a judgement call sitting in front of a duplicate-delivery hazard.Moving the provable case to
rejecteddeletes the allowlist and makes it an invariant: Retry never re-delivers anunknown, no exceptions to reason about. The asymmetry justifies being strict — refusing a legitimate retry costs you a retype; allowing a bad one silently puts a second copy of your message in the model's context, where you won't see it.Four states, one meaning each:
pendingacceptedrejectedunknownWhat changed in the code
rejectedinstead ofunknown.performSendcannot re-deliver anunknownat all.Review history worth knowing
A mid-review commit made mobile rotate its operation id on unknown, which host-side is a second dispatch — the exact defect this PR removes, reintroduced on another surface. It was caught, reverted, and the guard restored with a test that fails against the pre-fix code. The mobile send fixture was also replaced: it returned a shape that structurally could not express this bug, which is why the inversion passed review.
Testing
pnpm tcclean. Affected suites green; mobilesrc/session160 files / 1511 tests. Every new test ablated — including an arm running the production file at the pre-fix commit with the new tests kept, which fails.One pre-existing failure,
claude-structured-real-cli.test.ts, verified to fail identically on plainmain.Visual proof
The only user-visible change is copy, tabulated above. Not run in the app — flagging that rather than claiming N/A.
Notes
dispatchStateenum — no new value, no codec change, no capability gate. Verified against shipped code: the id-rotatingrejectedbranch predates fix(native-chat): settle a structured send on admission, not on the provider echo #19863, so already-shipped clients handle it.unknownby a dead child or host restart still has no recourse but retyping. feat(native-chat): decide a restart-stranded send against provider history #20139 is the fix for that.journal-reducer.tsis at 299 of its 300 counted lines. The next statement added there needs a split, not a shave.