Skip to content

feat(dashboard): reopen closed sessions with Cmd/Ctrl+Shift+T - #20437

Closed
hungtnvu wants to merge 3 commits into
kirodotdev:mainfrom
hungtnvu:feat/reopen-closed-session
Closed

hungtnvu wants to merge 3 commits into
kirodotdev:mainfrom
hungtnvu:feat/reopen-closed-session

Conversation

@hungtnvu

@hungtnvu hungtnvu commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: Let a user reopen a session they just closed with Cmd/Ctrl+Shift+T, the way a browser reopens a closed tab.

Closing a session is one keystroke (Cmd/Ctrl+W), but undoing an accidental close means opening History, finding the conversation and clicking it. No shortcut or command reopens a closed session, so there is nothing to bind one to either.

Why it matters

Accidental closes are common when working across several sessions from the keyboard, and the recovery path breaks that flow every time. Cmd/Ctrl+Shift+T is the reopen convention in every browser, terminal and editor, so it is the chord users already try.

Not a goal

  • A persistent "recently closed" list that survives a reload. History already covers older sessions.
  • A visible "Recently closed" menu or panel.
  • Changing what closing a session does.

What changed (motivation → approach → change)

New command reopen-chat, in the Actions group of the shortcut registry, so it appears in the Cmd+/ reference and is rebindable in Settings → Shortcuts
Default chord ⌘⇧T on macOS, Ctrl+Shift+T on Windows/Linux, with an Option/Alt+Shift+T alias. Browsers keep Ctrl+Shift+T for themselves, so in a browser tab the alias is the working chord, exactly like New chat and Close session
What it reopens Sessions this tab closed, newest first, up to 20 (website/src/lib/recentlyClosedSessions.ts)
Nothing to reopen The chord shows "No recently closed sessions." instead of doing nothing, through the shell's existing notice: it dispatches setAgentSwitchNotice, the same status card and 6-second expiry that focus mode and a deferred model switch already use for neutral messages. No new state, reducer or component; App.tsx and chatSlice.ts's reducers are unchanged from main
Transcript key The slot payload and the resume response carry history_key, the transcript session key the backend's own slot_history_key rule picks (src/kiro_crew/dashboard/slot_projection.py), unfolded, so a channel session (including a Slack thread whose transcript predates the slack:<ts> key migration) reopens its real transcript
Split View Reopen leaves Split View once the reopened session has taken the view, so it is what the page shows. It passes leaveSplit to resumeFromHistory, which records it on main's existing lastResumeActivation, and the chat page leaves Split View on it the way it already does for a new chat's activation (website/src/pages/chat/page/activeSlotState.ts). Other resumes (History, the command palette) are unchanged
Desktop menu Refresh Token moves off CmdOrCtrl+Shift+T to ⌘⌥T on macOS and Ctrl+Alt+Shift+T on Windows/Linux, so the reopen chord reaches the page. Plain Ctrl+Alt+T is avoided because GNOME and Ubuntu open a terminal on it. The File Explorer's own Cmd/Ctrl+T new-folder-tab shortcut ignores the Shift variant (website/src/apps/file-explorer/FileExplorerPage.tsx), so the chord does not also open a tab there

A close is recorded only when the user closed the session (Cmd+W, the sidebar ✕, a session menu). It is recorded at the press, so Cmd+Shift+T right after Cmd+W finds it and rapid closes keep their press order, and if the server refuses the close, only that close's own entry is dropped, so a refused close is never offered and a later successful close of the same session keeps its entry. Reopen first waits for that close to finish (and, when it was refused, for each older entry it falls back to), so a close still waiting on the next session's transcript cannot clear the reopened one when it lands. Only then does it ask the leave guard, once, against the page on screen at that moment; a declined leave puts the entry back for the next press. If a close is slow, the leave prompt therefore appears after it finishes rather than at the press. Swaps that retire a tab for another one, bulk cleanup and apps closing their own sessions are not user closes and are not recorded. Sessions on a surface the chat page cannot show are skipped. Incognito and temporary sessions are recorded, because their transcript stays in History for the user to reopen (docs/decisions/2026-09-25-incognito-and-temporary-chats-keep-their-transcript.md).

