Improve autocomplete behaviour #8669
Open
aibrahim- wants to merge 5 commits into
Open
Conversation
Three related fixes around the native-input widget's autocomplete: 1. Avoid spurious "loading from scratch" on widget re-open with same text. showNativeInput dropped the onClearAutocomplete call that emptied searchResults and re-triggered a fetch; restores the suggestions list visibility from the adapter when the cache matches the prefill. 2. Reveal the browser behind the closing widget earlier. hideNtp now runs at the start of hideNativeInput so the webpage is visible during the exit animation, instead of after the 200ms exit + 150ms fade leaves the NTP background filling the screen. 3. Always keep an autocomplete cache for the omnibar's text so in-widget typing never permanently displaces the omnibar's results. Adds an always-on parallel pipeline in BrowserTabViewModel (omnibarAutocompleteCache) fed by onOmnibarTextChanged; the widget restores from it on close (non-navigation) and on open if the cache matches the prefill. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Dismiss the IME and cancel any in-flight enter animation when the hosting tab is backgrounded so the keyboard does not leak onto the next tab, and seed beginEnterAnimationPreview's state locally instead of reading from NativeInputStateProvider — ViewScope injection isn't guaranteed to be in place by the time it runs on a tab-switch attach. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit fbc586b. Configure here.
fbc586b to
16e361d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Task/Issue URL: https://app.asana.com/1/137249556945/project/1214157224317277/task/1214964760144656?focus=true
Description
Three related fixes around the native-input widget's autocomplete:
Avoid spurious "loading from scratch" on widget re-open with same text. showNativeInput dropped the onClearAutocomplete call that emptied searchResults and re-triggered a fetch; restores the suggestions list visibility from the adapter when the cache matches the prefill.
Reveal the browser behind the closing widget earlier. hideNtp now runs at the start of hideNativeInput so the webpage is visible during the exit animation, instead of after the 200ms exit + 150ms fade leaves the NTP background filling the screen.
Always keep an autocomplete cache for the omnibar's text so in-widget typing never permanently displaces the omnibar's results. Adds an always-on parallel pipeline in BrowserTabViewModel (omnibarAutocompleteCache) fed by onOmnibarTextChanged; the widget restores from it on close (non-navigation) and on open if the cache matches the prefill.
Steps to test this PR
UI changes
Note
Medium Risk
Touches autocomplete flow logic and native-input widget lifecycle/teardown, which could cause regressions in suggestions rendering or keyboard/tab-switch behavior if the new caching and backgrounding hooks misfire.
Overview
Improves native-input widget autocomplete so reopening the widget with the same text can immediately reuse cached omnibar suggestions instead of clearing state and refetching.
Adds an always-on (setting-gated) omnibar autocomplete cache in
BrowserTabViewModel, feeds it from rendered omnibar text, and exposes a restore path used when the widget opens/closes to prevent in-widget typing from permanently displacing omnibar results.Tightens widget lifecycle behavior: reveals the live page earlier during exit (moves
hideNtp), addsonTabBackgroundedto synchronously dismiss IME/tear down the widget on tab hide/swipe, guards enter-complete focus against detached views, and updates enter-animation preview to apply correct per-tab state for top/bottom layouts. Tests cover cache gating, restore behavior, and pixel implications.Reviewed by Cursor Bugbot for commit 16e361d. Bugbot is set up for automated code reviews on this repo. Configure here.