This repository was archived by the owner on Nov 24, 2026. It is now read-only.
Repository navigation
Conversation
mhsnook
force-pushed
the
claude/optimistic-acknowledge-layer
branch
2 times, most recently
from
June 27, 2026 09:06
b7ee273 to
f59e804
Compare
mhsnook
force-pushed
the
claude/optimistic-acknowledge-layer
branch
from
June 27, 2026 10:09
f59e804 to
d968805
Compare
acknowledged state for optimistic mutations (depth 1)acknowledged state for optimistic mutations
mhsnook
force-pushed
the
claude/optimistic-acknowledge-layer
branch
from
June 27, 2026 14:18
d968805 to
c1b387d
Compare
Adds an additive 'acknowledged' milestone between optimistic and synced, so UIs can respond when the server accepts a write (the acknowledgement) without waiting for it to sync back. Core (@tanstack/db): - Transaction.acknowledge() + Transaction.isAcknowledged. acknowledge() is a no-op-safe setter a collection adapter calls when the server confirms a write. isAcknowledged resolves at the acknowledgement, or together with isPersisted when no adapter calls it, and rejects on failure — always safe to await and never later than isPersisted. isPersisted/$synced semantics and the optimistic overlay are unchanged. - New $acknowledged virtual property (true once acknowledged, always true when $synced). Wired through row enrichment, the virtual-prop cache, group-by aggregation, and emitted as a virtual-prop-only update when it flips mid-flight. Adapter (@tanstack/electric-db-collection): - wrapped insert/update/delete handlers call transaction.acknowledge() after the server responds, before awaiting the txid. One line each; non-breaking. Includes docs/proposals/acknowledged-and-settled.md and tests. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_012VvSGi4YvJ5cYtJosqXkMe
mhsnook
force-pushed
the
claude/optimistic-acknowledge-layer
branch
from
June 27, 2026 14:39
c1b387d to
222eb0e
Compare
2 of 8 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The idea
An optimistic mutation against a realtime-sync backend has two confirmations, not one:
Today both are awaited inside one handler, so every UI signal (
$synced,isPersisted) flips only at S. But for most UIs A is the signal that matters — once the server has the write, drop the spinner. The library already tracks A internally (recomputeOptimisticStateseparates active from completed-but-not-settled overlays); this PR just exposes it.What this adds (all additive, non-breaking)
Core —
@tanstack/db:Transaction.acknowledge()— a no-op-safe setter a collection adapter calls when the server confirms a write.Transaction.isAcknowledged— resolves at the ack; resolves together withisPersistedwhen no adapter callsacknowledge(); rejects on failure. Always safe to await, never resolves later thanisPersisted.$acknowledgedvirtual property —trueonce acknowledged, alwaystruewhen$syncedistrue. Wired through row enrichment, the virtual-prop cache, and group-by aggregation, and emitted as a virtual-prop-only update when it flips mid-flight.Adapter —
@tanstack/electric-db-collection:transaction.acknowledge()after the server responds, before awaiting the txid. One line each.Note: It is entirely up to the Electric SQL and Tanstack folks whether to make this change. I included it here because it's the clearest demonstration of the new feature.
Why it's non-breaking at every layer
isPersisted/$syncedare untouched — the handler still blocks on the echo, so their timing is identical to today. The snappiness lives entirely on the new$acknowledged/isAcknowledged, which didn't exist before.$acknowledged.Consuming it
Tests
packages/db/tests/transaction-acknowledge.test.ts(new): ack flips$acknowledgedwhile persisting without settling; emits a virtual-prop-only update; ack/settle coincide when no adapter callsacknowledge(); failure rejectsisAcknowledged; synced rows are acknowledged; idempotent.hasVirtualPropsshape test and the virtual-prop strip helpers for the new prop.Verification:
@tanstack/dbtypechecks clean, builds, and passes the full suite (2406 passed).@tanstack/electric-db-collectionpasses (463 passed). The onlytscerrors in the electric package are pre-existingCannot find module '@tanstack/electric-db-collection'from the unbuilt e2e suite, present onmain.🤖 Generated with Claude Code
Generated by Claude Code