Reopening uses the same resumeFromHistory path as History and the command palette, keyed by the recorded transcript key rather than the dashboard slot key. A session bound to Slack or another channel keeps its transcript under that channel's key, so guessing dashboard:<key> would open an empty session. The key is sent unfolded because ConversationLog._path finds a pre-migration Slack thread's bare <ts>.jsonl only from the slack:<ts> spelling. The backend sends the key it uses (typed in website/src/types/index.chat.ts; the resume response stays untyped like the rest of main's resume thunk, and resumeFromHistory in website/src/store/chat/lifecycle.ts copies its history_key onto the slot row), and the client never guesses one: a slot without history_key is not recorded. The jump to /chat goes through the draft guard (useGuardedLeave), like the notification panel's resume. The session leaves the list only once leaving is allowed, a failed resume puts the same entry back, and a session that is already open again is skipped, matched by slot key or by history_key, so a linked session reopened from History under its folded transcript key counts as open.

In the shortcuts reference (website/src/components/ShortcutsModal.tsx) a combo's keys never split across lines: a row breaks only between combos. From the sm breakpoint up the label stays on one line, with a gap of at least 12px (sm:gap-3) before its keys; below it each row puts a full-width label above its combos, so a narrow window never squeezes the label into a one-word column. The two new strings are in every locale catalog under website/src/i18n and the pseudolocale. website/electron/README.md names the new Refresh Token chords.

Backwards compatibility

Breaking: the desktop app's Connection → Refresh Token menu accelerator moves from CmdOrCtrl+Shift+T to Cmd+Alt+T (macOS) and Ctrl+Alt+Shift+T (Windows/Linux). Writer sweep on origin/main @ 6f92c0e: website/electron/app-menu.js (the only accelerator, moved), website/electron/README.md (updated), website/electron/window-lifecycle.js tray item (no accelerator, unchanged). The Mochi app's own toggleWindow default is a separate global shortcut in its own store and is untouched.

The slot payload's and the resume response's history_key is a new optional field; older clients ignore it, and the client still works against a gateway that omits it. Removes nothing: no command, route, record or setting is removed; one menu accelerator moves.

Tests

  • website/src/test/reopenClosedSession.test.tsx: the stack order, dedupe, cap and filters; the transcript key is the backend's history_key, and a slot without one is not recorded; the chord on both platforms and the alias; Cmd+W then reopen through api.resumeChatSlot; the close is recorded at the press while the DELETE is still pending, and rapid closes keep press order; a refused close is not offered, and a late refusal leaves a newer close of the same session in place; reopen during a close that is still loading the next session's transcript waits for it and the reopened session stays active with its transcript; a leave guard dirtied on another route during that wait is asked once after it, and declining keeps the entry; the same holds when the newest pending close is refused and reopen falls back to an older, already-closed entry; a declined leave keeps the page and the entry; an allowed leave lands on /chat; nothing to reopen sets the shell notice and asks nothing; a failed channel reopen keeps its key for the retry; a reopened session closed again before any slots update is still offered, because resume carries history_key onto its optimistic row; a session already reopened from History under a different slot key is walked past; the reference row keeps each combo's keys together; a held chord's auto-repeats reopen nothing more; reopen asks the page to leave Split View.
  • website/src/test/ChatPageMoreCoverage.test.tsx: a resume with leaveSplit leaves Split View and shows the resumed chat; one without it keeps Split View.
  • website/src/apps/file-explorer/FileExplorerPageCoverage.test.tsx: Cmd/Ctrl+Shift+T on the File Explorer does not open a folder tab, and plain Cmd/Ctrl+T still does.
  • test/test_slot_history_key_projection.py: history_key for a dashboard slot, a linked Slack slot and an unbound channel-origin slot is the unfolded slot_history_key; a pre-migration Slack thread's key resolves to its legacy <ts>.jsonl, and reopening by it through the resume route restores that transcript (fails with the old folded key); the resume response, fresh and already-live, returns the same history_key as the slot list.
  • website/src/hooks/useSessionActions.cov80.test.tsx: a sidebar/menu close is offered once it lands; its deleteSlot mock is thunk-shaped, matching what close dispatches.
  • website/electron/test/app-menu.test.js: Refresh Token is on Cmd+Alt+T / Ctrl+Alt+Shift+T and no menu item claims Shift+T.

Manual verification

Rendered from a production build of this head with website/scripts/capture-shortcuts-registry.mjs, website/scripts/capture-settings-accelerator-caption.mjs (Connection menu built from the real buildMenuTemplate, which also asserts the macOS caption) and a scratch variant of them. Closed and reopened a session with the browser aliases (Alt+Shift+W, then Alt+Shift+T) against the built SPA with a stubbed API: the close sent DELETE chat-2, the reopen sent resume dashboard_chat-2, and the transcript came back. Checked Settings → Shortcuts in browser and macOS desktop hosts, the Cmd+/ reference at 1280px and 360px, the Windows Connection menu, and the chord with nothing to reopen. Typecheck, the website build and the related frontend and backend tests pass locally.

Screenshots / video

Closing "Fix the flaky upload retry test" with Alt+Shift+W, then reopening it with Alt+Shift+T, browser tab at 1440px:

After Alt+Shift+W: the session is gone and Draft the release notes is showing

After Alt+Shift+T: the closed session is back with its transcript

Settings → Shortcuts, browser tab: the new row under Close session, Alt+Shift+T leading and Ctrl+Shift+T marked desktop-app-only.

Settings → Shortcuts, Reopen closed session row, browser tab

Windows Connection menu: Refresh Token on Ctrl+Alt+Shift+T. On macOS the native menu shows ⌘⌥T.

Connection menu with Refresh Token on Ctrl+Alt+Shift+T

Pressing the chord with nothing to reopen shows "No recently closed sessions." in the shell's existing notice. It is the same card a failed agent switch uses, unchanged from main, shown here with the agent-switch message:

Shell notice card at 1440px, unchanged from main

Shell notice card at 390px, unchanged from main

macOS desktop row and the Cmd+/ reference

Settings → Shortcuts, macOS desktop: ⌘⇧T or ⌥⇧T

Shortcuts reference, browser tab, 1280px: Actions group, each label at least 12px from its keys

Shortcuts reference at 360px: full-width label above its combos, each combo on one line

Related Issues

Fixes #18969

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

@hungtnvu
hungtnvu requested review from a team and KiroCrewCaptain as code owners October 14, 2026 19:05
@hungtnvu
hungtnvu requested a review from mbriones98 October 14, 2026 19:05
@github-actions github-actions Bot added readiness: checking Automated validation is still running fork Pull request from a fork (external contributor) labels Oct 14, 2026
@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5, fork) — ✅ PASS (a BLOCK with no Trigger and no Outcome does not block)

