Repository navigation
fix(dashboard): keep the open-tab reopen seed across restarts (release/0.8.0) - #17233
Conversation
The periodic flush loop is armed before the startup open-tab restore, so a flush firing in the pre-restore gap snapshotted an empty/partial open_slots.json over a good seed, dropping idle sessions into "older sessions" after a restart. Before the restore latch flips, _persist_open_slots now MERGES the on-disk seed into the live keys instead of pruning, so a pre-restore crash keeps both the seeded tabs and any boot-time tab; the sibling _persist_context_snapshots writes the union (no prune) in the same window. A transient seed read failure (e.g. a Windows sharing violation) now SKIPS the whole write rather than merging an empty read, preserving the seed for the next flush. The open_slots_restored latch, set by both restore drivers on every exit, flips the writers back to pruning once the live set is authoritative. Covered by two-boot / pre-restore-crash / transient-read-failure regression tests. Co-authored-by: kirocrew-agent <agent@kirocrew.local> (cherry picked from commit c4fd3a4)
Design Review (Fable 5) — ✅ PASSDesign-level review of Design-Verdict: PASS Verify the hand-resolved spec conflict in learn-cron-dashboard.md carries main's two sentences verbatim — the only hunk of this cherry-pick that was merged by hand. [DESIGN-REVIEWED] a8958c4 |
First Principles Review (Fable 5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Verify the "3 failed on release tip What this change shipsInventory (7 items) — 7 justifiedIntent: FIX — backport #15735 so a restart on 0.8 no longer drops idle sessions into "older sessions" or zeroes every context meter (fixes #15719; failing-on-base tests named).
[FIRST-PRINCIPLES-REVIEWED] a8958c4 |
GPT 5.6 Review — 🔴 changes requested (blocking)GPT 5.6 found at least one blocking issue that must be resolved before merging This comment is updated in place on each push. BLOCKING -- src/kiro_crew/dashboard/dashboard_persistence.py:363 -- transient snapshot read failure still destroys saved readings
Adjudication (Opus 5) — is blocking on each finding proportionate?F1 — harm rung: HIGH (saved per-tab context readings for every other tab are replaced by the live subset, with no retry once latched). [ADJUDICATION] a8958c4 total=0 uphold=0 downgrade=0 False positive or not applicable? A repository writer can comment: |
Opus 5 Review — ✅ no blocking findingsReviewed Review detailsNothing blocks; the open-tab persistence latch never flips on the headless API surface, and the edited spec sentence points at a file that does not exist. FINDING — src/kiro_crew/dashboard/dashboard_persistence.py:252 — FINDING — docs/system-specs/modules/learn-cron-dashboard.md:2435 — the changed sentence redirects FINDING — docs/system-specs/modules/learn-cron-dashboard.md:2435 — the same changed line still asserts [OPUS-REVIEWED] a8958c4 Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
…before restore (#18277) _persist_context_snapshots merges context_snapshots.json into memory before it writes. A read that failed with an OSError (a Windows sharing violation) was swallowed to an empty map and latched as loaded, so the next flush replaced the file with only the live readings and destroyed every other tab's saved context reading, with no retry. ensure_context_snapshots_loaded now returns False on an OSError read and leaves the loaded flag unset. The flush skips its write and keeps the map dirty, so the next pass retries against the intact file. This holds before and after the boot restore: after restore an open tab with no fresh reading still has its reading only on disk. Content that was read but does not parse is still merged as empty and latched, so the next write repairs it instead of switching persistence off for good. Follow-up to #15735 and #17233, which apply the same rule to the open_slots.json seed read. Co-authored-by: kirocrewcaptain <kirocrewcaptain@amazon.com>
Problem / Motivation
Goal: On 0.8, a restart keeps idle sessions in the active sidebar list and keeps each session's saved context-window reading, instead of dropping every session into "older sessions" and showing 0% context everywhere.
Backport of #15735 to release/0.8.0. At startup
start_flush_loop()arms the 5s periodic flush before the open-tab restore runs, and several awaits separate the two. A flush landing in that gap sees a_slotsthe restore has not populated yet (empty, or only a tab opened during boot) and writes it overopen_slots.json, so the next restart has an empty or partial seed and every other session lands in "older sessions"._persist_context_snapshotshas the same hazard: it prunescontext_snapshots.jsondown toset(_slots), so once the seeded tabs are gone their stored context readings go with them and each reopened session renders a 0% meter until its next turn.Why it matters
Stable Toolbox users on 0.8.0.x report exactly this after an update or restart: all sessions show 0% context window (used ~0) and the active-session set is gone. Every abrupt restart turns into a tab-by-tab recovery with no context reading to trust.
Not a goal
restore_window_minutesor the "older sessions" grouping.What changed (motivation → approach → change)
src/kiro_crew/dashboard/state.pyopen_slots_restoredlatch, False until the boot open-tab restore has runsrc/kiro_crew/dashboard/chat_persistence.pyfinally(missing file, early return and raise included)src/kiro_crew/dashboard/dashboard_persistence.py_persist_open_slotsMERGES the on-disk seed into the live keys instead of pruning, and skips the write on a transient seed read failure;_persist_context_snapshotswrites the union without pruning in the same window. Both prune as before once restore has runtest/test_open_slots_persistence.py,test/test_context_bar_reopen.pydocs/system-specs/modules/learn-cron-dashboard.mdCherry-pick of
c4fd3a446c. All five source and test files applied cleanly. The one conflict was in the spec: main's hunk sits beside thechat_api/composition paragraph that does not exist on this branch (it came with #16427), so the branch's structure was kept and only the two sentences #15735 changed were applied.Backwards compatibility
Compatible: no field, type, kind or key is rejected, renamed or removed. The change only suppresses two disk writes during a window where their result was never authoritative; the on-disk formats of
open_slots.jsonandcontext_snapshots.jsonare unchanged.Tests
aa37ae70a1):test_two_boot_restart_keeps_idle_sessions_active,test_flush_before_restore_does_not_wipe_seedandtest_context_snapshot_prune_skipped_before_restorefail (3 failed).test_open_slots_persistence.py+test_context_bar_reopen.py: 105 passed, the same count as on main.test_open_slots_persistence.pythat this PR does not touch (identical on main).Manual verification
N/A — the unit tests reproduce the pre-restore flush and the two-boot restart deterministically, which a manual abrupt-restart repro cannot.
Related Issues
Fixes #15719 on release/0.8.0. Backport of #15735.