Repository navigation
fix(chat): stop completed turn timers and preserve terminal state across races - #169
Merged
Merged
Conversation
Delayed session lists and snapshot reads could overwrite delivered run completion, while initial stream readiness skipped gap repair. Reconcile concurrent entries, guard list writes with request and session revisions, queue hydration repairs, and let terminal turn timestamps stop duration labels. Cover the real HostProvider races with integration regressions.
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.
Summary
Fix a completed assistant turn continuing to show an increasing thinking/response duration until the user sends another message or reloads the chat.
This is a frontend state-reconciliation issue, not evidence that the model is still working. In the investigated incident, the persisted Run had finished after approximately five minutes; a later user message made the old duration snap back to that recorded value.
Reproduced causes
The regression tests render the real
HostProviderwith the real event dispatcher and transcript store; only Host network responses are controlled.runningstatus. Older lists can also overtake newer ones, or incorrectly clear a newly started Run.readSessioncan return an older snapshot afterrun_completedwas delivered, replacing the live transcript and losing its terminal entry.These races are deterministically reproduced. Without a historical browser/network trace, we cannot establish which race triggered the original incident.
Changes
Validation
Rebased onto current upstream
master(aa8548e).pnpm run test:frontend: 759 passed across 146 files.pnpm exec vp check: formatting, lint and types passed without warnings.pnpm run slop-check: passed.pnpm run build: passed (bundle-size advisory only).git diff --check.Additional regressions cover completion, failure, abort/interruption, a new Run after completion, live deltas during reads, ongoing tool turns, initial-read gaps, queued repair reads, retry state, and model/reasoning metadata changes. Before the fix, integration regressions failed on the actual state-overwrite paths. A local replay using only redacted lifecycle metadata confirms that a completed turn stays stopped at its recorded duration even with a stale busy flag.
Deployment / review
No production deployment, server restart, account change, or chat mutation was performed. This PR is for maintainer review and normal release integration. No private chat contents, account identifiers, server credentials, or raw production artifacts are included.