Skip to content

feat(browser): match Chrome's omnibox Escape in the address bar - #23763

Closed
Bansng wants to merge 51 commits into
stablyai:mainfrom
Bansng:feat/address-bar-escape-chrome-parity
Closed

Bansng wants to merge 51 commits into
stablyai:mainfrom
Bansng:feat/address-bar-escape-chrome-parity

Conversation

@Bansng

@Bansng Bansng commented Sep 29, 2026 •

Copy link
Copy Markdown

ELI5

In Chrome, pressing Escape in the address bar undoes what you typed, one step at a time, and then gives the keyboard back to the page. Orca's in-app browser only closed the suggestion list. Your half-typed text stayed, and the cursor stayed in the bar. Now Escape in Orca works the way it does in Chrome.

What Changed

Each Escape press in the address bar does the first of these steps that applies:

  1. If you arrowed onto a suggestion, the bar goes back to what you typed. The list stays open, and the caret returns to where it was.
  2. If the suggestion list is open, it closes. Your text stays.
  3. If the text differs from the page address, the bar reverts to the page address with all of it selected. The list closes, and focus stays in the bar.
  4. Otherwise, focus moves to the page.

Before, every press restored the typed text and closed the list, so steps 3 and 4 never happened.

With the macOS Korean IME, an Escape pressed mid-syllable closes the list and keeps the syllable. The next press continues with step 3, which matches Chrome (checked by hand). That IME sends two keydowns for one Escape: a marked Escape/229, then an unmarked Escape/27. The bar ignores the second keydown, the same way Orca already ignores the second Enter of a composition.

The same steps apply everywhere the bar appears: local pages, client-hosted pages, remote streamed pages, and the document preview's address edit. In the document preview, step 4 leaves edit mode.

Where to start reviewing

  • browser-address-bar-escape.ts: resolveAddressBarEscape is a pure function that picks the step. useBrowserAddressBarEscape applies it and is now the only Escape handler for the bar.
  • use-browser-address-bar-text.ts: useBrowserAddressBarText now owns both the bar text and committedAddress, the text that step 3 reverts to. Page-driven writes update committedAddress even while you type, the same way Chrome updates its permanent URL text. Before, the local pane and the edit-session hook each had their own copy of this sync logic.
  • BrowserAddressBar takes two new required props: committedAddress and onLeaveAddressBar, which says where focus goes for that pane.

The rest follows from those three:

  • useBrowserPageChromeFocus returns leaveAddressBarForPage, which cancels any retrying address-bar focus grab before it focuses the page. Without the cancel, a new tab's grab pulls focus back one frame later.
  • The window capture-phase Escape listener in use-browser-address-bar-dismissal.ts is removed, and so is the document preview's own Escape handler. Blur and webview-focus dismissal do not change.
  • useImeEnterGestureOwnership becomes useImeKeyGestureOwnership(key), so Escape reuses the Enter IME handling.
  • use-address-bar-selection-after-commit.ts replaces two copies of the code that sets the selection after React commits the value.
  • Some code moves only to keep files under the line limit, mainly into use-browser-address-bar-overlay.ts and useBrowserAddressBarDismissal.

Why

The step order comes from Chromium's OmniboxEditModel::OnEscapeKeyPressed. It lives in one pure function, so the unit tests read like Chrome's case table.

Alternatives I rejected:

  • Extend the window capture listener. Escape would then have two entry points, and the listener would need refs for state that the input handler already has.
  • Give each pane an onEscape(step) callback. Four panes would each re-implement the order, and per-pane drift is the bug this PR fixes.
  • Track a "user is editing" flag, as Chrome does. The flag must stay in sync across typing, revert, submit, and remount. Comparing the text with committedAddress needs no extra state.

Two known differences from Chrome:

  • If you retype the exact page address and press Escape, focus moves to the page. Chrome keeps focus in the bar.
  • The bar now stops Escape from bubbling, so Markup mode's window listener no longer sees an Escape typed in the bar. Grab mode already ignored editable targets, and capture-phase listeners still run first.

Linked Issue

Fixes #23762

Visual Proof

Type ladder in the address bar of a loaded page, then press Escape three times. Each state below was recorded from the rendered app, built once at the base commit and once at this branch:

Step Before After
Typed ladder ladder, dropdown open ladder, dropdown open
Escape 1 dropdown closes dropdown closes
Escape 2 no change page URL, all selected
Escape 3 no change focus moves to the page

In the before build, the screenshots after Escape 1, 2, and 3 are byte-identical.

Testing

  • pnpm tc and pnpm lint pass. pnpm build passes every desktop step and stops at build:mobile-web, because this machine has no mobile/ dependencies. This PR changes no file under mobile/.

  • pnpm test src/renderer/src/components/browser-pane: 116 files, 934 tests pass. A full pnpm test run fails 15 files, none under browser-pane. Each failure also appears on the base commit or comes from the local environment: a missing pg package, a stale .cross-version-checkouts directory, and a timing test that passes alone.

  • New e2e tests/e2e/browser-address-bar-escape.spec.ts drives the real Electron app with ORCA_BACKGROUND_LAUNCH=1. It covers an arrowed suggestion, an edit with the list open, an edit with no list rows, and an unedited bar. It passed on every macOS run except one, which timed out at app launch before any Escape step. The next 12 runs passed.

  • paired-client-hosted-browser-host-strip.spec.ts fails at its "Close hosted page" click with and without this change.

  • I checked each new unit test by breaking the behavior it guards and confirming that the test fails.

  • The e2e found one bug during development, now covered by a test: reverting with an open but empty list made the page's own row reopen the list.

  • No test of its own: the local pane writing the committed address through setAddressBarValueFromPage. The local pane shares the hook that the client-hosted pane's failed-load Escape test covers.

  • Manually tested on macOS in a dev build: Korean composition, an edited address, and an arrowed suggestion.

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

AI Disclosure

Written with Claude Code (Claude Opus 5.5 as the lead, with Claude Fable 5.1 and Claude Sonnet 5 for design candidates and adversarial review).

Review

An adversarial review by three models (Claude Opus 5.5, Claude Fable 5.1, and Claude Sonnet 5) found five actionable issues, all fixed here: a second source for the committed address, a focus grab that leaving did not cancel, duplicated selection code, a comment that overclaimed what stopPropagation blocks, and an Escape handler rebuilt on every render.

  • Cross-platform. Escape means the same on macOS, Linux, and Windows, and the code has no platform branch. The IME handling is the one already used for Enter, which handles both keyup orders: Windows and Linux redispatch before keyup, and macOS redispatches after. Only macOS was tested by hand.
  • SSH, remote, and local. Renderer only, with no IPC, RPC, or stream change. Remote streamed pages consume Escape in the bar and do not forward it. Escape typed inside the remote page is forwarded as before.
  • Agents and integrations. Nothing agent-specific or provider-specific changes. The Enter IME handling behaves the same for the native chat composer, the quick-command menu, and the worktree picker, and their tests pass.
  • Performance. One pure function call per keydown. The window keydown listener that ran while the dropdown was open is gone.
  • UI quality. No visual or style change.
  • Security. No new input parsing, storage, or network use.

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Ensure no issues in: Security, Cross-platoform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred). Lint and typecheck pass. pnpm test and pnpm build have local failures that are not from this change, listed under Testing.

Loading
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.

[Feature]: Escape in the browser address bar should back out one step at a time, like Chrome

2 participants