Skip to content

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

Merged
bolichen97 merged 2 commits into
mainfrom
crew/communitycrew/reopen-closed-session
Nov 5, 2026
Merged

bolichen97 merged 2 commits into
mainfrom
crew/communitycrew/reopen-closed-session

Conversation

@bolichen97

Copy link
Copy Markdown
Contributor

Supersedes #20437, original work by @hungtnvu.

#20437 picked up a merge commit from Update branch, and PR Hygiene allows only 1 or 2 commits with no merge. This PR carries the same two commits rebased onto current main: @hungtnvu's feat(dashboard) commit unchanged (author kept), and the line-cap test split (Co-authored-by: Hung Vu). The rebase also picks up main's fix for the flaky test_the_row_names_no_routed_id_the_child_may_have_withheld (#29982).

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 and others added 2 commits November 5, 2026 04:44
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 #18969
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
bolichen97 requested review from a team and KiroCrewCaptain as code owners November 5, 2026 04:45
@bolichen97
bolichen97 enabled auto-merge (squash) November 5, 2026 04:45
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 5, 2026
@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

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

Design-Verdict: PASS

Nothing blocks: history_key is a new optional field the backend computes with its existing slot_history_key rule, the reopen list lives only in the browser tab, and the one accelerator move is listed as Breaking.

Notes

  • The File Explorer's Cmd/Ctrl+T new-tab handler now ignores Shift as well. So Cmd/Ctrl+Shift+T no longer opens a folder tab there, and it reopens a closed session instead. The description mentions this, but the ## Backwards compatibility section does not list it as a behaviour change.

[DESIGN-REVIEWED] 5f770c9

Description read

[DESCRIPTION-READ] 69825ebd15503177e77fbe8985f981e5721de6df469716fb63997e8fb51cf82d

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.

@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]:

Approving 5f770c9. This carries #20437, which I approved on 25a04fb, rebased onto main so the PR has two commits again.

I compared the two with git range-diff against each one's merge base. Both commits match the reviewed ones. The only differences are context lines in ChatPageMoreCoverage.test.tsx, where the neighbouring describe block changed on main. Hung Vu stays the author of the feature commit, and the line-cap commit's author changed from w to bolichen97. No source line differs.

My earlier review of #20437 still stands for this code. The shortcut reopens through the existing resumeFromHistory and slot resume route. The backend only adds a read-only history_key field. Both of bolichen97's points are fixed (held-chord auto-repeat, resume.py at the line cap). The non-blocking follow-ups from that review carry over, most notably that a session closed and then permanently deleted reopens as an empty session under its old title.

CI on this head was still running when I posted; no check had failed yet. I did not re-run the tests locally for this head, because the code is unchanged from the head I tested.

@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 5f770c990f8f526953effd44c27ddad028d763f1 — 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 blocks: every item comes from the stated goal or from a chord conflict that would otherwise swallow the keystroke. One layout rider is a note.

Notes

  • Item 6 — rides along: flex flex-col … sm:flex-row makes every row in the shortcuts reference stack its label above its keys below sm. That changes rows that have nothing to do with reopening. The harm this PR names is only that the reopen row's two chords plus a tag overflow. Subtraction: drop the below-sm flex-col/w-full restacking and keep only the flex-nowrap combo span, which already stops a chord from breaking mid-combo.

What this change ships

Inventory (8 items) — 7 justified

Intent: undo an accidental session close with Cmd/Ctrl+Shift+T, the way a browser reopens a closed tab. ADDITION.

  1. New rebindable "Reopen closed session" chord (⌘⇧T / Ctrl+Shift+T, alias Alt+Shift+T), listed in the shortcuts reference — justified
  2. Reopen walks back through up to 20 sessions this tab closed, newest first, kept in memory only — justified
  3. Pressing the chord with nothing to reopen shows "No recently closed sessions." — justified
  4. Desktop Refresh Token accelerator moves to ⌘⌥T / Ctrl+Alt+Shift+T — justified
  5. File Explorer's Cmd/Ctrl+T no longer opens a folder tab when Shift is held — justified
  6. Shortcuts reference rows stack on narrow windows, and a combo's keys no longer split across lines — rides along: restacks every row, beyond the reopen row's overflow
  7. Reopening leaves Split View — justified
  8. Slot payload and resume response carry a new history_key field (golden fixtures updated) — justified

[FIRST-PRINCIPLES-REVIEWED] 5f770c9

Description read

