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

@greptile

@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 wires up a ⌘B / Ctrl+B global shortcut to toggle the workspace sidebar. The shortcut is registered as collapse-sidebar in the central command registry with allowInEditable: false (preventing conflicts with native bold in text editors), and a new formatCommandShortcut helper derives the display string from the registry so tooltips can never drift from the bound key.

  • commands-utils.ts: Adds the collapse-sidebar command definition and formatCommandShortcut, which tokenises any Mod+… shortcut string and renders platform-correct symbols (⌘B vs Ctrl+B).
  • sidebar.tsx: Registers the command handler, computes collapseShortcut once per render, and passes it to both the collapse-button SidebarTooltip and the WorkspaceHeader expand affordance.
  • workspace-header.tsx: The collapsed-state expand button is now wrapped in a Tooltip.Root tree and accepts an optional expandShortcut prop, completing the discoverability story for both sidebar states.

Confidence Score: 5/5

Safe to merge — the change is additive, touches only sidebar toggling and tooltip display, and correctly guards the shortcut from editable surfaces.

All three files make narrow, well-scoped additions: the new command entry, a pure helper function, and two tooltip wrappers. The allowInEditable: false guard prevents any input/textarea interference. The formatCommandShortcut helper derives its output directly from the registry, eliminating tooltip/binding drift. No state management, data paths, or API routes are affected.

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 new formatCommandShortcut helper that derives display strings from the registry — no drift risk, correct tokenisation for Mod+B.
apps/sim/app/workspace/[workspaceId]/w/components/sidebar/components/workspace-header/workspace-header.tsx Wraps the collapsed-state expand button in Tooltip.Root/Trigger/Content with an optional expandShortcut prop; falls back gracefully to plain text when the prop is absent.
apps/sim/app/workspace/[workspaceId]/w/components/sidebar/sidebar.tsx Registers the collapse-sidebar global command, derives collapseShortcut via formatCommandShortcut, and threads it through both the collapse-button SidebarTooltip and the WorkspaceHeader expand affordance.

Sequence Diagram

sequenceDiagram
    participant User
    participant GlobalCommandsProvider
    participant SidebarStore
    participant Sidebar
    participant WorkspaceHeader

    User->>GlobalCommandsProvider: keydown ⌘B / Ctrl+B
    Note over GlobalCommandsProvider: allowInEditable: false<br/>skips inputs/textareas
    GlobalCommandsProvider->>SidebarStore: toggleCollapsed()
    SidebarStore-->>Sidebar: isCollapsed state change
    alt Sidebar expanding (was collapsed)
        Sidebar->>WorkspaceHeader: "isCollapsed=false"
        WorkspaceHeader-->>User: Full sidebar visible, collapse tooltip shows ⌘B
    else Sidebar collapsing (was open)
        Sidebar->>WorkspaceHeader: "isCollapsed=true, expandShortcut=⌘B"
        WorkspaceHeader-->>User: Collapsed expand button, tooltip shows ⌘B
    end
Loading

Reviews (4): 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

@greptile

@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

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