Repository navigation
fix(dashboard): keep a switched variant on bounded transcript reads - #31970
Conversation
0eeb71c to
836d322
Compare
A bounded slot-detail read served the disk copy of every row it matched to the live window by id, so an in-place edit the save had not flushed yet (a variant switch whose save failed and waits for the next flush) repainted the text the user had just switched away from. The no-limit read serves the window and showed the right text, so the two disagreed. The id walk now serves the window's copy of a row it matched, when the id appears once in the disk region; a repeated caller-supplied id keeps the disk copies. Rows disk holds that the window does not (another writer's append) stay where disk put them, so row counts, total and next_before do not change. Part of #7526
836d322 to
f016d9f
Compare
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: the bounded page now serves the window's copy of a row it has already matched, which is the copy the no-limit read already serves. Rows outside the window keep the disk copy. [DESIGN-REVIEWED] f016d9f Description read[DESCRIPTION-READ] ce70f438b043c9144cda9e7bfe557529b57753bdfb2285e5ae7e82fce71257a2 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 |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing to check. What this change shipsInventory (5 items) — 5 justifiedIntent: after a user switches a reply's variant, a bounded transcript refresh should keep showing that choice, not the disk copy left behind by a failed save. FIX.
[FIRST-PRINCIPLES-REVIEWED] f016d9f Description read[DESCRIPTION-READ] d89f3a052c22f0c79936986e6b115217e296b46d82fed56a04f79558b9d826ae That sha256 names the PR description this verdict read. 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: |
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Approved for the on-call. Review lanes pass on f016d9f, no conflict, no open change request.
…31970) A bounded slot-detail read served the disk copy of every row it matched to the live window by id, so an in-place edit the save had not flushed yet (a variant switch whose save failed and waits for the next flush) repainted the text the user had just switched away from. The no-limit read serves the window and showed the right text, so the two disagreed. The id walk now serves the window's copy of a row it matched, when the id appears once in the disk region; a repeated caller-supplied id keeps the disk copies. Rows disk holds that the window does not (another writer's append) stay where disk put them, so row counts, total and next_before do not change. Part of #7526 (cherry picked from commit fd51cbc)
Problem / Motivation
Goal: A bounded transcript read shows the reply variant the user switched to, never the one disk still holds until the next save lands.
Switching a regenerated reply's variant edits that row in the live window first and then saves. When the save fails it reports success and leaves the retry to the periodic flush, so for a while the window holds the chosen variant and disk holds the old one. Every bounded read in that gap (the pane refresh, the background warm on each reconnect) served the disk copy and repainted the variant the user had just switched away from. The no-limit read served the window and showed the right text, so the two reads disagreed.
Why it matters
The user's explicit choice is silently undone on screen, and it comes back or goes away depending on which read ran last. Most dashboard refreshes now take the bounded read, so this is the read users see.
Not a goal
total,next_before, fork indices and the client's cursor math: no row is added, dropped or moved.What changed (motivation → approach → change)
A bounded slot-detail read builds its page from disk and adds the window rows disk does not have yet. To decide which window rows are already on disk it matches them by
meta.midinside the window's region, and for a matched row it served the disk copy. A row edited in place but not yet saved therefore read back stale.The match already says which window row and which disk row are the same message, so the page now serves the window's copy of a matched row, the same copy the no-limit read serves. This applies only when the id appears once in that disk region: a repeated id (ids are caller-supplied) keeps the disk copies, since there the pairing is a guess. Disk rows no window row matches stay where disk put them, so another writer's append still shows.
The change is one function,
_append_unflushed_tail_from_offsetindashboard/chat_api/slot_detail.py. Its three callers all get the rule: the indexed bounded page, the bounded full-reader fallback, and the no-limit read of a chain with a mid-chain rotation. The history spec describes the rule.Backwards compatibility
Compatible: every row the page served before is served at the same index; only which copy of a row both stores hold is served, and the renderer redacts either copy the same way.
Removes nothing: no row, field or route is removed; the page's row count is unchanged.
Tests
test/test_slot_detail_disk_window_authority.py: the two content tests from the test(chat): ratchet the bounded slot-detail disk-vs-window disagreement #8650 ratchet lose their strict-xfail marker and pass (a variant switch read withlimit, and the bounded and no-limit reads agreeing on it).test_indexed_page_serves_the_selected_variant: the switch on a real saved transcript, read through the indexed page (the full reader is made to fail, so the test proves which path served it).test_a_foreign_row_sharing_the_id_is_still_served: disk holds the window row's id twice (another writer's row and the row's own copy), and both disk rows are served. It pins the once-only rule: with that check removed it fails, whileprove.pycannot list it because main serves disk copies too.Proof: PROVEN test/test_slot_detail_disk_window_authority.py::TestContentDisagreement::test_bounded_read_returns_the_selected_variant, test/test_slot_detail_disk_window_authority.py::TestContentDisagreement::test_both_branches_agree_on_content, test/test_slot_detail_disk_window_authority.py::TestContentDisagreement::test_indexed_page_serves_the_selected_variant (head 0eeb71c)
Determinism: the file ran 20 times at
-n0and 10 times at-n 4 --dist loadgroup --max-worker-restart=2besidetest_dashboard_chat_pagination_suffix.pyandtest_slot_detail_delta.py, all green, plus one shuffled order (seed 25997), green. The related backend set (2282 tests) passes locally.Manual verification
N/A: the tests drive the real handler through an aiohttp client on a real saved transcript, which is the path a refresh takes.
Screenshots / video
N/A: no frontend file changes; the page carries the same rows, with the text the window already shows.
Related Issues
Part of #7526
Sibling sweep
Swept: git grep -nE "_append_unflushed_tail|read_messages_chained_full" -- src/kiro_crew/dashboard
Sibling: src/kiro_crew/dashboard/chat_api/slot_detail.py:957 -- changed here
Sibling: src/kiro_crew/dashboard/chat_fork.py:1031 -- not affected -- the fork saves the window before it reads disk and aborts when that save fails
Sibling: src/kiro_crew/dashboard/chat_api/resume_window.py:23 -- not affected -- it serves the disk prefix plus the window, so the window already wins
Pattern harvest
Not generalizable: the defect is which side of one existing id match a single reconciliation helper served, not a shape that recurs elsewhere.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)