Skip to content

fix:shortcut for changing hand and cursor mode#5131

Open
Rjshakya wants to merge 2 commits into
simstudioai:mainfrom
Rjshakya:fix(shortcut)
Open

fix:shortcut for changing hand and cursor mode#5131
Rjshakya wants to merge 2 commits into
simstudioai:mainfrom
Rjshakya:fix(shortcut)

Conversation

@Rjshakya

Copy link
Copy Markdown

Adds keyboard shortcuts for switching canvas modes and updates the matching UI labels.

  • P → switch to Pointer (cursor) mode
  • M → switch to Mover (hand) mode

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation
  • Other: ______

Testing

  • Verified the new commands are registered in COMMAND_DEFINITIONS.
  • Confirmed workflow-controls.tsx calls setMode('cursor') / setMode('hand') from the handlers.
  • Shortcuts are set with allowInEditable: false, so they won't fire while typing in inputs/textareas.

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)

Screenshots/Videos

before :
https://github.com/user-attachments/assets/dc64c564-56ad-49d8-b3bc-43757b3ae633

after :

after.mp4

@vercel

vercel Bot commented Jun 18, 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 18, 2026 9:36pm

Request Review

@cursor

cursor Bot commented Jun 18, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
Small UX-only change to canvas mode switching and labels; no auth, data, or execution path changes.

Overview
Adds global keyboard shortcuts to switch the workflow canvas between Pointer and Mover: P → cursor mode, M → hand mode. Both commands are registered in the central command registry with allowInEditable: false so they do not fire while typing in inputs.

workflow-controls wires those commands to the existing setMode store and surfaces the keys in the canvas mode tooltip (Tooltip.Shortcut) and in the mode popover labels.

Reviewed by Cursor Bugbot for commit 08248c1. Bugbot is set up for automated code reviews on this repo. 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.

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.

Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 3b8f2b8. Configure here.

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

greptile-apps Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds P and M keyboard shortcuts for switching between Pointer (cursor) and Mover (hand) canvas modes, and updates the tooltip and popover UI to display the shortcut hints.

  • Shortcut registration (commands-utils.ts): Two new command definitions are added with shortcuts Shift+P and Shift+M, but the UI labels display bare P and M — users pressing the advertised key alone will find the command never fires.
  • UI wiring (workflow-controls.tsx): Commands are registered via useRegisterGlobalCommands, the tooltip is upgraded to Tooltip.Shortcut, and popover items now include a shortcut badge alongside each label.

Confidence Score: 3/5

The new shortcut commands are wired up correctly at the handler level, but the shortcut key strings in the registry require Shift while every user-visible label omits it, so the advertised shortcuts will not work as shown.

The core behaviour of the feature is broken as shipped: shortcuts are registered as Shift+P / Shift+M but the tooltip and popover both display bare P / M, meaning users following the UI hint will never trigger the command. The fix is a one-line change in either the registry or the labels.

Both changed files need attention: commands-utils.ts to decide whether the shortcut should be bare P/M or Shift+P/Shift+M, and workflow-controls.tsx to update the displayed keys to match whatever is chosen.

Important Files Changed

Filename Overview
apps/sim/app/workspace/[workspaceId]/utils/commands-utils.ts Adds two new command IDs and definitions for pointer/mover canvas mode shortcuts, but the registered shortcuts (Shift+P, Shift+M) don't match the UI labels (P, M), making the shortcuts non-functional as advertised.
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/workflow-controls/workflow-controls.tsx Registers the new commands, updates the tooltip to use Tooltip.Shortcut, and shows shortcut labels in the popover — correct direction, but shortcut keys displayed (P, M) are inconsistent with the Shift+ prefix in the registry. Minor trailing whitespace in two className strings.

Sequence Diagram

%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
    participant User
    participant GlobalCommandsProvider
    participant CanvasModeStore

    User->>GlobalCommandsProvider: keydown P (as shown in UI)
    GlobalCommandsProvider->>GlobalCommandsProvider: "matchesShortcut() requires shiftKey===true"
    GlobalCommandsProvider-->>User: No match, command ignored
    User->>GlobalCommandsProvider: keydown Shift+P (actual registered)
    GlobalCommandsProvider->>CanvasModeStore: setMode('cursor')
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
    participant User
    participant GlobalCommandsProvider
    participant CanvasModeStore

    User->>GlobalCommandsProvider: keydown P (as shown in UI)
    GlobalCommandsProvider->>GlobalCommandsProvider: "matchesShortcut() requires shiftKey===true"
    GlobalCommandsProvider-->>User: No match, command ignored
    User->>GlobalCommandsProvider: keydown Shift+P (actual registered)
    GlobalCommandsProvider->>CanvasModeStore: setMode('cursor')
Loading

Reviews (1): Last reviewed commit: "fix:shortcut for changing hand and curso..." | Re-trigger Greptile

Comment on lines +97 to +106
'set-canvas-mode-pointer': {
id: 'set-canvas-mode-pointer',
shortcut: 'Shift+P',
allowInEditable: false,
},
'set-canvas-mode-mover': {
id: 'set-canvas-mode-mover',
shortcut: 'Shift+M',
allowInEditable: false,
},

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 registered shortcut (Shift+P / Shift+M) does not match what the UI displays (P / M). The matchesShortcut function enforces an exact match on e.shiftKey, so pressing bare P or M alone will never fire these commands. Either drop the Shift+ prefix here to match the displayed label, or update the tooltip and popover labels to show ⇧P / ⇧M.

Suggested change
'set-canvas-mode-pointer': {
id: 'set-canvas-mode-pointer',
shortcut: 'Shift+P',
allowInEditable: false,
},
'set-canvas-mode-mover': {
id: 'set-canvas-mode-mover',
shortcut: 'Shift+M',
allowInEditable: false,
},
'set-canvas-mode-pointer': {
id: 'set-canvas-mode-pointer',
shortcut: 'P',
allowInEditable: false,
},
'set-canvas-mode-mover': {
id: 'set-canvas-mode-mover',
shortcut: 'M',
allowInEditable: false,
},

Comment on lines 143 to +155
@@ -137,7 +152,10 @@ export const WorkflowControls = memo(function WorkflowControls() {
}}
>
<Cursor className='size-3' />
<span>Pointer</span>
<div className=' flex items-center gap-2 '>

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 Both className strings have stray whitespace — the first has a trailing space and the second has both a leading and trailing space. These are harmless but inconsistent with the surrounding code style.

Suggested change
<div className='flex items-center gap-2'>
<span>Mover</span>
<span className='opacity-70'>M</span>
</div>
</PopoverItem>
<PopoverItem
onClick={() => {
setMode('cursor')
setIsCanvasModeOpen(false)
}}
>
<Cursor className='size-3' />
<div className='flex items-center gap-2'>

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

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