Skip to content

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

Closed
charleslpan wants to merge 1 commit into
luke/chat-live-statementsfrom
luke/chat-write-txid
Closed

charleslpan wants to merge 1 commit into
luke/chat-live-statementsfrom
luke/chat-write-txid

Conversation

@charleslpan

@charleslpan charleslpan commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

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()::text in its own RETURNING. 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_read upsert 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 chatWriteAnswerSchema variant gains an optional txid.

  • Store: readTo now answers { txid } or false. A message or channel row answered by a write carries txid; one read back doesn't.

The host's wait on the txid is #3923's child PR.

Tests

  • New chat-store.test.ts case:
    • 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.ts checks that a read-to through the route carries the txid, and that a repeat carries none.
  • Goldens for chatWriteAnswerSchema and codingAgentChatWriteAnswerViewSchema were regenerated under LUKE_UPDATE_FIXTURES=1. The only change is the optional txid.
  • 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

View guided diff Turn on auto-fix

…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. The write answers'
JSON Schema goldens gain the optional txid.

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

vercel Bot commented Oct 20, 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 20, 2026 10:12pm UTC

Request Review

@luke-agent

luke-agent Bot commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

Closing for now: the developer moved every area onto the central live layer with Neon Realtime off (LUKE_REALTIME, #4267; held polls, #4272), and this change only does something with Realtime on. The branch is kept, so the PR can be reopened and rebased when LUKE_REALTIME goes back on.

This branch was successfully deployed

1 active deployment
Preview — ca8ef433 Deployed Oct 20, 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