Skip to content

Second change - #3766

Merged
austinywang merged 3 commits into
mainfrom
partial
May 9, 2026
Merged

austinywang merged 3 commits into
mainfrom
partial

Conversation

@austinywang

@austinywang austinywang commented May 9, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • What changed?
  • Why?

Testing

  • How did you test this change?
  • What did you verify manually?

Demo Video

For UI or behavior changes, include a short demo video (GitHub upload, Loom, or other direct link).

  • Video URL or attachment:

Review Trigger (Copy/Paste as PR comment)

@codex review
@coderabbitai review
@greptile-apps review
@cubic-dev-ai review

Checklist

  • I tested the change locally
  • I added or updated tests for behavior changes
  • I updated docs/changelog if needed
  • I requested bot reviews after my latest commit (copy/paste block above or equivalent)
  • All code review bot comments are resolved
  • All human review comments are resolved

Note

Medium Risk
Changes right-sidebar shortcut behavior and focus restoration logic in AppDelegate, which can affect key handling and window focus across main windows. Risk is moderated by added shortcut routing tests covering the new toggle and file-explorer mode behavior.

Overview
Updates right-sidebar shortcut handling so “Toggle Right Sidebar” now toggles visibility (hide if visible; otherwise reveal and focus the sidebar) via new toggleRightSidebarVisibilityInActiveMainWindow, removing the older toggleRightSidebarInActiveMainWindow and the focus/terminal-toggle behavior.

Changes the Open File Explorer shortcut to always reveal the right sidebar in Files mode (and focus the first item) instead of a generic toggle, and updates the corresponding SwiftUI menu command to use the new visibility toggle.

Adds tests asserting that the focus-right-sidebar shortcut flips fileExplorer.isVisible on successive presses, and that Open File Explorer selects .files even if .find was previously active.

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


Summary by cubic

Fixes right-sidebar shortcuts to match labels: Cmd-Option-B now toggles visibility, and Cmd-Shift-E always opens the Files mode and focuses the first item. Refactors shortcut routing to explicit visibility/mode actions and adds tests to prevent regressions.

  • Bug Fixes

    • Cmd-Option-B routes to a visibility toggle via toggleRightSidebarVisibilityInActiveMainWindow (no longer just shifts focus back to the terminal).
    • Cmd-Shift-E routes to focusRightSidebarInActiveMainWindow(mode: .files, focusFirstItem: true) so Files is selected even if Find was last used.
    • Removed toggleRightSidebarInActiveMainWindow and updated related logs/labels from “focus” to “visibility”.
    • Added unit tests for visibility toggle and Files-mode selection.
  • Dependencies

    • Update vendor/bonsplit submodule pointer.

Written for commit 538e60a. Summary will update on new commits.

Summary by CodeRabbit

  • Improvements

    • Right sidebar toggle functionality refined; terminal focus is now restored when the sidebar is hidden.
    • Enhanced file explorer and sidebar keyboard shortcut interactions.
  • Tests

    • Added verification tests for right sidebar toggle and file explorer shortcut behavior.

The remappable right-sidebar shortcuts had drifted: the action labeled Toggle Right Sidebar only moved focus back to the terminal, and Open File Explorer reused the last right-sidebar mode instead of selecting Files. Route those shortcuts through explicit shared actions so Cmd-Option-B toggles visibility and Cmd-Shift-E opens the Files mode regardless of the previous mode.

Constraint: Do not include the pre-existing vendor/bonsplit submodule dirty state

Rejected: Keep Cmd-Shift-E as a generic sidebar visibility toggle | it preserves stale Find mode and violates the action label

Confidence: high

Scope-risk: narrow

Directive: Keep right-sidebar shortcut labels aligned with visibility and mode behavior; do not route Open File Explorer through a mode-preserving toggle

Tested: ./scripts/reload.sh --tag fix-right-sidebar-toggle --launch

Not-tested: Local unit test suite per repository testing policy
@vercel

vercel Bot commented May 9, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
cmux Building Building Preview, Comment May 9, 2026 0:21am
cmux-staging Building Building Preview, Comment May 9, 2026 0:21am

@chatgpt-codex-connector

Copy link
Copy Markdown

To use Codex here, create a Codex account and connect to github.

@coderabbitai

coderabbitai Bot commented May 9, 2026 •

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 14f6433d-cc33-450a-b4bd-8e8df2c242d1

📥 Commits

Reviewing files that changed from the base of the PR and between 23dfd15 and 538e60a.

📒 Files selected for processing (4)
  • Sources/AppDelegate.swift
  • Sources/cmuxApp.swift
  • cmuxTests/AppDelegateShortcutRoutingTests.swift
  • vendor/bonsplit

📝 Walkthrough

Walkthrough

This PR refactors the right-sidebar toggle and focus API in AppDelegate by removing two keyboard-focus-based methods and introducing a new visibility-based toggle method. The new method directly manages fileExplorerState.isVisible and restores terminal focus when hiding. Shortcut routing and menu commands are updated to use the new API, and two test cases validate the behavior for visibility toggling and mode switching.

Changes

Right Sidebar Toggle/Focus API Refactoring

Layer / File(s) Summary
API Changes: Visibility Toggle Method
Sources/AppDelegate.swift
Removes toggleRightSidebarInActiveMainWindow and toggleRightSidebarKeyboardFocusInActiveMainWindow; adds toggleRightSidebarVisibilityInActiveMainWindow that toggles fileExplorerState.isVisible and calls restoreTerminalFocusAfterRightSidebarHiddenIfNeeded() when hiding.
Shortcut Routing Updates
Sources/AppDelegate.swift
Updates .toggleFileExplorer shortcut to call focusRightSidebarInActiveMainWindow(mode: .files, focusFirstItem: true) and .focusRightSidebar shortcut to call the new visibility toggle method with updated debug logging.
Menu Command Integration
Sources/cmuxApp.swift
"Toggle Right Sidebar" menu command is rewired to call the new toggleRightSidebarVisibilityInActiveMainWindow() method instead of the previous keyboard-focus toggle.
Tests and Validation
cmuxTests/AppDelegateShortcutRoutingTests.swift
Two new test cases: testFocusRightSidebarShortcutTogglesRightSidebarVisibility verifies visibility toggling on Cmd+Option+B; testOpenFileExplorerShortcutSelectsFilesModeWhenFindWasActive verifies mode switching to .files on Cmd+Shift+E when sidebar was in .find mode.
Dependencies
vendor/bonsplit
Submodule commit reference is updated to a new revision.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • manaflow-ai/cmux#3733: Both PRs modify right-sidebar toggle behavior and shortcut routing in AppDelegate and related wiring.
  • manaflow-ai/cmux#3728: Introduces the shortcut labels and architectural changes that align with this PR's toggle and mode-switching refactoring.
  • manaflow-ai/cmux#3104: Both PRs refactor AppDelegate shortcut routing and right-sidebar toggle logic.

Poem

A toggle born anew in sight,
No keyboard dance, just visible light—
When hidden, terminal takes the stage,
Two shortcuts waltz across the page. 🎭

✨ 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 partial

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.

@austinywang
austinywang merged commit 53c458e into main May 9, 2026
16 of 24 checks passed
@greptile-apps

greptile-apps Bot commented May 9, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR refactors the right sidebar shortcut behavior: the old 3-state focus cycle (toggleRightSidebarOrTerminalFocus) is replaced with a clean 2-state visibility toggle (toggleRightSidebarVisibilityInActiveMainWindow), and the "Open File Explorer" shortcut is changed from a toggle to an always-open-in-files-mode action. Two new tests cover the primary transitions for both shortcuts.

  • AppDelegate.swift: Removes toggleRightSidebarInActiveMainWindow, renames and reworks toggleRightSidebarKeyboardFocusInActiveMainWindow \u2192 toggleRightSidebarVisibilityInActiveMainWindow. When visible, the sidebar is hidden and terminal focus is restored; when hidden, focusRightSidebar() is called to show and focus.
  • cmuxApp.swift: One-line update to the menu action; fallback chain unchanged.
  • vendor/bonsplit: Submodule bumped with no description of what changed upstream.

Confidence Score: 4/5

Safe to merge; production logic is clean with only minor test coverage gaps and an undescribed submodule bump.

The refactor to toggleRightSidebarVisibilityInActiveMainWindow is straightforward and the new tests cover the primary show/hide transitions. However, the semantic shift where a visible-sidebar + terminal-focused shortcut press now hides the sidebar (previously it moved focus to the sidebar) has no test coverage. The vendor/bonsplit submodule bump is also undescribed.

Sources/AppDelegate.swift around the show/hide logic in toggleRightSidebarVisibilityInActiveMainWindow, and vendor/bonsplit for the undescribed upstream change.

Important Files Changed

Filename Overview
Sources/AppDelegate.swift Removes toggleRightSidebarInActiveMainWindow and reworks toggleRightSidebarKeyboardFocusInActiveMainWindow → toggleRightSidebarVisibilityInActiveMainWindow: 2-state visibility toggle with hide+focus-restore or show via focusRightSidebar(). The .toggleFileExplorer path now always opens in Files mode.
Sources/cmuxApp.swift One-line update to call the renamed toggleRightSidebarVisibilityInActiveMainWindow; fallback chain unchanged. No issues.
cmuxTests/AppDelegateShortcutRoutingTests.swift Adds two new tests for visibility-toggle and mode-selection shortcuts. Does not cover the sidebar-visible + terminal-focused edge case.
vendor/bonsplit Submodule bumped from f65eccb to 90f4981 with no description of what changed upstream.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Keyboard shortcut fired] --> B{Which action?}
    B -->|.focusRightSidebar| C[toggleRightSidebarVisibilityInActiveMainWindow]
    B -->|.toggleFileExplorer| D[Task at MainActor - focusRightSidebarInActiveMainWindow mode=.files]
    C --> E{context available?}
    E -->|No| F[return false]
    E -->|Yes| G{state available?}
    G -->|No| F
    G -->|Yes| H{state.isVisible?}
    H -->|Yes - hide| I[state.setVisible false + restoreTerminalFocus + return true]
    H -->|No - show| J[focusForInWindowCommand + focusRightSidebar + return result]
    D --> K[Shows sidebar in Files mode and focuses first item]
Loading

Reviews (1): Last reviewed commit: "Merge branch 'main' of https://github.co..." | Re-trigger Greptile

Comment on lines +4507 to +4508
window.makeKeyAndOrderFront(nil)
RunLoop.main.run(until: Date(timeIntervalSinceNow: 0.05))

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 Test covers only two of three sidebar states

testFocusRightSidebarShortcutTogglesRightSidebarVisibility always begins with state.setVisible(false) before driving the shortcut, so it verifies the "hidden → show" and "visible → hide" transitions only. The previous toggleRightSidebarOrTerminalFocus() had a third state: sidebar visible with keyboard focus on the terminal, where the old behavior would have moved focus to the sidebar. The new toggleRightSidebarVisibilityInActiveMainWindow unconditionally hides the sidebar in that state instead — a user-visible change that has no test coverage. If that semantic change is intentional, a comment or a third test case would prevent a future accidental reversion.

Comment thread vendor/bonsplit
@@ -1 +1 @@
Subproject commit f65eccb2e4bf3e77662902f7c44a650fba3b3540
Subproject commit 90f4981f6a990a2282b2433a67f32edc89306c36

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 Opaque submodule bump

The vendor/bonsplit submodule is advanced from f65eccb to 90f4981 with no description of what changed or why. Please add a brief note in the PR description explaining the relevant upstream commits (e.g., bug fix, API change, version tag) so reviewers and the audit trail can evaluate the change.

This branch was successfully deployed

1 active deployment
Preview – cmux — 538e60a1 Deployed May 9, 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.

1 participant