UX-level review of 263a99e63c9491c70d177182d11c44d5b734dcc2 via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

UX-Verdict: PASS

cannot evaluate: missing the "No recently closed sessions." notice. The two attached notice screenshots show the card saying "invalid agent name" instead, which is a different message.

Evidence gaps

  • Empty-reopen notice. The diff adds dispatch(setAgentSwitchNotice(i18nT('hooks.useKeyboardShortcuts.no_recently_closed_session'))) → "No recently closed sessions.", but none of the 9 images shows it. attachment-05 (desktop) and attachment-06 (mobile) show the shell notice card with "invalid agent name", so they don't count as evidence for this string. To close the gap, attach desktop and narrow captures of the card showing "No recently closed sessions." after pressing the chord with nothing to reopen.
  • Settings → Shortcuts row. The description says the command can be rebound there, but no image shows the "Reopen closed session" row in that tab. To close the gap, attach a screenshot of that row.

Notes

  • ShortcutRow at sm+ (attachment-08): "Close session" wraps its secondary combo onto a second line, but "New chat" keeps both combos on one line, squeezed up against its label. Rows in the same group break differently, so the key column zig-zags. Make every row in a group wrap the same way, e.g. always put the secondary combo on its own line once any row in the group needs it.
  • In attachment-09 (narrow), the "DESKTOP APP ONLY" tag drops onto a third line by itself under "Reopen closed session", so it's no longer next to the combo it describes. Keep the tag on the same line as the "or Ctrl+Shift+T" combo.

[UX-REVIEWED] 263a99e

Description read

[DESCRIPTION-READ] 277523447cd802e0b7fcc002ad0482ebc4ce24bf865a0c625655fdb2571ca7d5

That sha256 names everything this verdict read: the PR description, plus the 12 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 Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5, fork) — ✅ PASS

Design-level review of 25a04fb9058cb54e443f9e02257626da0098e007 via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing blocks. The design reuses the existing resume path and the backend's own slot_history_key. The one take-away, the Refresh Token accelerator, is listed as Breaking along with its full writer sweep.

Notes

  • The reopen logic is now copied in two places, the closeSlot closures in useKeyboardShortcuts.ts and useSessionActions.ts. Moving that remember/track/forget sequence into one helper in recentlyClosedSessions.ts would stop a third close site from recording it differently.

[DESIGN-REVIEWED] 25a04fb

Description read

[DESCRIPTION-READ] 2428f55e83f4160a2118d1fddd561614a1097d52a81de35b5411d993ac509231

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 Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5, fork) — ✅ PASS

Premise-level review of 263a99e63c9491c70d177182d11c44d5b734dcc2 via the fork AI-review pipeline — 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

No item blocks. The shortcuts-modal layout rework restacks every row on narrow windows, which is more than the new chord needs; it is a note, not a blocker.

Notes

  • Item 7 — oversized: "below it each row puts a full-width label above its combos". This changes how every row in the reference lays out below sm. The only harm the diff names is the reopen-chat row overflowing "in a browser host", and the no-wrap combo fixes that.
    Subtraction: in ShortcutRow keep the flex-nowrap combo wrapper. Delete the below-sm stacking: the flex-col/w-full classes and the base items-stretch, gap-1 and justify-start that go with them. Keep the original row layout at every width.
    Clears when: the mechanism is removed, or a human amends the Goal.

What this change ships

Inventory (8 items) — 7 justified

