Skip to content

Commit 1557615

Browse files
authored
Add Duck.ai chat download killswitch (#5838)
Task/Issue URL: https://app.asana.com/0/488551667048375/1209839796813035/f ### Description - Add a killswitch around the chat download functionality. ### Steps to test this PR - [x] Go to Duck.ai and send a prompt - [x] Go to recent chats and download a chat - [x] Verify that the chat is downloaded - [x] Go to feature flag inventory and disable `aiChatDownload` - [x] Go to recent chats and download a chat - [x] Verify that the chat is not downloaded
1 parent b4cc47a commit 1557615

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-1
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* Copyright (c) 2025 DuckDuckGo
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.duckduckgo.duckchat.impl
18+
19+
import com.duckduckgo.anvil.annotations.ContributesRemoteFeature
20+
import com.duckduckgo.di.scopes.AppScope
21+
import com.duckduckgo.feature.toggles.api.Toggle
22+
23+
@ContributesRemoteFeature(
24+
scope = AppScope::class,
25+
featureName = "aiChatDownload",
26+
)
27+
28+
interface AIChatDownloadFeature {
29+
30+
@Toggle.DefaultValue(true)
31+
fun self(): Toggle
32+
}

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ class DuckChatWebViewActivity : DuckDuckGoActivity(), DownloadConfirmationDialog
107107
@Inject
108108
lateinit var duckChat: DuckChatInternal
109109

110+
@Inject
111+
lateinit var aiChatDownloadFeature: AIChatDownloadFeature
112+
110113
private val binding: ActivityDuckChatWebviewBinding by viewBinding()
111114

112115
private var pendingFileDownload: PendingFileDownload? = null
@@ -163,7 +166,11 @@ class DuckChatWebViewActivity : DuckDuckGoActivity(), DownloadConfirmationDialog
163166
}
164167

165168
it.setDownloadListener { url, _, contentDisposition, mimeType, _ ->
166-
requestFileDownload(url, contentDisposition, mimeType)
169+
appCoroutineScope.launch(dispatcherProvider.io()) {
170+
if (aiChatDownloadFeature.self().isEnabled()) {
171+
requestFileDownload(url, contentDisposition, mimeType)
172+
}
173+
}
167174
}
168175

169176
contentScopeScripts.register(

0 commit comments

Comments
 (0)