Skip to content

feat(ui): add keyboard shortcut hint to chat input#1402

Open
fl-sean03 wants to merge 2 commits intokagent-dev:mainfrom
fl-sean03:feat/hotkey-submit-hint-v2
Open

feat(ui): add keyboard shortcut hint to chat input#1402
fl-sean03 wants to merge 2 commits intokagent-dev:mainfrom
fl-sean03:feat/hotkey-submit-hint-v2

Conversation

@fl-sean03
Copy link
Contributor

Summary

Adds a subtle text hint next to the Send button showing the keyboard shortcut to submit a message:

  • macOS: ⌘+Enter to send
  • Windows/Linux: Ctrl+Enter to send

The hint uses text-xs text-muted-foreground styling to stay unobtrusive, and is positioned to the left of the action buttons using mr-auto.

Implementation

  • Added useMemo hook with navigator.userAgent detection to determine OS
  • Single <span> element in the existing button row — no layout changes
  • Falls back to "Ctrl" for SSR (server-side rendering) compatibility

Closes #824

Signed-off-by: Sean Florez sean@opspawn.com

Display a subtle "Ctrl+Enter to send" (or "⌘+Enter to send" on macOS)
hint next to the Send button so users discover the keyboard shortcut.

- OS-aware: detects macOS via navigator.userAgent and shows ⌘ symbol
- Uses muted foreground color and extra-small text to stay unobtrusive
- Positioned left of the action buttons with mr-auto for alignment

Closes kagent-dev#824

Signed-off-by: Sean Florez <sean@opspawn.com>
Copilot AI review requested due to automatic review settings February 28, 2026 00:31
@fl-sean03 fl-sean03 requested a review from peterj as a code owner February 28, 2026 00:31
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds an OS-specific keyboard shortcut hint next to the chat Send button to make the “submit” hotkey more discoverable (issue #824), matching the existing Ctrl/Cmd + Enter key handling in the input.

Changes:

  • Detects platform to choose between (macOS/iOS) and Ctrl (Windows/Linux) for the displayed hint.
  • Renders a subtle shortcut hint ({shortcutKey}+Enter to send) in the chat input action row.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 77 to 81
const shortcutKey = useMemo(() => {
if (typeof navigator !== "undefined") {
return /Mac|iPhone|iPad|iPod/.test(navigator.userAgent) ? "⌘" : "Ctrl";
}
return "Ctrl";
Copy link

Copilot AI Feb 28, 2026

Choose a reason for hiding this comment

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

shortcutKey is computed during render with a server fallback of "Ctrl" but will compute to "⌘" on macOS/iOS in the browser, which can cause a server/client HTML mismatch (hydration warning) and a visible text flip. Consider initializing state to "Ctrl" and updating it in a useEffect after mount, or render the hint only after mount (or use suppressHydrationWarning on the span) so server and first client render match.

Suggested change
const shortcutKey = useMemo(() => {
if (typeof navigator !== "undefined") {
return /Mac|iPhone|iPad|iPod/.test(navigator.userAgent) ? "⌘" : "Ctrl";
}
return "Ctrl";
const [shortcutKey, setShortcutKey] = useState<"Ctrl" | "⌘">("Ctrl");
useEffect(() => {
if (typeof navigator !== "undefined" && /Mac|iPhone|iPad|iPod/.test(navigator.userAgent)) {
setShortcutKey("⌘");
}

Copilot uses AI. Check for mistakes.
Replace useMemo with useState + useEffect to detect the OS-specific
shortcut key (⌘ vs Ctrl). The server always renders "Ctrl" as the
default, and the client updates to "⌘" on Mac after mount, avoiding
a server/client HTML mismatch.

Signed-off-by: fl-sean03 <fl.sean03@gmail.com>
@fl-sean03 fl-sean03 force-pushed the feat/hotkey-submit-hint-v2 branch from c535819 to 9166b51 Compare February 28, 2026 04:00
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.

Add hint on the hotkey to submit the query to the agents in the UI

2 participants