Skip to content

fix(session-ui): preserve mentions when the context menu opens - #42547

Open
gold-beyond wants to merge 1 commit into
anomalyco:devfrom
gold-beyond:fix-context-menu-mention
Open

fix(session-ui): preserve mentions when the context menu opens#42547
gold-beyond wants to merge 1 commit into
anomalyco:devfrom
gold-beyond:fix-context-menu-mention

Conversation

@gold-beyond

Copy link
Copy Markdown

Issue for this PR

Closes #42546

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Opening the @ context menu (the + button → "Context") used to rebuild the draft via setText(promptText + "@"). promptText only joins text parts, so mention content was dropped, and setText moves every non-text part to the end — silently rewriting the draft (e.g. hi @src/index.ts and @src/index.ts became hi and @@src/index.ts@src/index.ts).

This changes openContext to emit a draft.addText command instead, which appends @ at the caret via the existing addText store action and keeps the prompt structure intact.

How did you verify your code works?

  • Added a machine test asserting context.open emits draft.addText (not draft.setText).
  • Added an e2e test that builds a draft with two mentions, opens the context menu, and asserts both mentions keep their order with and between them.
  • bun typecheck in packages/session-ui passes.
  • bun test src/v2/components/prompt-input in packages/session-ui: 17 pass.

Screenshots / recordings

This is not a UI change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Opening the @ context menu via the plus button rebuilt the draft with
setText(promptText + "@"), which drops mention content and moves every
mention chip to the end of the prompt. Append "@" at the caret with
draft.addText instead, keeping the existing prompt structure intact.

Fixes anomalyco#42546
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.

Opening the @ context menu reorders existing mentions and rewrites the draft

1 participant