Skip to content

fix(dashboard): keep a switched variant on bounded transcript reads - #31970

Merged
KiroCrewCaptain merged 1 commit into
mainfrom
fix/7526-bounded-read-keeps-variant
Nov 7, 2026
Merged

KiroCrewCaptain merged 1 commit into
mainfrom
fix/7526-bounded-read-keeps-variant

Conversation

@bolichen97

Copy link
Copy Markdown
Contributor

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

  • The length half of Bounded slot-detail read cannot reconcile disk history with the live slot window #7526 (disk rows in the window's region that the window does not hold). That shape is another writer's append as often as a deleted tail, and the bounded read keeps showing it. Regenerate already commits its rewrite before it drops rows from the window, so its failed save no longer leaves a deleted tail behind. Its two strict-xfail tests stay red.
  • Id-less (legacy) transcript regions: the ordered body walk is unchanged.
  • 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.mid inside 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_offset in dashboard/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 with limit, and the bounded and no-limit reads agreeing on it).
  • Same file, 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).
  • Same file, 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, while prove.py cannot list it because main serves disk copies too.
  • The two length tests keep the marker; its reason names what keeps them red.

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 -n0 and 10 times at -n 4 --dist loadgroup --max-worker-restart=2 beside test_dashboard_chat_pagination_suffix.py and test_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

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

@bolichen97
bolichen97 requested review from a team and KiroCrewCaptain as code owners November 7, 2026 01:42
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 7, 2026
@bolichen97
bolichen97 enabled auto-merge (squash) November 7, 2026 01:44
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Nov 7, 2026
@bolichen97
bolichen97 force-pushed the fix/7526-bounded-read-keeps-variant branch from 0eeb71c to 836d322 Compare November 7, 2026 03:59
@bolichen97

Copy link
Copy Markdown
Contributor Author

Rebased: main moved in docs/system-specs/modules/history.md since this head went green (678769e -> e6524c8); CI re-running.

[operator: bolichen97]

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
@bolichen97
bolichen97 force-pushed the fix/7526-bounded-read-keeps-variant branch from 836d322 to f016d9f Compare November 7, 2026 06:54
@bolichen97

Copy link
Copy Markdown
Contributor Author

Rebased: main moved in docs/system-specs/modules/history.md since this head went green (e6524c8 -> a3fb5af); CI re-running.

[operator: bolichen97]

@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Nov 7, 2026
@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision f016d9f83fef07f45d12891109ca4dcc378fff93 touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Does not block merge.

@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of f016d9f83fef07f45d12891109ca4dcc378fff93 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of f016d9f83fef07f45d12891109ca4dcc378fff93 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

First-Principles-Verdict: PASS

Nothing to check.

What this change ships

Inventory (5 items) — 5 justified

Intent: 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.

  1. A bounded read (indexed page or full-reader fallback) now shows the window's copy of a row whose id appears once on disk, so the switched variant stays on screen — justified
  2. When disk holds the same id more than once, the read keeps serving both disk copies — justified
  3. A no-limit read of a chain that rotated mid-chain gets the same window-copy rule — justified
  4. The two length tests from Bounded slot-detail read cannot reconcile disk history with the live slot window #7526 stay strict-xfail, with a reason that names what keeps them red — justified
  5. The history spec gains a paragraph on which copy a matched row is served from — justified

[FIRST-PRINCIPLES-REVIEWED] f016d9f

Description read

[DESCRIPTION-READ] d89f3a052c22f0c79936986e6b115217e296b46d82fed56a04f79558b9d826ae

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of f016d9f83fef07f45d12891109ca4dcc378fff93 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] f016d9f

False positive or not applicable? A repository writer can comment:
/ai-review override gpt f016d9f83fef07f45d12891109ca4dcc378fff93 false-positive: <reason, 20 to 500 characters>

@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed f016d9f83fef07f45d12891109ca4dcc378fff93 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] f016d9f

Verdict parsed from the review's SHA-scoped output markers for commit f016d9f83fef07f45d12891109ca4dcc378fff93.

False positive or not applicable? A repository writer can comment:
/ai-review override fable f016d9f83fef07f45d12891109ca4dcc378fff93 false-positive: <reason, 20 to 500 characters>

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Nov 7, 2026

@KiroCrewCaptain KiroCrewCaptain left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved for the on-call. Review lanes pass on f016d9f, no conflict, no open change request.

@KiroCrewCaptain
KiroCrewCaptain merged commit fd51cbc into main Nov 7, 2026
97 checks passed
@KiroCrewCaptain
KiroCrewCaptain deleted the fix/7526-bounded-read-keeps-variant branch November 7, 2026 07:40
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Nov 7, 2026
buluoray pushed a commit that referenced this pull request Nov 8, 2026
…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)
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.

2 participants