Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions apps/sim/app/workspace/[workspaceId]/utils/commands-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ export type CommandId =
| 'clear-terminal-console'
| 'focus-toolbar-search'
| 'fit-to-view'
| 'set-canvas-mode-pointer'
| 'set-canvas-mode-mover'

/**
* Static metadata for a global command.
Expand Down Expand Up @@ -92,6 +94,16 @@ export const COMMAND_DEFINITIONS: Record<CommandId, CommandDefinition> = {
shortcut: 'Mod+Shift+F',
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 thread
cursor[bot] marked this conversation as resolved.
Comment on lines +97 to +106

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,
},

}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,14 @@ export const WorkflowControls = memo(function WorkflowControls() {
id: 'fit-to-view',
handler: handleFitToView,
}),
createCommand({
id: 'set-canvas-mode-pointer',
handler: () => setMode('cursor'),
}),
createCommand({
id: 'set-canvas-mode-mover',
handler: () => setMode('hand'),
}),
])

const [contextMenu, setContextMenu] = useState<{ x: number; y: number } | null>(null)
Expand Down Expand Up @@ -118,7 +126,11 @@ export const WorkflowControls = memo(function WorkflowControls() {
</Button>
</div>
</PopoverTrigger>
<Tooltip.Content side='top'>{mode === 'hand' ? 'Mover' : 'Pointer'}</Tooltip.Content>
<Tooltip.Content side='top'>
<Tooltip.Shortcut keys={mode === 'hand' ? 'M' : 'P'}>
{mode === 'hand' ? 'Mover' : 'Pointer'}
</Tooltip.Shortcut>
</Tooltip.Content>
</Tooltip.Root>
<PopoverContent side='top' sideOffset={8} maxWidth={100} minWidth={100}>
<PopoverItem
Expand All @@ -128,7 +140,10 @@ export const WorkflowControls = memo(function WorkflowControls() {
}}
>
<Hand className='size-3' />
<span>Mover</span>
<div className='flex items-center gap-2 '>
<span>Mover</span>
<span className='opacity-70'>M</span>
</div>
</PopoverItem>
<PopoverItem
onClick={() => {
Expand All @@ -137,7 +152,10 @@ export const WorkflowControls = memo(function WorkflowControls() {
}}
>
<Cursor className='size-3' />
<span>Pointer</span>
<div className=' flex items-center gap-2 '>
Comment on lines 143 to +155

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!

<span>Pointer</span>
<span className='opacity-70'>P</span>
</div>
</PopoverItem>
</PopoverContent>
</Popover>
Expand Down