Skip to content

feat(sidebar): add ⌘B shortcut to collapse/expand sidebar#5047

Open
waleedlatif1 wants to merge 2 commits into
stagingfrom
worktree-sidebar-cmdb-collapse
Open

feat(sidebar): add ⌘B shortcut to collapse/expand sidebar#5047
waleedlatif1 wants to merge 2 commits into
stagingfrom
worktree-sidebar-cmdb-collapse

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • Added ⌘B (Ctrl+B on Windows) global shortcut to collapse/expand the workspace sidebar
  • Registered as a first-class entry in the central command registry (collapse-sidebar, Mod+B)
  • Surfaced the shortcut in the collapse button's tooltip via the existing Tooltip.Shortcut, platform-aware (⌘ vs Ctrl)

Type of Change

  • New feature

Testing

Tested manually — ⌘B toggles the sidebar from anywhere in the workspace; tooltip shows the shortcut.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)
@vercel

vercel Bot commented Jun 15, 2026

Copy link
Copy Markdown

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

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Jun 15, 2026 1:59am

Request Review

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

@cursor

cursor Bot commented Jun 15, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
UI-only keyboard shortcut and tooltip wiring; no auth, data, or API changes. Mod+B may overlap with browser bold in some contexts, but the command is disabled in editable fields.

Overview
Adds a workspace-wide Mod+B (collapse-sidebar) global command that toggles sidebar collapse via the existing sidebar store, with allowInEditable: false so it does not fire while typing in inputs.

Introduces formatCommandShortcut in the command registry so tooltip labels stay aligned with registered bindings (macOS symbols vs Ctrl+ labels elsewhere). The collapse control and collapsed Expand sidebar affordance show that shortcut through Tooltip.Shortcut.

SidebarTooltip gains an optional shortcut prop for the same pattern on the collapse button.

Reviewed by Cursor Bugbot for commit 97d8c98. Configure here.

@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.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 64d4dd0. Configure here.

@greptile-apps

greptile-apps Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds a ⌘B / Ctrl+B keyboard shortcut to toggle the workspace sidebar, wiring it through the central command registry (collapse-sidebar, Mod+B, allowInEditable: false) and surfacing it in both the collapse button tooltip and the expand affordance in WorkspaceHeader. A new formatCommandShortcut helper derives display strings from COMMAND_DEFINITIONS, eliminating the risk of tooltips drifting from the registered binding.

  • Registry entry (commands-utils.ts): adds 'collapse-sidebar' to CommandId, declares Mod+B with allowInEditable: false (matching run-workflow and clear-terminal-console to preserve native bold in editable fields), and adds formatCommandShortcut for platform-aware tooltip labels.
  • Sidebar (sidebar.tsx): registers the handler via useRegisterGlobalCommands, extends SidebarTooltip with an optional shortcut prop, and passes the formatted shortcut to both the collapse button and WorkspaceHeader.
  • WorkspaceHeader (workspace-header.tsx): wraps the collapsed-state expand button in a Tooltip.Root/Trigger/Content tree so the ⌘B hint is discoverable from both open and collapsed states.

Confidence Score: 5/5

Safe to merge — the shortcut is correctly scoped to non-editable contexts, tooltips derive from a single source of truth, and both the collapse and expand affordances surface the hint.

The three previously flagged concerns are all resolved in this revision. isMacPlatform() is SSR-safe, formatCommandShortcut is pure and correct for multi-token shortcut strings, and the Tooltip wrapper in WorkspaceHeader degrades cleanly when expandShortcut is omitted. No new logic errors or regressions introduced.

No files require special attention.

Important Files Changed

Filename Overview
apps/sim/app/workspace/[workspaceId]/utils/commands-utils.ts Adds collapse-sidebar command definition with allowInEditable: false and a well-documented formatCommandShortcut helper; both additions are clean and follow existing patterns.
apps/sim/app/workspace/[workspaceId]/w/components/sidebar/sidebar.tsx Registers the collapse command, threads the formatted shortcut string through SidebarTooltip and WorkspaceHeader; changes are minimal, consistent with existing patterns, and free of logic errors.
apps/sim/app/workspace/[workspaceId]/w/components/sidebar/components/workspace-header/workspace-header.tsx Wraps the collapsed-state expand button with Tooltip.Root/Trigger/Content to expose the keyboard shortcut hint; JSX restructuring is correct and the new expandShortcut prop is optional with a safe fallback.

