feat(database,service,features): a sidebar section's or repository pin's write answers the transaction it committed in

Merged
CH
7d ago
+350-109

The service half of the txid wait for the pins-and-sections area: every write the host's followed sidebar shows now answers the transaction it changed a row in, so the host can wait for it to land on the live view before it answers the window (host PR follows once #4423 merges).

What changed

  • task-section-store.ts: each mutating statement (insert, edit, move, delete a section, put/move/remove an entry) reads pg_current_xact_id()::text in its own RETURNING, as Neon's mutations guide does. writeTaskSections answers it as txid beside the sections. No extra transaction or statement.
  • repository-pin-store.ts: pin and unpin return it the same way; setRepositoryPin answers { pins, txid? }.
  • A write that changes no row answers no txid: a section made again under its id, edited to the title and icon it had, moved to where it stood, an entry moved to where it stood, a delete of what's gone, a pin already pinned, an unpin already gone. Edit and move now skip a row that already stands so (is distinct from), so a no-op writes nothing.
  • Wire: taskSectionsWrittenSchema and repositoryPinsWrittenSchema (the GET answers plus an optional txid) are the PUT outputs; TaskClient.writeTaskSection / pinRepository answer them. The host takes the sections and pins out of them as before and ignores the txid until the host PR.

Old work: the txid half of #3960 (branch luke/live-sidebar, and luke/live-sidebar-txid) was never pushed, and #3960's one commit carries no txid, so this is written fresh after the chat pattern in #4251.

Out of scope: task pins (the tasks-and-agents worker's), Better Auth's writes, the agent tools' section writes (they get the txid from the store but wait on nothing).

Tests

  • store: every changing write answers a distinct txid, every no-op answers none, for sections and pins (task-section-store.test.ts).
  • routes: the PUT answers carry a txid when they wrote and none when they didn't (repository-pins-procedures.test.ts, task-sections-procedures.test.ts).

Made with Luke


Devin Review