feat(service,database): chat writes answer the transaction they committed in
Part of making workspace chat live over Neon Realtime. Stacked on #3916. One change: chat writes return their txid, as Neon's mutations guide does it.
What changes
-
txid from the write itself. Each chat write reads
pg_current_xact_id()::textin its ownRETURNING. The covered writes are:- a post
- an answer
- a resolve
- a channel's read-to
- a topic channel opened or edited
Chat writes run several statements in one transaction, so the txid comes from the write that changes the row, as the guide says. There's no extra round trip.
-
A write that changes nothing answers no txid, so there's nothing to wait for. That covers:
- a post repeated under its key
- a read-to where the cursor already stands (the
chat_readupsert only moves forward) - an edit that leaves the topic as it was (
is distinct from) - a read-to of every channel, which the window never sends
-
Wire: each
chatWriteAnswerSchemavariant gains an optionaltxid. -
Store:
readTonow answers{ txid }orfalse. A message or channel row answered by a write carriestxid; one read back doesn't.
The host's wait on the txid is #3923's child PR.
Tests
- New
chat-store.test.tscase:- a post answers a txid, and its repeat doesn't
- a read-to answers one, and the same read-to again doesn't
- a topic open and a real edit answer one, and a no-op edit doesn't
coding-agents-app.test.tschecks that a read-to through the route carries the txid, and that a repeat carries none.- Goldens for
chatWriteAnswerSchemaandcodingAgentChatWriteAnswerViewSchemawere regenerated underLUKE_UPDATE_FIXTURES=1. The only change is the optionaltxid. - Checks were run one at a time on the stack's top: tsc for each touched package, biome, oxlint, knip, discarded-effect, the repository checks, and the affected vitest suites.
Made with Luke