fix(web): finish local prompt state from session snapshot after a reconnect - #1572
Merged
Conversation
🦋 Changeset detectedLatest commit: c8ed644 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
commit: |
wbxl2000
force-pushed
the
fix/web-prompt-finish-on-snapshot
branch
from
July 12, 2026 10:50
9ef18ec to
c8ed644
Compare
This was referenced Jul 12, 2026
Merged
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.
Related Issue
No linked issue — the problem is explained below.
Problem
In the web UI, a turn that finishes while the client is disconnected (laptop
closed, backgrounded tab, network drop) can leave the session stuck: the
working spinner never stops and the next message is queued behind a turn that
already ended.
The missed turn end is normally recovered by durable-event replay on
reconnect, but not when the client rebuilds from a session snapshot instead —
server-initiated resync (buffer overflow / epoch change / delta gap) or an
LRU-evicted subscription rebuild. Local prompt state (in-flight flag, sending
flag, cached prompt id, the message queue) was only ever cleared by the WS
sessionStatusChangedidle/aborted event, and snapshots never delivered one.What changed
Web-only fix; no server, protocol, or UI style changes.
useWorkspaceState) is now entered by every local turn start: promptsubmit, steer, and skill activation. A snapshot requested before or during
a turn start can tell it cannot reflect that turn.
syncSessionFromSnapshotrejects a snapshot that predates a local turn(or raced one) and re-syncs once the turn start settles, instead of
permanently ignoring it. Snapshots that fall behind the live cursor during
the fetch are dropped (one retry) rather than applied — resync/LRU rebuilds
still always apply because their projector was deliberately reset.
inFlightTurn === null, status idle/aborted), it finishes the local prompt state through thesame cleanup the WS idle path uses (
finishPromptLocal), without firingcompletion notifications/sounds — opening a historical session must not cry
wolf.
actually advancing, so a late duplicate idle can never drain a second
queued message.
window focus/onlinealso trigger the existing stale-socket recovery(previously only
visibilitychange); recovery still only reconnects whenthe socket actually looks stale.
Tests cover the snapshot finish path, the running/awaiting cases, the
new-prompt-during-fetch and submit-pending rejections, and the settle
callback retry.
Checklist
gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.