feat(web): add global command palette and remap shortcuts#367
Conversation
- map Cmd/Ctrl+K to open the global command menu - remap New Session to Cmd/Ctrl+Shift+O - add shadcn-style CommandDialog/Command UI with shortcut hints - allow Cmd/Ctrl+K even when input is focused - update keyboard shortcuts settings page Refs ColeMurray#337
Greptile SummaryThis PR adds a global command palette (Cmd/Ctrl+K) backed by Two issues were found:
Prompt To Fix All With AIThis is a comment left during a code review.
Path: packages/web/src/components/global-command-menu.tsx
Line: 108
Comment:
**cmdk value collision hides duplicate sessions**
The `value` prop passed to `CommandItem` is `\`${sessionTitle} ${repoLabel}\``. Since `sessionTitle` falls back to `\`${session.repoOwner}/${session.repoName}\`` when `title` is `null`, any two unnamed sessions in the same repo will share an identical `value` string.
The `cmdk` library uses `value` as the key in an internal `Map` to track items for filtering and selection. When two items share the same value, the second registration overwrites the first, causing one of the sessions to silently disappear from the list.
This is reproducible whenever a user has multiple active (non-archived) sessions in the same repository without custom titles.
Fix: include `session.id` in the `value` so every item is guaranteed to be unique while still being searchable by title and repo:
```suggestion
value={`${session.id} ${sessionTitle} ${repoLabel}`}
```
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: packages/web/src/components/sidebar-layout.tsx
Line: 65-67
Comment:
**Cmd/Ctrl+K can't close the command menu**
`handleOpenCommandMenu` unconditionally sets `isCommandMenuOpen` to `true`. Because `shouldIgnoreGlobalShortcutForAction` returns `false` for `"open-command-menu"` even inside editable elements, pressing Cmd/Ctrl+K while the dialog's `CommandInput` is focused will re-fire this callback — but since the state is already `true`, it is silently a no-op.
Standard command-palette UX (VS Code, Linear, etc.) expects the same shortcut to both open and close the palette. Users who press Cmd+K to dismiss the menu will instead find nothing happens until they reach for Escape.
Consider toggling the state instead:
```suggestion
const handleOpenCommandMenu = useCallback(() => {
setIsCommandMenuOpen((prev) => !prev);
}, []);
```
How can I resolve this? If you propose a fix, please make it concise.Last reviewed commit: ad483cd |
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
ColeMurray
left a comment
There was a problem hiding this comment.
Nit (non-blocking): This useSWR call works correctly via SWR's cache deduplication with the sidebar's fetch — no extra network request. However, it keeps the sessions data referenced in component state even when the command menu is closed. Consider conditionally passing the key so sessions are only held when the menu is open:
const { data: sessionsResponse } = useSWR<SessionListResponse>(
status === "authenticated" && Boolean(session) && isCommandMenuOpen
? SIDEBAR_SESSIONS_KEY
: null
);SWR's cache already has the data from the sidebar, so activating the key when the menu opens returns cached results instantly — no loading flash. At current scale (25 items max) this is negligible, but worth noting if session payloads grow.
Conditionally pass the SWR key so sessions data is only referenced when the command menu is open. SWR cache deduplication ensures instant results from the sidebar's existing fetch.
Refs #337