Skip to content

fix(web): settle first turns recovered before the create response - #1809

Merged
chuks-qua merged 4 commits into
mainfrom
fix/recovered-creation-runtime
Oct 6, 2026
Merged

chuks-qua merged 4 commits into
mainfrom
fix/recovered-creation-runtime

Conversation

@chuks-qua

@chuks-qua chuks-qua commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

What

The composer and project tree could stay on "running" forever after a new thread's first turn ended. This happened after a failed turn and after a completed one.

When the server's thread-startup binding push arrives before the create-and-send response, the client recovers the new thread from the thread list. That path skipped the runtime snapshot the response carries. The thread record stayed running with no execution ID, so the turn's terminal event could never correlate to it. This is likely right after a server restart, when the server is slower.

  • Recovery now reads the server's runtime snapshots with the thread list and applies the thread's snapshot before the placeholder transfer, as the response path does.
  • When the server has no runtime for the thread yet, the transfer starts idle, and the turn's canonical events claim and settle the record.
  • Every transfer reconciles the persisted record against the canonical replica, which settles a turn whose terminal arrived first.

Verified on the worktree runtime by restarting the server, then failing a Claude first turn through the composer, with a client store dump at the end:

  • Before: stuck on Stop in 3 of 4 production-build runs and 1 of 5 dev-build runs. The record was running with turnExecutionId: null while the canonical turn was Errored.
  • After: 7 of 7 dev-build runs settled, with a matching execution ID. One more run failed in the harness before sending.
  • Three new store tests fail before the fix and pass after. 102 web test files pass, and web typecheck and repo lint pass.

Why

A turn that had ended still looked like it was running. That blocked the composer and left a false activity dot in the project tree.

Review Notes

When recovery finds no runtime snapshot, the composer shows Send for about 0.5 s until the turn's canonical events claim the record. That happened in 5 of 7 runs. Removing it would mean letting a running record with no identity claim a canonical turn, which breaks the existing guard that an older turn must not cancel a newer pending send.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

Before: turn failed on the server, composer stuck on Stop and Thinking

After: failed first turn settles and the composer returns to Send

When the thread-startup binding push arrives before the create-and-send
response, the client recovers the new thread from the thread list. That
path skipped the runtime snapshot the response carries, so the record
stayed running with no execution identity. The turn's terminal event
could never correlate to it, and the composer and project tree kept
showing the turn as running.

Recovery now reads the server's runtime snapshots with the thread list
and applies the thread's snapshot before the placeholder transfer, as
the response path already does.
A recovered thread could still end up running with no execution
identity. Recovery may run before the server lists the turn's runtime,
and a stale running snapshot can land after the turn's terminal event.

Recovery without a snapshot now transfers the placeholder as idle, so
the turn's canonical events claim and settle the record. Every transfer
reconciles the persisted record against the canonical replica, which
settles a turn whose terminal arrived first.
@chuks-qua
chuks-qua force-pushed the fix/recovered-creation-runtime branch from bf75b5e to 72a54da Compare October 6, 2026 17:50
@chuks-qua
chuks-qua merged commit e6999d7 into main Oct 6, 2026
6 checks passed
@chuks-qua
chuks-qua deleted the fix/recovered-creation-runtime branch October 6, 2026 17:58
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