Reviews (5): Last reviewed commit: "improvement(sidebar): address review — s..." | Re-trigger Greptile

Comment thread apps/sim/app/workspace/[workspaceId]/utils/commands-utils.ts
@greptile-apps

greptile-apps Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR registers ⌘B / Ctrl+B as a global shortcut to collapse/expand the workspace sidebar, wires it through the central COMMAND_DEFINITIONS registry, and surfaces a platform-aware key hint in the collapse button's tooltip via Tooltip.Shortcut.

  • collapse-sidebar is added to COMMAND_DEFINITIONS with shortcut: 'Mod+B' and allowInEditable: true; the sidebar registers a handler that calls toggleCollapsed().
  • SidebarTooltip gains an optional shortcut prop that switches from a plain <p> to a Tooltip.Shortcut when provided; the collapse button passes isMac ? '⌘B' : 'Ctrl+B'.
  • The shortcut hint is only surfaced on the collapse button (sidebar open state); the expand path in WorkspaceHeader does not carry the hint, leaving a discoverability gap for users who first see the collapsed sidebar.

Confidence Score: 4/5

Safe to merge; the changes are small and self-contained, with no effect on data or auth. The main practical risk is Mod+B being intercepted in text inputs/contenteditable elements, which could break bold formatting if rich-text editors exist in the workspace.

The implementation is clean and consistent with how other global shortcuts are wired. The allowInEditable: true on Mod+B is the one decision that could cause unexpected behavior: the capture-phase listener calls preventDefault() unconditionally, so any future (or existing) rich-text editor would silently lose its bold shortcut. The tooltip string is also hardcoded rather than derived from the registry, which is a minor drift risk. Neither concern is blocking, but the allowInEditable choice is worth deliberate confirmation from the team.

commands-utils.ts — specifically the allowInEditable: true decision for collapse-sidebar deserves a second look before merging.

Important Files Changed

Filename Overview
apps/sim/app/workspace/[workspaceId]/utils/commands-utils.ts Adds collapse-sidebar to the CommandId union and registers it with shortcut Mod+B and allowInEditable: true. The choice of Mod+B (Bold) with allowInEditable: true is the one aspect worth scrutinising given the capture-phase interceptor in the provider.
apps/sim/app/workspace/[workspaceId]/w/components/sidebar/sidebar.tsx Wires the collapse-sidebar global command to toggleCollapsed(), adds an optional shortcut prop to SidebarTooltip, and surfaces the platform-aware key hint on the collapse button. Hardcoded display string doesn't derive from COMMAND_DEFINITIONS, creating a potential drift risk.

Sequence Diagram

sequenceDiagram
    participant User
    participant GlobalCommandsProvider
    participant Sidebar

    User->>GlobalCommandsProvider: keydown ⌘B / Ctrl+B (capture phase)
    GlobalCommandsProvider->>GlobalCommandsProvider: matchesShortcut("collapse-sidebar")
    GlobalCommandsProvider->>GlobalCommandsProvider: e.preventDefault() + e.stopPropagation()
    GlobalCommandsProvider->>Sidebar: handler() → toggleCollapsed()
    Sidebar->>Sidebar: isCollapsed state flipped

    Note over User,Sidebar: Tooltip path (sidebar expanded)
    User->>Sidebar: hover collapse button
    Sidebar->>User: SidebarTooltip shows "Collapse sidebar ⌘B"
Loading

Reviews (2): Last reviewed commit: "feat(sidebar): add ⌘B shortcut to collap..." | Re-trigger Greptile

Comment thread apps/sim/app/workspace/[workspaceId]/utils/commands-utils.ts
Comment thread apps/sim/app/workspace/[workspaceId]/w/components/sidebar/sidebar.tsx Outdated
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

@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 97d8c98. Configure here.

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile review

@waleedlatif1 waleedlatif1 deleted the branch staging July 1, 2026 05:43
@waleedlatif1 waleedlatif1 reopened this Jul 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant