Skip to content

Add Ask about tab/page items to the Duck.ai attach menu#9003

Open
malmstein wants to merge 10 commits into
07-02-uti_add_to_contextual_sheetfrom
feature/david/attach_menu_context_items
Open

Add Ask about tab/page items to the Duck.ai attach menu#9003
malmstein wants to merge 10 commits into
07-02-uti_add_to_contextual_sheetfrom
feature/david/attach_menu_context_items

Conversation

@malmstein

@malmstein malmstein commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Task/Issue URL:
Tech Design URL (if applicable):

Draft — stacked on feature/david/contextual_sheet_changes (Page Context attachment) → feature/david/native_chat_input_flag (#8946). Asana task to be added later.

Description

Adds a contextual-mode-only item to the Duck.ai unified input's attach (paper-clip) menu, chosen by whether page context is attached:

  • No context → "Ask about tab": attaches the current page as the Page Context chip (from the stacked Page Context PR); sends no prompt.
  • Context attached → "Ask about page": submits the prompt "Ask about page" with the page-context JSON, reusing the existing onPromptSent / generateContextPrompt path.

DuckChatContextualViewModel is the single source of truth (showContext); the fragment bridges it to the unified input's chip (observe showContextsetPageContext/clearPageContext; chip-remove → removePageContext). isContextual defaults false so omnibar / new-tab attach menus are unchanged.

Note: this PR only adds the attach-menu items. Making the unified input the contextual sheet's initial-state composer was explored and intentionally not included here (the bottom-sheet sizing needs a different approach) — to be revisited separately.

Steps to test this PR

Ask about tab / page (internal build, contextual mode)

  • Open Duck.ai contextual sheet on a web page, start a chat so the unified input shows
  • Tap the paper-clip → with no page context attached, the menu shows Ask about tab; tapping it adds the page-context chip (no prompt sent)
  • Tap the paper-clip again → menu now shows Ask about page; tapping it submits "Ask about page" and Duck.ai answers using the page context
  • Remove the chip → menu reverts to Ask about tab
  • Omnibar / new-tab attach menu is unchanged (no context item)

UI changes

Before After
(Upload before screenshot) (Upload after screenshot)

🤖 Generated with Claude Code


Note

Medium Risk
Changes how in-chat native prompts reach the web layer and when page context is attached or cleared; regressions could affect contextual chat submits, keyboard UX, or omnibar attach menus if isContextual wiring is wrong.

Overview
Contextual Duck.ai gets page-context actions on the unified input’s attach menu and a visible chip, with submission behavior tightened so context isn’t dropped mid-chat.

In contextual mode only, the attach menu shows Ask about tab (attaches page context, no prompt) or Ask about page (sends the fixed “Ask about page” prompt with pageContext JSON) depending on whether a chip is present; removing the chip resets the menu. The fragment mirrors showContext from DuckChatContextualViewModel into setPageContext / clearPageContext on the native widget.

All native submits from the contextual sheet—initial INPUT and WEBVIEW follow-ups—now go through onPromptSubmittedonPromptSent / generateContextPrompt instead of the manager’s direct submitAIChatNativePrompt JS path for in-chat messages, so page context attached from the menu is included on follow-ups. After send, the page-context chip is cleared like other attachments; leaving INPUT for chat can hide the keyboard via ChangeSheetState.hideKeyboard, and Ask about page quick-action flow can emit FocusInput.

Reviewed by Cursor Bugbot for commit 8da2dee. Bugbot is set up for automated code reviews on this repo. Configure here.

@malmstein malmstein force-pushed the feature/david/contextual_sheet_changes branch from 83c21fb to d7b980c Compare June 25, 2026 08:04
@malmstein malmstein force-pushed the feature/david/attach_menu_context_items branch from d007b89 to bc2c50d Compare June 25, 2026 08:04
@malmstein malmstein force-pushed the feature/david/contextual_sheet_changes branch from d7b980c to b894f70 Compare June 25, 2026 08:43
@malmstein malmstein force-pushed the feature/david/attach_menu_context_items branch 2 times, most recently from 1a89d31 to 6beb0ad Compare June 25, 2026 08:59
@malmstein malmstein force-pushed the feature/david/contextual_sheet_changes branch from b894f70 to 7718c96 Compare June 25, 2026 08:59
@malmstein malmstein force-pushed the feature/david/attach_menu_context_items branch from 6beb0ad to 7f91fbe Compare June 25, 2026 09:13
@malmstein malmstein force-pushed the feature/david/contextual_sheet_changes branch 2 times, most recently from 082f655 to 99b4ce3 Compare June 25, 2026 09:28
@malmstein malmstein force-pushed the feature/david/attach_menu_context_items branch 2 times, most recently from 2b44bd7 to f0ea17f Compare June 25, 2026 09:38
@malmstein malmstein force-pushed the feature/david/contextual_sheet_changes branch 2 times, most recently from 16710e8 to 7c2b6ce Compare June 25, 2026 10:29
@malmstein malmstein force-pushed the feature/david/attach_menu_context_items branch from f0ea17f to 568124a Compare June 25, 2026 10:29
@malmstein malmstein force-pushed the feature/david/attach_menu_context_items branch from 568124a to 1817c0a Compare July 2, 2026 21:28
@malmstein malmstein changed the base branch from feature/david/contextual_sheet_changes to 07-02-uti_add_to_contextual_sheet July 2, 2026 21:28
@malmstein malmstein force-pushed the 07-02-uti_add_to_contextual_sheet branch from 172be5e to 80b3243 Compare July 3, 2026 12:42
@malmstein malmstein force-pushed the feature/david/attach_menu_context_items branch from 1817c0a to 7155012 Compare July 3, 2026 12:44
@malmstein malmstein marked this pull request as ready for review July 3, 2026 22:08

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

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.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit d4e3d38. Configure here.


override fun setPageContext(title: String, url: String, faviconUrl: String?) {
attachmentView?.setPageContext(PageContextAttachment(title = title, url = url, faviconUrl = faviconUrl))
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Page context lost before attach

Medium Severity

setPageContext only forwards to attachmentView when that plugin view already exists, unlike setContextualAttachmentActions, which keeps pending callbacks and applies them in wirePluginView. If renderViewState pushes page context before the attachment plugin is wired, the call is dropped with no retry, so the chip and attach-menu state can stay out of sync with showContext even though prompts still include page context.

Additional Locations (2)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit d4e3d38. Configure here.

malmstein and others added 9 commits July 7, 2026 11:12
Replace generic 'Remove file' with 'Remove page context' for accessibility clarity.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The contextual sheet's unified input dropped an attached page
context when a prompt was sent while a chat was already in
progress: WEBVIEW-mode submits built their own JS event in the
manager, bypassing the ViewModel's generateContextPrompt, which
is the only place that injects pageContext. Route every widget
submit (INPUT and WEBVIEW) through the ViewModel so the prompt is
built in one place, and delete the manager's duplicate send path.

Also in this batch:
- Drop the page-context chip from the input once a prompt is
  sent, mirroring how image attachments are cleared on submit.
- Focus the input when "Ask about page" is tapped, via a new
  ViewModel FocusInput command, so the keyboard and tools row
  come up in one tap.

Follow-ups in a running chat now also fire the
contextualPromptSubmittedWith/WithoutContext pixels.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
When a prompt is sent from the contextual sheet's initial (INPUT)
state, the sheet moves to the chat but the soft keyboard stayed
up, covering the streaming reply. Hide it as part of that
transition.

The flag rides on the existing ChangeSheetState command rather
than a separate one: commandChannel is capacity-1 DROP_OLDEST, so
two commands emitted in the same burst would lose the older.
Follow-ups sent from within a running chat are unaffected.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@malmstein malmstein force-pushed the feature/david/attach_menu_context_items branch from d4e3d38 to 8da2dee Compare July 7, 2026 09:14
@malmstein malmstein force-pushed the 07-02-uti_add_to_contextual_sheet branch from 80b3243 to 6e28196 Compare July 7, 2026 09:14

Copy link
Copy Markdown
Contributor Author

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants