anomalyco / anomalyco/opencode

Submitted prompt is stored twice in the app message store (fork dialog duplicates, undo leaves a ghost)

Open
#41,428 0 comments 0 reactions 1 assignee View on GitHub

@Brendonovich is already working on this.

Since Aug 9, 2026.

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

Description

Description

Since #41001 (91132551) the web/desktop app keeps two copies of every submitted prompt in the client message store.

The prompt input adds an optimistic user message stamped with the client's Date.now() and sends the same message id to the server, which persists it with its own timestamp when the prompt lands — so the server copy's time.created is always a bit later. The message.updated handler now resolves rows by messageKey (time.created + id) instead of id, misses the optimistic row because the key differs, and splices the server copy in next to it: same id, two rows.

Knock-on effects until a full session refetch: the fork dialog reads this store without deduping, so the prompt is listed twice; message.removed deletes only the first same-id row, so removing the message leaves a ghost copy; mergeOptimisticPage never confirms the optimistic item because its exact-key search misses too. Same pattern in server-session.ts (message.updated handler and mergeOptimisticPage), sync.tsx, and global-sync/event-reducer.ts.

Steps to reproduce
  1. In the web app, submit a prompt in any session
  2. The session's message store now holds two rows with the same message id and different time.created — the fork dialog lists the prompt twice
  3. Unit-level repro: sync a createServerSession store containing a message at time.created: 1, then apply message.updated with the same id at time.created: 2 — the store ends up with 2 rows instead of replacing the one
OpenCode version

dev @ 0bff28de

Operating System

reproduced at the store level (unit test), platform-independent

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.