Skip to content

feat(service,database): chat writes answer the transaction they committed in - #4426

Merged
luke-agent[bot] merged 1 commit into
mainfrom
luke/chat-write-txid-v2
Oct 21, 2026
Merged

luke-agent[bot] merged 1 commit into
mainfrom
luke/chat-write-txid-v2

Conversation

@charleslpan

@charleslpan charleslpan commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

The service half of the chat area of the txid rollout: each chat write a window makes returns its txid on the wire answer, as Neon's mutations guide describes, so the host (next PR) can wait for it on the followed chat before answering.

  • pg_current_xact_id()::text is read in the write's own RETURNING: a post, an ask answered, a resolve, a channel read to a place, a topic opened or edited. No extra transaction.
  • A write that changes no row answers no txid: a post repeated under its key, a read to where the cursor already stands (the cursor upsert now moves only forward via setWhere, so it writes nothing otherwise), a topic edit that leaves it as it stands, and a read of every channel (the window never sends it).
  • chatWriteAnswerSchema gains an optional txid on each variant.

Tests: the chat store's writes answer a txid and their no-ops none; the window's read-to answers one, then none read again.

Ported from #4251 (luke/chat-write-txid, ca8ef43), closed when Realtime was switched off; its branch sat on a stack, so this is a fresh cherry-pick onto today's main rather than a reopen. The JSON Schema goldens it touched aren't on main anymore, so none change here.

Made with Luke

View guided diff Turn on auto-fix


Devin Review

…tted in

As Neon's mutations guide says: each write's own RETURNING reads
pg_current_xact_id()::text, so a post, an answer, a resolve, a channel's
read, and a topic opened or edited answer the txid a follower of the chat
waits for on its live query. A write that changed nothing answers none: a
post repeated under its key, a read to where the cursor stands (the upsert
moves it only forward), an edit that leaves the topic as it stands, and a
read of every channel, which the window never sends.

Co-authored-by: luke-agent[bot] <339870089+luke-agent[bot]@users.noreply.github.com>
@vercel

vercel Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
luke-web Ready Ready Preview Oct 21, 2026 8:46pm UTC

Request Review

@luke-agent
luke-agent Bot added this pull request to the merge queue Oct 21, 2026
Merged via the queue into main with commit a3b9578 Oct 21, 2026
11 of 12 checks passed
@luke-agent
luke-agent Bot deleted the luke/chat-write-txid-v2 branch October 21, 2026 20:56

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 2 potential issues.

Devin Review

Comment thread packages/service/src/agents/workspace-chat.ts
Comment thread packages/database/src/models/chat-store.ts

This branch was successfully deployed

1 active deployment
Preview — dc8440ba Deployed Oct 21, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant