Skip to content

🎨 Palette: Add keyboard shortcut for search input - #183

Open
mkk2026 wants to merge 1 commit into
masterfrom
palette/add-search-shortcut-7944634498791727082
Open

🎨 Palette: Add keyboard shortcut for search input#183
mkk2026 wants to merge 1 commit into
masterfrom
palette/add-search-shortcut-7944634498791727082

Conversation

@mkk2026

@mkk2026 mkk2026 commented Apr 3, 2026

Copy link
Copy Markdown
Owner

💡 What: Added a global keyboard shortcut (Cmd+K for Mac, Ctrl+K for Windows) to quickly focus the main search input field.
🎯 Why: Searching is a primary action on the Threat Monitor dashboard. Adding a standard keyboard shortcut allows power users to navigate the app much faster without reaching for the mouse, significantly improving the data exploration experience.
📸 Before/After: The search input now displays a subtle, OS-specific visual hint (⌘K or Ctrl K) when the input is empty and not focused.
Accessibility:

  • The <Input /> component now dynamically receives the aria-keyshortcuts attribute (e.g., Meta+K or Control+K) depending on the user's OS, ensuring screen readers can announce the shortcut properly.
  • The visual hint uses semantic <kbd> tags.
  • SSR hydration mismatch vulnerabilities were mitigated by wrapping the OS-specific display in an isMounted state check.

PR created automatically by Jules for task 7944634498791727082 started by @corebrimtech

Summary by CodeRabbit

  • New Features
    • Added keyboard shortcut support to quickly activate the search input using Ctrl+K (Windows/Linux) or Cmd+K (Mac).
    • Added visual keyboard shortcut hint indicators in the search area to guide users on available shortcuts.
    • Improved search input with enhanced platform-specific responsiveness and better accessibility features.

Co-authored-by: corebrimtech <175357468+corebrimtech@users.noreply.github.com>
@vercel

vercel Bot commented Apr 3, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
security-news-scraper Ready Ready Preview, Comment Apr 3, 2026 0:17am

@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@coderabbitai

coderabbitai Bot commented Apr 3, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

The changes implement OS-specific keyboard shortcut hints for a search input component. A global keydown listener detects Ctrl+K / Meta+K and focuses the search field. Visual hints ("⌘ K" or "Ctrl K") are conditionally rendered, with platform detection using navigator.platform and SSR-safe mounting logic. Documentation was added to describe this approach.

Changes

Cohort / File(s) Summary
Documentation
.Jules/palette.md
Added journal entry (2026-10-27) documenting approach for OS-specific keyboard shortcut hints, including isMounted pattern, modifier key handling, and dynamic aria-keyshortcuts attribute guidance.
Search Input Enhancement
src/app/page.tsx
Added keyboard shortcut functionality: useRef import, isMounted and isMac state tracking, global keydown listener for Ctrl+K / Meta+K, dynamic aria-keyshortcuts attribute, increased right padding (pr-12pr-24), and conditional rendering of visual kbd hint (⌘ K / Ctrl K).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

Poem

🐰 A shortcut springs forth with a keystroke so fleet,
Platform-aware hints make the search feel complete!
Meta or Ctrl, both paths now unite,
No hydration mismatch—just focused delight! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title refers to adding a keyboard shortcut for search input, which is the core change, but the emoji and 'Palette' prefix add noise and reduce clarity.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch palette/add-search-shortcut-7944634498791727082

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/app/page.tsx (1)

61-66: Consider a more robust OS detection approach.

navigator.platform is deprecated. While it still works in most browsers, consider using a fallback pattern that checks navigator.userAgentData?.platform first (modern Chromium browsers) and falls back to navigator.platform:

