-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Duck.ai Contextual: Page Context attachment #7635
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
Duck.ai Contextual: Page Context attachment #7635
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
88fbfc1 to
9f0e813
Compare
...at-impl/src/main/java/com/duckduckgo/duckchat/impl/contextual/DuckChatContextualViewModel.kt
Outdated
Show resolved
Hide resolved
duckchat/duckchat-impl/src/main/java/com/duckduckgo/duckchat/impl/helper/DuckChatJSHelper.kt
Show resolved
Hide resolved
...at-impl/src/main/java/com/duckduckgo/duckchat/impl/contextual/DuckChatContextualViewModel.kt
Outdated
Show resolved
Hide resolved
692ac53 to
ecfd8bd
Compare
duckchat/duckchat-impl/src/main/java/com/duckduckgo/duckchat/impl/RealDuckChat.kt
Show resolved
Hide resolved
ecfd8bd to
7281450
Compare
...at-impl/src/main/java/com/duckduckgo/duckchat/impl/contextual/DuckChatContextualViewModel.kt
Show resolved
Hide resolved
...at-impl/src/main/java/com/duckduckgo/duckchat/impl/contextual/DuckChatContextualViewModel.kt
Show resolved
Hide resolved
...hat-impl/src/main/java/com/duckduckgo/duckchat/impl/contextual/DuckChatContextualFragment.kt
Show resolved
Hide resolved
...at-impl/src/main/java/com/duckduckgo/duckchat/impl/contextual/DuckChatContextualViewModel.kt
Show resolved
Hide resolved
...at-impl/src/main/java/com/duckduckgo/duckchat/impl/contextual/DuckChatContextualViewModel.kt
Show resolved
Hide resolved
...uckchat-impl/src/test/kotlin/com/duckduckgo/duckchat/impl/helper/RealDuckChatJSHelperTest.kt
Show resolved
Hide resolved
app/src/main/java/com/duckduckgo/app/browser/BrowserTabFragment.kt
Outdated
Show resolved
Hide resolved
Task/Issue URL: https://app.asana.com/1/137249556945/project/1174433894299346/task/1213089462953308?focus=true ### Description - This PR expands the sheet when the keyboard opens in input mode - Also makes sure that the sheet goes over the toolbar ### Steps to test this PR Enable contextualMode _Sheet fully expands_ - [ ] Open the app and start a contextual chat - [ ] Verify sheet is in half expanded state when opened - [ ] Focus on the input field - [ ] Sheet should now be full expanded (over the toolbar) - [ ] Hide the keyboard (back gesture or hide keyboard) - [ ] Sheet should now be in half expanded state - [ ] Enter a prompt and focus the web input - [ ] Sheet should be in expanded state - [ ] Hide the keyboard - [ ] Sheet should still be in expanded state <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Adjusts BottomSheetBehavior sizing/state based on runtime view and IME visibility, which can vary across devices and may cause layout/interaction regressions in contextual chat. > > **Overview** > Ensures the Duck.ai contextual bottom sheet can **cover the full screen (including over the toolbar)** by sizing the sheet container to the root view height and setting the bottom sheet `peekHeight` accordingly. > > Adds IME detection in `DuckChatContextualFragment` and routes it to `DuckChatContextualViewModel.onKeyboardVisibilityChanged` so the sheet **expands when the keyboard opens in input mode** and returns to half-expanded when the keyboard closes; behavior is backed by new unit tests. > > Tweaks bottom-sheet configuration (`isFitToContents = false`, `expandedOffset = 0`) and small UI/log changes (remove top margin, use `isInvisible` for the clear button, update log tag). > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit c58d9ea. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
Co-authored-by: Cursor <cursoragent@cursor.com>
8966b32 to
93607ad
Compare
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.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
| it.copy( | ||
| sheetMode = SheetMode.INPUT, | ||
| showFullscreen = true, | ||
| prompt = "", |
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.
userRemovedContext flag not reset on new chat
Medium Severity
The onNewChatRequested function resets sheetMode, showFullscreen, and prompt but fails to reset userRemovedContext to false. When a user removes page context and later starts a new chat, the stale userRemovedContext = true flag persists, preventing automatic context attachment from working for the new conversation even though the user expects fresh context behavior.
joshliebe
left a comment
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.
LGTM, working well! 🚀



Task/Issue URL: https://app.asana.com/1/137249556945/project/1157893581871903/task/1213010969250403?focus=true
Description
This PR adds the changes agreed in the Ship Review for the context attachment feature
Steps to test this PR
Make sure you enable contextualMode and automaticContextAttachment FF
Turn Automatic Context Attachment in Settings / AI Features
New context UI
Automatic context attachment - Setting ON
Automatic context attachment - Setting OFF
Sheet fully expands
Note
Medium Risk
Changes core Duck.ai contextual bottom-sheet UX/state (keyboard-driven expansion, context attach/detach rules, and lifecycle listener management), which can introduce regressions in sheet behavior and context sending. No auth/payment or sensitive data handling changes, but it alters how/when page context is attached and persisted.
Overview
Improves Duck.ai contextual mode page-context attachment flow and UI: adds a dedicated “Attach Page Content” control, clear-text handling, updated summarize prompt text, and refines when context is shown/attached (including tracking when the user explicitly removed context).
Tightens automatic context attachment behind a new
DuckChatFeature.automaticContextAttachment()remote toggle and updates JS handling sogetAIChatPageContextonly returns context for explicitreason=userActionrequests (notinit).Refactors bottom-sheet behavior to better match browser/keyboard state: the contextual sheet now opens half-expanded, expands when the keyboard is visible, syncs container height to browser layout changes, restores omnibar state when hiding, and cleans up layout/bottom-sheet/keyboard listeners on view destruction; tests updated accordingly.
Written by Cursor Bugbot for commit 93607ad. This will update automatically on new commits. Configure here.