Skip to content

Make Cmd+Shift+T reopen the last closed item - #9132

Merged
austinywang merged 6 commits into
mainfrom
issue-9126-cmdshiftt-reopen-window
Jul 30, 2026
Merged

austinywang merged 6 commits into
mainfrom
issue-9126-cmdshiftt-reopen-window

Conversation

@austinywang

@austinywang austinywang commented Jul 29, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • move the built-in Cmd+Shift+T binding from the workspace-only action to the existing unified Reopen Last Closed action
  • restore the newest closed panel, workspace, or whole window through the shared ClosedItemHistoryStore LIFO path, including window workspaces and geometry
  • preserve explicit legacy workspace-only bindings while keeping the existing action ID compatible with cmux.json and Settings
  • document the new default and localize the shared shortcut label in English and Japanese

Architecture

This builds on the existing close-history owner rather than adding window-only state. Window closure already records a value-typed SessionWindowSnapshot, and restoration creates a fresh AppKit window from that snapshot. No live closed-window or PTY context is retained, and surface-level restore can continue to share the same stack (#4427).

Validation

  • regression test committed before the fix; focused red proof: https://github.com/manaflow-ai/cmux/actions/runs/30427465225
  • swift test --disable-xctest --package-path Packages/macOS/CmuxSettings (265 tests passed)
  • ./scripts/lint-pbxproj-test-wiring.sh (626 test files)
  • Swift frontend parse of all touched Swift/test files
  • localization catalog parse plus English/Japanese key verification
  • dependency-free TypeScript bundle check for web/data/cmux-shortcuts.ts
  • git diff --check

Closes #9126
Cross-reference: #4427


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.


Summary by cubic

Cmd+Shift+T now reopens the last closed item—panel, workspace, or window—in LIFO order and restores window geometry. Settings now also preserve legacy unbindings so Cmd+Shift+T won’t override them. Closes #9126.

  • New Features

    • Bind “Reopen Last Closed” to Cmd+Shift+T (panels/workspaces/windows; restores window frames).
    • Localized label (EN/JA); command palette and docs/web shortcuts updated; keeps the reopenClosedBrowserPanel action ID for Settings compatibility.
  • Migration

    • reopenClosedWorkspace is unbound by default; Cmd+Shift+T defaults to reopenClosedBrowserPanel.
    • Existing explicit bindings or unbindings for reopenClosedWorkspace are preserved and suppress the default on reopenClosedBrowserPanel.

Written for commit bdf5cc9. Summary will update on new commits.

Review in cubic

@coderabbitai

coderabbitai Bot commented Jul 29, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: e7033bb9-8470-4f0c-8b2d-587257fc5173

📥 Commits

Reviewing files that changed from the base of the PR and between dec474e and bdf5cc9.

📒 Files selected for processing (13)
  • Packages/macOS/CmuxSettings/Sources/CmuxSettings/Values/ShortcutAction+Defaults.swift
  • Packages/macOS/CmuxSettings/Sources/CmuxSettings/Values/ShortcutAction+DisplayName.swift
  • Packages/macOS/CmuxSettings/Sources/CmuxSettings/Values/ShortcutAction+LegacyDefaultResolution.swift
  • Packages/macOS/CmuxSettingsUI/Sources/CmuxSettingsUI/Bindings/ShortcutListModel+Resolution.swift
  • Packages/macOS/CmuxSettingsUI/Tests/CmuxSettingsUITests/ShortcutListLegacyOverrideTests.swift
  • Sources/KeyboardShortcutSettings.swift
  • Sources/KeyboardShortcutSettingsLookup.swift
  • cmux.xcodeproj/project.pbxproj
  • cmuxTests/KeyboardShortcutContextSwiftTests.swift
  • cmuxTests/ReopenLastClosedTests.swift
  • cmuxTests/WorkspaceRecoveryTests.swift
  • skills/cmux-settings/references/shortcut-actions.md
  • web/data/cmux-shortcuts.ts
💤 Files with no reviewable changes (1)
  • cmuxTests/WorkspaceRecoveryTests.swift

📝 Walkthrough

Walkthrough

Cmd+Shift+T now defaults to reopening closed browser panels while legacy workspace bindings can displace that default. Shortcut resolution, UI binding lookup, documentation, and window-restoration tests were updated accordingly.

Changes

Reopen Last Closed Shortcut

Layer / File(s) Summary
Shortcut defaults and conflict resolution
Packages/macOS/CmuxSettings/..., Sources/KeyboardShortcutSettings*, skills/cmux-settings/..., web/data/cmux-shortcuts.ts
The browser-panel action receives Cmd+Shift+T, the workspace action becomes unbound by default, and legacy conflict resolution handles explicit workspace bindings.
UI binding lookup and overrides
Packages/macOS/CmuxSettingsUI/Bindings/..., Packages/macOS/CmuxSettingsUI/Tests/...
Explicit shortcut lookup is centralized, with tests covering workspace overrides and unbindings.
Window restoration and shortcut tests
cmuxTests/ReopenLastClosedTests.swift, cmuxTests/KeyboardShortcutContextSwiftTests.swift, cmuxTests/WorkspaceRecoveryTests.swift, cmux.xcodeproj/project.pbxproj
Tests cover mixed history restoration, window LIFO reopening, shortcut metadata, conflict resolution, and project inclusion of the new test suite.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant KeyboardShortcutSettings
  participant ClosedItemHistoryStore
  participant MainWindow
  User->>KeyboardShortcutSettings: Press Cmd+Shift+T
  KeyboardShortcutSettings->>ClosedItemHistoryStore: Restore newest closed item
  ClosedItemHistoryStore->>MainWindow: Reopen window or panel
  MainWindow-->>User: Restore workspace, tabs, and frame
Loading

Possibly related issues

  • Issue 6999: Covers the same ReopenLastClosedTests and Cmd+Shift+T shortcut migration.
  • Issue 7000: Covers the same restoration tests and shortcut default changes.

Possibly related PRs

  • manaflow-ai/cmux#8841: Updates the same reopen-last-closed shortcut pair and legacy conflict-resolution behavior.

Suggested reviewers: lawrencecchen, azooz2003-bit

🚥 Pre-merge checks | ✅ 24 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (24 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately highlights the main change: Cmd+Shift+T now reopens the last closed item.
Description check ✅ Passed The description covers the change, rationale, validation, and issue linkage, though some template sections are only lightly filled.
Linked Issues check ✅ Passed The changes satisfy #9126 by making Cmd+Shift+T reopen the latest closed item in LIFO order, including windows, with customizable bindings.
Out of Scope Changes check ✅ Passed The added tests, docs, project wiring, and localization all support the shortcut and restore behavior, with no clear unrelated scope.
Cmux Swift Actor Isolation ✅ Passed No new actor-isolation debt: the new production helpers are pure/value-side, and the only @MainActor additions are tests; ShortcutListModel stays MainActor-isolated.
Cmux Swift Blocking Runtime ✅ Passed Touched production Swift files add no semaphores, sleeps, locks, syncs, or polling; the only waitUntil loop is confined to the new test suite.
Cmux Browser Automation Off-Main ✅ Passed PR only changes shortcut/settings and tests; it does not touch the scoped browser automation files or routing policy.
Cmux Expensive Synchronous Load ✅ Passed Touched files only adjust shortcut conflict resolution and tests; no agent-history loaders, broad scans, or heavy sync parsing were added to main/interactive paths.
Cmux Cache Substitution Correctness ✅ Passed PASS: The new shortcut lookups use event-driven stores with initial snapshots; UI starts observing before use, so no stale/cold cache substitution in a persistence path.
Cmux No Hacky Sleeps ✅ Passed No changed non-Swift runtime code uses sleeps/timers; the touched TS file is static shortcut data, and the only polling helper is Swift test-only.
Cmux Algorithmic Complexity ✅ Passed All new logic is O(1) dictionary/set lookup or fixed enum mapping; no nested scans, batch rescans, or hot-path re-sorting were added.
Cmux Swift Concurrency ✅ Passed No new legacy async patterns appear in the touched cmux Swift code; the only Task usage is test-only Task.yield(), which the rule allows.
Cmux Swift @Concurrent ✅ Passed No touched Swift code adds or changes async isolation/@Concurrent; the new test work is explicitly @MainActor UI-bound.
Cmux Swift Package Boundaries ✅ Passed PASS: The only production Swift change is in CmuxSettings package code; app-root Sources/ are untouched, and the new legacy-resolution logic is package-scoped and testable.
Cmux Swiftpm Lockfiles ✅ Passed pbxproj only adds ReopenLastClosedTests wiring; no Package.resolved, Package.swift, or .gitignore changes, and no SwiftPM package-reference edits were present.
Cmux Swift Logging ✅ Passed No added print/debugPrint/dump/NSLog/Logger in touched production Swift; the only stdout use is in XCTest assertions, which the policy allows.
Cmux User-Facing Error Privacy ✅ Passed PASS: Touched production files only change shortcut defaults/labels/conflict resolution; no user-facing errors, alerts, API bodies, or sensitive details were added.
Cmux Full Internationalization ✅ Passed Swift uses String(localized:) with existing xcstrings entries; web routing/messages are locale-aligned, and the only web copy change is a moved EN/JA note, not new untranslated text.
Cmux Swiftui State Layout ✅ Passed Touched SwiftUI-adjacent code only refactors shortcut resolution; no new ObservableObject/@published, GeometryReader, lazy-row store refs, or render-time state writes were introduced.
Cmux Architecture Rethink ✅ Passed PASS: The diff adds synchronous legacy-default resolution and localization; the only polling/synchronization is confined to tests, with no new runtime timing/observer/lock side channels.
Cmux Swift Auxiliary Window Close Shortcuts ✅ Passed Diff only changes shortcut/settings code and test-only window fixtures; no new standalone cmux-owned window, identifier, or close-shortcut ownership changes.
Cmux Source Artifacts ✅ Passed All changed paths are intentional source/docs/tests/config/data; none are logs, caches, scratch dirs, or build artifacts.
Cmux No Test Or Debug Seam In Production Source ✅ Passed The only production-source patch adds legacy conflict-resolution logic in ShortcutAction+LegacyDefaultResolution.swift; no #if DEBUG seam or test-only accessor was added.
Cmux No Ambient Global State ✅ Passed Touched production Swift adds/adjusts extension methods and private helpers only; no new file-scope funcs, mutable globals, or singleton/state ownership patterns were introduced.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch issue-9126-cmdshiftt-reopen-window

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

Cmd+Shift+T should reopen the previously closed window (window-level restore, not just surfaces)

1 participant