Skip to content

Duck.ai: Show Page Context#7524

Merged
malmstein merged 39 commits intodevelopfrom
feature/david/01-19-duck.ai_show_page_context
Jan 30, 2026
Merged

Duck.ai: Show Page Context#7524
malmstein merged 39 commits intodevelopfrom
feature/david/01-19-duck.ai_show_page_context

Conversation

@malmstein
Copy link
Copy Markdown
Contributor

@malmstein malmstein commented Jan 19, 2026

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

Description

This PR adds the ability to attach page context and prompt sending it

Steps to test this PR

-Enable contextualMode FF

Context refreshed

  • Open Settings and ensure “Automatic Page Context” is enabled
  • Open a site and open the contextual menu
  • Verify the page title and favicon become visible
  • Without hiding the contextual sheet, navigate to another site in the browser
  • Verify the new page title and favicon become visible

Prompt with context

  • Open Settings and ensure “Automatic Page Context” is enabled
  • Open a site and open the contextual menu
  • Verify the page title and favicon become visible
  • Tap on “Summarise This Page” and submit
  • Verify Duck.ai opens and the context is attached at the top of the page

Prompt without context

  • Open a site and open the contextual menu
  • Verify the page title and favicon become visible
  • Tap on X to remove the page context
  • Verify page context has been removed and the clip icon is visible
  • Tap on the clip icon
  • Verify the page context is added again
  • Remove it and enter any prompt
  • Verify Duck.ai opens and the context is not attached

Note

Medium Risk
Adds new contextual-mode data flow (content-scope pageContext messages, new ViewModel/state, and per-tab URL persistence) that can affect Duck.ai navigation and JS/native messaging behavior. Risk is moderated by targeted unit/instrumentation test updates but touches several browser/chat integration points.

Overview
Enables Duck.ai contextual mode to collect, display, and optionally attach the current page context (title/favicon/content) when sending a native prompt, with UI controls to remove/re-add the attachment.

Introduces a new content-scope pageContext feature (config/store/repository + JS message handler) and wires it through BrowserTabViewModel.processJsCallbackMessage via new Command.PageContextReceived, which BrowserTabFragment forwards to a shared contextual ViewModel.

Refactors the contextual bottom sheet to a new DuckChatContextualViewModel, adds sidebar chat URL generation (DuckChat.getDuckChatUrl(..., sidebar)), supports JS requests for getAIChatPageContext, and persists/clears per-tab contextual chat URLs via DuckChatContextualDataStore (hooked into tab deletion/clear-all).

Written by Cursor Bugbot for commit 4d18986. This will update automatically on new commits. Configure here.


Copy link
Copy Markdown
Contributor Author

malmstein commented Jan 19, 2026

@malmstein malmstein mentioned this pull request Jan 19, 2026
17 tasks
@malmstein malmstein force-pushed the feature/david/01-19-duck.ai_automatic_context_setting branch from ee8999d to eb4c39d Compare January 23, 2026 08:42
@malmstein malmstein force-pushed the feature/david/01-19-duck.ai_show_page_context branch 4 times, most recently from 299b90f to cb97f02 Compare January 23, 2026 10:21
@malmstein malmstein force-pushed the feature/david/01-19-duck.ai_automatic_context_setting branch from bdc2bff to 552a005 Compare January 23, 2026 10:21
@malmstein malmstein force-pushed the feature/david/01-19-duck.ai_show_page_context branch from 0c907de to 5ee523e Compare January 23, 2026 10:42
Base automatically changed from feature/david/01-19-duck.ai_automatic_context_setting to develop January 23, 2026 12:46
@malmstein malmstein force-pushed the feature/david/01-19-duck.ai_show_page_context branch 5 times, most recently from 423ee3c to d608bfc Compare January 27, 2026 13:28
@malmstein malmstein requested a review from mikescamell January 27, 2026 15:47
@malmstein malmstein marked this pull request as ready for review January 27, 2026 15:47
@malmstein malmstein force-pushed the feature/david/01-19-duck.ai_show_page_context branch from 6dd66d9 to f5200be Compare January 27, 2026 20:04
@malmstein malmstein force-pushed the feature/david/01-19-duck.ai_show_page_context branch from f5200be to 5b162d9 Compare January 28, 2026 09:48
Comment thread app/src/main/java/com/duckduckgo/app/browser/BrowserTabFragment.kt
@malmstein malmstein force-pushed the feature/david/01-19-duck.ai_show_page_context branch from 5b162d9 to 7c51d92 Compare January 28, 2026 11:02
@malmstein malmstein force-pushed the feature/david/01-19-duck.ai_show_page_context branch from e1b038b to 327f4d8 Compare January 30, 2026 11:13
Task/Issue URL:
https://app.asana.com/1/137249556945/project/1174433894299346/task/1213004332490553?focus=true

### Description
This PR adds support for adding / removing context from the web input

### Steps to test this PR

_Automatic Context Attachment OFF_
- [x] Open app, Settings / AI Feature
- [x] Ensure Automatic Context Attachment is disabled
- [x] Open Contextual sheet
- [x] Enter any prompt, ensure that no context is added
- [x] Once Duck.ai is visible, tap on the clip icon on the web input
- [x] Select Current Tab Content
- [x] Verify context is added
- [x] Tap on the new X button that appars
- [x] Verify content is removed from the web input
- [x] Add the context again and enter a prompt
- [x] Verify context has been added and is showing at the top of Duck.ai

_Automatic Context Attachment ON_
- [x] Open app, Settings / AI Feature
- [x] Ensure Automatic Context Attachment is enabled
- [x] Open Contextual sheet
- [x] Enter any prompt, ensure that no context is added (you’ll have to
remove it)
- [x] Once Duck.ai is visible, verify that the context is now appearing
in the web input
- [x] Enter a prompt
- [x] Verify context has been added and is showing at the top of Duck.ai

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Medium Risk**
> Moderate risk: adds new JS bridge behavior and persists per-tab chat
URLs in DataStore, which can affect contextual chat UX and state cleanup
when tabs are deleted.
> 
> **Overview**
> Adds **contextual Duck.ai web-input context support** by extending
`DuckChatJSHelper.processJsCallbackMessage` to handle a new
`getAIChatPageContext` method and conditionally return the current page
context (based on request reason and the *automatic context attachment*
setting).
> 
> Enhances **contextual sheet session behavior** by persisting/restoring
a per-tab chat URL (including chat history detection via `chatID`),
adding a native “new chat” action, and ensuring contextual chat state is
cleared when tabs (or all tabs) are deleted via `TabDataRepository`.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
69b0ded. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
Copy link
Copy Markdown
Contributor

@cursor cursor Bot left a comment

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.

Comment thread app/src/main/java/com/duckduckgo/app/browser/BrowserTabFragment.kt
Copy link
Copy Markdown
Contributor

@joshliebe joshliebe left a comment

Choose a reason for hiding this comment

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

LGTM 🚀

@malmstein malmstein merged commit 2fda138 into develop Jan 30, 2026
15 checks passed
@malmstein malmstein deleted the feature/david/01-19-duck.ai_show_page_context branch January 30, 2026 15:33
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.

3 participants