Skip to content

Commit 6905215

Browse files
committed
Merge remote-tracking branch 'origin/next' into claude/project-thread-x1ore2-4474-pin
2 parents 68d630e + 663ecb0 commit 6905215

14 files changed

Lines changed: 698 additions & 14 deletions
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@solidjs/signals": patch
3+
---
4+
5+
A memo's error staged with a hold now reaches the memos and derived stores that derive from it: `latest()` of them throws the proposed error and `isPending()` of them is `true` until the hold commits, as for the memo itself (D-41).
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@solidjs/signals": patch
3+
---
4+
5+
A memo born into a hold that reads `latest()` in its pass (for example by calling a function a `Loading` fallback returned) no longer mounts that `Loading` again and again once the content lands. The memo's re-run is still the hold's own work, so it joins the hold whatever it asked before (D-25), and the boundary it mounts belongs to the hold and appears at its commit (D-13): the screen goes straight to the content.

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,11 +220,11 @@ A held display-ahead world ("a lane") is a hold seen from the outside. A render
220220

221221
### D-27. A verdict reader's mount is a mainline mount
222222

223-
**From:** F-6, F-4, F-1. **Scenarios:** S-31.
223+
**From:** F-6, F-4, F-1. **Scenarios:** S-31, S-46.
224224

225225
A `<Show when={latest(x) > 0}>` opens at once (display-ahead). The `<Loading>` it mounts is a mainline mount: it does not inherit the display-ahead world, so its content reads the screen's `x`. Inside an action's own flush that content's first pass reads the staging the action is about to hold, so it is born held (D-2): the boundary shows its fallback beside the committed `x = 0`, and `content 1` appears at the landing. Never `content 1` beside `x = 0`. A first pass created by an _optimistic_ lane, by contrast, is that lane's work (a binding an optimistic mount creates lands with its element).
226226

227-
**Why the two differ, and what the mount's content may show (clarified 2026-10-28).** A plain read is never display-ahead; only a read that asks (`latest`, `isPending`) or a slot that is guessed (an optimistic value, F-11) is. A guess is _slot-level_: it is the value of its slot for the whole screen, so every plain read of it agrees and an optimistic mount's plain reads show it without tearing. `latest(x)` is _read-level_: only the reads that say `latest` see the held value. A mount's children are _gated_ by the display-ahead read, not _derived_ from it (F-6's "what is rendered from a display-ahead read" is the derivation — `fetch(latest(x))` — not the branch it opens); their plain `x()` is an independent read, and showing it the held value would make a plain read's answer depend on which `Show` wraps it — two plain reads of one signal disagreeing on one screen. So the content reads the screen, and the fallback it shows is `Loading` declining to tear over content that is, by the author's choice of a plain read, not yet the committed value. To show the held value inside the branch, read it there as `latest(x)`: `content {latest(x)}` shows `content 1` now, with no fallback.
227+
**Why the two differ, and what the mount's content may show (clarified 2026-10-28).** A plain read is never display-ahead; only a read that asks (`latest`, `isPending`) or a slot that is guessed (an optimistic value, F-11) is. A guess is _slot-level_: it is the value of its slot for the whole screen, so every plain read of it agrees and an optimistic mount's plain reads show it without tearing. `latest(x)` is _read-level_: only the reads that say `latest` see the held value. A mount's children are _gated_ by the display-ahead read, not _derived_ from it (F-6's "what is rendered from a display-ahead read" is the derivation — `fetch(latest(x))` — not the branch it opens); their plain `x()` is an independent read, and showing it the held value would make a plain read's answer depend on which `Show` wraps it — two plain reads of one signal disagreeing on one screen. So the content reads the screen, and the fallback it shows is `Loading` declining to tear over content that is, by the author's choice of a plain read, not yet the committed value. To show the held value inside the branch, read it there as `latest(x)`: `content {latest(x)}` shows `content 1` now, with no fallback. **Whoever opened the hold (ruled 2026-10-30):** an action is a way to extend a hold, not a different kind of one — a plain write held by an async memo on screen is the same case: the branch a display-ahead `Show` opens is born held and keeps the fallback until the landing, `latest(x)` inside shows ahead, a `Loading` inside shows its fallback (S-46, `tests/display-ahead-plain-write-content.test.ts`).
228228

