Skip to content

Fix #3662: toggle right sidebar with CMD+SHIFT+E instead of just focusing - #3875

Closed
austinywang wants to merge 7 commits into
mainfrom
issue-3662-right-sidebar-toggle
Closed

austinywang wants to merge 7 commits into
mainfrom
issue-3662-right-sidebar-toggle

Conversation

@austinywang

@austinywang austinywang commented May 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Fix Cmd+Shift+E so the right-sidebar shortcut shows and focuses when hidden, focuses when visible but unfocused, and hides when already focused.
  • Add a command palette entry for the same right-sidebar action and update shortcut/menu/docs labels from focus to toggle.

Repro

  1. Open cmux.
  2. Press Cmd+Shift+E to show the right sidebar.
  3. Press Cmd+Shift+E again.

Before this change, the second press only refocused/restored focus while leaving the sidebar visible. Now it closes the focused right sidebar.

Fixes #3662


Note

Medium Risk
Moderate risk because it changes core keyboard focus/visibility behavior for the right sidebar and routes multiple entry points through new toggle logic; regressions would be user-visible but limited in scope.

Overview
Fixes the right-sidebar keyboard shortcut to behave as a true toggle: show+focus when hidden, focus when visible but unfocused, and hide when already focused, via a new tri-state RightSidebarFocusShortcutAction and performRightSidebarFocusShortcut() in MainWindowFocusController.

Adds a command palette command (palette.toggleRightSidebar) wired to the same toggle behavior, and updates command palette contribution plumbing (shared constant text helper, new contribution for the toggle). Tests are updated/added to cover the new toggle decision logic and command palette mapping, and the obsolete MainWindowFocusToggleDestination/toggle path is removed.

Reviewed by Cursor Bugbot for commit f13b247. Bugbot is set up for automated code reviews on this repo. Configure here.


Summary by cubic

Cmd+Shift+E now toggles the right sidebar based on focus: show+focus when hidden, focus when visible, and hide when focused—and it restores the previously focused main panel when hiding. The command palette adds palette.toggleRightSidebar with the same focus-aware behavior. Fixes #3662.

  • New Features

    • Added a command palette entry (palette.toggleRightSidebar) that routes through the focus-aware toggle.
  • Refactors

    • Consolidated behavior under MainWindowFocusController.performRightSidebarFocusShortcut with a tri-state RightSidebarFocusShortcutAction; removed the old focus toggle path and MainWindowFocusToggleDestination, and routed AppDelegate and the command palette through the new path.
    • Updated tests for the tri-state decision, hide-to-restore behavior, and command mapping; extracted a small command palette text helper.

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

Summary by CodeRabbit

  • New Features

    • Dedicated "Toggle Right Sidebar" command added to the command palette.
  • Improvements

    • Smarter keyboard focus behavior for the right sidebar: hides when already focused, focuses when visible but unfocused, or shows and focuses when hidden.
    • Audible feedback (system beep) when a focus toggle cannot be completed.
  • Tests

    • Added tests covering command palette and right-sidebar focus shortcut behavior.

Review Change Stack

The Cmd+Shift+E regression needs a small decision seam so tests can describe the intended tri-state behavior without driving AppKit focus state. This commit introduces the seam and the failing expectations while preserving the current visible-focused behavior for the fix commit to change.

Constraint: Tests must exercise behavior through a runtime seam, not source text.\nRejected: Add an end-to-end AppKit shortcut test only | too much focus/window setup for the decision being locked.\nConfidence: high\nScope-risk: narrow\nDirective: Keep Cmd+Shift+E behavior expressed as one tri-state decision: hidden shows and focuses, visible-unfocused focuses, visible-focused hides.\nTested: Not run per task instructions.\nNot-tested: CI has not run this failing checkpoint yet.
Cmd+Shift+E already owned the right-sidebar focus path, but the focused-sidebar branch restored terminal focus while leaving the sidebar visible. Keep the visibility decision inside MainWindowFocusController, so shortcut, menu, and command palette dispatchers share one MainActor decision surface.

Constraint: Preserve the committed failing test as the first commit in the regression pair.

Constraint: Do not run local tests or bare xcodebuild for this task.

Rejected: Add a separate close-only shortcut path | it would split right-sidebar visibility behavior across entrypoints.

Confidence: high

Scope-risk: narrow

Directive: Keep Cmd+Shift+E behavior expressed as hidden shows and focuses, visible-unfocused focuses, and visible-focused hides.

Tested: git diff --check

Not-tested: Local unit tests and local app build, per task instruction to rely on CI before tagged reload.
@vercel

vercel Bot commented May 12, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
cmux Ready Ready Preview, Comment May 12, 2026 1:24am
cmux-staging Building Building Preview, Comment May 12, 2026 1:24am

@coderabbitai

coderabbitai Bot commented May 12, 2026 •

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

Adds a stateful right-sidebar keyboard-focus action (hide/focus/show-and-focus), implements execution in MainWindowFocusController, wires a dedicated command-palette command and ContentView handler, routes AppDelegate to the new performer, and adds tests verifying action resolution and command mapping.

Changes

Right Sidebar Toggle Shortcut

Layer / File(s) Summary
Toggle Action State Model
Sources/MainWindowFocusController.swift
RightSidebarFocusShortcutAction enum defines hide, focus, and showAndFocus with a resolve(isVisible:isFocused:) helper.
Keyboard focus intent types
Sources/MainWindowFocusTypes.swift
Removes MainWindowFocusToggleDestination and ensures MainWindowKeyboardFocusIntent (including rightSidebar(mode:)) appears before MainWindowFindShortcutTarget.
Toggle Execution Logic
Sources/MainWindowFocusController.swift
rightSidebarFocusShortcutAction(isVisible:currentResponder:) computes action using effectiveFocusOwner; performRightSidebarFocusShortcut(currentResponder:) executes hide/focus/show-and-focus via focusRightSidebar() or by hiding and restoring focus.
Keyboard Shortcut Routing
Sources/AppDelegate.swift
toggleRightSidebarKeyboardFocusInActiveMainWindow(preferredWindow:) now calls keyboardFocusCoordinator.performRightSidebarFocusShortcut(currentResponder:) with window?.firstResponder.
Command Palette Definition
Sources/ContentView+RightSidebarCommandPalette.swift
Adds commandPaletteToggleRightSidebarCommandID, constantCommandPaletteText(_:), maps the new command ID to .focusRightSidebar, adds commandPaletteRightSidebarToggleCommandContribution(), and refactors mode contributions to use the shared helper.
ContentView Command Integration
Sources/ContentView.swift
Inserts the right-sidebar toggle contribution into the palette sequence and registers a handler under the new command ID that invokes AppDelegate.toggleRightSidebarKeyboardFocusInActiveMainWindow(...), playing a system beep if it fails.
Unit Tests
cmuxTests/*
Adds tests asserting the command-palette toggle maps to .focusRightSidebar, validates contribution title uses the focus label, and adds RightSidebarFocusShortcutActionTests for visible+focused → .hide, visible+unfocused → .focus, hidden → .showAndFocus; updates related shortcut tests to use responder-aware assertions and a hide-case test that clears visibility.

Sequence Diagram

sequenceDiagram
  participant User as User / Keyboard
  participant ContentView
  participant CommandPalette
  participant AppDelegate
  participant MainWindowFocusController
  User->>ContentView: invoke "Toggle Right Sidebar" command
  ContentView->>CommandPalette: resolve command ID -> shortcut action (.focusRightSidebar)
  CommandPalette->>AppDelegate: call toggleRightSidebarKeyboardFocusInActiveMainWindow(...)
  AppDelegate->>MainWindowFocusController: performRightSidebarFocusShortcut(currentResponder: window?.firstResponder)
  MainWindowFocusController->>MainWindowFocusController: compute RightSidebarFocusShortcutAction (hide/focus/showAndFocus)
  MainWindowFocusController->>MainWindowFocusController: execute action (hide / focus / showAndFocus)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • manaflow-ai/cmux#3408: Both PRs modify ContentView's command-palette wiring for right-sidebar commands (adding/handling right-sidebar command IDs and the shared shortcut-action resolver).
  • manaflow-ai/cmux#3766: Both PRs modify AppDelegate entrypoints and shortcut routing for right-sidebar behavior.
  • manaflow-ai/cmux#3748: Both PRs touch right-sidebar toggle/focus wiring across AppDelegate and command-palette.

Poem

🐰 I hopped to the keyboard, a toggle in mind,
Hide, focus, or show — no longer confined,
Commands sing the path, AppDelegate leads,
The sidebar obeys all tidy keyboard creeds ✨

🚥 Pre-merge checks | ✅ 14 | ❌ 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 (14 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: Cmd+Shift+E now toggles the right sidebar instead of only focusing it, directly addressing the fix for issue #3662.
Linked Issues check ✅ Passed The code changes fully implement the requirements from #3662: toggle behavior (show+focus when hidden, focus when visible but unfocused, hide when focused), command palette entry, and updated labels from focus to toggle.
Out of Scope Changes check ✅ Passed All changes are directly scoped to implementing the right-sidebar toggle behavior and command palette integration. The removal of MainWindowFocusToggleDestination is necessary refactoring for the main objective.
Cmux Swift Actor Isolation ✅ Passed New value enums and @MainActor methods properly maintain Swift 6 actor isolation. No implicit MainActor types, Sendable violations, or background access issues.
Cmux Swift Blocking Runtime ✅ Passed No blocking patterns introduced in new code. All changes are deterministic: new enums and methods for right sidebar toggle focus logic. Pre-existing blocking in ContentView unchanged.
Cmux No Hacky Sleeps ✅ Passed PR is Swift-only. Check applies to TypeScript, JavaScript, shell, and non-Swift runtime code only. Swift covered separately by swift-blocking-runtime check.
Cmux Swift Concurrency ✅ Passed No prohibited async patterns introduced. New code (RightSidebarFocusShortcutAction, performRightSidebarFocusShortcut, command palette handler) is synchronous, appropriate for keyboard event handling.
Cmux Swift @Concurrent ✅ Passed All new synchronous functions are @MainActor-isolated. No async functions added. No @concurrent issues. All work is intentionally UI-bound. Complies with rules.
Cmux Swift File And Package Boundaries ✅ Passed PR adheres to swift-file-package-boundaries rules: new file 148 lines (under 400 limit), minimal additions to oversized files, cohesive focus controller, comprehensive tests.
Cmux Swift Logging ✅ Passed No logging violations found. No print, debugPrint, dump, NSLog, or Logger declarations were added to production code. Changes involve right-sidebar focus logic only.
Cmux Swiftui State Layout ✅ Passed Conforms to SwiftUI state rules: uses modern @Observable with @State, no new @Published patterns, no GeometryReader layout issues or render-time mutations.
Cmux Architecture Rethink ✅ Passed Single production path with pure tri-state action, clear ownership, no timing repairs/locks/observers/duplicates. Old toggle logic removed. Tests verify invariants.
Cmux Swift Auxiliary Window Close Shortcuts ✅ Passed PR does not add or change standalone windows. Right sidebar is an embedded SwiftUI view, not a standalone NSWindow/NSPanel. Changes only modify existing focus/visibility logic.
Description check ✅ Passed The pull request description includes all required sections from the template: a clear Summary explaining what changed and why, and a comprehensive Repro section demonstrating the fix. However, the Testing, Demo Video, and Checklist sections are missing.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch issue-3662-right-sidebar-toggle

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 and usage tips.

origin/main introduced a separate pure right-sidebar toggle action while this branch changes the focus shortcut semantics. The merge keeps both entrypoints: Toggle Right Sidebar performs visibility toggle, while Toggle Right Sidebar Focus uses Cmd+Shift+E and now hides only when the right sidebar already owns focus.

Constraint: PR merge state was DIRTY after creation.

Rejected: Collapse the new pure toggle action into the focus shortcut | it would discard upstream's clearer visibility command.

Confidence: medium

Scope-risk: broad

Directive: Keep pure visibility toggle and focus-shortcut tri-state separate after this merge.

Tested: git diff --cached --check

Not-tested: Local tests and local app build, per task instruction to rely on CI before tagged reload.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@Sources/ContentView`+RightSidebarCommandPalette.swift:
- Around line 85-96: Extract the duplicated local closure into a single private
static helper and have both
commandPaletteRightSidebarToggleCommandContribution() and
commandPaletteRightSidebarModeCommandContributions() call it; specifically, add
a private static function (e.g., constantTitle(_: String) ->
(CommandPaletteContextSnapshot) -> String) that returns the closure used to
produce constant titles/subtitles, then replace the inline constant closures in
both functions with calls to this new helper so duplication is removed while
keeping the exact return type and behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: d3c6bac8-7aba-430a-8643-fa26139ea422

📥 Commits

Reviewing files that changed from the base of the PR and between 0ce2a24 and 49e1a32.

📒 Files selected for processing (9)
  • Resources/Localizable.xcstrings
  • Sources/AppDelegate.swift
  • Sources/ContentView+RightSidebarCommandPalette.swift
  • Sources/ContentView.swift
  • Sources/KeyboardShortcutSettings.swift
  • Sources/MainWindowFocusController.swift
  • Sources/cmuxApp.swift
  • cmuxTests/RightSidebarCommandPaletteTests.swift
  • web/data/cmux-shortcuts.ts

Comment thread Sources/ContentView+RightSidebarCommandPalette.swift
@greptile-apps

greptile-apps Bot commented May 12, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR implements a tri-state toggle for Cmd+Shift+E: show+focus when the right sidebar is hidden, focus-only when visible but unfocused, and hide when already focused. It also adds a palette.toggleRightSidebar command palette entry wired to the same logic.

  • MainWindowFocusController: the old toggleRightSidebarOrTerminalFocus/focusToggleDestination pair is replaced by performRightSidebarFocusShortcut + RightSidebarFocusShortcutAction.resolve, centralising the tri-state decision; the .hide arm correctly delegates to restoreFocusedPanelFocusFromRightSidebarIfNeeded (which handles both terminal and browser panels).
  • Command palette: palette.toggleRightSidebar is registered and routed through toggleRightSidebarKeyboardFocusInActiveMainWindow so it shares the same tri-state path as the keyboard shortcut.
  • Tests: new unit tests cover all three RightSidebarFocusShortcutAction.resolve branches and the command-palette shortcut mapping; existing tests are updated to use the new API.

Confidence Score: 5/5

Safe to merge — the tri-state toggle is well-scoped and the focus-restoration path has been corrected to handle both terminal and browser panels.

The refactor cleanly centralises the hide/focus/show decision in RightSidebarFocusShortcutAction.resolve, the hide arm delegates to restoreFocusedPanelFocusFromRightSidebarIfNeeded (which already handles non-terminal panels), and the command palette routing goes through the same tri-state path as the keyboard shortcut. All previously raised concerns have been addressed in the current HEAD, and new tests cover the three resolve branches and the command-palette mapping.

No files require special attention.

Important Files Changed

Filename Overview
Sources/MainWindowFocusController.swift Replaces toggleRightSidebarOrTerminalFocus/focusToggleDestination with performRightSidebarFocusShortcut + RightSidebarFocusShortcutAction; hide arm correctly calls restoreFocusedPanelFocusFromRightSidebarIfNeeded; .focus/.showAndFocus collapse is documented.
Sources/MainWindowFocusTypes.swift Removes now-unused MainWindowFocusToggleDestination enum; clean deletion with no remaining references.
Sources/AppDelegate.swift toggleRightSidebarKeyboardFocusInActiveMainWindow now calls performRightSidebarFocusShortcut(currentResponder:) instead of toggleRightSidebarOrTerminalFocus; blank line removal is cosmetic.
Sources/ContentView+RightSidebarCommandPalette.swift Adds commandPaletteRightSidebarToggleCommandContribution and maps palette.toggleRightSidebar to .focusRightSidebar; local helper extracted to static constantCommandPaletteText.
Sources/ContentView.swift Registers palette.toggleRightSidebar command handler routed through toggleRightSidebarKeyboardFocusInActiveMainWindow, consistent with the keyboard shortcut path.
cmuxTests/RightSidebarCommandPaletteTests.swift Adds RightSidebarFocusShortcutActionTests covering all three resolve branches and two command-palette mapping tests; thorough coverage of the new logic.
cmuxTests/ShortcutAndCommandPaletteTests.swift Updates existing tests to use rightSidebarFocusShortcutAction/performRightSidebarFocusShortcut; testFocusShortcutHideClearsRightSidebarIntentWhenTerminalIsUnavailable now correctly expects true (hide succeeds) and asserts isVisible is false.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["Cmd+Shift+E\nor palette.toggleRightSidebar"] --> B["toggleRightSidebarKeyboardFocusInActiveMainWindow"]
    B --> C["performRightSidebarFocusShortcut(currentResponder:)"]
    C --> D["rightSidebarFocusShortcutAction(isVisible:, currentResponder:)"]
    D --> E["RightSidebarFocusShortcutAction.resolve(isVisible:, isFocused:)"]
    E -->|"!isVisible"| F[".showAndFocus"]
    E -->|"isVisible && isFocused"| G[".hide"]
    E -->|"isVisible && !isFocused"| H[".focus"]
    F --> I["focusRightSidebar()"]
    H --> I
    G --> J["state.setVisible(false)"]
    J --> K["restoreFocusedPanelFocusFromRightSidebarIfNeeded(currentResponder:)"]
    K -->|"panel is TerminalPanel"| L["focusTerminal()"]
    K -->|"panel is BrowserPanel"| M["workspace.focusPanel + restoreFocusIntent"]
    K -->|"no panel available"| N["focusTerminalOrReleaseRightSidebarFocus"]
Loading

Reviews (3): Last reviewed commit: "Restore focused panel after right sideba..." | Re-trigger Greptile

Comment thread Sources/ContentView.swift
Comment on lines +7171 to +7177
registry.register(commandId: Self.commandPaletteToggleRightSidebarCommandID) {
if AppDelegate.shared?.toggleRightSidebarInActiveMainWindow(
preferredWindow: observedWindow ?? NSApp.keyWindow ?? NSApp.mainWindow
) != true {
NSSound.beep()
}
}

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.

P1 Command palette calls the wrong toggle function

The command palette handler calls toggleRightSidebarInActiveMainWindow, which is a pure visibility flip (visible→hide, hidden→show) with no focus awareness. The keyboard shortcut path calls toggleRightSidebarKeyboardFocusInActiveMainWindow → performRightSidebarFocusShortcut, which implements the new tri-state logic (focus when visible-but-unfocused, hide when focused, show+focus when hidden). Because the wrong function is used here, invoking "Toggle Right Sidebar" from the command palette when the sidebar is visible but unfocused will hide it instead of focusing it — the exact opposite of the intended PR behavior and inconsistent with the keyboard shortcut.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in f4af32a by routing the command palette entry through toggleRightSidebarKeyboardFocusInActiveMainWindow, so it now shares the same tri-state path as Cmd+Shift+E.

— Claude Code

Comment on lines +487 to +493
case .hide:
state.setVisible(false)
_ = restoreTerminalFocusAfterRightSidebarHiddenIfNeeded()
return true
case .focus, .showAndFocus:
return focusRightSidebar()
}

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.

P2 .focus and .showAndFocus arms collapse to identical code

Both case .focus and case .showAndFocus resolve to the same return focusRightSidebar() call, making RightSidebarFocusShortcutAction.showAndFocus a dead branch in performRightSidebarFocusShortcut. focusRightSidebar() already calls state.setVisible(true) unconditionally, so the distinction is correct at the resolve level, but the switch loses it immediately. If a future caller needs to behave differently for "focus only" vs "show then focus", the current collapsed arms offer no leverage. Consider at minimum a comment explaining why both arms reduce to the same call.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed in f4af32a with an inline comment explaining why .focus and .showAndFocus intentionally share focusRightSidebar().

— Claude Code

CodeRabbit flagged the duplicated local constant closure in the new right-sidebar palette contribution. Extract one private helper in the extension and keep the visibility-toggle command and mode commands on the same small text factory.

Constraint: Address high-priority review feedback before CI handoff.

Rejected: Leave duplicate local closures | review requested removal and the helper is behavior-preserving.

Confidence: high

Scope-risk: narrow

Directive: Keep palette contribution labels constant through this helper unless a command becomes context-sensitive.

Tested: git diff --check

Not-tested: Local tests and local app build, per task instruction to rely on CI before tagged reload.
The command palette entry must exercise the same focus-aware right-sidebar path as Cmd+Shift+E. A plain visibility toggle would hide a visible but unfocused sidebar instead of focusing it, which reintroduces split behavior across entrypoints.

Constraint: Shared behavior policy requires keyboard shortcut and command palette entrypoints to use one action path.

Rejected: Keep the palette on the pure visibility toggle | it diverges from the issue's focus-aware toggle semantics and review feedback.

Confidence: high

Scope-risk: narrow

Tested: git diff --check

Not-tested: Local tests/builds per user instruction; CI will verify.
@austinywang

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 12, 2026

Copy link
Copy Markdown
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit f4af32a. Configure here.

Comment thread Sources/MainWindowFocusController.swift
Comment on lines +487 to +490
case .hide:
state.setVisible(false)
_ = restoreTerminalFocusAfterRightSidebarHiddenIfNeeded()
return true

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.

P1 The .hide case calls restoreTerminalFocusAfterRightSidebarHiddenIfNeeded(), which routes through focusTerminalOrReleaseRightSidebarFocus and only knows how to focus a TerminalPanel. If the panel that was active before the user invoked Cmd+Shift+E is a browser panel, focusTerminal() will either jump to an unrelated terminal or fail entirely, leaving focus adrift. The pre-PR path for the same key event used restoreFocusedPanelFocusFromRightSidebarIfNeeded, which inspects workspace.focusedPanelId, handles non-terminal panels explicitly, and only falls back to focusTerminalOrReleaseRightSidebarFocus when no panel is available.

Suggested change
case .hide:
state.setVisible(false)
_ = restoreTerminalFocusAfterRightSidebarHiddenIfNeeded()
return true
case .hide:
state.setVisible(false)
_ = restoreFocusedPanelFocusFromRightSidebarIfNeeded(currentResponder: currentResponder)
return true

The right-sidebar shortcut now has one production execution path through performRightSidebarFocusShortcut. Keeping the older terminal/sidebar focus-toggle helper left tests covering behavior that production no longer used.

Constraint: Shared behavior policy requires tests and entrypoints to exercise the production action path.

Rejected: Keep the helper for tests only | it would preserve a dead branch and confuse future shortcut changes.

Confidence: high

Scope-risk: narrow

Tested: rg confirmed no remaining references; git diff --check

Not-tested: Local tests/builds per user instruction; CI will verify.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@Sources/ContentView`+RightSidebarCommandPalette.swift:
- Around line 32-33: The command palette entry for
Self.commandPaletteToggleRightSidebarCommandID currently returns the
.focusRightSidebar action but the UI uses .toggleRightSidebar.label for the
title, causing a mismatch; fix it by returning .toggleRightSidebar instead of
.focusRightSidebar (or alternatively update the title to use
.focusRightSidebar.label), updating the switch/case that maps
Self.commandPaletteToggleRightSidebarCommandID so the action and label
(.toggleRightSidebar or .focusRightSidebar.label) are consistent.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 81958575-3a9c-476e-a468-16ea98965832

📥 Commits

Reviewing files that changed from the base of the PR and between 49e1a32 and f4af32a.

📒 Files selected for processing (4)
  • Sources/AppDelegate.swift
  • Sources/ContentView+RightSidebarCommandPalette.swift
  • Sources/ContentView.swift
  • Sources/MainWindowFocusController.swift

Comment thread Sources/ContentView+RightSidebarCommandPalette.swift
The focus-aware right-sidebar toggle should preserve the user's previous main-panel context when hiding the sidebar. The command palette entry also now uses the same shortcut action for its title and shortcut hint.

Constraint: Shortcut, menu, and palette behavior share one tri-state focus path.

Rejected: Terminal-only restoration | loses focus context for browser or other non-terminal panels.

Confidence: high

Scope-risk: narrow

Tested: git diff --check

Not-tested: Local tests/builds per user instruction; CI will verify.
@austinywang

Copy link
Copy Markdown
Contributor Author

Closing — the underlying behavior (Cmd+Shift+E toggles the right sidebar dock) was already shipped through a different change, so this branch is no longer needed.

This branch was successfully deployed

1 active deployment
Preview – cmux — f13b2473 Deployed May 12, 2026 by vercel[bot]
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.

I can't figure out how to close the right sidebar for the dock.

1 participant