Repository navigation
fix(dashboard): keep the reply and its footer when a turn ends abnormally - #19984
Conversation
UX Review (Opus 5.5) — ⏭️ skippedRevision |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS On stall, compaction and retry ends, the new What this change shipsInventory (7 items) — 6 justifiedIntent: when a turn ends on an error, a timeout, a stall or a cancel, the user keeps the reply they watched stream, along with its cost, model and actions. This is a FIX (Refs #19855; it widens #17669's Stop-only scope, whose test the description says it replaces).
[FIRST-PRINCIPLES-REVIEWED] e6711d1 Description read[DESCRIPTION-READ] 3d985190d0558d5d85affbe4455086ec77f50c138ac7c6df71663df0cda03021 That sha256 names the PR description this verdict read. Recompute it with |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Check that the recovery continuations (pipe-death requeue, stale/tool-stall) don't regenerate the answer from scratch beneath the partial reply that is now saved permanently. [DESIGN-REVIEWED] e6711d1 Description read[DESCRIPTION-READ] db8d8a36a84bae86f2ceb9f3328a1a09e7b210a4515c763a273b10263217090f That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
9116574 to
6292fd3
Compare
|
self-added: yes
|
|
|
6292fd3 to
c501ce5
Compare
|
|
c501ce5 to
e6711d1
Compare
|
|
|
|
|
i had a fix for #19855 in review when this opened, so i ran my backend tests against this branch and your test files against mine. mine is now up as #20128 and i think it should be the one taken: it covers everything here (your
happy to split #20128 into the backend and frontend halves if you'd rather land it that way, but i'd take it over this one as it stands. |
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Approved after a maintainer read the review notes on this head. The open notes are follow-up polish, not blockers.
Problem / Motivation
Goal: A reply keeps its saved text and its footer (model, credits, elapsed, and its Copy/Fork actions) when its turn ends on an error, a mid-reply 5xx, the time limit, a stall recovery or a prompt timeout.
The line under a reply that names the model, the credits and the elapsed time is missing whenever the turn does not finish normally. In the stall, lost-connection and prompt-timeout cases the text that streamed before the card is not saved as a reply at all, so it has no actions and is gone after a reload.
Why it matters
These ends are common on a busy backend: every capacity blip, stall recovery or timeout leaves a reply with no cost, no model and no actions, and some of them lose the reply text on reload. The credits are still billed and written to the usage row, so the footer and the usage page disagree.
Not a goal
ChatPage.tsx/messageRenderers.tsx). Left for a follow-up; the issue stays open.stop_reason == "timeout") arm, which another open PR adds.What changed (motivation → approach → change)
turn_statssaved; shown once the frontend half landschunkrows, never savedturn_stats; footer shown once the frontend half landsexcept Exception)EVENT_COMPLETE(turn ceiling, late Stop)Root cause:
_record_abnormal_turn_usageindashboard/chat_runner.py, the seam every abnormal end shares, attachedturn_statsonly for a Stop press. The recovery arms and the generic exception arm returned without calling_persist_partial_reply, and the seam's once-per-turn guard returned before any footer whenEVENT_COMPLETEhad already written the row.The seam now attaches a footer on every end with a turn boundary: the completion's own figures (first-token time included) when
EVENT_COMPLETEalready measured the turn, otherwise the one shared provider read. Both the end-of-turn attach and this seam write through_attach_owned_turn_statsinchat_turn/turn_stats.py, one scan narrowed to reply rows this runner appended (slot._turn_reply_mids), so a workflow result that lands in the window mid-turn never takes the turn's figures. The end-of-turn attach keeps the plain boundary scan only for a turn that recorded no reply row (a command's own confirmation)..github/black-baseline.txtdropstest/test_turn_stats.py, which is black-clean now.On the retry ends a continuation reply follows the saved partial, and today's footer rule in
ChatPage.tsxhides a footer whenever another assistant row follows before the next user row. Those rows carry the data now; they show it once the frontend half of #19855 lands. The four recovery arms and the generic exception arm call_persist_partial_reply. A_reply_flushedflag keeps the text to one saved row. The turn-stats-footer spec describes the new rule.Backwards compatibility
Compatible: rows gain
meta.turn_statsand saved replies where they had none; no field, key or caller changes shape.Removes nothing: every existing row, footer and usage row is still written; this only adds the ones that were missing.
Tests
test/test_abnormal_turn_usage_row_15013.py, driving the real_run_chat:TestStoppedTurnFooter::test_an_involuntary_cancel_gets_the_footer_tooreplaces the old pin that an involuntary cancel stays bare.TestAbnormalEndFooterpins the footer after a terminal error, a post-token transient,stale_recoverand tool stall (the text saved once, nochunkrows left), a prompt timeout (plus its usage row), a cancel after completion, a late cancel that keeps the end-of-turn footer whole, a late cancel that leaves another writer's row without the footer, and one saved row when a recovery arm then fails.test/test_turn_stats.py::TestAttachTurnStats::test_reply_mids_skips_a_row_another_writer_appendedpins the narrowed scan, andtest_a_completed_turn_leaves_a_row_another_writer_appended_alonepins it on the end-of-turn attach.The new or changed cases are red without the production change and green on this head. Determinism: the file passed repeat runs and 3 shuffled orders (seeds 1-3),
-n 2and-n0. The backend related set (run_scoped_tests.py --surface backend) passed on this head: 20825 passed, 6 skipped.Manual verification
N/A — unit coverage sufficient: each end is driven through the real
_run_chatwith a fake stream; the frontend reads the samemeta.turn_statsa completed turn writes.Related Issues
Refs #19855
Pattern harvest
Rule candidate: review-prompt
Pattern: an early
returnfrom a turn's end-handling arm skips the end-of-turn persist/attach; every exit path of a turn must go through the one shared save helper.Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)