[DESCRIPTION-READ] 8c7b76d60b6d540fd92fda7bccb20d690cdbd57a1aa6bcdcd0aa013ab3e0ade3

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 5, 2026

Copy link
Copy Markdown
Contributor

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

UX-level review of 5f770c990f8f526953effd44c27ddad028d763f1 — 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 notice card in shot-05 shows a different message, "invalid agent name", so nobody has seen what the new empty-stack feedback looks like.

Evidence gaps

  • Empty-stack notice: pressing the reopen chord with nothing to reopen shows the new string "no_recently_closed_session": "No recently closed sessions." through setAgentSwitchNotice. No screenshot shows it, and the blind read has no entry for it (shot-05 and shot-06 show "invalid agent name" in that card). To close the gap, attach a screenshot of the notice on the chat page right after pressing ⌥⇧T / Alt+Shift+T with an empty stack.

Notes

  • ShortcutRow: the new sm:shrink-0 label and sm:gap-3 push "Close session" onto two lines in a wide dark modal, while "New chat" just above stays on one (shot-08). The blind reader saw "the same kind of information laid out differently". Rows look ragged in the reference the user scans most. Keep two-chord rows on one line when the modal is wide enough, or wrap every row the same way.
  • "DESKTOP APP ONLY" plus the footnote's "the alternatives work everywhere" still leaves the reader unable to tell which chord works where ("I am NOT sure which combination it calls the 'alternative'"). This is now on the reopen row too. Put the tag right next to the chord it covers, or reword it to "Ctrl+Shift+T: desktop app only".

[UX-REVIEWED] 5f770c9

Description read

[DESCRIPTION-READ] 89a9700394085e3c8dae44f19c417219ff7752e787369becabbedfc908d99cfc

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 Nov 5, 2026

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] 5f770c9

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

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

@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings (all downgraded on adjudication)

GPT 6.1 flagged blocking issues on 5f770c990f8f526953effd44c27ddad028d763f1; Opus 5.5 adjudication downgraded every one of them. Downgraded: the remedy each one needs is disproportionate to the harm it prevents. Adjudication downgraded all 1 blocking finding(s): the remedy each one requires is disproportionate to the harm it prevents.

This comment is updated in place on each push.

Review details

BLOCKING -- website/src/hooks/useKeyboardShortcuts.ts:1110 -- A delayed reopen overrides a newer reopen choice

while (ref && !((await waitForClosedSession(ref)) && !isOpen(ref))) {
Trigger: Close A successfully, then close B and press reopen twice while B’s close remains pending. The first handler pops B and waits; the second pops A and completes resumeFromHistory. When B’s close settles, the first handler dispatches B’s resume afterward.
Outcome: B replaces A on screen despite A being the latest reopen choice. The activation guards accept B because its request ordering and origin are captured only after the close wait.
Anchor: defect
Fix: Serialize reopen attempts in keypress order through the close waits and resume dispatch, so an earlier press cannot dispatch after a later one.

[BLOCK-MERGE-DOWNGRADED] 5f770c9
[GPT-REVIEWED] 5f770c9

Adjudication (Opus 5.5) — is blocking on each finding proportionate?

F1 — LOW. This needs three things at once: the user presses reopen twice (repeats are dropped, useKeyboardShortcuts.ts:1094), a close is still pending (recentlyClosedSessions.ts:72,80), and the presses go into independent async tasks that each pop and wait (useKeyboardShortcuts.ts:1109-1111). The worst case is that both sessions reopen and the older one ends up focused. Nothing is lost, the user can see it, and one click on the other slot fixes it (resume at :1126). There is no recovery path in the code, and none is needed.
The real fix is a reopen queue in module or ref state, plus ordering capture across the close wait and the resume dispatch. That mechanism would exist only for this millisecond-scale race, so its cost and the upkeep it adds outweigh a LOW harm that the user can see and fix.

[ADJUDICATION] 5f770c990f8f526953effd44c27ddad028d763f1 total=1 uphold=0 downgrade=1
DOWNGRADE F1 website/src/hooks/useKeyboardShortcuts.ts:1110 reason=disproportionate-remedy
[GPT-ADJUDICATED] 5f770c990f8f526953effd44c27ddad028d763f1

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 5f770c990f8f526953effd44c27ddad028d763f1 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 5, 2026
@bolichen97
bolichen97 merged commit 73b24ca into main Nov 5, 2026
98 checks passed
@bolichen97
bolichen97 deleted the crew/communitycrew/reopen-closed-session branch November 5, 2026 05:44
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Nov 5, 2026
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.

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

3 participants