feat(service): a sent message answers the transaction that wrote its row
Merged
CH
4d ago+123+123+012345678901234567890123456789-24-24-01234567890123456789
Service half of the send-message area of the txid rollout, following Neon's optimistic-mutations guide (https://neon.com/docs/ai/skills/neon-realtime/references/mutations.md). Ported from the service part of #4188 (closed when Realtime was switched off); the host wait follows in its own PR on top of #4423.
What changed
- Database (
writer.ts): the message insert's ownRETURNINGalso readspg_current_xact_id()::text.writeAwaitingLineanswers thattxidwhen it wrote the row; a line already standing under its key answers none. No extra transaction or round trip. - Service (
steer.ts,messages-procedures.ts):steerCodingAgentWrittenanswers the outcome beside the txid, andsteerCodingAgentkeeps its answer for its other callers (chat notify, tools, automations).POST /api/agents/{id}/messagesanswers{ agent, txid? }. - Features:
codingAgentMessageAnswerSchema(wire) andcodingAgentMessageAnswerViewSchema(view); the contract andHostedCodingAgentClient.messageuse them.txidis an optional key, so released desktops ignore it.
Tests
coding-agent-store.test.ts: a written line answers a decimal txid; a repeat under the same key answers none.coding-agents-app.test.ts: the send route answers a txid for a fresh send and none for a repeat; the other send tests read the new answer schema.
Ran: typecheck for database, features, service, host; vitest run on the three touched test files; biome; oxlint.
Made with Luke