Intent: reopen an accidentally closed session with one keystroke, as in a browser. This is an ADDITION.

  1. New "Reopen closed session" command, ⌘⇧T / Ctrl+Shift+T with an Alt+Shift+T alias, rebindable — justified
  2. The last 20 user closes in this tab are remembered, and repeated presses walk back through them — justified
  3. With nothing to reopen, the chord shows "No recently closed sessions." — justified
  4. Slot payload and resume response carry history_key, the backend's transcript key — justified
  5. A reopen leaves Split View so the reopened session is the one on screen — justified
  6. Desktop Refresh Token shortcut moves from Cmd/Ctrl+Shift+T to ⌘⌥T, or Ctrl+Alt+Shift+T on Windows/Linux — justified
  7. Shortcuts reference: combos never wrap, and the label stacks above the keys on narrow windows — oversized
  8. File Explorer's Cmd/Ctrl+T no longer fires when Shift is held — justified

[FIRST-PRINCIPLES-REVIEWED] 263a99e

Description read

[DESCRIPTION-READ] e62db63185e266af968bf5be3bb8723760a2c94d36a7460f3ce15eba783c1d44

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 Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review (fork) — ✅ no blocking findings

Reviewed 263a99e63c9491c70d177182d11c44d5b734dcc2 via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 263a99e

@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review (fork) — ✅ no blocking findings

Reviewed 263a99e63c9491c70d177182d11c44d5b734dcc2 via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 263a99e

@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 Oct 14, 2026
@hungtnvu

Copy link
Copy Markdown
Contributor Author
settings-row-browser settings-row-desktop-mac connection-menu-refresh-token-win nothing-to-reopen-notice shortcuts-modal-browser shortcuts-modal-narrow-360

@hungtnvu
hungtnvu force-pushed the feat/reopen-closed-session branch from c83422a to 85f62f0 Compare October 14, 2026 22:04
@hungtnvu

Copy link
Copy Markdown
Contributor Author

self-added: no
mechanism: slot payload carries history_key; reopen resumes by it and restores the same ref on failure

  • Bare slot keys reopen empty sessions and corrupt saved metadata

fixed in 85f62f0. Reopen no longer resumes by the bare slot key.
Backend slot_projection.to_dict emits history_key = safe_key(slot_history_key(slot)), the same stem History rows and resume.py use, for dashboard, linked and unbound channel-origin slots.
recentlyClosedSessions records that stem as ClosedSessionRef.historyKey; reopen calls resumeFromHistory({key: ref.historyKey}); the already-open check keeps the bare key.
A failed resume puts the identical ref back (restoreClosedSession), so a retry never re-derives a dashboard
stem.
Older payloads without history_key fall back to linked_session_key / origin link / dashboard_, matching slot_history_key's own order.
Tests: test/test_slot_history_key_projection.py (dashboard, linked, unbound channel); reopenClosedSession.test.tsx (backend key preferred, channel retry keeps its stem).

@hungtnvu

Copy link
Copy Markdown
Contributor Author

fixed in 85f62f0. ShortcutsModal row label is shrink-0 with max-w-[55%]; the chord column and each alternate chord wrap instead.
"Reopen closed session" stays on one line at 1280px and at a 360px viewport; long chord pairs wrap below.
Evidence in the PR body: Cmd+/ reference at full width and at 360px, plus the Settings → Shortcuts row in browser and macOS desktop hosts.
Regression test in reopenClosedSession.test.tsx pins the row layout classes.

@hungtnvu

Copy link
Copy Markdown
Contributor Author

fixed in 85f62f0. With nothing to reopen the chord shows the shell's existing role=status notice: "No recently closed sessions — find older ones in History".
It asks nothing and does not navigate; it names History as the place for older sessions.
String is in every locale catalog; screenshot of the notice is in the PR body.
Test: "asks nothing when there is nothing to reopen, only shows the notice".

@hungtnvu

Copy link
Copy Markdown
Contributor Author

fixed in 85f62f0. Refresh Token is Cmd+Alt+T on macOS and Ctrl+Alt+Shift+T on Windows/Linux, so it no longer collides with GNOME/Ubuntu's Ctrl+Alt+T terminal shortcut.
No menu item claims Shift+T, so Cmd/Ctrl+Shift+T reaches the page.
app-menu.test.js asserts both accelerators; electron/README.md names them; Windows Connection menu screenshot is in the PR body.

@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 Oct 14, 2026
@hungtnvu
hungtnvu force-pushed the feat/reopen-closed-session branch from 85f62f0 to 9760b3f Compare October 14, 2026 23:46
@hungtnvu

Copy link
Copy Markdown
Contributor Author

Pushed 9760b3ff: Backend Tests (Windows) (8) failed on 85f62f0b at test/test_chat_slot_facade_contract.py::test_to_dict_key_order_and_single_source_scan. Its pinned _TO_DICT_KEYS tuple did not include the new history_key field, so the tuple now lists it after linked_session_key. The branch is also rebased onto main (37449b3c -> fbca1a17) so that it picks up the test files that moved on main. CI is re-running.

