Skip to content

Fix omnibar backspace/arrow key loss after prefix deletion - #1413

Merged
austinywang merged 1 commit into
mainfrom
issue-1409-omnibar-backspace-arrow
Mar 14, 2026
Merged

austinywang merged 1 commit into
mainfrom
issue-1409-omnibar-backspace-arrow

Conversation

@austinywang

@austinywang austinywang commented Mar 14, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Replaces the SwiftUI TextField in the command palette with a native AppKit NSTextField via NSViewRepresentable
  • Arrow keys, backspace, enter, and escape now stay on the AppKit field editor delegate, so they can't be lost when a SwiftUI scope transition (e.g. deleting the > prefix) tears down .onKeyPress modifiers
  • Removes the now-unnecessary handleCommandPaletteControlNavigationKey helper

Test plan

  • Open command palette (Cmd+P), type >somecommand, then backspace to delete the > — arrow keys and enter should still work
  • Verify up/down arrows navigate the result list
  • Verify Enter runs the selected result
  • Verify Escape dismisses the palette
  • Verify IME input (e.g. Japanese) still works correctly

Fixes #1409

🤖 Generated with Claude Code


Summary by cubic

Fixes the command palette losing arrow keys, backspace, enter, and escape after deleting the ">" prefix by replacing the SwiftUI text field with a native AppKit text field. Fixes #1409.

  • Bug Fixes

    • Arrow keys and enter/escape keep working after deleting the ">" prefix.
    • IME input is preserved (commands are ignored while composing).
    • More reliable focus when opening and updating the palette.
  • Refactors

    • Replaced the SwiftUI TextField with an NSViewRepresentable wrapping NSTextField.
    • Removed the obsolete handleCommandPaletteControlNavigationKey helper.

Written for commit 48ec609. Summary will update on new commits.

Summary by CodeRabbit

Release Notes

  • Bug Fixes
    • Improved keyboard navigation handling in the command palette search field for more reliable processing of navigation inputs.
    • Enhanced focus management for the search input to maintain consistent keyboard behavior during interactions.

The SwiftUI TextField lost arrow-key and backspace handlers when the
query prefix (">") was deleted, because the scope transition tore down
the .onKeyPress modifiers. Using an NSViewRepresentable with an AppKit
field editor keeps navigation commands (up/down/enter/escape) on the
native delegate, making them immune to SwiftUI scope changes.

Fixes #1409

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@vercel

vercel Bot commented Mar 14, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
cmux Building Building Preview, Comment Mar 14, 2026 1:17am

@greptile-apps greptile-apps 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.

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@coderabbitai

coderabbitai Bot commented Mar 14, 2026 •

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c0de7686-fc7d-4c41-af0c-9d1b520799be

📥 Commits

Reviewing files that changed from the base of the PR and between 98f5553 and 48ec609.

📒 Files selected for processing (1)
  • Sources/ContentView.swift

📝 Walkthrough

Walkthrough

This change replaces the SwiftUI TextField-based command palette search input with a custom NSViewRepresentable that bridges an AppKit NSTextField into SwiftUI. The new implementation introduces CommandPaletteNativeTextField and CommandPaletteSearchFieldRepresentable to handle advanced keyboard navigation, focus management, and callback routing.

Changes

Cohort / File(s) Summary
Command Palette Search Input Refactor
Sources/ContentView.swift
Replaced SwiftUI TextField with AppKit-backed NSViewRepresentable bridge (CommandPaletteSearchFieldRepresentable) and NSTextField subclass (CommandPaletteNativeTextField) to enable robust keyboard navigation handling, focus synchronization, and lifecycle management for the command palette search field. Removed legacy handleCommandPaletteControlNavigationKey helper function.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A rabbit hops through keyboard keys,
Where AppKit bridges SwiftUI with ease,
No more broken arrows, no navigation loss,
The backspace now dances, no keyboard toss!
With focus and text fields in perfect align,
The command palette search works just fine! ✨

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch issue-1409-omnibar-backspace-arrow
📝 Coding Plan
  • Generate coding plan for human review comments

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.

@austinywang
austinywang merged commit 80fea62 into main Mar 14, 2026
8 of 13 checks passed

@cubic-dev-ai cubic-dev-ai 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.

No issues found across 1 file

This branch was successfully deployed

1 active deployment
Preview — 48ec6094 Deployed Mar 14, 2026 by vercel[bot]
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.

Omnibar: backspace breaks arrow key navigation

1 participant