feat(service,features): an inbox mark, answer, or close answers the transaction it committed in
Merged
CH
10d ago+207+207+012345678901234567890123456789-90-90-01234567890123456789
The service half of the inbox's txid wait: each member write on the inbox returns the txid of the transaction that changed its row, as Neon's mutations guide describes. The host PR that waits on it with confirmWrite (#4423) follows.
What changes
inbox-store.ts:pg_current_xact_id()::textis read in theRETURNINGof the write that changes the row. No extra transaction or statement is added.upsertRead,upsertUnread, andupsertAllRead(mark read, mark unread, mark all read).answerItem(answer by revision, and answer to an ask by its message).memberCloseItem(a member's close).
- No-op writes carry no txid:
- A mark already standing.
- Mark all read with nothing unread.
- An answer or close sent again under the same key.
- Wire (
inbox-wire.ts):inboxAnsweredSchema,inboxMessagedSchema(an answer by reply),inboxReadStateSchema, andinboxReadAllSchemaeach get an optionaltxid. A desktop that doesn't know the field drops it. - Out of scope: a plain thread message carries no txid here. It isn't one of the inbox area's writes (mark, answer, close).
Old work
#3264 merged without a txid half. Its head (refs/pull/3264/head) has no txid hunks, and no *inbox*txid* branch exists, so this is new code. It follows the chat txid PR (#4251) as its pattern.
Tests
inbox-store.test.ts:- mark read and mark unread return a txid the first time and none when repeated
- mark all read returns one txid, and
{ marked: 0 }with no txid when nothing was unread - an answer and a close each return their own txid
inbox-threads.test.ts: an answer to an ask is taken with a txid, and the same answer sent again (REPEATED) has none.coding-agents-app.test.ts: the PUT and DELETE read routes and mark all read carry a txid on the wire.
Made with Luke