-
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
base: develop
Are you sure you want to change the base?
Duck.ai Contextual: Page Context attachment #7635
Conversation
88fbfc1 to
9f0e813
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 3 potential issues.
| contextTitle = title, | ||
| contextUrl = url, | ||
| tabId = tabId, | ||
| showContext = _viewState.value.allowsAutomaticContextAttachment && _viewState.value.showContext, |
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.
Automatic context attachment never auto-attaches due to AND logic
High Severity
The logic showContext = _viewState.value.allowsAutomaticContextAttachment && _viewState.value.showContext in onPageContextReceived prevents automatic context attachment from working. Since showContext initially starts as false, the AND operation always evaluates to false even when automatic attachment is enabled. This causes the "init" request from the web to never receive page context, as the JS helper checks userEnabledContextAttachment && isAutomaticContextAttachmentEnabled(). The operator likely needs to be || (OR) instead of && (AND) to auto-attach when the feature is enabled.
|
|
||
| private fun ensureBrowserIsCompatibleWithContextualSheetState() { | ||
| val bottomSheetBehavior = BottomSheetBehavior.from(binding.duckAiContextualFragmentContainer) | ||
| bottomSheetBehavior.state = BottomSheetBehavior.STATE_HALF_EXPANDED |
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.
Sheet state command dropped due to channel overflow
Medium Severity
The removal of bottomSheetBehavior.state = BottomSheetBehavior.STATE_HALF_EXPANDED from ensureBrowserIsCompatibleWithContextualSheetState() causes the sheet to potentially appear in an incorrect state. The commandChannel has capacity 1 with DROP_OLDEST overflow, and onSheetOpened sends ChangeSheetState followed immediately by LoadUrl. The first command is dropped when the second is sent, so the sheet state is never set. Previously, the direct state assignment provided a guaranteed initial state that is now missing.
Additional Locations (1)
| null | ||
| } | ||
| } else { | ||
| logcat { "Duck.ai Contextual: page context is empty, can't add 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.
Duplicated function calls can be consolidated
Low Severity
getPageContextResponse(featureName, method, it, pageContext) is called identically in two separate branches (lines 163 and 165). These could be consolidated into a single call using a combined condition:
if (pageContext != null && (reason == REASON_USER_ACTION || (reason == REASON_INIT && shouldAddContext))) {
getPageContextResponse(featureName, method, it, pageContext)
} else { ... }


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
Note
Medium Risk
Changes when and how page content is attached/sent to Duck.ai via the JS bridge and new feature-flag checks, which can affect privacy-sensitive context sharing and session persistence behavior.
Overview
Duck.ai contextual mode now has explicit, gated page-context attachment behavior. Automatic context attachment on
initis only sent when both the newautomaticContextAttachmentremote toggle and the user setting are enabled (whileuserActionrequests still return context), and the JS bridge now receives an explicituserEnabledContextAttachmentflag.Contextual sheet UX/behavior is updated. The UI adds a dedicated “Attach Page Content” affordance, a clear-text button, tweaks layout sizing/padding, and adjusts bottom-sheet state changes (less forced half/expanded transitions, more logging). URL persistence is tightened to only store chat URLs when in webview mode, with tests updated/added to cover the new gating and persistence rules.
Written by Cursor Bugbot for commit 325271b. This will update automatically on new commits. Configure here.