Skip to content

Navigate open selections with Ctrl-N and Ctrl-P#4394

Open
colonelpanic8 wants to merge 7 commits into
pingdotgg:mainfrom
colonelpanic8:t3code/fix-dropdown-keyboard-navigation
Open

Navigate open selections with Ctrl-N and Ctrl-P#4394
colonelpanic8 wants to merge 7 commits into
pingdotgg:mainfrom
colonelpanic8:t3code/fix-dropdown-keyboard-navigation

Conversation

@colonelpanic8

@colonelpanic8 colonelpanic8 commented Jul 23, 2026

Copy link
Copy Markdown

What Changed

  • Preserve the prompt pickers' native Arrow Up/Down, Enter, and type-to-search behavior across model, effort, access, machine, checkout/worktree, and branch selection.
  • Translate Ctrl-N/Ctrl-P to Down/Up while the focused control owns an open command palette, combobox, autocomplete, select, menu, listbox, or composer suggestion menu.
  • Run selection arbitration before application shortcuts, so Ctrl-N navigates an open picker instead of opening a new thread.
  • Route tooltip-wrapped effort and access triggers to their owned popup surfaces.
  • Return focus to prompt entry after a prompt-picker selection completes.
  • Leave ordinary text editing, terminals, keybinding capture fields, and unrelated visible pickers untouched.
  • Add focused coverage for every prompt picker, portaled composer suggestions, modifier exclusions, empty menus, tooltip trigger ownership, and app-root registration.

Why

Prompt controls should behave consistently as keyboard-first selection surfaces. Readline-style Ctrl-N/Ctrl-P navigation must take precedence over global shortcuts while a picker is open, and completing a selection should return the user directly to prompt entry.

UI Changes

Interaction-only; there are no layout or styling changes.

Verified in an isolated authenticated web environment:

  1. Opened the command palette from the sidebar.
  2. Pressed Ctrl-N; highlight moved from Add project to Open settings while the query stayed empty and the palette stayed open.
  3. Pressed Ctrl-P; highlight moved back to Add project.
  4. Confirmed no new-thread action fired.

Interaction recording

The follow-up prompt-focus flow was also launched in an isolated environment. API authentication succeeded, but the collaborative preview remained on its pairing route, so that pass could not reach the prompt surface for a second recording.

Checklist

  • vp test run apps/web/src/selectionNavigation.test.ts apps/web/src/AppRoot.test.tsx apps/web/src/components/chat/composerProviderState.test.tsx (26 tests pass)
  • vp check (0 errors; 11 unrelated existing warnings)
  • Focused formatting and lint for all changed prompt-picker files
  • Integrated Ctrl-N/Ctrl-P web verification and interaction recording
  • vp run typecheck — existing @effect/vitest export errors in oxlint-plugin-t3code; no errors in changed files

Note

Medium Risk
Global capture-phase key handling can interact with other shortcuts, but scope is narrow (Ctrl-only, open picker surfaces) and covered by unit tests; widespread UI callback wiring is low-risk behavior change.

Overview
Readline-style navigation while pickers are open: A new selectionNavigation module maps Ctrl-N / Ctrl-P to ArrowDown / ArrowUp on the focused control when an owned menu, select, combobox, listbox, command palette, or composer suggestion surface is open. It registers at app root via SelectionNavigationBindings in capture phase so navigation wins over global shortcuts (e.g. new thread on Ctrl-N). Tooltip-wrapped runtime and traits triggers are linked via data-chat-* markers; portaled composer suggestions use data-composer-command-menu. Terminals, keybinding-capture fields, modified chords, empty suggestion menus, and unrelated pickers are excluded.

Focus return after choosing: Composer and branch toolbar pickers thread an optional onSelectionComplete callback (wired to scheduleComposerFocus from chat) so closing a menu after model, traits, runtime mode, environment, or workspace selection returns focus to prompt entry. Mobile branch menus use controlled open state and closeOnClick on radio items for the same flow.

Reviewed by Cursor Bugbot for commit 7a843d8. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Add Ctrl-N/Ctrl-P keyboard navigation for open selection surfaces in the composer

  • Adds SelectionNavigationBindings, mounted globally in AppRoot, which intercepts Ctrl+N/Ctrl+P keydown events and translates them to ArrowDown/ArrowUp on the focused element when a selection surface (menu, select, combobox, command menu) is open.
  • Core logic lives in selectionNavigation.ts, which uses aria attributes, data-slot markers, and DOM heuristics to detect the active surface and route the synthetic key event.
  • Composer pickers (provider/model, traits, runtime mode, environment selectors) gain an onSelectionComplete callback that refocuses the composer after a selection is made.
  • Risk: the global capturing keydown listener intercepts events before other handlers; Ctrl+N/P behavior in terminals and keybinding capture fields is explicitly excluded but other edge cases may exist.

Macroscope summarized 7a843d8.

@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: fdda84c1-ee68-4e76-9a68-05e80e9cd01f

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:L 100-499 changed lines (additions + deletions). labels Jul 23, 2026
Comment thread apps/web/src/selectionNavigation.ts
@macroscopeapp

macroscopeapp Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Needs human review

This PR introduces a new keyboard navigation feature (Ctrl-N/P for selection menus) with global event handling and changes across multiple UI components. New user-facing capabilities warrant human review.

You can customize Macroscope's approvability policy. Learn more.

@colonelpanic8
colonelpanic8 force-pushed the t3code/fix-dropdown-keyboard-navigation branch 3 times, most recently from 12e607a to bbe7273 Compare July 23, 2026 21:47
Comment thread apps/web/src/selectionNavigation.ts
@colonelpanic8
colonelpanic8 force-pushed the t3code/fix-dropdown-keyboard-navigation branch from bb487f3 to 641e30d Compare July 23, 2026 22:28
Comment thread apps/web/src/selectionNavigation.ts
Comment thread apps/web/src/selectionNavigation.ts
Comment thread apps/web/src/selectionNavigation.ts
@colonelpanic8
colonelpanic8 force-pushed the t3code/fix-dropdown-keyboard-navigation branch 2 times, most recently from 0b6f818 to 873c2a5 Compare July 24, 2026 01:41
Comment thread apps/web/src/selectionNavigation.ts
Comment thread apps/web/src/components/chat/TraitsPicker.tsx
@colonelpanic8
colonelpanic8 force-pushed the t3code/fix-dropdown-keyboard-navigation branch from 873c2a5 to ac909b9 Compare July 24, 2026 02:32

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 5eb4ad5. Configure here.

Comment thread apps/web/src/components/chat/TraitsPicker.tsx
@colonelpanic8
colonelpanic8 force-pushed the t3code/fix-dropdown-keyboard-navigation branch from 5eb4ad5 to 7a843d8 Compare July 24, 2026 06:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant