fix(chat): emit one earned terminal per turn - #903
Conversation
c789589 to
c7cca9e
Compare
WaylandYang
left a comment
There was a problem hiding this comment.
The ProducerEvent split is the right shape for #857's step 3: every producer exit path I traced (size limit, model error, cancelled-then-answer, fallback, empty answer, save failure, success) now yields an outcome and the spawn loop emits exactly one terminal, with Closed-without-terminal correctly surfaced as an error given how live::emit freezes the snapshot. Two changes before merge:
- Drop commit
b8fec3d2(vector index drop/build lock incrates/utopia-store/src/vector_index.rsand its test) into its own PR. It is unrelated to #857 and undocumented here; it looks reasonable on its own and deserves its own description. - The terminal table in
chat_terminal_tests.rslost itspendinglist and the injection-point section without gaining rows. The targeted tests do exist on dev (chat_persistence_tests.rs,chat_fallback_tests.rs,chat_registry_tests.rs), so either add the rows or name those tests in the comment so the table stays the place reviewers look.
Optional: make Progress a type that cannot hold a terminal event (today a done frame sent as progress is only caught at runtime), and put the saved message id on done so a client can verify the "earned" claim. The parser swap and its CR/CRLF tests look good.
Signed-off-by: Floating-Y <118035379+Floating-Y@users.noreply.github.com> Signed-off-by: Wayland Yang <wayland0916@gmail.com>
|
Applied the two review points as maintainer edits so this can land; your commit and sign-off are kept, mine is added.
Locally on a fresh database: the 48 chat tests pass, clippy is clean, and the web suite (135 tests) and build pass with the pinned |
b8fec3d to
4dab0d6
Compare
WaylandYang
left a comment
There was a problem hiding this comment.
Both review points applied: the vector-index commit is #908 on its own, and the terminal table names the targeted test files; 48 chat tests, clippy, and the web suite pass locally; CI green. Approving to clear the earlier request-changes.
Addresses #857
This PR follows the direction proposed in #857: it uses
eventsource-parserfor client SSE framing and consolidates server terminal emission at the stream boundary.The intent is to make
donedepend on a saved assistant message and to return one terminal event for each stream. I'd appreciate feedback on whether this matches the intended terminal contract, especially for fallback and reconnect paths.Changes
eventsource-parserfor client SSE framing.Validation
cargo fmt --all --checkcargo clippy --workspace --all-targets -- -D warningscargo build --workspacecargo test -p utopia-server api::chat -- --test-threads=1— 48 passedcargo test --workspace --quiet -- --skip gbk_euc_h_pdf_extracts_chinese_text— passedpnpm -C web test— 135 passedpnpm -C web buildThe skipped PDF test requires Poppler, which is unavailable on this Windows host; CI installs it.