Skip to content

fix: apply address bar rule without page URL#125

Open
liby wants to merge 1 commit into
runjuu:mainfrom
liby:fix/99-address-bar-focus-without-url
Open

fix: apply address bar rule without page URL#125
liby wants to merge 1 commit into
runjuu:mainfrom
liby:fix/99-address-bar-focus-without-url

Conversation

@liby

@liby liby commented Jul 18, 2026

Copy link
Copy Markdown

Fixes #99

Problem

With a Browser Rules address bar default input source configured, focusing an empty Chrome omnibox and typing while a Pinyin input source is active switches the input source only after the first keystroke. The switch lands mid-composition, which can leave an orphaned candidate window: the omnibox stops responding to Enter and Delete until the input source is toggled manually.

Root cause

An empty omnibox exposes no observable web-area URL, so AppKind.from classified the browser as a normal app and the address bar rule could not fire on focus. It only fired after the first key triggered another accessibility event.

Changes

  • Make BrowserInfo.url optional and treat address bar focus alone as a browser context, so the address bar rule applies on focus, before typing starts (AppKind.makeBrowserInfo).
  • Keep the context stable while the address bar stays focused: URL changes during editing reflect omnibox edits or suggestions rather than navigation, and no longer re-trigger input source switches (isSameAppOrWebsite).
  • Website rules, tab switching, and navigation outside the address bar keep their existing URL-based behavior; browser states without a URL produce no website id, so they never pollute the per-site keyboard cache.
  • Unwrap the now-optional URL in StatusItemController's browser rule menu.

Testing

  • New unit tests: Tests/AppKindComparisonTests.swift (9 cases) covering browser context creation with and without a URL, entering/leaving the address bar, suggestion-driven URL changes, and navigation (run via Cmd+U).
  • Manual scenario on a Debug build with Pinyin Simplified + Chrome: focusing an empty omnibox now switches to the address bar input source before the first keystroke and the candidate window no longer gets stuck; suggestion changes while typing do not re-trigger switches; website rules resume after leaving the omnibox.

An empty Chrome omnibox exposes no web-area URL, so `AppKind.from`
classified the browser as a normal app and the address bar default
input source rule only fired after the first keystroke. Forcing the
switch mid-composition left the Pinyin candidate window orphaned and
the omnibox unresponsive to Enter and Delete (runjuu#99).

- Make `BrowserInfo.url` optional and treat address bar focus alone
  as a browser context, so the rule fires on focus, before typing
  starts.
- Keep the context stable while the address bar stays focused: URL
  changes then reflect omnibox edits or suggestions rather than
  navigation, and must not re-trigger input source switches.
- Skip website ids for browser states without a URL and unwrap the
  now-optional URL in the browser rule menu.
- Cover `makeBrowserInfo` and context comparison in
  `AppKindComparisonTests`.
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.

[Bug] Forcing input source switch during active composition in Chrome omnibox leaves orphaned candidate window

1 participant