anomalyco / anomalyco/opencode

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

Open
#42,546 0 comments 0 reactions 1 assignee View on GitHub

@Brendonovich is already working on this.

Since Aug 14, 2026.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

Description

On the session page with the v2 prompt composer, opening the @ context menu (the + button → "Context") silently rewrites the draft: any existing @ mentions get moved to the end of the prompt and the text between them loses its position.

Steps to reproduce
  1. Open a session (the bug is in the v2 composer on the session page).
  2. Type hi , then @src, and click the src/index.ts suggestion to insert a mention.
  3. Type and, then @src again, and click the suggestion to insert a second mention.
  4. The draft now reads: hi @src/index.ts and @src/index.ts.
  5. Click the + button and select Context (or press Esc to close the menu without picking anything).
Expected behavior

The draft stays intact; the two mentions keep their positions and and remains between them.

Actual behavior

The draft is rewritten to something like hi and @@src/index.ts@src/index.ts — both mention chips are moved to the end, extra spaces appear, and the text between the mentions is displaced. This happens even if you immediately close the menu.

Root cause

openContext in packages/session-ui/src/v2/components/prompt-input/machine.ts unconditionally runs draft.setText(promptText(persisted) + "@"). promptText only joins text parts (dropping mention content), and setText moves every non-text part to the end of the prompt, so the mention structure is destroyed.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.