@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 Oct 15, 2026
@hungtnvu
hungtnvu force-pushed the feat/reopen-closed-session branch from 9760b3f to 393177a Compare October 15, 2026 16:42
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Oct 15, 2026
@hungtnvu
hungtnvu force-pushed the feat/reopen-closed-session branch from 6c3f3d6 to debe47c Compare October 21, 2026 18:35
@hungtnvu

Copy link
Copy Markdown
Contributor Author
  • Re-closing a resumed session loses its reopen entry — fixed in debe47cee, as suggested.

Both resume responses (fresh and already-live) in chat_api/resume.py now return history_key, computed by the same slot_projection._history_key the slot list publishes, so the two cannot disagree.
resumeFromHistory carries it onto the optimistic row, so rememberClosedSession records a close that lands before any WebSocket slots update.
Regression test re-closing a resumed slot before a slots update keeps it reopenable (close, reopen, close again with no slots frame, reopen) fails without the frontend change; backend tests pin history_key on both resume paths.
Gateways that omit the field keep the previous behaviour: the client copies it only when present.

@github-actions github-actions Bot removed the readiness: action required A blocking check or review needs attention label Oct 21, 2026
@hungtnvu

Copy link
Copy Markdown
Contributor Author

self-added: no
mechanism: deleteSlot's navigation-failure fallback (clearSlotState), unchanged from main

  • An earlier pending close can erase the reopened transcript — rebutted (adjudication already downgraded it).

The clearing comes from deleteSlot's switchSlot(prev).unwrap().catch(() => clearSlotState) in website/src/store/chatSlice.ts, which this PR does not change.
The same race exists on main with no reopen involved: close A, activate any other session while A's fallback fetch is pending, and a failed fetch clears that session's view. Reopen is one more way to activate a session during that window, not a new defect.
The reopen loop waits for the close of the entry it reopens, which is the close that can clear that session; an unrelated earlier close's failed fallback is a deleteSlot concern.
Fencing that fallback against newer activations changes every close path's failure handling, outside this PR's goal (reopen the last closed session). Nothing is lost: the transcript stays on disk and reopens from History.

@hungtnvu

Copy link
Copy Markdown
Contributor Author

The Opus 5.5 fork lane on d827e7475 did not review: run 39675572700 failed in setup with getIDToken call failed ... connect ECONNREFUSED 20.85.130.105:443 (12 retries), so its check reads "review incomplete". Every other check on this head is green, and Opus passed on the previous head 16dc0f576, which has the same code. Could a maintainer re-run that lane? I can't trigger fork lane runs from the fork.

@hungtnvu

Copy link
Copy Markdown
Contributor Author
  • A stale close rejection deletes a successful retry's reopen entry

fixed in 29ed913: both close paths (useSessionActions close handler and the Cmd/Ctrl+W shortcut) now drop only the ClosedSessionRef their own close recorded, via forgetClosedSessionRef(ref) filtering by entry identity.
The key-wide forgetClosedSession had no other caller and is removed, so no close path can clear another close's entry.
Regression test: a late refusal of an earlier close of A leaves a newer recorded close of A on the stack and reopen still returns it; it fails with the key-wide removal.

@hungtnvu

Copy link
Copy Markdown
Contributor Author
  • Rapid reopen presses activate sessions in response order

rebutted (adjudicator downgraded it as disproportionate-remedy): two reopen presses whose resumes finish out of order bring both sessions back with nothing lost; only which one is in front differs, which one click corrects.
The ordering lives in resumeFromHistory.fulfilled, the shared resume reducer every History and palette resume uses; it has no request-ID check on success on main either, so this PR adds no new ordering defect.
Serializing reopens through both the close wait and the resume would add a queue to a rare, recoverable, visible race; not changed.

@hungtnvu

Copy link
Copy Markdown
Contributor Author
  • Rapid reopen presses activate sessions in reverse press order

rebutted, same class as the 62ed7d4 disposition (adjudicator downgraded it again as disproportionate-remedy): both reopened sessions come back with transcripts intact; only which tab is focused differs, and one click corrects it.
Success-path activation order is owned by the shared resumeFromHistory.fulfilled reducer, which has no request-ID ordering on main either; a reopen-only press queue across close settlement, leave guard and resume would be new ordering state for a rare, visible, recoverable race. Not changed.

@hungtnvu

Copy link
Copy Markdown
Contributor Author
  • Overlapping reopens activate sessions out of keypress order

