Untitled conversation
- User
[Reborn WebUI Beta] Add WebUI idempotency and accepted-message ledger Parent tracker: #3607 Module: M2 — Native Product Workflow / Inbound Facade Priority: P0
Goal
Make WebUI mutations idempotent so duplicate browser submits do not create duplicate turns/messages.
Scope
- Use client action id / idempotency key for create-thread and send-message.
- Preserve accepted-message ref/outcome for duplicate requests.
- Handle concurrent duplicate submissions safely.
Acceptance criteria
- Duplicate send returns the same accepted ref/outcome.
- Concurrent duplicate send creates at most one accepted message/turn.
- Failed validation does not create a ghost turn/message.
- Retry after transient unavailable state has deterministic behavior.
- Tests cover same-thread duplicate, cross-thread duplicate rejection, and concurrent duplicate behavior.
Interface
No new interfaces are introduced.
- Assistant
I’ll trace the WebUI mutation path and persistence abstractions first, then implement the ledger at the narrowest authoritative layer and test through the actual handlers.
- Assistant
rgis unavailable in this checkout, so I’m using targetedfind/grep. The relevant spec confirms this belongs in the chat feature and, if persisted, must cover both PostgreSQL and libSQL. - Assistant
The key race is “reserved but not yet queued.” I’m implementing a durable two-phase ledger (
pending→accepted): validation and channel availability happen first, one database claimant queues the message, duplicates wait for that claimant’s recorded outcome, and failed queueing releases the pending claim for a deterministic retry. Cross-thread reuse of the same key is a conflict. - Assistant
The browser now generates one key per logical action and reuses the same key from the existing send retry link. I’ve also kept unkeyed API callers backward-compatible; keyed requests require the durable store so they never silently degrade to unsafe in-memory deduplication.
- Assistant
The caller-level coverage now exercises sequential replay, cross-thread key rejection, concurrent duplicate submission, validation failure, transient channel unavailability, and create-thread replay against libSQL. I also added the idempotency header to the explicit CORS allowlist so hosted WebUI deployments don’t fail preflight.
- Assistant
The libSQL handler tests are passing, including the concurrent race (one queued message, identical accepted ID for both callers). I’m finishing the PostgreSQL/default-feature compile and migration checksum guard now.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.