Skip to content

Commit a76e73c

Browse files
authored
Delete DuckChatWebViewActivity (#7328)
Task/Issue URL: https://app.asana.com/1/137249556945/project/488551667048375/task/1211755763011422?focus=true ### Description - This is no longer needed since Duck.ai is currently tied to the `BrowserActivity` using `DuckChatWebViewFragment` ### Steps to test this PR - [ ] Open Duck.ai - [ ] Verify that it is launched correctly <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Deletes the standalone DuckChatWebViewActivity and shifts opening/closing Duck.ai to BrowserNav with updated session handling; cleans up manifest and tests. > > - **DuckChat flow**: > - Remove `DuckChatWebViewActivity` and `DuckChatWebViewActivityViewModel` (and related tests). > - In `RealDuckChat`, drop `keepSession` and standalone activity path; always use `BrowserNav.openDuckChat/closeDuckChat`. > - Adjust session logic: `hasSessionActive` now based on `hasActiveSession()` unless `forceNewSession`. > - Remove `DuckChatWebViewActivityWithParams` usage and `startDuckChatActivity` helper. > - **Manifest**: > - Delete `com.duckduckgo.duckchat.impl.ui.DuckChatWebViewActivity` entry. > - **Tests**: > - Update `RealDuckChatTest` to assert `BrowserNav` intents and active-session behavior; remove obsolete WebView activity tests. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 6957e7a. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent 96d162c commit a76e73c

File tree

6 files changed

+57
-874
lines changed

6 files changed

+57
-874
lines changed

duckchat/duckchat-impl/src/main/AndroidManifest.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,6 @@
2727
android:exported="false"
2828
android:label="@string/duck_ai_shortcut_settings_title"
2929
android:parentActivityName="com.duckduckgo.duckchat.impl.ui.settings.DuckChatSettingsActivity" />
30-
<activity
31-
android:name="com.duckduckgo.duckchat.impl.ui.DuckChatWebViewActivity"
32-
android:exported="false"
33-
android:label="@string/duck_chat_title"
34-
android:configChanges="keyboardHidden|orientation|screenSize|smallestScreenSize|screenLayout|navigation|keyboard"/>
3530
<activity
3631
android:name="com.duckduckgo.duckchat.impl.inputscreen.ui.InputScreenActivity"
3732
android:exported="false" />

duckchat/duckchat-impl/src/main/java/com/duckduckgo/duckchat/impl/RealDuckChat.kt

Lines changed: 6 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ import com.duckduckgo.duckchat.impl.pixel.DuckChatPixelName.DUCK_CHAT_NEW_ADDRES
4949
import com.duckduckgo.duckchat.impl.pixel.DuckChatPixelParameters
5050
import com.duckduckgo.duckchat.impl.pixel.DuckChatPixelParameters.NEW_ADDRESS_BAR_SELECTION
5151
import com.duckduckgo.duckchat.impl.repository.DuckChatFeatureRepository
52-
import com.duckduckgo.duckchat.impl.ui.DuckChatWebViewActivityWithParams
5352
import com.duckduckgo.navigation.api.GlobalActivityStarter
5453
import com.duckduckgo.privacy.config.api.PrivacyConfigCallbackPlugin
5554
import com.squareup.anvil.annotations.ContributesBinding
@@ -297,7 +296,6 @@ class RealDuckChat @Inject constructor(
297296
private val _showMainButtonsInInputScreen = MutableStateFlow(false)
298297

299298
private val _chatState = MutableStateFlow(ChatState.HIDE)
300-
private val keepSession = MutableStateFlow(false)
301299
private val _showInputScreenOnSystemSearchLaunch = MutableStateFlow(false)
302300
private val _showVoiceSearchToggle = MutableStateFlow(false)
303301
private val _showFullScreenMode = MutableStateFlow(false)
@@ -410,15 +408,9 @@ class RealDuckChat @Inject constructor(
410408
}
411409

412410
override fun closeDuckChat() {
413-
if (keepSession.value) {
414-
browserNav.closeDuckChat(context).apply {
415-
flags = Intent.FLAG_ACTIVITY_NEW_TASK
416-
context.startActivity(this)
417-
}
418-
} else {
419-
appCoroutineScope.launch {
420-
closeChatFlow.emit(Unit)
421-
}
411+
browserNav.closeDuckChat(context).apply {
412+
flags = Intent.FLAG_ACTIVITY_NEW_TASK
413+
context.startActivity(this)
422414
}
423415
}
424416

@@ -552,21 +544,15 @@ class RealDuckChat @Inject constructor(
552544
val hasSessionActive =
553545
when {
554546
forceNewSession -> false
555-
keepSession.value -> hasActiveSession()
556-
else -> false
547+
else -> hasActiveSession()
557548
}
558549

559550
duckChatFeatureRepository.registerOpened()
560551

561552
withContext(dispatchers.main()) {
562553
pixel.fire(DuckChatPixelName.DUCK_CHAT_OPEN, parameters = params)
563-
if (keepSession.value) {
564-
logcat { "Duck.ai: restoring Duck.ai session $url hasSessionActive $hasSessionActive" }
565-
openDuckChatSession(url, hasSessionActive)
566-
} else {
567-
logcat { "Duck.ai: opening standalone Duck.ai screen $url" }
568-
startDuckChatActivity(url)
569-
}
554+
logcat { "Duck.ai: restoring Duck.ai session $url hasSessionActive $hasSessionActive" }
555+
openDuckChatSession(url, hasSessionActive)
570556
}
571557
}
572558
}
@@ -584,16 +570,6 @@ class RealDuckChat @Inject constructor(
584570
context.startActivity(this)
585571
}
586572
}
587-
588-
private fun startDuckChatActivity(url: String) {
589-
globalActivityStarter
590-
.startIntent(context, DuckChatWebViewActivityWithParams(url))
591-
?.apply {
592-
flags = Intent.FLAG_ACTIVITY_NEW_TASK
593-
context.startActivity(this)
594-
}
595-
}
596-
597573
private fun appendParameters(
598574
parameters: Map<String, String>,
599575
url: String,
@@ -721,7 +697,6 @@ class RealDuckChat @Inject constructor(
721697
isImageUploadEnabled = imageUploadFeature.self().isEnabled()
722698
isStandaloneMigrationEnabled = duckChatFeature.standaloneMigration().isEnabled()
723699

724-
keepSession.value = duckChatFeature.keepSession().isEnabled()
725700
keepSessionAliveInMinutes = settingsJson?.sessionTimeoutMinutes ?: DEFAULT_SESSION_ALIVE
726701

727702
cacheUserSettings()

0 commit comments

Comments
 (0)