rebutted, same class as the 29ed913 and 62ed7d4 dispositions (adjudicator downgraded it again as disproportionate-remedy): both reopened sessions come back with transcripts intact; only which one ends up focused differs, and one click corrects it.
Success-path activation order is owned by the shared resumeFromHistory.fulfilled reducer, which orders dispatches rather than keypresses on main too; a reopen-only press queue across close settlement, leave guard and resume would be new ordering state for a rare, visible, recoverable race. Not changed.

@hungtnvu

Copy link
Copy Markdown
Contributor Author
  • A delayed reopen overrides a later reopen press

rebutted, same class as the 26860c5, 29ed913 and 62ed7d4 dispositions (adjudicator downgraded it again as disproportionate-remedy): both reopened sessions come back with transcripts intact; only which one ends up focused differs, and one click corrects it.
Success-path activation order is owned by the shared resumeFromHistory.fulfilled reducer, which orders dispatches rather than keypresses on main too; a reopen-only press queue across close settlement, leave guard and resume would be new ordering state for a rare, visible, recoverable race. Not changed.

@github-actions

Copy link
Copy Markdown
Contributor

Security Scope Review (fork) — 🔴 BLOCK (blocking)

Which legitimate operations does 2be451b2190256e0599aed4f2f585bab81659bdc newly refuse? Model proposes, scripts/deny_diff.py decides — updated in place on each push. A script-confirmed regression blocks PR readiness.

the review scope was never resolved: the generate job did not finish (it timed out, failed or was cancelled), so no leg ran; its log names the step that stopped

No [SCOPE-REVIEWED] marker for this head was produced, so the model's text is withheld: it cannot be shown to describe this revision. See the job logs.

@hungtnvu

Copy link
Copy Markdown
Contributor Author
  • Concurrent reopen presses reverse the selected-session order

rebutted, same class as the 26860c5, 29ed913 and 62ed7d4 dispositions (adjudicator downgraded it again): both reopened sessions come back with transcripts intact; only which one ends up focused differs, and one click corrects it.
Activation order is owned by the shared resumeFromHistory.fulfilled reducer, which orders dispatches rather than keypresses on main too; a reopen-only press queue would be new ordering state for a rare, visible, recoverable race. Not changed.

@hungtnvu

Copy link
Copy Markdown
Contributor Author
  • Second notice mechanism — duplicate of agentSwitchNotice

fixed in 3bb7db8 by subtraction: reopenNotice, setReopenNotice, the ReopenNotice component and its App test are deleted, and the reopen shortcut now dispatches setAgentSwitchNotice(i18nT('hooks.useKeyboardShortcuts.no_recently_closed_session')).
App.tsx, store/chat/state.ts, chatSlice.ts's reducers and both slice-surface tests are back to main's versions; the PR is down from 38 files to 32.

  • Item 7 — shortcut rows stack below sm -- rebutted

unchanged, as in the earlier rounds' disposition (span 772a5f983b00): the owner kept the narrow-window stacking, and this note is not a blocker.

@hungtnvu

Copy link
Copy Markdown
Contributor Author
  • Concurrent reopen presses reverse the active-session order

rebutted, same class as the 0d42389, 21e0a8e, 26860c5 and 29ed913 dispositions (adjudicator downgraded it again as disproportionate-remedy): both reopened sessions come back with transcripts intact; only which one ends up focused differs, and one click corrects it.
Activation order is owned by the shared resumeFromHistory.fulfilled reducer, which orders dispatches rather than keypresses on main too; a reopen-only press queue would be new ordering state for a rare, visible, recoverable race. Not changed.

@hungtnvu

Copy link
Copy Markdown
Contributor Author

Frontend Lint & Type Check is red on 2c0902e because of main, not this PR: the website/src/components/RedactionCards.tsx:1102 document.body portal lint error comes from #19843 (a2a12ab), and main's own CI is red on the same commit. #25429 fixes it; I'll rebase onto main once that merges.

@hungtnvu

Copy link
Copy Markdown
Contributor Author
  • Concurrent reopen presses reverse the active-session order

rebutted, same class as the 0d42389, 21e0a8e, 26860c5, 29ed913 and 2c0902e dispositions (adjudicator downgraded it again as disproportionate-remedy): both reopened sessions come back with transcripts intact; only which one ends up focused differs, and one click corrects it.
Activation order is owned by the shared resumeFromHistory.fulfilled reducer, which orders dispatches rather than keypresses on main too; a reopen-only press queue would be new ordering state for a rare, visible, recoverable race. Not changed.

@hungtnvu

hungtnvu commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

Could a maintainer please click Approve and run workflows for a190375dc? I rebased onto main on 2 Nov to fix a conflict in src/kiro_crew/dashboard/slot_projection.py, and the 17 workflow runs for this head (CI, Build, Fast Gate and the AI review lanes) have been waiting for approval since then.

The previous head, 208e351d3, passed all CI and every review lane except the fork Design Review, which never started. This head should get that lane running too. Thanks!

