Skip to content

fix(mobile): a reply still being written is not drawn as finished - #1344

Merged
huichen merged 2 commits into
mainfrom
pr/huichen
Oct 25, 2026
Merged

huichen merged 2 commits into
mainfrom
pr/huichen

Conversation

@huichen

@huichen huichen commented Oct 25, 2026

Copy link
Copy Markdown
Collaborator

What and why

The sync lane treated get_state.activeRun as 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 typed interruptedRun, 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

  • fix(mobile): a reply still being written is not drawn as finished — require the host registry and a whole-run log read to agree before settling a reply; type interruptedRun on RemoteSessionState

Verification

  • npx tsc --noEmit in packages/remote-client — clean
  • npx eslint src tests in packages/remote-client — clean
  • npx jest --runInBand in packages/remote-client — 31 suites / 667 tests passed
  • npx tsc --noEmit in packages/remote-protocol — clean
  • npx tsc --noEmit in mobile (Node 22, the CI line) — clean
  • npx jest --runInBand src/remote src/features/chat in mobile (Node 22) — 79 suites / 1682 tests passed

Notes

  • RemoteSessionState.interruptedRun is additive and optional; an older host omits it, and the lane then falls back to the log read alone.
  • Behaviour change: a get_state with no activeRun no longer settles a reply whose whole-run log carries no agent_end. A run that died mid-flight still settles, because the host reports it as interrupted.

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.
@huichen
huichen enabled auto-merge (squash) October 25, 2026 01:18
@huichen
huichen merged commit 7c08d14 into main Oct 25, 2026
14 checks passed
@huichen
huichen deleted the pr/huichen branch October 25, 2026 01:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant