Skip to content

fix: Cmd+Left/Right tab shortcuts broken when sidebar has focus — scroll jumps instead#841

Open
scriptease wants to merge 1 commit intoRunMaestro:rcfrom
scriptease:feat/cmd-arrow-broken
Open

fix: Cmd+Left/Right tab shortcuts broken when sidebar has focus — scroll jumps instead#841
scriptease wants to merge 1 commit intoRunMaestro:rcfrom
scriptease:feat/cmd-arrow-broken

Conversation

@scriptease
Copy link
Copy Markdown

@scriptease scriptease commented Apr 15, 2026

Summary

  • Cmd+Left/Right Arrow configured as previous/next tab shortcuts had no effect when the sidebar had focus — groups collapsed/expanded instead

Root Cause

handleSidebarNavigation in useKeyboardNavigation.ts was catching all ArrowLeft/ArrowRight events when the sidebar had focus, regardless of modifier keys. Only Alt+Cmd+Arrow was previously excluded. The handler called preventDefault() and returned true, preventing the nextTab/prevTab shortcut handlers from ever being reached.

Fix

Broadened the guard in handleSidebarNavigation to skip any Cmd/Ctrl+Arrow combination (with or without Alt). Plain ArrowLeft/ArrowRight (no modifiers) still handles group collapse/expand in the sidebar.

Test plan

  • Configure "Next Tab" → Cmd+Right Arrow, "Previous Tab" → Cmd+Left Arrow
  • Click an agent in the sidebar to give it focus
  • Press Cmd+Right Arrow — should navigate to next tab, not collapse a group
  • Press Cmd+Left Arrow — should navigate to previous tab, not collapse a group
  • Plain ArrowLeft/ArrowRight (no Cmd) still collapses/expands groups in sidebar
  • Alt+Cmd+Arrow still toggles layout as expected

Summary by CodeRabbit

  • Bug Fixes
    • Refined sidebar arrow-key keyboard navigation behavior when using Cmd/Ctrl modifier keys for more consistent shortcut handling.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 15, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 817cdd1f-f468-4794-b7ae-a5fb7d35e91b

📥 Commits

Reviewing files that changed from the base of the PR and between 3ccb6ad and 80e121d.

📒 Files selected for processing (1)
  • src/renderer/hooks/keyboard/useKeyboardNavigation.ts
✅ Files skipped from review due to trivial changes (1)
  • src/renderer/hooks/keyboard/useKeyboardNavigation.ts

📝 Walkthrough

Walkthrough

Updated the sidebar arrow-key shortcut suppression logic in the keyboard navigation hook. Modified the condition to skip command/control-modified arrow keys regardless of the Alt modifier state, and clarified that unmodified arrow keys remain reserved for group and bookmarks collapse/expand operations.

Changes

Cohort / File(s) Summary
Keyboard Navigation Logic
src/renderer/hooks/keyboard/useKeyboardNavigation.ts
Broadened the condition for suppressing sidebar arrow-key shortcuts to skip whenever Cmd/Ctrl is held with ArrowLeft/ArrowRight, regardless of Alt modifier. Updated accompanying comment to clarify that plain unmodified arrow keys are reserved for group and bookmarks collapse/expand behavior.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

A rabbit hops through arrow keys,
With modifiers dancing with ease,
Ctrl and Cmd now skip right through,
While plain arrows do their due,
Group collapse—the nav's debut! 🐰⌨️

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title directly addresses the main fix: broadening the guard condition for Cmd+Left/Right arrow shortcuts to work when sidebar has focus, which is the primary change in the changeset.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@scriptease scriptease marked this pull request as draft April 15, 2026 15:07
@scriptease scriptease force-pushed the feat/cmd-arrow-broken branch from 3ccb6ad to 80e121d Compare April 15, 2026 15:10
@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented Apr 15, 2026

Greptile Summary

Adds a targeted isModifiedArrow guard in handleSidebarNavigation that returns early when metaKey or ctrlKey is held with ArrowLeft/ArrowRight, so user-configured Cmd+Left/Right (or Ctrl+Left/Right) tab shortcuts are no longer consumed by the sidebar. Plain arrow keys and other modifier combinations are unaffected.

Confidence Score: 5/5

Safe to merge — the fix is minimal, correct, and does not regress existing sidebar navigation behaviour.

The change is a single targeted guard that early-returns for Cmd/Ctrl+ArrowLeft/Right before any side-effecting code is reached. No logic is removed; plain arrows and all other modifiers behave identically to before. No new P0/P1 findings were identified beyond what previous threads already cover.

No files require special attention.

Important Files Changed

Filename Overview
src/renderer/hooks/keyboard/useKeyboardNavigation.ts Adds an isModifiedArrow guard (lines 143–145) to skip Cmd/Ctrl+ArrowLeft/Right events before the sidebar collapse/expand logic, letting user-configured tab shortcuts pass through; all other navigation logic is untouched.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[KeyboardEvent fires] --> B{focus === sidebar?}
    B -- No --> Z[return false]
    B -- Yes --> C{Target is input element?}
    C -- Yes --> Z
    C -- No --> D{Cmd/Ctrl + ArrowLeft or ArrowRight?}
    D -- Yes --> Z2[return false - pass to tab shortcut handler]
    D -- No --> E{Key in arrow/space set?}
    E -- No --> Z
    E -- Yes --> F[e.preventDefault called]
    F --> G{Which key?}
    G -- ArrowLeft --> H[Collapse group or bookmarks]
    G -- ArrowRight --> I[Expand group or bookmarks]
    G -- Space --> J[Collapse group, jump to nearest visible]
    G -- ArrowUp or ArrowDown --> K[Navigate sessions, auto-expand collapsed groups]
Loading

Reviews (2): Last reviewed commit: "`Cmd+Left/Right` tab shortcuts broken wh..." | Re-trigger Greptile

Comment thread src/renderer/hooks/keyboard/useKeyboardNavigation.ts
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/main/index.ts`:
- Around line 606-607: The branch-name check using /rc/i.test(branch) is too
broad and can match strings like "feature/force-icon"; update the condition
around the icon selection (the if that checks branch and tag and sets iconFile =
'Maestro_rc.png') to only match an exact "rc" branch or "rc/..." pattern (e.g.,
test for branch === 'rc' or branch starting with 'rc/' or use a regex anchored
to the start like ^rc(?:\/|$) with case-insensitivity) so only true
release-candidate branches get the RC icon.
- Around line 609-611: The empty catch swallowing git resolution errors should
be replaced to capture the thrown error: change the catch block handling the
"git resolution / icon selection" logic to catch (err) and either log a clear
warning including the error (using the existing logger, e.g.,
processLogger.warn/error or console.warn) and continue with the dev-icon
fallback for expected failures, or re-throw unexpected errors so they surface to
Sentry; update the catch in the icon-selection try/catch in index.ts to log the
error message and stack and only swallow known/recoverable cases while
re-throwing others.
🪄 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: CHILL

Plan: Pro

Run ID: aaf30585-40e0-44a0-8f53-781fd391b35c

📥 Commits

Reviewing files that changed from the base of the PR and between 03eb4ba and 3ccb6ad.

⛔ Files ignored due to path filters (12)
  • build/icon.ico is excluded by !**/*.ico
  • build/icon.png is excluded by !**/*.png
  • build/newest-icon/Maestro.png is excluded by !**/*.png
  • build/newest-icon/Maestro_dev.ico is excluded by !**/*.ico
  • build/newest-icon/Maestro_dev.png is excluded by !**/*.png
  • build/newest-icon/Maestro_dev_dock.png is excluded by !**/*.png
  • build/newest-icon/Maestro_dock.png is excluded by !**/*.png
  • build/newest-icon/Maestro_rc.ico is excluded by !**/*.ico
  • build/newest-icon/Maestro_rc.png is excluded by !**/*.png
  • build/newest-icon/Maestro_rc_dock.png is excluded by !**/*.png
  • build/old-icon/icon.ico is excluded by !**/*.ico
  • build/old-icon/icon.png is excluded by !**/*.png
📒 Files selected for processing (6)
  • build/icon.icns
  • build/newest-icon/Maestro_dev.icns
  • build/newest-icon/Maestro_rc.icns
  • build/old-icon/icon.icns
  • src/main/index.ts
  • src/renderer/hooks/keyboard/useKeyboardNavigation.ts

Comment thread src/main/index.ts Outdated
Comment thread src/main/index.ts Outdated
@scriptease scriptease marked this pull request as ready for review April 15, 2026 15:19
@scriptease
Copy link
Copy Markdown
Author

@pedramamini I tried to set CMD+left and right but the navigation view would keep stealing the arrow keys

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.

2 participants