Index runtime hook subscriptions and share scoped sync counts

This commit is contained in:
2026-11-09 21:38:26 +08:00
parent b833f0a2fc
commit bb5bc9d8e9
5 changed files with 166 additions and 16 deletions
+22 -1
View File
@@ -277,7 +277,8 @@ Import from `/react` for React only, or the re-export in `/react-flow`.
its own lease. Controller replacements keep independent token slots. Preview
geometry remains shared across views; active ownership and controls belong to
the owning view. Host bindings still handle pointer capture and events.
- `useOperation(id)` observes both the logical record and its frozen request.
- `useOperation(id)` observes both the logical record and its frozen request;
request-only changes are included without observing unrelated Root fields.
- `useAsset(id)` resolves a releasable display handle, returns metadata plus
loading/ready/error/url/retry, and releases on ref/owner change or unmount.
Ready means the display handle resolved; it does not prove upload ACK, image
@@ -542,3 +543,23 @@ subscription removes its bucket and releases the upstream listener. A controller
identity change (engine/view/target/incarnation) creates a private lease slot, so
old cleanup cannot consume the replacement controller's token. This does not
change the one shared gesture owner, its history unit or durable task lifecycle.
Operation, asset metadata and sync-count channels share one upstream editor
listener per engine. Their dependency tuples contain only the tables they read
(and the loading flag for counts). Table identities use weak object IDs, so a
channel caches a primitive version signature and selected values rather than an
old Root or full table. Changed tables recheck subscribed IDs; unchanged tables
skip those reads. Read caches and last-notified values stay separate so an early
`getSnapshot()` cannot consume another observer's notification.
Sync counts build one scalar index per operations/requests/loading version:
project totals plus canvas→counts. Requests spanning multiple pending operations
count once per matching canvas. Operations with no canvas remain in project
counts. Unknown canvas queries return the shared zero count without growing the
index. This preserves the existing blocked/unknown definitions; table changes
still require a traversal, not a per-record ledger write-set update.
Asset display effects keep their previous ownership, abort/release and retry
rules. Durable-only completion/error/close is still read from the independent
durability source, so saving and synchronization remain distinct.