Skip to content

Commit 2e24ac3

Browse files
test(signals): pin GabbeV's board shape from #3726 on L2
The #3726 comment's playground, fetched: an async card source behind a memo (`createMemo(() => ready() ?? pending)`), a derived `createStore(() => source(), [])`, `createOptimisticStore` over it and a keyed `<For>`, remounted under a `<Loading>` that has already revealed; a count outside the view. Before, Activity → Board left "All cards: 1" beside an empty lane: the remounted readers were parked on the derive's first flight under the boundary's hold, and the held synchronous landing never woke them — the case PR #3732 listed as open (red on its base with and without its fix). Same root-cause family as the report, not a distinct bug. On L2 the revealed boundary holds the view switch (A29: a boundary already showing content holds like any reader) and the lane reveals with its rows as one frame — the count and the list never disagree. Pinned as the playground itself (web spec) and a signals reduction. The report's own playground, fetched too: the `Source:` hole is outside the `<Loading>` and the promise is created once — the first web test and the signals "report's playground" test now follow it exactly. Co-authored-by: Cursor <[email protected]>
1 parent f436b9d commit 2e24ac3

3 files changed

Lines changed: 228 additions & 55 deletions

File tree

‎packages/signals/docs/RULES-INDEX.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ Status legend: **live** stated and standing · **ruled** carries an explicit rul
7373
| A26 | ruled | `docs/SPEC-ASYNC-SEMANTICS.md:85` | — | action-await-contract.test.ts×2 posture-store-parity.test.ts×2 visibility-oracle-store.states.ts×2 visibility-oracle.states.ts×1 visibility-oracle.test.ts×1 | [ruled 2026-07-17] An ambient transaction window is one flush; parking is flush-driven — (**ruled 2026-07-17**, #2913; **enforcement hardened 2026-08-31**, #3141 — parking is flush-driven, and a trans… |
7474
| A27 | ruled | `docs/SPEC-ASYNC-SEMANTICS.md:271` | — | loading-value.test.ts×2 visibility-oracle.states.ts×18 visibility-oracle.test.ts×1 | [ruled 2026-08-10] The commit-#0 loading window is loading-class and verdict-quiet — (**ruled 2026-08-10**) **The commit-#0 loading window is loading-class and verdict-quiet.** A node born committed v… |
7575
| A28 | ruled, mechanism landed | `docs/SPEC-ASYNC-SEMANTICS.md:69` | constants.ts×1 core.ts×12 lanes.ts×2 scheduler.ts×3 types.ts×1 verdict.ts×2 store.ts×4 | createOptimistic.test.ts×5 held-derivation-not-a-proposal-3612.test.ts×1 latest-held-till-flush.test.ts×1 posture-store-parity.test.ts×5 question-scoped-pending.test.ts×3 snapshot-derived-store-rows.test.ts×1 createOptimisticStore.test.ts×10 optimistic-draft-visibility-3665.test.ts×5 optimistic-list-mutation-matrix.harness.ts×1 optimistic-list-mutation-matrix.test.ts×2 shallow.test.ts×1 woken-transaction-adopts-staged-bump.test.ts×1 treeshake.test.ts×2 verdict-contract.test.ts×1 visibility-oracle-store.states.ts×8 visibility-oracle.states.ts×8 | [ruled, mechanism landed 2026-09-15] A write becomes visible at flush — to every channel — (**ruled 2026-09-08**; supersedes the #2922 mid-tick pull) **A write becomes visible at flush — to every chan… |
76-
| A29 | amended | `docs/SPEC-ASYNC-SEMANTICS.md:93` | boundaries.ts×1 action.ts×1 constants.ts×1 core.ts×8 effect.ts×1 scheduler.ts×3 signals.ts×1 store.ts×1 | adoption-unchanged-key-read-3706.test.ts×9 body-end-supersession-visibility.test.ts×1 born-held.test.ts×3 boundary-not-born-held-3540.test.ts×4 createProjection.draft-lifetime-3585.test.ts×1 direct-commit-readers-posture.test.ts×1 held-conditional-memo.test.ts×1 held-frame-dependencies.test.ts×2 held-truth-lane-only.test.ts×3 l2-contract.test.ts×1 latest-held-till-flush.test.ts×2 optimistic-read-lane-not-transaction-3698.test.ts×3 posture-born-held-and-observation.test.ts×1 posture-store-parity.test.ts×6 derived-presence-async-3726.test.ts×2 optimistic-untracked-reads-f3-f5.test.ts×1 store-unchanged-read-independent-write-3688.test.ts×1 treeshake.test.ts×3 visibility-oracle-store.states.ts×5 visibility-oracle-store.test.ts×1 visibility-oracle.states.ts×9 visibility-oracle.test.ts×1 write-proposals-3494.test.ts×1 | [ruled, amended in place 2026-09-13 (#3408)] A tracked read served a live transaction's staged value enters that transaction — A tracked computation served a node's staged `_pendingValue` — a value a … |
76+
| A29 | amended | `docs/SPEC-ASYNC-SEMANTICS.md:93` | boundaries.ts×1 action.ts×1 constants.ts×1 core.ts×8 effect.ts×1 scheduler.ts×3 signals.ts×1 store.ts×1 | adoption-unchanged-key-read-3706.test.ts×9 body-end-supersession-visibility.test.ts×1 born-held.test.ts×3 boundary-not-born-held-3540.test.ts×4 createProjection.draft-lifetime-3585.test.ts×1 direct-commit-readers-posture.test.ts×1 held-conditional-memo.test.ts×1 held-frame-dependencies.test.ts×2 held-truth-lane-only.test.ts×3 l2-contract.test.ts×1 latest-held-till-flush.test.ts×2 optimistic-read-lane-not-transaction-3698.test.ts×3 posture-born-held-and-observation.test.ts×1 posture-store-parity.test.ts×6 derived-presence-async-3726.test.ts×3 optimistic-untracked-reads-f3-f5.test.ts×1 store-unchanged-read-independent-write-3688.test.ts×1 treeshake.test.ts×3 visibility-oracle-store.states.ts×5 visibility-oracle-store.test.ts×1 visibility-oracle.states.ts×9 visibility-oracle.test.ts×1 write-proposals-3494.test.ts×1 | [ruled, amended in place 2026-09-13 (#3408)] A tracked read served a live transaction's staged value enters that transaction — A tracked computation served a node's staged `_pendingValue` — a value a … |
7777
| A30 | ruled | `docs/SPEC-ASYNC-SEMANTICS.md:227` | async.ts×3 attribution.ts×1 constants.ts×1 core.ts×1 effect.ts×1 scheduler.ts×4 | async-landing-deps-3461.test.ts×3 held-conditional-effect.test.ts×1 held-conditional-memo.test.ts×1 held-frame-dependencies.test.ts×2 ispending-in-boundary-on-3528.test.ts×1 lane-frame-deferred-run-3662.test.ts×1 lane-frame-held-lane-3662.test.ts×1 posture-born-held-and-observation.test.ts×1 treeshake.test.ts×2 write-proposals-3494.test.ts×2 zombie-rerun-after-commit-3546.test.ts×2 | [ruled 2026-09-13 (#3410)] A memo's dependencies are the committed frame's until the frame is replaced — A pass that _staged_ its value has not replaced the committed frame, so the committed value sti… |
7878
| A31 | live | `docs/SPEC-ASYNC-SEMANTICS.md:101` | boundaries.ts×1 core.ts×1 verdict.ts×1 | ispending-combined-atomic-3442.test.ts×1 | [live 2026-09-14 (#3442)] A memo computes under its own lane posture, never its puller's — A memo's value is one shared slot every reader sees, so its pass runs under the lane posture the memo itself … |
7979
| A32 | ruled | `docs/SPEC-ASYNC-SEMANTICS.md:109` | core.ts×4 lanes.ts×1 store.ts×1 | visibility-oracle-store.states.ts×8 visibility-oracle-store.test.ts×1 visibility-oracle.states.ts×9 visibility-oracle.test.ts×1 | [ruled 2026-09-14] Children-forbidden readers see the frame, not the graph — `createTrackedEffect` and `onSettled` callbacks are effect-phase code that runs after the frame is decided. They read the f… |

‎packages/signals/tests/store/derived-presence-async-3726.test.ts‎

Lines changed: 105 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,21 @@ import {
2828
NotReadyError,
2929
action,
3030
createLoadingBoundary,
31+
createMemo,
32+
createOptimisticStore,
3133
createRenderEffect,
3234
createRoot,
3335
createSignal,
3436
createStore,
3537
flush,
3638
isPending,
39+
mapArray,
3740
untrack,
3841
type Store
3942
} from "../../src/index.js";
4043

4144
const tick = () => new Promise(r => setTimeout(r, 0));
45+
const sleep = (ms: number) => new Promise(r => setTimeout(r, ms));
4246
const microtasks = async () => {
4347
for (let i = 0; i < 5; i++) await Promise.resolve();
4448
};
@@ -149,32 +153,33 @@ describe("sync landing after a pending first flight wakes unchanged-node readers
149153
});
150154

151155
describe("#3726 on the hold model — the parked reader is the derive's, woken by its first commit", () => {
152-
it("the report's sequence: source write and promise resolution in one timer callback, under <Loading>", async () => {
153-
const [source, setSource] = createSignal<number[] | null>(null);
154-
let resolve!: (v: number[]) => void;
156+
it("the report's playground: one promise, its timer writes the source and resolves it; presence under <Loading>, source outside", async () => {
155157
let presence = "";
156158
let sourceState = "";
157159
let shown: unknown;
158160
createRoot(() => {
159-
const [store] = createStore<number[]>(() => {
160-
const s = source();
161-
if (s) return s;
162-
return new Promise<number[]>(r => (resolve = r));
163-
}, []);
161+
const [ready, setReady] = createSignal<number[]>();
162+
const pending = new Promise<number[]>(resolve =>
163+
setTimeout(() => {
164+
setReady([1]);
165+
resolve([1]);
166+
}, 10)
167+
);
168+
const [data] = createStore<number[]>(() => ready() ?? pending, []);
169+
createRenderEffect(
170+
() => (ready() ? "resolved" : "pending"),
171+
v => {
172+
sourceState = v;
173+
}
174+
);
164175
const boundary = createLoadingBoundary(
165176
() => {
166177
createRenderEffect(
167-
() => ("length" in store ? "present" : "missing"),
178+
() => ("length" in data ? "present" : "missing"),
168179
v => {
169180
presence = v;
170181
}
171182
);
172-
createRenderEffect(
173-
() => (source() ? "resolved" : "pending"),
174-
v => {
175-
sourceState = v;
176-
}
177-
);
178183
return "content";
179184
},
180185
() => "fallback"
@@ -189,17 +194,12 @@ describe("#3726 on the hold model — the parked reader is the derive's, woken b
189194
// No manual flush: the scheduler's own microtask, as in the app.
190195
await microtasks();
191196
expect(shown).toBe("fallback");
197+
expect(sourceState).toBe("pending");
192198
expect(presence).toBe("");
193199

194-
// The report's timer callback: the source lands the derive synchronously
195-
// and the superseded first flight resolves in the same tick.
196-
await new Promise<void>(r =>
197-
setTimeout(() => {
198-
setSource([1]);
199-
resolve([1]);
200-
r();
201-
}, 0)
202-
);
200+
// The timer: the source lands the derive synchronously and the
201+
// superseded first flight resolves in the same tick.
202+
await sleep(30);
203203
await microtasks();
204204
expect(sourceState).toBe("resolved");
205205
expect(presence).toBe("present");
@@ -323,3 +323,84 @@ describe("#3726 on the hold model — the parked reader is the derive's, woken b
323323
expect(presence).toBe("present");
324324
});
325325
});
326+
327+
/** GabbeV's board (the #3726 comment), reduced: an async card source behind
328+
* a memo → a derived `createStore` → `createOptimisticStore` → a keyed list,
329+
* remounted under a loading boundary that has already revealed. Before, the
330+
* remounted readers were parked on the derive's first flight under the
331+
* boundary's hold and the held synchronous landing never woke them — an
332+
* empty lane beside the outside count (PR #3732's open case; red on its base
333+
* with and without its fix). On L2 the revealed boundary holds the view
334+
* switch (A29: a boundary already showing content holds like any reader)
335+
* and the lane reveals with its rows as one frame. The web twin renders the
336+
* playground itself (`packages/web/test/derived-presence-async-3726.spec.tsx`). */
337+
describe("#3726 board shape — a lane remounted under a revealed boundary fills at the held sync landing", () => {
338+
type Card = { id: string; title: string };
339+
const snapshot: Card[] = [{ id: "1", title: "Review the proposal" }];
340+
341+
it("async source → derived store → optimistic store → keyed list, remounted", async () => {
342+
const [view, setView] = createSignal<"board" | "activity">("board");
343+
let shown: unknown;
344+
let mounts = 0;
345+
createRoot(() => {
346+
const boundary = createLoadingBoundary(
347+
() => {
348+
// The `{view() === 'board' ? <CardList /> : null}` hole.
349+
const hole = createMemo(() => {
350+
if (view() !== "board") return null;
351+
mounts++;
352+
const [ready, setReady] = createSignal<Card[]>();
353+
const pending = new Promise<Card[]>(resolve =>
354+
setTimeout(() => {
355+
setReady(snapshot);
356+
resolve(snapshot);
357+
}, 10)
358+
);
359+
const source = createMemo(() => ready() ?? pending);
360+
const [localCards] = createStore(() => source(), [] as Card[]);
361+
const [cards] = createOptimisticStore(localCards);
362+
return mapArray(
363+
() => cards,
364+
card => card().title,
365+
{ keyed: (c: Card) => c.id }
366+
);
367+
});
368+
return () => {
369+
const h = hole();
370+
return h === null ? null : h();
371+
};
372+
},
373+
() => "fallback"
374+
);
375+
createRenderEffect(
376+
() => {
377+
const b = boundary();
378+
return typeof b === "function" ? b() : b;
379+
},
380+
v => {
381+
shown = v;
382+
}
383+
);
384+
});
385+
await microtasks();
386+
expect(shown).toBe("fallback");
387+
await sleep(30);
388+
await microtasks();
389+
expect(shown).toEqual(["Review the proposal"]);
390+
expect(mounts).toBe(1);
391+
392+
setView("activity");
393+
await microtasks();
394+
expect(shown).toBe(null);
395+
396+
setView("board");
397+
await microtasks();
398+
// Held: the revealed boundary keeps its frame until the remounted
399+
// lane's flight lands.
400+
expect(shown).toBe(null);
401+
expect(mounts).toBe(2);
402+
await sleep(30);
403+
await microtasks();
404+
expect(shown).toEqual(["Review the proposal"]);
405+
});
406+
});

‎packages/web/test/derived-presence-async-3726.spec.tsx‎

Lines changed: 122 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,52 +2,144 @@
22
* @jsxImportSource @solidjs/web
33
* @vitest-environment jsdom
44
*/
5-
// #3726 — the report's shape: a derived `createStore` whose first run
6-
// returns a pending promise, read by presence (`"length" in store`) inside
7-
// `<Loading>` beside a read of the source; a timer callback writes the
8-
// source (the derive lands synchronously) and resolves the superseded
9-
// promise in the same tick. The presence hole stayed blank. The signals-side
10-
// pin is `packages/signals/tests/store/derived-presence-async-3726.test.ts`.
5+
// #3726 — the report's two playgrounds, verbatim in shape. The signals-side
6+
// pins are `packages/signals/tests/store/derived-presence-async-3726.test.ts`.
117
import { describe, expect, test } from "vitest";
12-
import { createSignal, createStore, Loading } from "solid-js";
8+
import {
9+
createMemo,
10+
createOptimisticStore,
11+
createSignal,
12+
createStore,
13+
For,
14+
Loading,
15+
Show
16+
} from "solid-js";
1317
import { render } from "../src/index.js";
1418

19+
const sleep = (ms: number) => new Promise(r => setTimeout(r, ms));
1520
const microtasks = async () => {
1621
for (let i = 0; i < 5; i++) await Promise.resolve();
1722
};
1823

1924
describe("presence read on an async derived store (#3726)", () => {
20-
test("shows `present` after the source resolves the derive synchronously", async () => {
25+
// A derived `createStore` whose first run returns a pending promise, read
26+
// by presence (`"length" in data`) inside `<Loading>`; a timer writes the
27+
// source (the derive lands synchronously) and resolves the superseded
28+
// promise in the same tick. The presence hole stayed blank while the
29+
// source hole outside the boundary updated.
30+
test("shows `present` after the source lands the derive synchronously", async () => {
2131
const div = document.createElement("div");
22-
let resolve!: (v: number[]) => void;
23-
let setSource!: (v: number[]) => void;
2432
const dispose = render(() => {
25-
const [source, set] = createSignal<number[] | null>(null);
26-
setSource = set;
27-
const [store] = createStore<number[]>(() => {
28-
const s = source();
29-
if (s) return s;
30-
return new Promise<number[]>(r => (resolve = r));
31-
}, []);
33+
const [ready, setReady] = createSignal<number[]>();
34+
const pending = new Promise<number[]>(resolve =>
35+
setTimeout(() => {
36+
setReady([1]);
37+
resolve([1]);
38+
}, 10)
39+
);
40+
const [data] = createStore(() => ready() ?? pending, []);
3241
return (
33-
<Loading fallback={<p>Loading</p>}>
34-
<p>Presence: {"length" in store ? "present" : "missing"}</p>
35-
<p>Source: {source() ? "resolved" : "pending"}</p>
36-
</Loading>
42+
<>
43+
<p>Source: {ready() ? "resolved" : "pending"}</p>
44+
<Loading fallback={<p>Loading…</p>}>
45+
<p>Presence: {"length" in data ? "present" : "missing"}</p>
46+
</Loading>
47+
</>
3748
);
3849
}, div);
3950
await microtasks();
40-
expect(div.innerHTML).toBe("<p>Loading</p>");
41-
42-
await new Promise<void>(r =>
43-
setTimeout(() => {
44-
setSource([1]);
45-
resolve([1]);
46-
r();
47-
}, 0)
51+
expect(div.innerHTML).toBe("<p>Source: pending</p><p>Loading…</p>");
52+
53+
await sleep(30);
54+
await microtasks();
55+
expect(div.innerHTML).toBe("<p>Source: resolved</p><p>Presence: present</p>");
56+
dispose();
57+
});
58+
59+
// GabbeV's board (issue comment): an async card source behind a memo, a
60+
// derived `createStore`, a `createOptimisticStore` over it and a keyed
61+
// `<For>`, remounted under a `<Loading>` that has already revealed; a
62+
// count outside the view. Before: after Activity → Board the count read
63+
// "All cards: 1" beside an empty lane — the remounted readers were parked
64+
// on the derive's first flight under the boundary's hold, and the held
65+
// synchronous landing never woke them (the case PR #3732 left open). On
66+
// L2 the revealed boundary holds the view switch (A29: a boundary already
67+
// showing content holds like any reader) and the lane reveals with its
68+
// card as one frame; the count and the list never disagree.
69+
test("a lane remounted under a revealed <Loading> fills beside the outside count", async () => {
70+
type Card = { id: string; title: string };
71+
const snapshot: Card[] = [{ id: "1", title: "Review the proposal" }];
72+
const div = document.createElement("div");
73+
let setView!: (v: "board" | "activity") => void;
74+
let mounts = 0;
75+
76+
function CardList() {
77+
mounts++;
78+
const [ready, setReady] = createSignal<Card[]>();
79+
const pending = new Promise<Card[]>(resolve =>
80+
setTimeout(() => {
81+
setReady(snapshot);
82+
resolve(snapshot);
83+
}, 10)
84+
);
85+
const source = createMemo(() => ready() ?? pending);
86+
const [localCards] = createStore(() => source(), [] as Card[]);
87+
const [cards] = createOptimisticStore(localCards);
88+
return (
89+
<For each={cards} keyed={card => card.id}>
90+
{card => <article>{card().title}</article>}
91+
</For>
92+
);
93+
}
94+
95+
function App() {
96+
const [view, set] = createSignal<"board" | "activity">("board");
97+
setView = set;
98+
const [allCards] = createSignal(snapshot);
99+
return (
100+
<main>
101+
<p>All cards: {allCards().length}</p>
102+
<section hidden={view() === "activity"}>
103+
<h2>To do</h2>
104+
<Loading fallback={<p>Loading lane…</p>}>
105+
{view() === "board" ? <CardList /> : null}
106+
</Loading>
107+
</section>
108+
<Show when={view() === "activity"}>
109+
<p>Activity view</p>
110+
</Show>
111+
</main>
112+
);
113+
}
114+
115+
const board =
116+
"<main><p>All cards: 1</p><section><h2>To do</h2><article>Review the proposal</article></section></main>";
117+
const activity =
118+
'<main><p>All cards: 1</p><section hidden=""><h2>To do</h2></section><p>Activity view</p></main>';
119+
120+
const dispose = render(() => <App />, div);
121+
await microtasks();
122+
expect(div.innerHTML).toBe(
123+
"<main><p>All cards: 1</p><section><h2>To do</h2><p>Loading lane…</p></section></main>"
48124
);
125+
await sleep(30);
126+
await microtasks();
127+
expect(div.innerHTML).toBe(board);
128+
expect(mounts).toBe(1);
129+
130+
setView("activity");
131+
await microtasks();
132+
expect(div.innerHTML).toBe(activity);
133+
134+
setView("board");
135+
await microtasks();
136+
// Held: the revealed boundary keeps its frame until the remounted lane's
137+
// flight lands — no fallback, no empty lane beside the count.
138+
expect(div.innerHTML).toBe(activity);
139+
expect(mounts).toBe(2);
140+
await sleep(30);
49141
await microtasks();
50-
expect(div.innerHTML).toBe("<p>Presence: present</p><p>Source: resolved</p>");
142+
expect(div.innerHTML).toBe(board);
51143
dispose();
52144
});
53145
});

0 commit comments

Comments
 (0)