@bolichen97 bolichen97 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks @hungtnvu. CI now runs on 195c8d4, and two blocking items need fixing before merge:

  1. Holding the reopen chord reopens several sessions. In website/src/hooks/useKeyboardShortcuts.ts, the 'reopen-chat' action has no e.repeat check. Every key auto-repeat pops another entry and starts its own resumeFromHistory. The last request wins, so the user lands on an older session, and the entries in between are used up. Fix: return early on e.repeat at the top of 'reopen-chat', the way 'new-chat' does. Add a test: one repeated keydown reopens exactly one session.
  2. File line cap. src/kiro_crew/dashboard/chat_api/resume.py is now 2,001 lines, over the 2,000-line cap (python3 scripts/check_file_line_cap.py). That fails Backend Ratchets & Boundaries and Frontend Ratchets & i18n. Fix: move a whole definition into a sibling module, or save the line inside your hunk. Do not add a baseline row.

Backend Tests (3.12, 3) is also red on this head. Please check whether it is yours after the fixes; if it is a flake, say so and it gets one rerun.

AI-assisted review (code-review-sage), sent by CommunityCrew

Add a rebindable reopen-chat command under Actions. Each user close
(Cmd+W, the sidebar X, session menus) that lands is recorded on a
per-tab in-memory stack; the chord pops it newest first and resumes
the session through the same path History and the command palette
use, so the transcript comes back intact. Sessions on a surface the
chat page cannot show are never recorded.

The desktop menu's Refresh Token moves from CmdOrCtrl+Shift+T to
CmdOrCtrl+Alt+T so the chord reaches the renderer.

Fixes kirodotdev#18969
@hungtnvu

hungtnvu commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author
  • Holding the reopen chord reopens several sessions

fixed in eb9dde5: the reopen-chat action returns early on e.repeat, like new-chat, so a held chord's auto-repeats are still claimed but reopen nothing more. reopenClosedSession.test.tsx adds a test that presses the chord with repeat: true after a close and checks that nothing resumes and the entry stays on the stack; it fails without the guard.

@hungtnvu

hungtnvu commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author
  • Reopening leaves the restored conversation hidden in Split View (upheld)

fixed in eb9dde5: reopen passes leaveSplit to resumeFromHistory, which records it on the existing lastResumeActivation only when the resume takes the view, and activeSlotState.ts leaves Split View on it the same way it already does for a new chat's lastCreatedActivation. Other resumes keep Split View as before. ChatPageMoreCoverage.test.tsx covers both (the leave case fails without the effect), and reopenClosedSession.test.tsx checks the shortcut sets the flag.

  • Pending closes reverse successive reopen requests (downgraded)

rebutted, same class as the earlier dispositions for this span (adjudicator downgraded it again as disproportionate-remedy): both reopened sessions come back with transcripts intact; only which one ends up focused differs, and one sidebar click fixes it. A per-press ordering queue across the close waits would cost more than this double-press-during-pending-close race.

@bolichen97

Copy link
Copy Markdown
Contributor

@hungtnvu we picked this up to drive it green. eb9dde5 addresses both items in my change request (the e.repeat guard and the resume.py line cap). It also fixes test/test_facade_read_budget.py and test/test_turn_golden.py, which fail on 195c8d4 and pass on eb9dde5 locally. Fork CI for eb9dde5 is approved. If anything else goes red, we will fix it on this branch on top of your commit, with you as co-author.

AI-assisted, sent by CommunityCrew

ChatPageMoreCoverage.test.tsx reached 2,018 lines once merged with
main, over the 2,000-line cap. Move the two resumeFromHistory
leaveSplit tests this PR added into ChatPage.reopenLeavesSplit.test.tsx
with only the setup they need. The old file is back to its main blob.

Co-authored-by: Hung Vu <hungvu@amazon.com>
@bolichen97

Copy link
Copy Markdown
Contributor

@hungtnvu eb9dde5 failed the file line cap once merged with current main: website/src/test/ChatPageMoreCoverage.test.tsx reached 2,018 lines (cap 2,000). I added 25a04fb905 on top of your commit, with you as co-author. It moves your two leaveSplit resume tests into website/src/test/ChatPage.reopenLeavesSplit.test.tsx, unchanged. Line cap, the two test files (83 tests, the new file 3 runs) and tsc pass locally.

AI-assisted, sent by CommunityCrew

@buluoray buluoray left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🤖 Kiro Crew Auto-Pipeline [operator: buluoray]:

🤖 Kiro Crew Auto-Pipeline [operator: buluoray]:

Approve. Nothing blocking at 25a04fb.

