Skip to content

Store a finished reply after its own message - #5259

Open
tomsmith8 wants to merge 2 commits into
masterfrom
claude/anchor-turn-rows
Open

Store a finished reply after its own message#5259
tomsmith8 wants to merge 2 commits into
masterfrom
claude/anchor-turn-rows

Conversation

@tomsmith8

Copy link
Copy Markdown
Collaborator

Problem

A user message is stored the moment it is sent; the reply is stored when its stream finishes, by appending to the end of the conversation. If another message lands in between — a second tab, another member of a shared room, or (until #5257) a stale copy of the chat that let a second send through while the first reply was still running — the stored order becomes

user 1 · user 2 · reply 1 · reply 2

and every reload shows both questions stacked above both answers.

Fix

appendTurnMessages takes the turn's id. When that turn's user row is already stored, the finished rows are inserted right after the turn's last row instead of at the end, so the transcript reads user 1 · reply 1 · user 2 · reply 2 whatever order the writes arrived in. When the turn is already last, or no turn is given (proposal intents store both rows in one write), the write is the same append as before.

The three assistant writers pass their turn id: /api/ask/quick (both the normal and the error-row write), /api/ask/sync, and the org MCP tool runner.

Not covered

The live-sync merge in an open tab is still append-only, so a tab that sees a reply arrive after someone else's later message shows it last until the next reload. The stored transcript, which every open and reload reads from, is now in order.

Tests

placeTurnRows behaviour through appendTurnMessages: rows land after their own user message ahead of a later one; plain append when the turn is already last or no turn id is given.

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.

2 participants