Fire Mode: BrowserModeStateHolder consolidation#9224
Open
0nko wants to merge 14 commits into
Open
Conversation
…instead of hard-coded REGULAR Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
… the frozen browser mode Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…d of sampling the global holder Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…icitly instead of sampling the global holder Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…sync promo stops sampling the global holder Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…ampling the global holder Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…en browser mode Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…t allowlist of boundary and mode-transition readers Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…ling the global holder in the import promo Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Member
Author
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
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/1207418217763355/task/1216655275619568?focus=true
API Proposal: https://app.asana.com/1/137249556945/project/1207418217763355/task/1216655924244593?focus=true
Description
Mostly mechanical rewiring of DI dependencies. The PR removes all ambient reads of the mutable global
BrowserModeStateHolder.currentModeso mode-dependentcomponents act on a frozen, correct
BrowserMode:labeled as
REGULAR(it worked only because the deleter chain also sampled the global mode).The ViewModel now passes the activity's frozen mode.
ModeAwareDuckAiChatStore: the unqualifiedDuckAiChatStoreis now an ActivityScoperesolution of the frozen mode; the deleter chain is explicitly
@RegularMode(Fire deletions arerouted directly to the Fire store by the data-clearing plugin).
ShowOnAppLaunchOptionHandler,DuckChatSyncRepository.record*, the chat-sync promo plugin path,AutoCompletecreation, the autofill import promo (mode bound at the tab-wiring seam), and re-scopesRealEscapeHatchTargetResolverto ActivityScope.DenyListedApilint entry banningcurrentModereads (detector extended to see Kotlinproperty getters). The seven irreducible readers (freeze/launch boundaries, mode-switch
orchestrators, mode-transition observers) carry
@Suppress+ a one-line justification each.No UI or user-facing behavior changes besides the Fire-mode history clear fix.
Deny-list exceptions
Every remaining
BrowserModeStateHolder.currentModeread carries@Suppress("DenyListedApi")and exists for one of three reasons — it mints the frozen value, it orchestrates the switch, or it consumes mode transitions, none of which a frozen per-activity value can replace:BrowserModeActivityModule.provideActivityBrowserMode— the freeze boundary itself: the single place that samples the holder to mint every activity's frozenBrowserMode, so it cannot inject the value it produces.FirstScreenHandlerImpl(two reads) — runs on process-level app-open lifecycle callbacks, where no activity component (and therefore no frozen mode) exists yet.BrowserViewModel.currentMode— mode-switch orchestrator: it writes the mode viaswitchTo()and must observe the live value it mutates to drive the switch UX.TabSwitcherViewModel.currentMode— hosts the Regular/Fire toggle: the same orchestrator role, writing viaswitchTo()and reacting to the live value.ExternalIntentProcessingStateImpl— cross-activity pending-intent state that must react to mode transitions and survive the activity recreation a switch causes, which a per-activity snapshot cannot represent.FireTabsPromoModeObserver— fires once on the first entry into Fire mode, which requires observing the stream of transitions rather than a snapshot.RealNativeInputStateStore— AppScope tab-state registry that must outlive activity recreation and follow the live mode so native-input surfaces always read the active mode's selected tab.Steps to test this PR
Fire-mode chat history clear
Two-mode smoke of rewired surfaces (Optional, no behavior change expected)
Note
Medium Risk
Wide DI rewiring across browser, autofill, and Duck.ai with a real Fire-mode chat-clear fix; incorrect mode threading could mis-route tabs, sync, or promos, though tests were updated throughout.
Overview
Replaces most ambient reads of
BrowserModeStateHolder.currentModewith an activity-frozenBrowserMode(minted once per activity) or an explicit mode argument passed from callers. Mode-dependent autocomplete, autofill, app-launch handling, Duck.ai sync bookkeeping, and chat history now key off that frozen value instead of sampling the global holder mid-flow.Autocomplete & search —
AutoCompleteFactory.createtakesbrowserMode;DefaultAutoCompletemoves toActivityScope. Switch-to-tab suggestions use the injected mode directly (noflatMapLateston the holder).Autofill —
BrowserAutofill/ configurator APIs threadbrowserModefrom the tab through JS setup and runtime config. In-browser Google password import promo uses the passed mode (no import promos in Fire).App launch —
ShowOnAppLaunchOptionHandlerreceivescurrentModefromFirstScreenHandlerat process-launch boundaries instead of reading the holder inside the handler.Duck.ai — Chat history clear uses the activity’s frozen mode (fixes Fire history clears being labeled
REGULAR). Syncrecord*APIs takemodeand skip non-syncable modes. Deleter/store paths use@RegularModewhere Fire clears bypass the Regular chain. Several readers (chat history repo, suggestions) move toActivityScope.Lint — Remaining justified
currentModereads are@Suppress("DenyListedApi")with short comments (freeze boundary, mode-switch orchestrators, transition observers, launch boundaries).Reviewed by Cursor Bugbot for commit 284fc3a. Bugbot is set up for automated code reviews on this repo. Configure here.