Skip to content

Fire Mode: Launch NTP in different modes#8742

Merged
0nko merged 3 commits into
developfrom
feature/ondrej/fire-mode-new-tabs
Jun 13, 2026
Merged

Fire Mode: Launch NTP in different modes#8742
0nko merged 3 commits into
developfrom
feature/ondrej/fire-mode-new-tabs

Conversation

@0nko

@0nko 0nko commented Jun 1, 2026

Copy link
Copy Markdown
Member

Task/Issue URL: https://app.asana.com/1/137249556945/project/1207418217763355/task/1215275434974447?focus=true

Description

This PR implements the functionality that allows launching NTPs specifically in Regular or Browser mode.

Steps to test this PR

  • Enable Fire tabs FF in dev settings
  • Make Search & Duck.ai option is enabled in AI settings
  • Open a new Duck.ai chat tab in Regular mode
  • Tap on the + button and tap on "New Fire tab"
  • Verify a new tab is launched and the browser is now in Fire Mode (Fire mode theme is used)
  • While in Fire Mode, open Duck.ai chat tab
  • Tap on the + button and tap on "New tab"
  • Verify a new tab is launched and the browser is now in Regular Mode (regular theme is used)

Note

Medium Risk
Touches core BrowserActivity lifecycle, mode switching, and intent handling; incorrect deferral or replay could drop tabs or mishandle launch intents, though ProcessIntent consumption is explicitly guarded.

Overview
Adds mode-aware new tab launches from Duck.ai’s “+” menu: New tab switches to Regular mode first; New Fire tab switches to Fire mode first.

Replaces the old FIRE→REGULAR-only deferred Intent stash with a general switchModeThen flow: pending work is stored as PendingModeSwitch (ProcessIntent or OpenNewTab), saved in instance state across activity recreate, then replayed in showWebContent. launchNewTab gains an optional browserMode parameter (default: current mode) and always goes through that deferral path when a switch is needed.

New PendingModeSwitch.kt defines bundle round-tripping; PendingModeSwitchTest covers encode/decode edge cases. runAction documents that carried intents are consumed via processIntent, not re-launched.

Reviewed by Cursor Bugbot for commit 407bc24. Bugbot is set up for automated code reviews on this repo. Configure here.

0nko commented Jun 1, 2026

Copy link
Copy Markdown
Member Author

@0nko 0nko requested a review from malmstein June 1, 2026 18:46
@0nko 0nko force-pushed the feature/ondrej/fire-mode-new-tabs branch from 3d52f23 to 96a48e5 Compare June 2, 2026 15:40
@0nko 0nko force-pushed the feature/ondrej/fire-mode-search-duckchat-input-theme branch from e607eec to 4ead19a Compare June 2, 2026 15:41
@0nko 0nko mentioned this pull request Jun 2, 2026
10 tasks
Comment thread app/src/main/java/com/duckduckgo/app/browser/PendingModeSwitch.kt Outdated
@0nko 0nko force-pushed the feature/ondrej/fire-mode-search-duckchat-input-theme branch from 4ead19a to 605d6de Compare June 5, 2026 20:13
@0nko 0nko force-pushed the feature/ondrej/fire-mode-new-tabs branch from 96a48e5 to 04a7fae Compare June 5, 2026 20:13

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

There are 2 total unresolved issues (including 1 from previous review).

Fix All in Cursor

❌ 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 04a7fae. Configure here.

Comment thread app/src/main/java/com/duckduckgo/app/browser/BrowserActivity.kt
@0nko 0nko force-pushed the feature/ondrej/fire-mode-search-duckchat-input-theme branch from 605d6de to 09cf304 Compare June 9, 2026 13:58
@0nko 0nko force-pushed the feature/ondrej/fire-mode-new-tabs branch from 04a7fae to 0bf23a7 Compare June 9, 2026 13:58

@malmstein malmstein left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, approving. did not install or smoke-test the APK — static-only. nice refactor: generalising the old pendingFireToRegularIntent into a typed PendingModeSwitch (ProcessIntent / OpenNewTab) carried across the recreate is clean, and the switchModeThen design that re-enters itself on the recreated instance is genuinely well thought through — the doc comments and the explicit intent-redirection security invariant on runAction are exactly what I'd want to see on this path. the rejection fallback only reaches OpenNewTab(FIRE) when fire is unavailable, which is the right behaviour.

one non-blocking ask before merge: please add the round-trip test for toBundle/toPendingModeSwitch — it's the piece most likely to break quietly and the easiest thing here to cover. and since I didn't run it, worth a quick device check of the chat-menu "new tab" / "new fire tab" entries and an external LAUNCH_REQUIRES_REGULAR_MODE intent arriving while in fire mode, to confirm the deferred action survives the recreate.

return bundle
}

internal fun Bundle.toPendingModeSwitch(): PendingModeSwitch? {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

toBundle / toPendingModeSwitch is the load-bearing part here — if it doesn't round-trip cleanly the deferred action is silently lost across the recreate. it's pure and Android-testable (same AndroidJUnit4 setup as RealTabTitleResolverTest from #8714) — can we add a round-trip test covering both PendingAction variants plus the null/garbage-bundle paths (unknown action, bad mode name, missing intent) before this merges?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added PendingModeSwitchTest (AndroidJUnit4, same setup as RealTabTitleResolverTest) — round-trips both PendingAction variants plus the null paths: empty bundle, unknown mode name, missing action, unknown action, and ProcessIntent with a missing intent. The malformed-bundle cases start from a valid bundle and corrupt one field, so a stale wire-format key fails the test rather than silently passing. 12f228066c.

@0nko 0nko force-pushed the feature/ondrej/fire-mode-search-duckchat-input-theme branch from 09cf304 to e8ca846 Compare June 11, 2026 09:29
@0nko 0nko requested a review from mikescamell as a code owner June 11, 2026 09:29
@0nko 0nko force-pushed the feature/ondrej/fire-mode-new-tabs branch from 0bf23a7 to 082a64a Compare June 11, 2026 09:30
@0nko 0nko force-pushed the feature/ondrej/fire-mode-search-duckchat-input-theme branch from 70eaff9 to 9465d5b Compare June 12, 2026 19:14
@0nko 0nko force-pushed the feature/ondrej/fire-mode-new-tabs branch from 082a64a to 428c983 Compare June 12, 2026 19:14
Base automatically changed from feature/ondrej/fire-mode-search-duckchat-input-theme to develop June 12, 2026 19:42
0nko and others added 3 commits June 12, 2026 21:45
toPendingModeSwitch() is a fail-soft parser: every other malformed-bundle
branch returns null. The bare BrowserMode.valueOf() was the one branch that
could throw on restore (e.g. a persisted name no longer in the enum), so
parse it with runCatching{}.getOrNull() to degrade to "no pending action"
like the rest of the function.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Covers both PendingAction variants (ProcessIntent, OpenNewTab) plus the
null-returning paths that silently drop a deferred action across recreation:
empty bundle, unknown mode name, missing/unknown action, and ProcessIntent
with a missing intent.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@0nko 0nko force-pushed the feature/ondrej/fire-mode-new-tabs branch from 12f2280 to 407bc24 Compare June 12, 2026 19:45
@0nko 0nko merged commit 71e668a into develop Jun 13, 2026
13 checks passed
@0nko 0nko deleted the feature/ondrej/fire-mode-new-tabs branch June 13, 2026 07:17
@0nko 0nko mentioned this pull request Jun 16, 2026
4 tasks
@0nko 0nko mentioned this pull request Jun 18, 2026
22 tasks
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.

2 participants