DuckChat

interface DuckChat

DuckChat interface provides a set of methods for interacting and controlling DuckChat.

Properties

Link copied to clipboard
abstract val activeVoiceChatSessions: Flow<Set<String>>

Emits the set of tab IDs that currently have an active voice session.

Functions

Link copied to clipboard
abstract fun getDuckChatUrl(query: String, autoPrompt: Boolean, sidebar: Boolean = false): String

Returns the Duck Chat URL to be used

Link copied to clipboard
abstract suspend fun isChatHistoryAvailable(): Boolean

Returns true when the native Duck.ai chat history surface is enabled by all gating feature flags. Suspending because the underlying feature-flag reads must not block the main thread.

Link copied to clipboard
abstract fun isDuckChatUrl(uri: Uri): Boolean

Determines whether a given Uri is a DuckChat URL. There are two Duck Chat URLs Legacy: https://duckduckgo.com/?q=DuckDuckGo+AI+Chat&ia=chat&duckai=5 After Migration: https://duck.ai/chat?q=DuckDuckGo+AI+Chat&duckai=5&atb=v520-1ru&ko=-1&t=ddg_android&migration=native-import https://app.asana.com/1/137249556945/task/1210497696306780

Link copied to clipboard
abstract fun isEnabled(): Boolean

Checks whether DuckChat is enabled based on remote config flag and user preference. Uses a cached value - does not perform disk I/O.

Link copied to clipboard
abstract suspend fun isStandaloneMigrationCompleted(): Boolean
Link copied to clipboard

Returns true if a voice session is currently active on the tab with the given tabId.

Observes the value for the automatic context attachment for Contextual Mode

Link copied to clipboard

Observes whether the user has enabled chat suggestions.

Observes the cosmetic value for the input screen user setting. Returns null if the cosmetic value has not been set before.

Link copied to clipboard

Observes whether Duck.ai input screen with a mode switch is enabled or disabled.

Observes whether the native input field user setting is enabled.

Link copied to clipboard

Emits the tab id whenever an end-voice-session action is requested (e.g. from the foreground service notification). Tabs should collect this flow and dispatch the end-voice-session JS event when their id is emitted.

Link copied to clipboard
abstract fun openDuckChat()

Opens the DuckChat WebView with optional pre-filled String query.

Link copied to clipboard
abstract fun openDuckChatWithAutoPrompt(query: String)

Auto-prompts the DuckChat WebView with the provided String query.

Link copied to clipboard
abstract fun openDuckChatWithPrefill(query: String)

Opens Duck Chat with a prefilled String query.

Link copied to clipboard
abstract fun openVoiceDuckChat()

Opens Duck.ai directly in voice mode (duck.ai/?mode=voice-mode).

Link copied to clipboard
abstract suspend fun setChatSuggestionsUserSetting(enabled: Boolean)

Set user preference for whether chat suggestions are shown in the input screen.

Link copied to clipboard
abstract suspend fun setCosmeticInputScreenUserSetting(enabled: Boolean)

Cosmetically sets the input screen user setting.

Link copied to clipboard
abstract suspend fun setInputScreenUserSetting(enabled: Boolean)

Set user setting to determine whether dedicated Duck.ai input screen with a mode switch should be used.

Link copied to clipboard
abstract fun showNewAddressBarOptionChoiceScreen(context: Context, isDarkThemeEnabled: Boolean)

Displays the new address bar option choice screen.

Link copied to clipboard
abstract suspend fun wasOpenedBefore(): Boolean

Returns true if Duck Chat was ever opened before.