Skip to content

Conversation

@malmstein
Copy link
Contributor

@malmstein malmstein commented Jan 30, 2026

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

  • Open Contextual Mode
  • Verify “Attach Page Context” is visible
  • Tap on “Attach Page Context”
  • Verify context has been attached
  • Remove the context
  • Tap on “Summarise Page Content"
  • Verify that the context has been attached and the prompt has been added
  • Tap on Send
  • Verify Duck.ai opens with prompt and context

Automatic context attachment - Setting ON

  • Open Contextual Mode
  • Enter a prompt
  • Verify Duck.ai opens without context attached
  • Verify that the context has been added to the web input
  • Enter any prompt
  • Verify context is added

Automatic context attachment - Setting OFF

  • Turn Automatic Context Attachment iOFF n Settings / AI Features
  • Open Contextual Mode
  • Verify context is not attached
  • Enter a prompt
  • Verify Duck.ai opens without context attached
  • Verify that the context has not been added to the web input
  • Enter any prompt
  • Verify context is not added

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

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 so getAIChatPageContext only returns context for explicit reason=userAction requests (not init).

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.

Copy link
Contributor Author

malmstein commented Jan 30, 2026

This stack of pull requests is managed by Graphite. Learn more about stacking.

@malmstein malmstein force-pushed the feature/david/01-30-duck.ai_contextual_page_context_attachment branch from 88fbfc1 to 9f0e813 Compare February 2, 2026 21:32
@malmstein malmstein marked this pull request as ready for review February 2, 2026 22:26
@malmstein malmstein force-pushed the feature/david/01-30-duck.ai_contextual_page_context_attachment branch from 692ac53 to ecfd8bd Compare February 3, 2026 10:10
@malmstein malmstein mentioned this pull request Feb 3, 2026
10 tasks
@malmstein malmstein force-pushed the feature/david/01-30-duck.ai_contextual_page_context_attachment branch from ecfd8bd to 7281450 Compare February 3, 2026 14:56
@joshliebe joshliebe self-requested a review February 3, 2026 17:04
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 -->
@malmstein malmstein force-pushed the feature/david/01-30-duck.ai_contextual_page_context_attachment branch from 8966b32 to 93607ad Compare February 4, 2026 11:14
Copy link

@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.

it.copy(
sheetMode = SheetMode.INPUT,
showFullscreen = true,
prompt = "",
Copy link

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.

Fix in Cursor Fix in Web

Copy link
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, working well! 🚀

@malmstein malmstein merged commit c3c80ef into develop Feb 4, 2026
42 checks passed
@malmstein malmstein deleted the feature/david/01-30-duck.ai_contextual_page_context_attachment branch February 4, 2026 13:16
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.

2 participants