Repository navigation
fix(mobile): a reply still being written is not drawn as finished - #1344
Merged
Merged
Conversation
The sync lane read `get_state.activeRun` as the only answer to "is this run still going", and settled every reply when the host did not name one. That is one source, not the only one: the state is a snapshot taken for a single request, so it can answer about a moment the run had not reached yet (a run that registers just after the snapshot, or whose registry entry a restart took with it). Settling on that silence published a live run as finished — on a phone (2026-10-25) a reply with a shell call still running and 36,640 tokens drew its settled footer and folded its answer away into "show process", while the tool row above it still said running. Two independent sources now have to agree that the run is over, and they fail in different ways, which is why neither is dropped: - the host's registry: `activeRun` names the run being worked on, and `interruptedRun` (already on the wire since the durable run lifecycle, now typed on `RemoteSessionState`) names the journal's unterminated run that nobody is working on any more; - the run's own log, as this pass read it: a read from the run's start that came back without an `agent_end` says the run has not finished. Only a whole-run read counts — a tail read proves a suffix, so a lost terminal still settles instead of locking the composer forever. Both directions are pinned: `open`/`reconnect` over a journal with no terminal keep the row streaming (and without it, no record of an end), while a run the host reports as interrupted settles — the shape an agent that died mid-run leaves behind, and the one thing the log alone cannot tell apart from a reply still being written. Folding needs no change: the card already folds only a settled reply, which is why the wrong flag produced both symptoms (finished footer and folded answer). Its assertion was falsified by removing that guard.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
What and why
The sync lane treated
get_state.activeRunas the only evidence that a reply was still being written, so any snapshot that came back without a named active run settled the reply — finished footer, answer folded into "show process" — while its tool rows still said running. On a phone that published a live run (a shell call in flight, 36,640 tokens) as finished.A reply now settles only when two independent sources agree the run is over: the host's registry (
activeRun, plus the newly typedinterruptedRun, which names a journal run nobody is working on any more) and the run's own log, read from the run's start. A tail read proves only a suffix, so it still settles on silence and cannot lock the composer.Commits
interruptedRunonRemoteSessionStateVerification
npx tsc --noEmitinpackages/remote-client— cleannpx eslint src testsinpackages/remote-client— cleannpx jest --runInBandinpackages/remote-client— 31 suites / 667 tests passednpx tsc --noEmitinpackages/remote-protocol— cleannpx tsc --noEmitinmobile(Node 22, the CI line) — cleannpx jest --runInBand src/remote src/features/chatinmobile(Node 22) — 79 suites / 1682 tests passedNotes
RemoteSessionState.interruptedRunis additive and optional; an older host omits it, and the lane then falls back to the log read alone.get_statewith noactiveRunno longer settles a reply whose whole-run log carries noagent_end. A run that died mid-flight still settles, because the host reports it as interrupted.