229229
**A joined pass's children are the hold's (promoted from A29, 2026-10-28):** a pass — a render effect included — that read a node with no screen to fall back to (a node born into the hold, never committed: D-2; D-4's tick-join) joins the hold: it has no committed value to show, so it is not a leaf reading the screen (D-3) but a reader that waits (A29 ruling A, 2026-10-01: "every reader derives from it — a render effect included — and joins"). A node it creates during that pass is born held: its value commits with the frame, and a mainline reader of it waits rather than showing it ahead of the frame (F-7) — the subtree-disagreement tear this rule guards against, a child's value on screen beside a parent frame still held. Shape: a lazy outlet's render effect reads a router query memo that has no committed value and creates a memo during that pass; the memo is the navigation's, even where its own first pass reads nothing held. This is the third mount beside the two above — a verdict reader's is mainline, an optimistic lane's is the lane's, a joined pass's is the hold's — and A29's "a held pass's children compute but do not effect and die with the commit that replaces their frame" is its archive form. Pins: `tests/lane-uninitialized-landing-3648.test.ts`, `tests/boundary-output-frame-reader.test.ts`, `tests/loading-fallback-in-flush-3540.test.ts`, `tests/fuzz-findings-l2.test.ts`.
230230

‎packages/signals/docs/SCENARIOS.md‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -636,6 +636,31 @@ const save = action(function* () { setX(1); yield gate; });
636636
| 2 | `gate`, body returns | `1 \| content 1` | |
637637
| ✗ | | after 1: `0 \| content 1` (the torn frame #3869 fixed) | |
638638

639+
### S-46. The content a display-ahead `Show` opens reads the screen, whoever opened the hold — D-27, D-37
640+
641+
_Ruled 2026-10-30 ("actions aren't special — they are a way to extend the hold"). Pinned: `tests/display-ahead-plain-write-content.test.ts` (signals, passes) and `web/test/display-ahead-plain-write-content-s46.spec.tsx` (through `Show` + `insert`; the plain row is `test.fails` — today the branch attaches with its text hole empty, `selected: ` and nothing, F-2's empty slot and #4417's mechanism). S-31's rule in the plain-write, no-boundary form: a write to `id` is held because an async memo over it is on screen; no action, no `Loading`._
642+
643+
```tsx
644+
const [id, setId] = createSignal(0);
645+
const detail = createMemo(() => fetchDetail(id()));
646+
<p>{id()}</p> <p>{detail()}</p>
647+
<Show when={latest(id) > 0} fallback="none">
648+
<p>selected: {id()}</p> {/* a plain read, under the display-ahead Show */}
649+
</Show>
650+
// primed: detail answered for id = 0
651+
```
652+
653+
| # | Action | Screen | Notes |
654+
| --- | ------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------- |
655+
| 0 | primed | `0 \| none \| d0` | |
656+
| 1 | `setId(1); flush()` — `fetchDetail(1)` in flight | `0 \| none \| d0` — the `Show` opens ahead (`latest` asked), but the branch is a mount whose first pass read the staging plainly: born held (D-27), it does not attach until the landing; the fallback stays | a plain `id()` means one thing on the whole screen — the `0` outside |
657+
| 1′ | same, content `selected: {latest(id)}` | `0 \| selected: 1 \| d0` | the read that asks sees ahead, at its own site |
658+
| 1″ | same, content inside a `<Loading fallback>` | `0 \| [fallback] \| d0` | S-31's form: the boundary catches the born-held read |
659+
| 2 | `fetchDetail(1)` lands | `1 \| selected: 1 \| d1` | |
660+
| ✗ | | after 1: `0 \| selected: 1 \| d0` — two plain reads of one signal disagreeing on one screen | |
661+
| ✗ | | after 1: `0 \| selected: 0 \| d0` — the branch attached with the committed value; a mount under a display-ahead reader is born held, not a D-3 leaf | |
662+
| ✗ | | after 1: `0 \| selected: (empty) \| d0` — the branch attached with its hole empty (F-2: never an empty slot). Today's screen through `Show` + `insert` | |
663+
639664
### S-39. A later unread value still throws — D-28
640665

641666
_Ruled 2026-10-09. The `n0`-first order already holds the mount. The `latest`-first order still publishes the empty slot; that is the violation._

‎packages/signals/src/core/async.ts‎

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,12 +214,39 @@ export function stageError(el: Computed<any>, error: any, inPass?: boolean): boo
214214
el._pendingValue = error instanceof StatusError ? error : new StatusError(el, error);
215215
el._config |= CONFIG_STAGED | CONFIG_STAGED_ERROR;
216216
// Readers parked on the flight re-run and derive from the staging; the
217-
// verdict readers the walk wakes need a flush (#4106).
217+
// verdict readers the walk wakes need a flush (#4106); the derivations it
218+
// reaches carry the staging (`settlePendingSource`).
218219
settlePendingSource(el);
219220
schedule();
220221
return true;
221222
}
222223

224+
/** D-41: a derivation of a staged error carries it, staged with the same
225+
* frame — marked, not re-run, as a published error marks it (a re-run would
226+
* replace the frame its content owns) — and its own verdict readers
227+
* re-derive (the settle walk). Only a verdict reads a derivation's staging
228+
* before its commit, so only the verdict engine marks. Not a boundary's
229+
* output, an async memo, an effect or a boundary's tree (`EFFECT_TRACKED <<
230+
* 23` spans CONFIG_FRAME and every effect type), nor one already carrying a
231+
* staged error: the commit's publish reaches them. A pending mark supersedes
232+
* the staging (`propagateStatus`). */
233+
function stageMark(node: Computed<any>, el: Computed<any>): void {
234+
if (
235+
!(
236+
node._config &
237+
(CONFIG_REDERIVE | CONFIG_STAGED_ERROR | CONFIG_ASYNC | (EFFECT_TRACKED << 23))
238+
)
239+
) {
240+
node._pendingValue = el._pendingValue;
241+
node._config |= CONFIG_STAGED_ERROR;
242+
queuePendingNode(node);
243+
// A derived store's readers are its family's (store/projection.ts): they
244+
// re-derive from the staging, as from the derive's status (#4189).
245+
(node as any).fam?.st(STATUS_ERROR);
246+
settlePendingSource(node);
247+
}
248+
}
249+
223250
export function settleErroredDependents(el: Computed<any>, error: any): void {
224251
let scheduled = false;
225252
const visited = new NewSet<Computed<any>>();
@@ -318,7 +345,13 @@ export function settlePendingSource(el: Computed<any>, source: Computed<any> = e
318345
// equal to the committed value notifies nobody — the source settling
319346
// is its verdict changing: it runs again. (Verdict readers exist only
320347
// with the verdict engine installed.)
321-
return holdWorkHook && node._config & CONFIG_VERDICT && enqueueSub(node);
348+
// D-41: a derivation of a staged error carries it (`stageMark`).
349+
return (
350+
holdWorkHook &&
351+
(node._config & CONFIG_VERDICT
352+
? enqueueSub(node)
353+
: el._config & CONFIG_STAGED_ERROR && stageMark(node, el))
354+
);
322355
visited.add(node);
323356
node._time = clock;
324357
const remaining = node._x?._pendingSources?.values().next().value;
@@ -1006,9 +1039,14 @@ export function propagateStatus(el: Computed<any>, status: number, error: any):
10061039
// it is served the committed value it already derived from (A10) and
10071040
// asks that question again. It waits on the source like any derivation
10081041
// (F-9), and asks its next question once, at the landing (#4397).
1042+
// A node carrying a staged error re-derives on a pending mark: its
1043+
// source asks again, and the staging it carried is not the answer
1044+
// (#4109, `stageMark`).
10091045
if (
10101046
sub._config & CONFIG_REDERIVE ||
1011-
(holdWorkHook && sub._config & CONFIG_VERDICT && !(pendingSource && holdWorkHook(sub, el))) ||
1047+
(holdWorkHook &&
1048+
(sub._config & CONFIG_VERDICT || (pendingSource && sub._config & CONFIG_STAGED_ERROR)) &&
1049+
!(pendingSource && holdWorkHook(sub, el))) ||
10121050
(status === STATUS_PENDING && link._gen !== sub._depGen)
10131051
) {
10141052
enqueueSub(sub);

‎packages/signals/src/core/core.ts‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,8 +463,14 @@ export function recompute(el: Computed<any>, create: boolean = false): void {
463463
// it joins nothing, so the write that reached it commits mainline.
464464
// `EFFECT_RENDER << 23` is CONFIG_FRAME (a render effect, a boundary's
465465
// tree and output), spelled from the effect type as at creation.
466+
// A verdict reader born into `tx` (`bornInto`: never committed) is the
467+
// hold's own work, whatever it asked before (D-25): it joins like any
468+
// held pass, so what it mounts is the hold's (D-13, #4467).
466469
if (tx._lane || el._config & CONFIG_LAGS) {
467-
} else if (!(el._config & (CONFIG_VERDICT | (EFFECT_RENDER << 23))))
470+
} else if (
471+
!(el._config & (CONFIG_VERDICT | (EFFECT_RENDER << 23))) ||
472+
(observeFlightHook && !(el._config & (EFFECT_RENDER << 23)) && bornInto(el, tx))
473+
)
468474
joinPassTx(tx, freshHook?.(el, el._statusFlags & STATUS_UNINITIALIZED));
469475
else if (
470476
tx !== flushTransaction &&
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
/**
2+
* S-46 (D-27, D-37; ruled 2026-10-30): the content a display-ahead `Show`
3+
* opens reads the screen, whoever opened the hold.
4+
*
5+
* A plain write to `id` is held because an async memo over it is on screen.
6+
* `<Show when={latest(id)}>` opens at once — `latest` is the read that asks
7+
* ahead — but a plain `id()` inside the branch is an independent read: it
8+
* means the same thing as the `<p>{id()}</p>` outside, the committed value.
9+
* The branch's first pass read the staging under a display-ahead reader, so
10+
* it is born held (D-27): it does not attach until the landing, and the
11+
* screen keeps the fallback. `latest(id)` inside shows `1` now; a `Loading`
12+
* inside shows its fallback now (S-31's form). Never `0` outside beside
13+
* `selected: 1` inside — two plain reads of one signal disagreeing on one
14+
* screen.
15+
*
16+
* S-31 (`verdict-mount-first-pass-3851`) pins the action + `Loading` form.
17+
* This is the plain-write, no-boundary form — "actions aren't special; they
18+
* are a way to extend the hold" — pinned so the rule's reach is explicit.
19+
*/
20+
import { describe, expect, it } from "vitest";
21+
import {
22+
createLoadingBoundary,
23+
createMemo,
24+
createRenderEffect,
25+
createRoot,
26+
createSignal,
27+
flush,
28+
latest,
29+
untrack
30+
} from "../src/index.js";
31+
32+
const settle = async () => {
33+
for (let i = 0; i < 3; i++) {
34+
await new Promise(r => setTimeout(r, 0));
35+
flush();
36+
}
37+
};
38+
39+
type Content = "plain" | "latest" | "loading";
40+
41+
async function run(content: Content) {
42+
const [id, setId] = createSignal(0);
43+
const gates: ((v: string) => void)[] = [];
44+
const fetchDetail = (v: number) => new Promise<string>(r => gates.push(() => r(`d${v}`)));
45+
let screenId: unknown;
46+
let slot: unknown;
47+
let screenDetail: unknown;
48+
createRoot(() => {
49+
// <p>{id()}</p>
50+
createRenderEffect(id, v => {
51+
screenId = v;
52+
});
53+
// <p>{detail()}</p> — the async over `id` that holds a write to it
54+
const detail = createMemo(() => fetchDetail(id()));
55+
createRenderEffect(detail, v => {
56+
screenDetail = v;
57+
});
58+
// <Show when={latest(id)} fallback="none">…</Show> — the branch is a
59+
// mount: a render effect created under the display-ahead reader, as
60+
// `Show` + `insert` create one for the child.
61+
const when = createMemo(() => latest(id) > 0);
62+
const children = createMemo(() =>
63+
when()
64+
? untrack(() => {
65+
if (content === "loading")
66+
return createLoadingBoundary(
67+
() => `selected: ${id()}`,
68+
() => "fallback"
69+
);
70+
createRenderEffect(
71+
() => `selected: ${content === "latest" ? latest(id) : id()}`,
72+
v => {
73+
slot = v;
74+
}
75+
);
76+
return "opened";
77+
})
78+
: "none"
79+
);
80+
createRenderEffect(
81+
() => {
82+
const c = children();
83+
return typeof c === "function" ? c() : c;
84+
},
85+
v => {
86+
// the mounted leaf writes the slot itself; "opened" is the branch
87+
// existing with its leaf not yet attached
88+
if (v !== "opened") slot = v;
89+
}
90+
);
91+
});
92+
flush();
93+
gates.shift()!("d0");
94+
await settle();
95+
const screens: unknown[] = [[screenId, slot, screenDetail]];
96+
97+
setId(1);
98+
flush();
99+
await settle();
100+
screens.push([screenId, slot, screenDetail]);
101+
102+
gates.shift()!("d1");
103+
await settle();
104+
screens.push([screenId, slot, screenDetail]);
105+
return screens;
106+
}
107+
108+
describe("S-46: the content a display-ahead Show opens reads the screen (plain-write hold)", () => {
109+
it("plain `id()` inside: the branch is born held, the fallback stays until the landing", async () => {
110+
expect(await run("plain")).toEqual([
111+
[0, "none", "d0"],
112+
[0, "none", "d0"],
113+
[1, "selected: 1", "d1"]
114+
]);
115+
});
116+
117+
it("`latest(id)` inside: the branch shows the held value now", async () => {
118+
expect(await run("latest")).toEqual([
119+
[0, "none", "d0"],
120+
[0, "selected: 1", "d0"],
121+
[1, "selected: 1", "d1"]
122+
]);
123+
});
124+
125+
it("a `Loading` inside: its fallback now, the content at the landing (S-31's form)", async () => {
126+
expect(await run("loading")).toEqual([
127+
[0, "none", "d0"],
128+
[0, "fallback", "d0"],
129+
[1, "selected: 1", "d1"]
130+
]);
131+
});
132+
});

0 commit comments

Comments
 (0)