Skip to content

ui-server: a stale draft save recreates an accepted outgoing snapshot #3733

Closed

Description

@schlessera

Context

Part of #3150. Found while building #3155's held snapshots on the #3588 snapshot list.

accept (packages/ui-server/src/drafts/store.ts:806-862) releases the accepted request's snapshot with UPDATE session_drafts SET outgoing_snapshots = ? (store.ts:821-823), and does not bump revision whenever the draft is kept (row.revision !== revision or a source mismatch, store.ts:837-845). A tab or device that read the draft before the acceptance still holds the released snapshot in its list. Its next PUT /api/drafts/:draftId passes If-Match, because the revision did not move, and lists that snapshot again. nextSnapshots (store.ts:362-412) finds no prior for its snapshotId (store.ts:389) and treats it as a new one, so the accepted send comes back as a dispatched snapshot. That phantom holds one of the chat's ten slots until someone runs Check, then Delete…, and its file references go back to outgoing.

Scope

  • A save cannot recreate a snapshot whose request the host already accepted for that draft.
  • A save carrying a stale snapshot list is refused or reconciled, never silently applied.

Out of scope

The client's handling (#3155) and the single-slot outgoing compatibility write, beyond applying the same rule to it.

Acceptance criteria

  • A ui-server test, failing first on the current tree: save a draft with a dispatched snapshot, accept its request with the draft kept (a newer revision exists), then PUT the old snapshot list under the current If-Match. Afterwards no snapshot names that requestId, the chat's live count is unchanged, and no outgoing ref points at its files.
  • Either rule makes that test pass: the acceptance bumps revision whenever it changes outgoing_snapshots, so the stale save gets 409 DRAFT_CONFLICT with current; or nextSnapshots refuses a new snapshot whose requestId is in session_draft_sends for that draft. The choice and why are recorded in docs/decisions/chat-attachments.md ("What ui-server: replace the single outgoing draft slot with the G1 snapshot list and 409 DRAFT_OUTGOING_FULL #3588 built").
  • The HTTP API doc's snapshot rules state the behaviour (docs/http-api.md#outgoing-snapshot-list-additive-0450-3588).

Verification

bun run test for the drafts store and route tests, plus bun run check:pr --base origin/main.

Contract impact

If the revision bump is chosen, a save after an acceptance can newly get 409 DRAFT_CONFLICT. That is within the documented If-Match contract, but it is documented anyway, and the PR carries the contract label and a minor ui-server changeset.

Activity

  1. added this to the 0.45.0 milestone on Nov 8, 2026
  2. added
    type: fixSomething is broken and must behave the way it is documented.
    area: ui-serverHono app factory: turn coordinator, auth, session catalog, routes, cron.
    priority: p2Wanted, not scheduled. Pulled in when a milestone has room.
    agent-readyContext and acceptance criteria are complete enough for an agent to take this unattended.
    on Nov 8, 2026
  3. self-assigned this
    on Nov 15, 2026
  4. schlessera commented on Nov 15, 2026

    @schlessera
    OwnerAuthor

    Claimed for implementation. Claim token: claim-b7a10469. Branch: fix/3733-stale-snapshot-save.

    collisions: closure-only with draft #3056; no path collisions

  5. schlessera commented on Nov 16, 2026

    @schlessera
    OwnerAuthor

    Merged in #4068 as 437ac873e through the integration lease (orchestrator merge queue for 0.45.0). Candidate confirmation passed on the exact head; the squash's own main run carries the post-merge heavy categories.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

agent-readyContext and acceptance criteria are complete enough for an agent to take this unattended.area: ui-serverHono app factory: turn coordinator, auth, session catalog, routes, cron.priority: p2Wanted, not scheduled. Pulled in when a milestone has room.type: fixSomething is broken and must behave the way it is documented.

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions