Skip to content

Keep completed chat turns completed across cold restarts - #68

Merged
MiguelsPizza merged 2 commits into
mainfrom
alex/persist-before-chat-done
Sep 15, 2026
Merged

MiguelsPizza merged 2 commits into
mainfrom
alex/persist-before-chat-done

Conversation

@MiguelsPizza

@MiguelsPizza MiguelsPizza commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

A browser restart immediately after a completed answer could trigger another model inference. Rook found this while upgrading a real Web Store 1.1.0.509 profile during release verification for Rook #166.

Think announced completion before committing the assistant message, then discarded the terminal stream while the enclosing recovery task could still be running. Move completion after persistence and retain the existing terminal stream until the next stream start reclaims it. This uses the existing discard: false cutover; it adds no storage shape, migration, timer, or recovery protocol. Exceptional terminal delivery and reconnect replay remain covered.

The new native regressions failed on the old behavior: both transports announced completion with zero durable assistant rows, and recovery of a real completed turn scheduled an extra continuation. The production upgrade regression additionally counts model requests, so duplicate inference cannot hide behind transcript reconciliation.

Validation: SDK exports, formatting, lint and type checks passed; all 679 Think tests passed with retries disabled. Rook ran 18 production-artifact checks, including three fresh-profile runs and three upgrades from Web Store 1.1.0.509, each with two cold restarts and exactly two model requests. The immutable SDK candidate is built from this commit. Full SDK repository CI passed. Rook adoption CI remains a release gate. Source ownership and the superseded immediate-discard policy are recorded in the fork inventory.

Consumer adoption: Rook #167. Merge this SDK owner change before the consumer release follow-up.

After durable commit, Think closes the observer stream before broadcasting the canonical transcript, so observers retain terminal activity duration/status and normalized message parts. Both transports assert the frame order; all four affected Chrome regression cases pass with retries disabled. The earlier rook-sdk-84c41693a052 candidate is withdrawn.

A cold restart can interrupt the enclosing recovery task after its answer commits. Retain the existing terminal stream through that window and announce completion only after persistence, so waking the task cannot infer another answer. The next turn already reclaims terminal streams.
@MiguelsPizza
MiguelsPizza marked this pull request as ready for review September 14, 2026 15:34
@MiguelsPizza
MiguelsPizza marked this pull request as draft September 14, 2026 15:46
Persistence must precede completion, but the observer accumulator still needs done before the canonical snapshot. Keep that wire order so stopping a turn preserves its elapsed label instead of replacing metadata with the final accumulator merge.
@MiguelsPizza
MiguelsPizza marked this pull request as ready for review September 14, 2026 21:47
@MiguelsPizza
MiguelsPizza merged commit c24ff4b into main Sep 15, 2026
1 check passed
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