Skip to content

feat(ui): add Cmd+K shortcuts dialog and Cmd+L chat focus#2722

Merged
tlgimenes merged 3 commits intomainfrom
tlgimenes/cmd-k-shortcuts
Mar 16, 2026
Merged

feat(ui): add Cmd+K shortcuts dialog and Cmd+L chat focus#2722
tlgimenes merged 3 commits intomainfrom
tlgimenes/cmd-k-shortcuts

Conversation

@tlgimenes
Copy link
Copy Markdown
Contributor

@tlgimenes tlgimenes commented Mar 16, 2026

What is this contribution about?

Add keyboard shortcut discoverability to the Mesh UI:

  • Cmd+K dialog: Opens a shortcuts reference dialog from anywhere in the app, listing all available keyboard shortcuts grouped by category (General, Editor, Chat, Questions, Monitoring)
  • Cmd+L focus: Focuses the chat input from anywhere, with a "⌘L to focus" hint that auto-hides when the input is already focused. The listener lives in ChatInput so it only works when the chat is rendered.
  • Centralized definitions: All shortcut key combos and descriptions live in a single file (keyboard-shortcuts.ts), with cross-platform support (⌘ on Mac, Ctrl elsewhere)

Files changed

  • New: apps/mesh/src/web/lib/keyboard-shortcuts.ts — centralized shortcut definitions, groups, and isModKey/isMac helpers
  • New: apps/mesh/src/web/components/keyboard-shortcuts-dialog.tsx — Dialog component rendering grouped shortcuts with <kbd> elements
  • Modified: apps/mesh/src/web/layouts/shell-layout.tsx — global Cmd+K keydown listener
  • Modified: apps/mesh/src/web/components/chat/input.tsx — Cmd+L focus listener and hint label

Screenshots/Demonstration

N/A

How to Test

  1. bun run --cwd=apps/mesh dev:client
  2. Press Cmd+K (or Ctrl+K on Linux/Windows) → shortcuts dialog opens
  3. Press Escape or click outside → dialog closes
  4. Click into the chat input, then press Cmd+K → dialog still opens (works from contenteditable)
  5. Press Cmd+L while focus is outside the chat → chat input receives focus, "⌘L to focus" hint disappears
  6. Click outside the chat input → hint reappears
  7. Navigate to a route without chat → Cmd+L does nothing (listener not mounted)

Migration Notes

N/A — no database or configuration changes.

Review Checklist

  • PR title is clear and descriptive
  • Changes are tested and working
  • Documentation is updated (if needed)
  • No breaking changes

tlgimenes and others added 2 commits March 16, 2026 17:08
Add a centralized keyboard shortcuts definition file and a dialog
that displays all available shortcuts, triggered by Cmd+K globally.

- Create keyboard-shortcuts.ts with shortcut definitions, groups,
  and cross-platform helpers (isModKey, isMac)
- Create KeyboardShortcutsDialog component using Radix Dialog
- Register global Cmd+K listener in ShellLayout (works even from
  contenteditable inputs)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add a global Cmd+L shortcut that focuses the chat input from anywhere
in the app. Shows a "⌘L to focus" hint that auto-hides when the input
is focused using CSS group-focus-within.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown
Contributor

🧪 Benchmark

Should we run the Virtual MCP strategy benchmark for this PR?

React with 👍 to run the benchmark.

Reaction Action
👍 Run quick benchmark (10 & 128 tools)

Benchmark will run on the next push after you react.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 16, 2026

Release Options

Should a new version be published when this PR is merged?

React with an emoji to vote on the release type:

Reaction Type Next Version
👍 Prerelease 2.172.3-alpha.1
🎉 Patch 2.172.3
❤️ Minor 2.173.0
🚀 Major 3.0.0

Current version: 2.172.2

Deployment

  • Deploy to production (triggers ArgoCD sync after Docker image is published)

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 issues found across 4 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="apps/mesh/src/web/layouts/shell-layout.tsx">

<violation number="1" location="apps/mesh/src/web/layouts/shell-layout.tsx:186">
P2: Guard the global `Cmd/Ctrl+L` handler so it only prevents default when a chat input is actually available to focus.</violation>
</file>

<file name="apps/mesh/src/web/components/chat/input.tsx">

<violation number="1" location="apps/mesh/src/web/components/chat/input.tsx:356">
P2: This adds a new `useEffect` by suppressing the repo's `ban-use-effect` rule instead of using an allowed pattern.

(Based on your team's feedback about avoiding `useEffect` in this codebase.) [FEEDBACK_USED]</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

The Cmd+L shortcut now registers directly in ChatInput instead of being
dispatched via a custom event from the shell layout. This ensures the
shortcut only works when the chat input is actually rendered.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@tlgimenes tlgimenes merged commit 8eba4cc into main Mar 16, 2026
15 checks passed
@tlgimenes tlgimenes deleted the tlgimenes/cmd-k-shortcuts branch March 16, 2026 20:24
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 2 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="apps/mesh/src/web/layouts/shell-layout.tsx">

<violation number="1" location="apps/mesh/src/web/layouts/shell-layout.tsx:174">
P2: Removing the shell-level `Cmd/Ctrl+L` path makes the advertised focus-chat shortcut stop working on routes where `ChatInput` is not mounted, such as the project home route.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

// oxlint-disable-next-line ban-use-effect/ban-use-effect
useEffect(() => {
const handler = (e: globalThis.KeyboardEvent) => {
if (isModKey(e) && e.code === "KeyK") {
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot Mar 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Removing the shell-level Cmd/Ctrl+L path makes the advertised focus-chat shortcut stop working on routes where ChatInput is not mounted, such as the project home route.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/mesh/src/web/layouts/shell-layout.tsx, line 174:

<comment>Removing the shell-level `Cmd/Ctrl+L` path makes the advertised focus-chat shortcut stop working on routes where `ChatInput` is not mounted, such as the project home route.</comment>

<file context>
@@ -171,22 +171,10 @@ function ShellLayoutContent() {
-        (e.target as HTMLElement).isContentEditable;
-
-      if (e.code === "KeyK") {
+      if (isModKey(e) && e.code === "KeyK") {
         e.preventDefault();
         setShortcutsDialogOpen(true);
</file context>
Fix with Cubic

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