Preserve exact chat outcomes across stream closure and reattachment - #851
Merged
WaylandYang merged 2 commits intoSep 21, 2026
Merged
Conversation
This was referenced Sep 21, 2026
Maya-Kid
force-pushed
the
fix/chat-stream-terminal-contract
branch
from
September 21, 2026 09:28
23806f3 to
147dba7
Compare
This was referenced Sep 21, 2026
Signed-off-by: dada-yan <BinjunYann@gmail.com>
Maya-Kid
force-pushed
the
fix/chat-stream-terminal-contract
branch
from
September 21, 2026 10:25
147dba7 to
7a3524c
Compare
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.
Latest dev synchronization (2026-09-21)
Based on
dev@474b904dc3e8014d42404a3c067af9906036a953; current head7a3524c605a1982a4a357658e20acd979f9b54f6.Conflict resolution retained both upstream
chat_terminal_testsand this PR’sstream_tests, each behindcfg(test).Revalidated the combined integration tree
6cd976351b4d7cc7389730fce530526f4d197992on isolated Linux PostgreSQL fixtures (all 675 tracked source files hash-matched):cargo test -p utopia-server api::chat::, listed and executed 47 tests. All 37 introduced tests were observed passing: Hand off exhausted tool runs to an evidence-only final answer #845 22, Keep older chat handles from unregistering newer generations #848 1, Publish citation sources added by document reads #849 2, Keep fallback retrieval failures distinct from empty results #850 4, Preserve exact chat outcomes across stream closure and reattachment #851 3, Do not report fallback chat completion when saving fails #852 3, and upstream Assert a chat turn ends in exactly one earned terminal #858 2. No test module was deleted during CI consolidation.The evidence-only handoff core remains frozen. Earlier validation below belongs to its stated historical heads. Automated browser checks do not replace the maintainer's requested visual review.
A normal Chat SSE connection currently invokes onDone twice; error, idle, or unterminated EOF also reaches the unconditional success callback. A reattachment between the server's terminal broadcast and registry removal receives a snapshot without that terminal.
Preserve the first done/error alongside the internal snapshot, under the existing snapshot/subscription lock. Late subscribers receive the unchanged snapshot JSON followed by the same terminal. Finished entries still return idle.
The shared browser consumer accepts one application terminal, reports unterminated EOF as an interruption, treats idle as reattachment-only, and cancels/releases its reader. It handles LF/CRLF/CR, split UTF-8 and multiline data without dispatching incomplete EOF fragments. No POST retry is added.
Validation:
Existing event meanings are restored without new wire fields, durable event storage or cancellation of server generation. Registry ownership (#848) and the history-to-idle handoff are separate fixes.
Additional integration validation: isolated tree
f7bcd0878bf490d6efb122b71d6f13d379df4709combines this change with #845 and the other scoped Chat fixes. Linux Rust fmt, strict workspace Clippy, workspace build and 1,013 tests pass (one pre-existing external-HTTPS RSS test ignored); frontend 129 module tests, 27 real-component browser subtests and build pass. Database/PDF test guards were enabled. This combined result is separate from the standalone checks above.The actual browser/backend integration additionally verifies live reattachment while a local scripted model is gated, the idle/history handoff, and a real fallback assistant INSERT rejection: the browser retains the safe error and generated text after EOF.