anomalyco / anomalyco/opencode
Opening the @ context menu reorders existing mentions and rewrites the draft
@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
- Open a session (the bug is in the v2 composer on the session page).
- Type
hi, then@src, and click thesrc/index.tssuggestion to insert a mention. - Type
and, then@srcagain, and click the suggestion to insert a second mention. - The draft now reads:
hi @src/index.ts and @src/index.ts. - Click the
+button and selectContext(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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.