♻️ Suggested improvement
   useEffect(() => {
     setIsMounted(true)
     if (typeof window !== 'undefined') {
-      setIsMac(navigator.platform.toUpperCase().indexOf('MAC') >= 0)
+      const platform = navigator.userAgentData?.platform ?? navigator.platform
+      setIsMac(platform.toUpperCase().includes('MAC'))
     }
   }, [])
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/app/page.tsx` around lines 61 - 66, The OS detection using deprecated
navigator.platform should be made more robust: in the useEffect callback that
calls setIsMounted and setIsMac, derive a platform string by preferring
navigator.userAgentData?.platform (if available), falling back to
navigator.platform and then navigator.userAgent (to cover older browsers),
normalize to upper/lower case, and setIsMac based on whether that platform
string contains "MAC" (or "MACINTOSH") to be case-insensitive and resilient to
missing fields; update the useEffect that currently references setIsMounted and
setIsMac to use this fallback logic.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/app/page.tsx`:
- Around line 68-78: The custom Input component does not forward refs so
searchInputRef passed from page.tsx never reaches the underlying <input> and
focus() silently fails; change the Input component to use React.forwardRef with
a signature like forwardRef<HTMLInputElement, InputProps>((props, ref) => { ...
}) and attach the forwarded ref to the actual input element (e.g., <input
ref={ref} ... />), keep existing props spread, update the component export to
the forwardRef result and adjust the InputProps type to extend
React.InputHTMLAttributes<HTMLInputElement> so ref usage (searchInputRef) from
the page will work and focus() will succeed.

---

Nitpick comments:
In `@src/app/page.tsx`:
- Around line 61-66: The OS detection using deprecated navigator.platform should
be made more robust: in the useEffect callback that calls setIsMounted and
setIsMac, derive a platform string by preferring
navigator.userAgentData?.platform (if available), falling back to
navigator.platform and then navigator.userAgent (to cover older browsers),
normalize to upper/lower case, and setIsMac based on whether that platform
string contains "MAC" (or "MACINTOSH") to be case-insensitive and resilient to
missing fields; update the useEffect that currently references setIsMounted and
setIsMac to use this fallback logic.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b9bfe8bc-d1d4-435d-921e-28236bb3a071

📥 Commits

Reviewing files that changed from the base of the PR and between 558fb10 and 6c2387a.

📒 Files selected for processing (2)
  • .Jules/palette.md
  • src/app/page.tsx

Comment thread src/app/page.tsx
Comment on lines +68 to +78
useEffect(() => {
const handleKeyDown = (e: KeyboardEvent) => {
if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === 'k') {
e.preventDefault()
searchInputRef.current?.focus()
}
}

document.addEventListener('keydown', handleKeyDown)
return () => document.removeEventListener('keydown', handleKeyDown)
}, [])

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Keyboard shortcut will silently fail — Input component lacks forwardRef.

The Input component in src/components/ui/input.tsx is a plain function component that does not use React.forwardRef. When you pass ref={searchInputRef} on line 372, React cannot forward it to the underlying <input> element, so searchInputRef.current will always be null. The focus() call on line 72 will do nothing.

You need to update the Input component to use forwardRef:

🔧 Proposed fix for `src/components/ui/input.tsx`
+import * as React from "react"
+
-function Input({ className, type, ...props }: React.ComponentProps<"input">) {
+const Input = React.forwardRef<HTMLInputElement, React.ComponentProps<"input">>(
+  ({ className, type, ...props }, ref) => {
   return (
     <input
+      ref={ref}
       type={type}
       data-slot="input"
       className={cn(
         "file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input flex h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
         "focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]",
         "aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
         className
       )}
       {...props}
     />
   )
-}
+  }
+)
+Input.displayName = "Input"
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/app/page.tsx` around lines 68 - 78, The custom Input component does not
forward refs so searchInputRef passed from page.tsx never reaches the underlying
<input> and focus() silently fails; change the Input component to use
React.forwardRef with a signature like forwardRef<HTMLInputElement,
InputProps>((props, ref) => { ... }) and attach the forwarded ref to the actual
input element (e.g., <input ref={ref} ... />), keep existing props spread,
update the component export to the forwardRef result and adjust the InputProps
type to extend React.InputHTMLAttributes<HTMLInputElement> so ref usage
(searchInputRef) from the page will work and focus() will succeed.

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