Repository navigation
Commit 58b9582
fix(signals): index-mode mapArray publishes the optimistic frame (F1) (#3682)
* fix(signals): index-mode mapArray publishes the optimistic frame (F1)
A mapArray pass writes the list's per-slot signals — the row accessors of
index mode (`keyed: false`), the index accessors of a keyed `<For>` with a
two-argument mapper — with `setSignal`. Under an action's lane pass those
writes were staged into the action's transaction instead of joining the
lane's frame (setSignal's plain path: queuePendingNode + `_pendingValue`),
and the row render effects were served the committed value by
readerSeesCommitted until the action landed. `<For keyed={false}>` showed
the pre-action list for the whole action while the keyed modes — whose
reorder rides the computed's own result into `_laneOverride` — showed the
optimistic one; a keyed row rendered its old index beside its new
neighbours (`1b,2c,3d,4e,5f,0a`).
The slot writes now go through the engine (`writeSlot` ->
`GlobalQueue._laneSlotWrite`, `laneSlotWrite` in core/optimistic.ts):
under a lane pass each is published as a derived override on the slot and
the slot joins the lane (assignOrMergeLane + laneOverride, lanes stage,
A17); a plain pass over a slot still carrying one — the landing, the
reversion, a mainline re-pass — lands through `landOnOverride` (A18: a
differing landing supersedes, an equal one confirms and the revert
promotes). Without the engine installed mapArray writes the slots plainly
as before. `laneOverride` is widened to any OptimisticNode.
Tests: tests/store/optimistic-maparray-index-frame-f1.test.ts pins the
index-mode frame (insert / delete / move / swap / reverse / rotate, confirm
and differing landings, reorder then a different landing, revert without a
truth, overlapping actions) and the keyed index-accessor twin, on the
derived and chained sources; packages/web/test/optimistic-for-index-frame-
f1.spec.tsx mirrors it through `<For keyed={false}>` and `<For keyed={fn}>`.
Matrix: every F1 row cleared (716/184/0 -> 821/79/0); the index reader now
fails exactly where the other readers do on the derived source (F4) and is
retagged there. The F6 rows (repeat, derived) were test pollution from F1 —
an it.fails row throwing at its apply checkpoint never released its gate,
so its action outlived the test — and pass now; unpinned.
optimistic-outside-refetch-619.test.ts had pinned the torn frame and the
index writes landing in a third frame; it now expects the whole frame and
asserts the settle with an ambient probe write (still fails with #3663
reverted).
Size: +15 B core-retained (the hook's static slot; treeshake ledger
26,649 -> 26,664), `laneSlotWrite` sheds with the engine, `writeSlot` with
map. Non-frozen ledger caps ratcheted with dated notes. The two frozen page
caps are exceeded — reported in the PR, not touched.
Docs: SPEC A17 mechanism index and status note the slot writes;
RULES-INDEX regenerated.
Co-authored-by: Claude via Cursor <[email protected]>
Co-authored-by: Cursor <[email protected]>
* fix(signals): F1 slot writes — one per-pass pick, no new hook slot
Golf + perf pass on the mapArray optimistic-frame fix (F1).
The per-slot `writeSlot` (a `GlobalQueue._laneSlotWrite ?? setSignal` pick at
every slot write) cost the plain path per-slot work — swap +14%/+22%, insert/
remove +6% on 1000-row lists — and +129 B / +230 B brotli on the frozen page
scenarios. The pick is now made ONCE per pass at the top of the update
branch: a lane pass marks the map (`_laneSlots`); a marked map routes its
slot writes through the engine while any lane is live (`activeLanes.size`),
and drops the mark when none is — a slot's override resolves with its lane's
transaction (or the batch for an orphan lane) before the completion wakes any
recompute, so a pass that finds no lane knows the slots are clean. An
unmarked map writes with `setSignal` directly, the pre-fix code.
The engine side is a branch inside the already-installed `_landOnOverride`
hook, discriminated by `!(el._config & CONFIG_OPTIMISTIC)` (mapArray slots
are never optimistic nodes; existing setSignal callers are unaffected): a
lane pass's write becomes the slot's derived override (A17), a plain pass's
write over one takes the landing path (A18), a plain write on a clean slot is
`setSignal`. The `_laneSlotWrite` static and `laneSlotWrite` are gone — core
floor back to 26,649 B minified (0 B core-retained).
Bench (1000 rows, median of 6 alternating rounds vs `next`): plain path
-5.9% .. +1.3% (noise); plain passes on a map after a settled action
-1.2% .. +3.3% (the mark clears on the first plain pass); action reverse
+13% / action swap +4% (the lane pass publishing per-slot overrides — the
fix itself).
Size (brotli vs `next`): page base 46,872 -> 46,853 (-19), hydrating 21,416
-> 21,402 (-14), page live 51,156 -> 51,260 (+104; frozen cap 51,160, over
by 100 — not touched). Minified: map +53 B, engine +144 B. Roughly 40 B of
each page delta is the signals prop-mangler reordering names across map.js
and scheduler.js (shared per-file frequency cache), not code: `+ createStore`
moves +19 B brotli at 0 B minified. Non-frozen ledger caps re-ratcheted to
the measured values with dated notes.
Co-authored-by: Claude via Cursor <[email protected]>
Co-authored-by: Cursor <[email protected]>
* chore(size): accept page:live delta for F1 index-mode frame (Size-Exception)
Rebased onto `next` @ d0ad11c (#3684). Against a clean build of that
commit the F1 branch measures page: base 46,885 -> 46,936 B (+51; 36 over
the frozen 46.90 KB) and page: live 51,220 -> 51,255 B (+35; 25 over the
frozen 51.23 KB). The maintainer accepted design (a) and the residual
(2026-09-27); both caps are raised under the PR body's `Size-Exception:`
line — page: base 46.90 -> 46.95 KB, page: live 51.23 -> 51.27 KB (the
smallest 0.01 KB step leaving >= 10 B headroom) — with dated history notes.
Real code: +53 B minified in map.js (~17 B compressed; the per-pass slot
writer pick), +144 B in optimistic.js (~46 B compressed; the slot arm in
landOnOverride, retained only with the engine). The remainder is the signals
prop-mangler's per-file name reorder: the same code measured -19 B on page:
base against the pre-#3684 `next`.
Non-frozen ledger caps re-ratcheted to the post-rebase measurements (down
where the PR now measures under): + createStore 17.36 -> 17.33 KB,
isPending/latest 12.73 -> 12.72, hydrating + stores 32.06 -> 32.02, CSR
Show/For 16.04 -> 16.05, CSR observe 17.88 -> 17.87, attribution 32.01 ->
31.99. size-limit exits 0; check-floor-caps passes with the body as
SIZE_EXCEPTION and fails without.
Co-authored-by: Claude via Cursor <[email protected]>
Co-authored-by: Cursor <[email protected]>
---------
Co-authored-by: Claude via Cursor <[email protected]>
Co-authored-by: Cursor <[email protected]>1 parent d0ad11c commit 58b9582
13 files changed
Lines changed: 925 additions & 112 deletions
File tree
- .changeset
- packages
- signals
- docs
- src
- core
- tests
- store
- web/test
- scripts/size
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
64 | | - | |
65 | | - | |
| 64 | + | |
| 65 | + | |
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
| |||
119 | 119 | | |
120 | 120 | | |
121 | 121 | | |
122 | | - | |
| 122 | + | |
123 | 123 | | |
124 | 124 | | |
125 | 125 | | |
| |||
0 commit comments