Repository navigation
feat(data): reconcile a shared tab's seed with the other tabs - #2629
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 3 potential issues.
Autofix Details
Bugbot Autofix prepared fixes for all 3 issues found in the latest run.
- ✅ Fixed: Gap reload can join stale request
- Seeds now record their wire key in
askedForvia theonSeedcallback, so the first reload after hydration sendsfresh: trueand the owner creates a new request instead of joining a potentially stale in-flight one.
- Seeds now record their wire key in
- ✅ Fixed: In-flight loads skip seed offers
- The owner's
valuebroadcast now carries a wall-clockattimestamp, and the replica'svalue()handler compares it againstentry.fetchedAt, skipping and counter-offering when the local value is newer, and passing the correct age torebasewhen accepting.
- The owner's
- ✅ Fixed: Join skips gap without a cursor
- The join path now sends
{ gap: true }when the upstream's cursor is still null but the joiner has a cursor, so the replica callsmissed()and reloads covered reads to recover potentially dropped events.
- The join path now sends
Or push these changes by commenting:
@cursor push e2b6bf1cb9
Preview (e2b6bf1cb9)
diff --git a/packages/octane/src/data/owner.ts b/packages/octane/src/data/owner.ts
--- a/packages/octane/src/data/owner.ts
+++ b/packages/octane/src/data/owner.ts
@@ -139,8 +139,14 @@ type ToReplica =
| { readonly t: 'failed'; readonly id: number; readonly error: unknown }
| { readonly t: 'frame'; readonly id: number; readonly frame: FeedFrame }
| { readonly t: 'end'; readonly id: number; readonly error?: unknown }
- /** Another replica loaded a read. */
- | { readonly t: 'value'; readonly name: string; readonly input: unknown; readonly value: unknown }
+ /** Another replica loaded a read; `at` is the wall-clock time it loaded. */
+ | {
+ readonly t: 'value';
+ readonly name: string;
+ readonly input: unknown;
+ readonly value: unknown;
+ readonly at: number;
+ }
/** A value another replica holds, which the owner passes on as it came. */
| Offer
/** Another replica sent a write. */
@@ -139,8 +139,14 @@ type ToReplica =
| { readonly t: 'failed'; readonly id: number; readonly error: unknown }
| { readonly t: 'frame'; readonly id: number; readonly frame: FeedFrame }
| { readonly t: 'end'; readonly id: number; readonly error?: unknown }
- /** Another replica loaded a read. */
- | { readonly t: 'value'; readonly name: string; readonly input: unknown; readonly value: unknown }
+ /** Another replica loaded a read; `at` is the wall-clock time it loaded. */
+ | {
+ readonly t: 'value';
+ readonly name: string;
+ readonly input: unknown;
+ readonly value: unknown;
+ readonly at: number;
+ }
/** A value another replica holds, which the owner passes on as it came. */
| Offer
/** Another replica sent a write. */
@@ -442,6 +448,7 @@ export function createDataOwner(options: {
name: payload.name,
input: payload.input,
value: reply.value,
+ at: hostDateNow(),
};
for (const port of replicas) if (!asked.get(started)!.has(port)) post(port, value);
},
@@ -442,6 +448,7 @@ export function createDataOwner(options: {
name: payload.name,
input: payload.input,
value: reply.value,
+ at: hostDateNow(),
};
for (const port of replicas) if (!asked.get(started)!.has(port)) post(port, value);
},
@@ -478,7 +485,9 @@ export function createDataOwner(options: {
id,
frame:
cursor === null
- ? {}
+ ? payload.cursor !== null
+ ? { gap: true }
+ : {}
: { cursor, gap: payload.cursor !== null && payload.cursor !== cursor },
} satisfies ToReplica);
return;
@@ -478,7 +485,9 @@ export function createDataOwner(options: {
id,
frame:
cursor === null
- ? {}
+ ? payload.cursor !== null
+ ? { gap: true }
+ : {}
: { cursor, gap: payload.cursor !== null && payload.cursor !== cursor },
} satisfies ToReplica);
return;
@@ -905,7 +914,12 @@ export function createReplica(
const held = inner.held(entry);
if (held) send({ t: 'offer', ...held });
};
- inner.onSeed(offer);
+ inner.onSeed((entry) => {
+ const key = `read\n${entry.key}`;
+ askedFor.add(key);
+ if (askedFor.size > 512) askedFor.delete(askedFor.values().next().value!);
+ offer(entry);
+ });
/**
* Take a value another replica holds, if it loaded later than the one held
@@ -905,7 +914,12 @@ export function createReplica(
const held = inner.held(entry);
if (held) send({ t: 'offer', ...held });
};
- inner.onSeed(offer);
+ inner.onSeed((entry) => {
+ const key = `read\n${entry.key}`;
+ askedFor.add(key);
+ if (askedFor.size > 512) askedFor.delete(askedFor.values().next().value!);
+ offer(entry);
+ });
/**
* Take a value another replica holds, if it loaded later than the one held
@@ -929,18 +943,20 @@ export function createReplica(
}
/** Take a value another replica loaded, for a read held here and not loading. */
- async function value(name: string, input: unknown, raw: unknown) {
+ async function value(name: string, input: unknown, raw: unknown, at: number) {
const entry: Entry | undefined = inner.wireEntry(entryKey(name, input));
if (!entry || entry.inflight || store.retired) return;
+ if (entry.hasBase && entry.fetchedAt >= at) return offer(entry);
let parsed: unknown;
try {
parsed = await parse(entry.read.output, raw);
} catch {
return;
}
if (store.retired || entry.inflight || inner.entries.get(entry.key) !== entry) return;
+ if (entry.fetchedAt >= at) return;
const reload = new Set<Entry>();
- inner.rebase(entry, parsed, false, reload);
+ inner.rebase(entry, parsed, false, reload, Math.max(0, hostDateNow() - at));
inner.finish(reload, [entry], entry.names);
}
@@ -929,18 +943,20 @@ export function createReplica(
}
/** Take a value another replica loaded, for a read held here and not loading. */
- async function value(name: string, input: unknown, raw: unknown) {
+ async function value(name: string, input: unknown, raw: unknown, at: number) {
const entry: Entry | undefined = inner.wireEntry(entryKey(name, input));
if (!entry || entry.inflight || store.retired) return;
+ if (entry.hasBase && entry.fetchedAt >= at) return offer(entry);
let parsed: unknown;
try {
parsed = await parse(entry.read.output, raw);
} catch {
return;
}
if (store.retired || entry.inflight || inner.entries.get(entry.key) !== entry) return;
+ if (entry.fetchedAt >= at) return;
const reload = new Set<Entry>();
- inner.rebase(entry, parsed, false, reload);
+ inner.rebase(entry, parsed, false, reload, Math.max(0, hostDateNow() - at));
inner.finish(reload, [entry], entry.names);
}
@@ -986,7 +1002,7 @@ export function createReplica(
feeds.get(message.id)?.end(message.error);
break;
case 'value':
- void value(message.name, message.input, message.value);
+ void value(message.name, message.input, message.value, message.at);
break;
case 'offer':
void offered(message);
@@ -986,7 +1002,7 @@ export function createReplica(
feeds.get(message.id)?.end(message.error);
break;
case 'value':
- void value(message.name, message.input, message.value);
+ void value(message.name, message.input, message.value, message.at);
break;
case 'offer':
void offered(message);You can send follow-ups to the cloud agent here.
Benchmark report🟢 No byte growth, no added work, and no timing changes beyond ±3%. Compares js-framework: 1k/10k row operationsAll 20 timed operations (20 without a verdict)
All 64 work counters are unchanged. Application bundle size (bytes)No changes across 111 measured values. Public-import reachability bundles (bytes)No changes across 141 measured values. |
…d reads reload fresh; gap on a cursorless join
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
octane-website-mcp | a065913 | Commit Preview URL Branch Preview URL |
Nov 13 2026, 11:14 PM |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.
Bugbot Autofix prepared fixes for both issues found in the latest run.
- ✅ Fixed: Older load can overwrite newer value
- Added a post-parse freshness guard
if (entry.hasBase && at <= entry.fetchedAt) return;invalue()to match the same patternoffered()already uses, preventing a stale payload from overwriting a newer one adopted duringawait parse.
- Added a post-parse freshness guard
- ✅ Fixed: Missing value timestamp breaks freshness
- Defaulted
message.attohostDateNow()viamessage.at ?? hostDateNow()at the call site so an older owner that omits the field produces a usable timestamp instead ofNaN.
- Defaulted
Or push these changes by commenting:
@cursor push d7b521a1a2
Preview (d7b521a1a2)
diff --git a/packages/octane/src/data/owner.ts b/packages/octane/src/data/owner.ts
--- a/packages/octane/src/data/owner.ts
+++ b/packages/octane/src/data/owner.ts
@@ -960,6 +960,7 @@ export function createReplica(
return;
}
if (store.retired || entry.inflight || inner.entries.get(entry.key) !== entry) return;
+ if (entry.hasBase && at <= entry.fetchedAt) return;
const reload = new Set<Entry>();
inner.rebase(entry, parsed, false, reload, Math.max(0, hostDateNow() - at));
inner.finish(reload, [entry], entry.names);
@@ -960,6 +960,7 @@ export function createReplica(
return;
}
if (store.retired || entry.inflight || inner.entries.get(entry.key) !== entry) return;
+ if (entry.hasBase && at <= entry.fetchedAt) return;
const reload = new Set<Entry>();
inner.rebase(entry, parsed, false, reload, Math.max(0, hostDateNow() - at));
inner.finish(reload, [entry], entry.names);
@@ -1007,7 +1008,7 @@ export function createReplica(
feeds.get(message.id)?.end(message.error);
break;
case 'value':
- void value(message.name, message.input, message.value, message.at);
+ void value(message.name, message.input, message.value, message.at ?? hostDateNow());
break;
case 'offer':
void offered(message);
@@ -1007,7 +1008,7 @@ export function createReplica(
feeds.get(message.id)?.end(message.error);
break;
case 'value':
- void value(message.name, message.input, message.value, message.at);
+ void value(message.name, message.input, message.value, message.at ?? hostDateNow());
break;
case 'offer':
void offered(message);You can send follow-ups to the cloud agent here.
Reviewed by Cursor Bugbot for commit 45b7b24. Configure here.
…ues from an older owner


Summary
react.html), which closes the issue's "same scenarios in both bindings" acceptance item.Why
Changes
owner.ts:offermessage{ name, input, value, at }; replicas send it and the owner passes it on unchanged;rebasewith the offer's age) or offers its own back when it holds a newer one;gapwhen the joining tab's cursor differs from the connection's.store.tsinternals:onSeed(notify)after a seed is adopted,held(entry)(the confirmed value and load time, ornullfor a missing, stale or loading value or a view), and anageparameter onrebase.examples/catalog.jsonregenerated.docs/data.md, the plan (decision 6 rewritten to match, delivery item 6), websitedata.mdx,llms.txt.octane. No PROTOCOL bump: an older tab ignoresoffer, andgapis an existing frame field.Validation
--project octane --project octane-prod: 20 files, 484 tests;data-owneranddata-persistre-run after merging main: 97 passed.pnpm typecheck:fileson changed files,pnpm format:files:check,pnpm examples:static:check,pnpm synccleanpnpm test,pnpm typecheck, full Shelf suite: left to CIperf-review:node scripts/perf-review-scan.mjs→ no candidates. Not a runtime hot path: one message per seeded read at hydration, and one comparison per offer received;adoptSeedgains one optional callback call.concise-code: src +83 −7. No new files or exports.held,onSeedandrebase'sageare store internals, and offers reuse the replica's existing value path (rebase+finish).octane/dataentry goes from 51,217 to 51,901 raw (+684) and from 19,849 to 20,085 gzip (+236);createDataStorealone goes from 31,332 to 31,489 raw (+157) and from 12,408 to 12,471 gzip (+63).Risk / follow-ups
@octanejs/app-coreworker entry.Provenance
agent-authored)Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.Note
Medium Risk
Changes cross-tab synchronization and feed reconnection behavior using wall-clock timestamps; a clock skew could briefly show a stale value until the next load or feed event corrects it.
Overview
Implements hydration and seed reconciliation for cross-tab
octane/data: after a tab hydrates from its server-render seed, it offers each seeded read (not views) to sibling tabs with a wall-clock load time (at). Tabs compare holdings—the older side adopts the newer value or counter-offers—so every tab converges on the freshest data without an extra network read.The owner protocol adds
offerpassthrough and timestamps on sharedvaluebroadcasts. Feed join frames now setgapwhen the replica’s seed cursor differs from the live connection, prompting a reload of the feed’s coverage instead of silently missing events.Store internals gain
onSeed,held, and optionalageonrebaseto support load-time comparison. Shelf e2e runs the shared-owner scenario on both mixed and React pages; unit tests cover newer/older seeds, feed gaps, overlapping async validation, and in-flight loads.Reviewed by Cursor Bugbot for commit a065913. Bugbot is set up for automated code reviews on this repo. Configure here.