-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Add fire actions to native chat history screen #8579
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
GerardPaligot
merged 25 commits into
develop
from
feature/gerard/chat-history-native-fire
May 20, 2026
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
9a4e885
Add Fire-all action to Duck.ai chat history screen
GerardPaligot 1f63b2d
Add select mode to Duck.ai chat history screen
GerardPaligot 0e3027d
Wire chat-history Delete-selected through the data-clearing plugin chain
GerardPaligot 5b7b751
Spare Pinned chats on Fire-all by routing N≥2 through Selected
GerardPaligot 5689b52
Match Duck.ai tabs by chatID query param, not full URL
GerardPaligot 15bec23
Cleanup fire implementation
GerardPaligot f5a8b72
Wire per-row Delete in chat history overflow menu
GerardPaligot 92627f3
Tighten FireDialogOrigin.ChatHistory shape
GerardPaligot 4bebf91
Merge DuckChats.Single into DuckChats.Selected
GerardPaligot 2117782
Fix flaky ChatHistoryViewModelTest tests by using awaitInitialLoaded
GerardPaligot 4ebab49
Collapse ChatHistoryViewModel UI flows into a single state holder
GerardPaligot 5b1c539
Rename _then test cases added on this branch to backtick natural English
GerardPaligot d1e1dd7
Stop ChatHistory fire dialog from restarting the app process
GerardPaligot c04c334
Reset back-press callback on Loading and Empty in ChatHistoryFragment
GerardPaligot 8528037
Reset toolbar nav CD on default toolbar and re-check fire dialog tag …
GerardPaligot e86a98b
Drop chat-history confirmation on EVENT_CLEAR_WITHOUT_RESTART_STARTED…
GerardPaligot c45e6a0
Align select-all unchecked indicator size with checked state
GerardPaligot 595e894
Flip chat-history row icon when selection toggles
GerardPaligot 8c012a7
Apply spotless formatting to multi-line when arm
GerardPaligot 29027b4
Cleanup after a mistake with latest rebase
GerardPaligot d1adba9
Include Pinned chats in Fire-all from chat history
GerardPaligot 3aa237f
Split chat-history bulk delete off the fire-button path
GerardPaligot b3569d9
Always confirm Fire-all from chat history
GerardPaligot d458161
Reconcile chat-history selection inside reduce
GerardPaligot 3f58bc3
Gate chat-history dispatch on showClearDuckAIChatHistory
GerardPaligot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
79 changes: 79 additions & 0 deletions
79
app/src/main/java/com/duckduckgo/app/fire/DuckAiTabsCleanupPlugin.kt
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| /* | ||
| * Copyright (c) 2026 DuckDuckGo | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package com.duckduckgo.app.fire | ||
|
|
||
| import android.net.Uri | ||
| import androidx.core.net.toUri | ||
| import com.duckduckgo.app.tabs.model.TabRepository | ||
| import com.duckduckgo.dataclearing.api.plugin.ClearableData | ||
| import com.duckduckgo.dataclearing.api.plugin.DataClearingPlugin | ||
| import com.duckduckgo.di.scopes.AppScope | ||
| import com.duckduckgo.duckchat.api.DuckChat | ||
| import com.squareup.anvil.annotations.ContributesMultibinding | ||
| import logcat.logcat | ||
| import javax.inject.Inject | ||
|
|
||
| /** Closes Duck.ai tabs left pointing at cleared chat URLs. Never touches non-Duck.ai tabs. */ | ||
| @ContributesMultibinding(AppScope::class) | ||
| class DuckAiTabsCleanupPlugin @Inject constructor( | ||
| private val tabRepository: TabRepository, | ||
| private val duckChat: DuckChat, | ||
| ) : DataClearingPlugin { | ||
|
|
||
| override suspend fun onClearData(types: Set<ClearableData>) { | ||
| types.forEach { type -> | ||
| when (type) { | ||
| is ClearableData.DuckChats.All -> closeAllDuckAiTabs() | ||
| is ClearableData.DuckChats.Selected -> closeTabsMatching(type.chatUrls) | ||
| else -> { /* not handled by this plugin */ } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| private suspend fun closeAllDuckAiTabs() { | ||
| val ids = tabRepository.getTabs() | ||
| .filter { tab -> tab.url?.toUri()?.let(duckChat::isDuckChatUrl) == true } | ||
| .map { it.tabId } | ||
| if (ids.isNotEmpty()) { | ||
| logcat { "Closing ${ids.size} open Duck.ai tab(s) after chat clear" } | ||
| tabRepository.deleteTabs(ids) | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Match by `chatID` query param rather than full URL equality — tabs drift (server redirects, | ||
| * extra query params accumulated during the session) so multiple tabs of the same chat would | ||
| * otherwise miss the match. | ||
| */ | ||
| private suspend fun closeTabsMatching(chatUrls: Set<String>) { | ||
| if (chatUrls.isEmpty()) return | ||
| val targetChatIds = chatUrls.mapNotNullTo(mutableSetOf()) { it.toUri().chatIdOrNull() } | ||
| if (targetChatIds.isEmpty()) return | ||
| val ids = tabRepository.getTabs() | ||
| .filter { tab -> tab.url?.toUri()?.chatIdOrNull() in targetChatIds } | ||
| .map { it.tabId } | ||
| if (ids.isNotEmpty()) { | ||
| logcat { "Closing ${ids.size} Duck.ai tab(s) matching the cleared subset" } | ||
| tabRepository.deleteTabs(ids) | ||
| } | ||
| } | ||
|
|
||
| private fun Uri.chatIdOrNull(): String? { | ||
| if (!duckChat.isDuckChatUrl(this)) return null | ||
| return getQueryParameter("chatID")?.takeIf { it.isNotBlank() } | ||
| } | ||
| } | ||
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: this is the third copy of
"chatID"in the codebase —RealDuckChathas a privateCHAT_ID_QUERY_NAMEconst,NativeInputManagerhardcodes it too. can we promote it so we stop duplicating it?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm opening an api proposal for this and I'll open a new PR for that.