Skip to content

fix(ui): avoid treating copy chords as note shortcut#375

Merged
benvinegar merged 1 commit into
mainfrom
fix/review-note-copy-shortcut
May 25, 2026
Merged

fix(ui): avoid treating copy chords as note shortcut#375
benvinegar merged 1 commit into
mainfrom
fix/review-note-copy-shortcut

Conversation

@benvinegar
Copy link
Copy Markdown
Member

Summary

  • Restrict the create review note shortcut to unmodified lowercase c
  • Avoid treating Ctrl/Cmd/Option/Shift modified c events as note creation
  • Add keyboard helper coverage for the shortcut matching policy

Testing

  • bun run typecheck
  • bun test src/ui/lib/ui-lib.test.ts src/ui/AppHost.interactions.test.tsx --test-name-pattern "review note shortcut|draft note focus"

This PR description was generated by Pi using OpenAI GPT-5

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 25, 2026

Greptile Summary

This PR fixes a long-standing issue where Ctrl+C / Cmd+C copy chords in the terminal would trigger the "create review note" keyboard shortcut. The fix extracts the matching logic into a dedicated isCreateReviewNoteKey helper that guards against all common modifier keys (ctrl, meta, option, shift).

  • keyboard.ts adds isCreateReviewNoteKey, replacing the previous inline case-insensitive check that ignored all modifier flags.
  • useAppKeyboardShortcuts.ts calls the new helper instead of the inline expression.
  • ui-lib.test.ts adds six assertions covering the positive path and all four modifier guards.

Confidence Score: 5/5

Safe to merge — the change tightens an existing keyboard shortcut check without altering any other behavior.

The old inline check matched any c keypress regardless of modifiers, so Ctrl+C / Cmd+C copy chords would accidentally trigger note creation. The new helper adds exact-case matching and four modifier guards that directly close that gap. The call-site change is a one-line swap, tests cover every guard, and TypeScript compilation is verified.

No files require special attention.

Important Files Changed

Filename Overview
src/ui/lib/keyboard.ts Adds isCreateReviewNoteKey with exact-case name/sequence check and four modifier guards; logic is consistent with the existing keyboard helper pattern.
src/ui/hooks/useAppKeyboardShortcuts.ts One-line call-site replacement — swaps the old unguarded inline expression for the new helper; no logic risk.
src/ui/lib/ui-lib.test.ts Adds a dedicated test block that covers the true-positive cases and all four modifier-blocked cases; createKeyEvent defaults are consistent with how real events arrive.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[KeyEvent received] --> B{isCreateReviewNoteKey?}
    B --> C{name === 'c' OR\nsequence === 'c'}
    C -- No --> D[No match — fall through]
    C -- Yes --> E{!ctrl AND\n!meta AND\n!option AND\n!shift}
    E -- No\ncopy chord / modified key --> D
    E -- Yes\nunmodified 'c' --> F[runAndCloseMenu / startUserNote]
Loading

Reviews (1): Last reviewed commit: "fix(ui): avoid treating copy chords as n..." | Re-trigger Greptile

@benvinegar benvinegar merged commit 678ac10 into main May 25, 2026
8 checks passed
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