Fire Mode: Add BrowserMode with plumbing#8478
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
5656af4 to
48c2480
Compare
There was a problem hiding this comment.
@0nko there are two main things that need done here:
- consider all the ways the app can launch with an
Intentand map carefully which will result inREGULARmode being enforced. more details: #8478 (comment) - feature flag around all of this! this is a majorly critical codepath and any mistakes here could be painful to pin down (e.g, intermittent feedback that something is weird) and we should be able to disable a single feature flag to get back to existing behavior if there are any problems.
| * comes up. Survives the mode-switch [recreate] via [onSaveInstanceState]; consumed by | ||
| * [BrowserStateRenderer.showWebContent]. | ||
| */ | ||
| private var pendingExternalIntent: Intent? = null |
There was a problem hiding this comment.
is this only used for an Intent received while in fire mode like the comment says? If so, maybe add that to the name of it to make it clearer.
this new thing is confusing because we also already have a similar concept for lastIntent where it similarly has a deferred processing step inside of showWebContent like the one you've added for pendingExternalIntent
it's not clear what relationship these two transient intents share with each other, nor the order in which they should be processed if both exist. I don't have a concrete suggestion yet for improving, but flagging as a point of confusion in case you can come up with a good way of combining these and/or making it clearer how each relate to the other.
There was a problem hiding this comment.
is this only used for an Intent received while in fire mode like the comment says? If so, maybe add that to the name of it to make it clearer.
Yeah, pendingExternalIntent is only written in launchNewSearchOrQuery behind shouldSwitchToRegularModeBeforeProcessingIntent(), which gates on currentMode == FIRE. I can rename it to make the trigger explicit, something like pendingFireToRegularIntent.
this new thing is confusing because we also already have a similar concept for lastIntent where it similarly has a deferred processing step inside of showWebContent like the one you've added for pendingExternalIntent
lastIntent defers until automatic data clearing is finished and uses a different lifecycle (it has to survive the clearer Job in the same Activity instance, whereas pendingExternalIntent has to survive the Activity recreation and is saved).
I can rename both flags to make their purpose explicit or I can try to think about a bigger refactoring.. Let me know what you think.
There was a problem hiding this comment.
I can rename both flags to make their purpose explicit or I can try to think about a bigger refactoring
I think the main thing is to understand the relationship between the two, if there is one. e.g., are they mutually exclusive? if not, what happens if both are set, does one need to be processed before the other etc...?
I don't know the answers to these because it's not clear in code yet. If you think you can make it clearer with renaming and comments, that sounds ok to me, thanks.
|
Thanks @CDRussell! This took longer than I expected because there are browser launch points all over the place.
Ready for another round. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ 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 c560a7b. Configure here.
# Conflicts: # app/src/main/java/com/duckduckgo/app/notification/model/PrivacyProtectionNotification.kt
c7fe0c4 to
2f0669e
Compare
| * limitations under the License. | ||
| */ | ||
|
|
||
| @file:SuppressLint("NoImplImportsInAppModule") |
There was a problem hiding this comment.
Supresses the lint error for the com.duckduckgo.duckchat.impl.ui.DuckChatWebViewFragment.Companion.* keys that are being used for arguments. This was an pre-existing issue that should eventually get fixed but it's unrelated to this change, aside from adding another key.


Task/Issue URL: https://app.asana.com/1/137249556945/project/1207418217763355/task/1214579513091724?focus=true
Description
This PR adds the new
BrowserModeand the related interfaces and their concrete implementations:BrowserModeStateHolderthat exposes enum classBrowserMode { REGULAR, FIRE }, which is the single source of truth for current mode. Theming overlay, tab switcher VM, mode-toggle pill, sync entry points, repository providers — all observe this Flow.FireModeAvailabilitythat checks the feature flag and the WebView feature supportBrowserModeplumbing to the main entry pointsRelated API proposal: https://app.asana.com/1/137249556945/project/1207418217763355/task/1214579944546013?focus=true
Steps to test this PR
Smoke testing that the app is launched correctly and opening an external link works as expected is sufficient.
Note
Medium Risk
Touches core
BrowserActivityintent processing and tab creation, adding mode-based recreation and deferred-intent handling which could affect external link/widget/shortcut launches. New mode plumbing is guarded by availability checks but has broad surface area across entry points.Overview
Introduces a new cross-module
BrowserModeconcept (REGULAR/FIRE) with aBrowserModeStateHoldersource-of-truth and an app implementation (RealBrowserModeStateHolder).Updates
BrowserActivityand tab creation to be mode-aware (adapter/BrowserTabFragmentarguments, DuckChat fragment args), and recreates the activity on mode changes; external entry-point intents can now be stamped asLAUNCH_REQUIRES_REGULAR_MODEand, if received while inFIRE, are deferred across a FIRE→REGULAR switch before processing.Adds a new
fire-mode-api/fire-mode-implwithFireModeAvailability(feature flag + WebView MultiProfile capability), wires it intoBrowserViewModel.switchToMode, and updates numerous launch points (widgets, shortcuts, onboarding/settings/internal screens, tests) to pass aBrowserLaunchSourceand correctly stamp intents.Reviewed by Cursor Bugbot for commit 2f0669e. Bugbot is set up for automated code reviews on this repo. Configure here.