This repository was archived by the owner on Oct 26, 2026. It is now read-only.
Repository navigation
Commit 8cd4db4
fix(components): recompile a react page on its content, not its schema identity (#13269)
Fixes #13268
Clause-②: no
## What changed
`ReactKindPage`
(`packages/components/src/renderers/layout/react-page.tsx`) built its
compile scope in a `useMemo` keyed on `[schema, adapter]`. `ReactRunner`
recompiles whenever the scope identity changes, and every compile mints
a new `Page` function, so a new schema object with the same content
remounted the page and wiped its `useState`. The console's `PageView`
hands `SchemaRenderer` a fresh spread of the page on every render, so
any `PageView` re-render reset a react page (measured on the showcase
Task Desk: `editId` reset and the open record drawer vanished).
The scope is now rebuilt only when what it is compiled from changes:
- the schema's **content**, compared structurally by a file-local
`sameContent` helper (plain objects and arrays by their own keys,
everything else by `Object.is`, cycle-safe). `page` in the scope carries
the whole schema, so this covers `source`, `data`, `variables`, and
every other page value the page can read (`context.params` included);
- the adapter, by identity (unchanged; the reason it stays a recompile
trigger is kept in the comment).
The cached scope lives in `useState` and is replaced during render when
the content moves (React's documented shape for state derived from
props), not in a `useMemo`: React may discard a memo, and here a new
object is a remount (AGENTS.md #10). A first draft held it in a ref;
`react-hooks/refs` flags reading a ref during render, so it moved to
state.
## Seam chosen, and why
`ReactKindPage`, not `PageView`. The defect is that the page keys its
compile on identity; any host can hand it a fresh object, and `PageView`
is only the one measured. Stabilising `PageView`'s spread would fix that
host and leave the contract identity-sensitive for every other.
`PageView.tsx` is untouched; StrictMode is untouched; `PageView`
re-renders are not suppressed. No new export or prop.
## Pins
(`packages/components/src/__tests__/react-page-content-identity.test.tsx`,
all under `React.StrictMode`)
- (a) a react page with `useState` set by a click keeps it across two
host re-renders that each hand it a new but equal schema object;
- (b) CONTROL: a changed `source` recompiles and the page resets;
- (c) CONTROL: a changed declared scope value (`variables.greeting`)
recompiles, the new value reaches the page, and the page resets.
Measured: scope values are compiled in, not passed as props, so a value
change reaches the page only through a recompile;
- (c2) CONTROL: a changed nested page value (`context.params`)
recompiles too.
`react-page-state.test.tsx` already had "survives a parent re-render",
but its host re-renders with a module-scope schema, the one shape a real
host does not produce; its header comment is updated to the new keying.
## Evidence
- Red on the unfixed tree (base `1ca759a16f`): (a) failed, `Tests 1
failed | 3 passed (4)`; the three controls passed.
- Ablation on the final implementation (head `c016ba798f`), via
`ablation-replace.mjs`: `!sameContent(compiled.schema, schema)` replaced
by `compiled.schema !== schema` (anchor x1 to x0, blob `149963d2927e` to
`16dddb7d4244`); (a) went red, `Tests 1 failed | 3 passed (4)`. Restored
by the tool's trap: blob after restore
`149963d2927e6dc51a1ff183e1ca24863ab6e077` equals the HEAD blob, `git
diff HEAD` empty. The test imports the renderer through `../renderers`
(source), so no build was in the path.
- Test family naming the touched file (20 existing files that name
`react-page` / `ReactKindPage` across components, console,
plugin-charts, plugin-list, sdui-parser, types, core, plus the new
file), `--maxWorkers=1`, at `c016ba798f`: `Test Files 21 passed (21)`,
`Tests 764 passed (764)`.
- `pnpm --filter @object-ui/components type-check` (after `pnpm --filter
'@object-ui/components^...' build`) exit 0 at `c016ba798f`;
`tsconfig.test.json --listFiles` includes the new test.
- `eslint --no-inline-config` on the 3 changed TS files: 0 errors.
`react-page.tsx` warnings: the same six pre-existing `no-explicit-any`
as base, minus the base's `react-hooks/exhaustive-deps` (the memo it sat
on is gone).
- Pre-tsc battery: `check:phantom-deps`, `self-import`,
`unreferenced-sources`, `doc-example-readers`, `handler-key-reads`,
`side-effects-array`, `element-data-source-declaration`, `spec-symbols`,
`action-forward-parity`, `designer-field-key-parity`,
`icon-record-names`, `i18n-keys`, `i18n-drift`, `i18n-designer-parity`,
`control-bytes`, `check-hand-rolled-comment-mask.mjs`,
`check-changeset-fixed.mjs`, `check-changeset-presence.mjs`,
`check:new-line-citations` all exit 0. `check:spec-floors` exit 1 with
"no-artifact: Build the workspace before running this gate": NOT
MEASURED (it reads built artifacts, and no full workspace build was run
here).
Declared to CI: the full `packages/components/` directory (no
whole-directory run here; the container's test lock is shared).
## Acceptance notes
- `PageView.tsx` still hands a fresh spread every render. That is now
harmless to react pages; other blocks under it are not in this card's
scope.
- A host that puts a non-plain value (a function, a `Date`) in the page
schema and hands a new one every render will still recompile each time:
`sameContent` compares such values by identity, the conservative answer.
Whether any producer of page metadata does that was not searched.
Changeset: `.changeset/13268-react-page-identity.md` (patch,
`@object-ui/components`).
Session: `https://claude.ai/code/session_01XVp19E1MYUTFM3dnkwz8gB`
---
_Generated by [Claude
Code](https://claude.ai/code/session_01XVp19E1MYUTFM3dnkwz8gB)_
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent a29f615 commit 8cd4db4
4 files changed
Lines changed: 200 additions & 26 deletions
File tree
- .changeset
- packages/components/src
- __tests__
- renderers/layout
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
15 | 17 | | |
16 | 18 | | |
17 | 19 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
148 | 148 | | |
149 | 149 | | |
150 | 150 | | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
151 | 202 | | |
152 | 203 | | |
153 | 204 | | |
| |||
195 | 246 | | |
196 | 247 | | |
197 | 248 | | |
198 | | - | |
199 | | - | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
200 | 261 | | |
201 | 262 | | |
202 | 263 | | |
203 | | - | |
| 264 | + | |
204 | 265 | | |
205 | 266 | | |
206 | | - | |
207 | | - | |
208 | | - | |
209 | | - | |
210 | | - | |
211 | | - | |
212 | | - | |
213 | | - | |
214 | | - | |
215 | | - | |
216 | | - | |
217 | | - | |
218 | | - | |
219 | | - | |
220 | | - | |
221 | | - | |
222 | | - | |
223 | | - | |
224 | | - | |
225 | | - | |
226 | | - | |
227 | | - | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
228 | 274 | | |
229 | 275 | | |
230 | 276 | | |
| |||
0 commit comments