What this does for users: after an accidental close (⌘W, the sidebar ✕ or a session menu), ⌘⇧T on macOS or Ctrl+Shift+T elsewhere brings the session back with its transcript, newest first, up to 20 per tab. In a browser tab the working chord is Option/Alt+Shift+T, because the browser keeps Ctrl+Shift+T for its own tabs. The desktop app's Connection menu item that refreshes the window's credential moves to Cmd+Alt+T (macOS) and Ctrl+Alt+Shift+T (Windows/Linux), so the chord reaches the page.

What I checked:

  • Reopen goes through the existing History resume (resumeFromHistory and POST /api/chat/slots/{slot}/resume). The backend change only adds a read-only history_key to the slot list and the two resume responses (slot_projection.py:616, resume.py:283 and :741). There is no new write path.
  • Only user closes are recorded. A refused DELETE drops its entry. Surfaces the chat page cannot show are skipped (recentlyClosedSessions.ts:61). Incognito and Temporary sessions are recorded, which matches the 2026-09-25 decision that their transcript stays in History. The record lives only in the tab's memory.
  • On terminals: the primary chord is left to the shell (useKeyboardShortcuts.ts:864). The File Explorer's Cmd/Ctrl+T now ignores Shift (FileExplorerPage.tsx:431). The shortcut registry test passes, 24/24.
  • Both earlier change requests are fixed at this head. Holding the chord now reopens one session (useKeyboardShortcuts.ts:1094): removing that line reddens "claims a held chord's auto-repeats without reopening another session" (1 failed, 31 passed). resume.py is at 2,000 lines, and the line cap check passes.
  • The last commit only moves the two leaveSplit tests into ChatPage.reopenLeavesSplit.test.tsx. ChatPageMoreCoverage.test.tsx is back to main's exact blob, and no source file changed.
  • Local runs: reopenClosedSession 32/32, useSessionActions.cov80 27/27, FileExplorerPageCoverage 69/69, and the shortcut registry and Shortcuts modal suites 78/78. ChatPage.reopenLeavesSplit did not run locally because of a missing local dependency; CI's frontend shards are green on this head.
  • The branch merges cleanly with main.

CI:

  • 87 success, 10 skipped, 4 failure on 25a04fb.
  • Backend Tests (3.12, 5) and Backend Tests (Windows) (5) both fail one test, test_decisions_model_route_derived.py::TestTheUsageRowOfARoutedStart::test_the_row_names_no_routed_id_the_child_may_have_withheld. The test reads the usage row before the background write finishes. Main fixed that race in #29982 after this branch's base, and this diff touches nothing on that path. The test passes 72/72 locally on this head and on main. Coverage Gate is red only because of it.
  • Updating the branch onto main should clear all three. A plain re-run may reuse the old merge commit.
  • The Opus 5.5 lane did not finish on this head. Its last finished verdict, "No findings" on eb9dde5, covered the same source.

Checked from source only: a real Electron window, Windows and macOS hosts, iframes and app frames (a keydown there does not reach the shell, the same as every other chord), and remote or member-thread sessions.

Follow-ups, not blocking:

  1. A session that was closed and then permanently deleted from History reopens as an empty session under its old title. The resume route treats a missing transcript as a new conversation and returns 200 with no messages. I reproduced this against this head. Nothing is persisted until the user types, so it does not block. Forgetting the entry when its History row is deleted, or skipping an empty resume, would fix it.
  2. A reopen the server refuses for good, for example a member thread opened on the wrong slot, goes back on top of the stack. Every later press retries it, so older entries cannot be reached until reload.
  3. The description's Tests list still names ChatPageMoreCoverage.test.tsx for the leaveSplit tests. They now live in ChatPage.reopenLeavesSplit.test.tsx.
  4. The remember, track and forget close sequence is written twice, in useKeyboardShortcuts.ts and useSessionActions.ts. One helper in recentlyClosedSessions.ts would keep the next close site consistent.
  5. Inside a terminal, the Option/Alt+Shift+T alias is still claimed by the page, as the existing Alt+Shift+N and Alt+Shift+W aliases are.

@bolichen97

Copy link
Copy Markdown
Contributor

@hungtnvu I made a mistake here: I used Update branch, which added a merge commit, and PR Hygiene allows only 1 or 2 commits with no merge. To avoid force-pushing over your branch, this continues in #30177. It has your commit unchanged (you stay the author) plus the line-cap test split, rebased onto current main. I'll close this PR once #30177 merges. Sorry for the noise.

AI-assisted, sent by CommunityCrew

@buluoray

buluoray commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

🤖 Kiro Crew Auto-Pipeline [operator: buluoray]: Closing in favour of #30177, which carries this change rebased onto main with two commits, so PR Hygiene passes. @hungtnvu stays the author of the feature commit there. The code matches what was reviewed here at 25a04fb. Thanks for the feature!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fork Pull request from a fork (external contributor) readiness: action required A blocking check or review needs attention

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Reopen recently closed sessions with Cmd/Ctrl+Shift+T

4 participants