Context
Found while reviewing #18570, which repairs this exact pair of defects in component/wrapper/MonacoEditor. The same two live in two more components. Captured first as a defect-note to AGENT:*; promoted here because the sighting is independent of the PR that surfaced it and the fix pattern is now proven twice in-tree.
The Problem
Neo.app.SharedCanvas and Neo.component.Sparkline each carry both halves of #18569, and either alone renders a light canvas inside a dark app.
Half one — they read the raw theme config, which is null by design. component/Base.mjs:269 defaults theme_ to null, and #18111's getTheme() docblock records why: "a child inside a themed scope carries no theme class of its own by design". A component that inherits its theme never populates that config.
let mode = this.theme?.includes('dark') ? 'dark' : 'light';
theme: me.theme?.includes('dark') ? 'dark' : 'light',The optional chain makes it silent: null?.includes(...) is undefined, undefined is falsy, the ternary answers 'light'. A dark app gets a light canvas and nothing reports an error.
The afterSetTheme halves have the matching gate:
if (value && this.isCanvasReady) { … }
if (me.offscreenRegistered && value) { … }container.Base#afterSetTheme propagates to live items on a change and leaves construction to createItem, so these fire on a theme toggle and never on first render. That asymmetry is why the defect survives casual use: it works for anyone who interacts with it and fails for everyone who only loads the page.
Half two — the name is not the answer. src/Main.mjs:1199 states the contract in the engine's own words:
"Every theme states its own scheme as --neo-color-scheme in its Global.scss, because the name cannot be trusted to carry it: theme-cyberpunk is dark and is named neither."
Measured: resources/scss/theme-cyberpunk/Global.scss declares --neo-background-color: #0d1117 and --neo-color-scheme: dark, and 'neo-theme-cyberpunk'.includes('dark') is false. All five shipped themes declare the token, one declaration each, no disagreement.
The Architectural Reality
Two in-tree precedents, both correct, both reachable from these files:
src/component/wrapper/Mermaid.mjs:39 — a themeMap config mapping all five shipped themes onto the library's own names, cyberpunk included. Being a config rather than a constant lets a consumer extend it for a theme Neo does not ship.
src/component/wrapper/MonacoEditor.mjs at #18570's head — resolves through getTheme() and maps through a themeMap, with the resolver kept pure so the creation path can build a correct instance instead of repainting one.
Do not "fix" this by exposing the canonical reader to the App Worker. That prescription was already raised and superseded on #18432: "The author's pre-implementation correction supersedes the original worker-side map prescription. The schemes already exist in component theme declarations, and the value is needed by Main.windowOpen on the main thread where computed CSS is available." Neo.Main#resolveThemeColorScheme (src/Main.mjs:1208) is @protected and absent from the app remote manifest, and the reason is sound: the token lives in CSS on the main thread, so a worker-side read is an async round trip. Both call sites here need the answer synchronously at registration — Sparkline.mjs:190 builds a register() payload — so an async resolution would reintroduce exactly the creation-time ordering hazard #18355 removed by deleting its timeout(150).
The declared map is the right answer for a worker-side consumer. The canonical token is the right answer for the main thread. Both already exist; this ticket adopts the first.
The Fix
Per component, mirroring MonacoEditor at #18570:
- Resolve through
getTheme() rather than the theme config, at the hook and at the registration/ready site.
- Map through a
themeMap config rather than a substring test.
- Drop the
value && / me.theme?. guards that exist only because the config was expected to carry the answer.
Contract Ledger Matrix
| Target Surface |
Source of Authority |
Proposed Behavior |
Fallback |
Docs |
Evidence |
SharedCanvas#afterSetIsCanvasReady |
src/app/SharedCanvas.mjs:63 |
resolves via getTheme() + themeMap |
unmapped theme keeps today's 'light' |
JSDoc |
null?.includes() → undefined → 'light' |
SharedCanvas#afterSetTheme |
:124 |
same; gate no longer needs value |
unchanged on unmapped |
JSDoc |
fires on toggle only today |
Sparkline#afterSetTheme |
src/component/Sparkline.mjs:119 |
same |
unchanged on unmapped |
JSDoc |
offscreenRegistered && value |
Sparkline renderer registration |
:190 |
resolved theme in the register() payload |
'light' as today |
JSDoc |
synchronous payload — no async resolution |
themeMap config (new, ×2) |
Mermaid.mjs:39 precedent |
five shipped themes; consumer-extensible |
absent key → today's default |
JSDoc |
cyberpunk → dark |
Decision Record impact
none — two consumers call the wrong accessor and guess where a declared answer exists. No wire format, no new API, no ADR authority touched.
Acceptance Criteria
- AC-1 In a dark app, a canvas created under a themed host hands its renderer
'dark' in the first payload it sends, with no theme change in between. This is the half that fails today; a toggle-only witness would pass against the current code.
⚠️ Corrected during implementation, and the correction is a narrowing. This AC first said "render dark on first paint". The rendered pixel is unreachable by construction, not merely unreached: main/DomAccess.mjs:944 hands the node to the worker with transferControlToOffscreen(), after which the owning thread cannot read it. The registration payload is the last value the component controls and is exactly the value that was wrong, so it is the honest boundary. Recorded here rather than quietly asserted at a lower bar.
- AC-2 ⚠️ Both directions, on the same instance. Light host → light, dark host → dark. An arm that only checks dark passes against a component hardcoded dark.
- AC-3
neo-theme-cyberpunk renders dark in both components. This is the arm that distinguishes a map from a substring test, and it reds if anyone reintroduces includes('dark').
- AC-4 An unmapped theme falls back to today's value rather than guessing, so adding a theme cannot silently flip an existing app.
- AC-5 Neither component reads the raw
theme config for this decision any more: grep -n "theme?.includes\|value.includes('dark')" src/app/SharedCanvas.mjs src/component/Sparkline.mjs returns zero.
Out of Scope
component/Base.mjs#getTheme() and theme propagation — the resolver is correct and already returns the right answer to both callers.
- Exposing
resolveThemeColorScheme to the App Worker — superseded on #18432, and the synchronous-registration constraint above makes it worse here than there.
MonacoEditor — repaired by #18570; this ticket is the other two consumers.
- Any change to the
--neo-color-scheme token or its main-thread reader.
Avoided Traps
- Do not propagate
theme down so the config stops being null. #18111 records the null as deliberate and removed exactly that behaviour.
- Do not resolve the scheme asynchronously.
Sparkline.mjs:190 builds a synchronous register() payload; an await there reintroduces the ordering hazard #18355 removed.
- Do not assert the worker-side config and call it covered. #18569 measured a correct config that never reached the DOM; the arm has to read what renders.
- Do not extend
includes('dark') with more names. The map is the point — a two-way name guess cannot express a theme whose name carries nothing, which is the whole finding.
Related
- #18569 / #18570 — the same pair of defects in
MonacoEditor, and the fix this ticket mirrors.
- #18432 / PR #18436 — established
--neo-color-scheme as the declared truth, and superseded the worker-side prescription.
- #18111 / #18106 —
getTheme() and the null-by-design contract.
- #8845 / #8727 — where
includes('dark') was first authored, when the shipped themes were only light and dark.
Sweeps. Live latest-20 open sweep at 2026-09-09T23:41:02Z — no equivalent; nearest are #18569 (the same defect in a third component, being fixed) and #18571 (portal theme propagation, a different layer). All-state search on the problem's nouns returned #18432, #14681, #8727, all closed and all this feature's origin rather than duplicates. A2A claim sweep — no open claim on canvas or sparkline theming. Own-assignment sweep — no same-surface hit. Memory Core sweep on the problem's nouns surfaced #18432's superseded prescription, which is why the Out of Scope section names it.
Origin Session ID: 206b8400-7fe8-472e-8018-446e550b784b
Retrieval Hint: query_raw_memories("theme darkness cannot be inferred from the name cyberpunk themeMap null by design") · anchors are SharedCanvas.mjs:63/:124, Sparkline.mjs:119/:190, and Mermaid.mjs:39 for the shape.
— Vega (Opus 5, Claude Code) 🌿
Context
Found while reviewing #18570, which repairs this exact pair of defects in
component/wrapper/MonacoEditor. The same two live in two more components. Captured first as a defect-note toAGENT:*; promoted here because the sighting is independent of the PR that surfaced it and the fix pattern is now proven twice in-tree.The Problem
Neo.app.SharedCanvasandNeo.component.Sparklineeach carry both halves of #18569, and either alone renders a light canvas inside a dark app.Half one — they read the raw
themeconfig, which isnullby design.component/Base.mjs:269defaultstheme_tonull, and #18111'sgetTheme()docblock records why: "a child inside a themed scope carries no theme class of its own by design". A component that inherits its theme never populates that config.// src/app/SharedCanvas.mjs:63 — afterSetIsCanvasReady let mode = this.theme?.includes('dark') ? 'dark' : 'light'; // src/component/Sparkline.mjs:190 — at renderer registration theme: me.theme?.includes('dark') ? 'dark' : 'light',The optional chain makes it silent:
null?.includes(...)isundefined,undefinedis falsy, the ternary answers'light'. A dark app gets a light canvas and nothing reports an error.The
afterSetThemehalves have the matching gate:// src/app/SharedCanvas.mjs:124 if (value && this.isCanvasReady) { … } // src/component/Sparkline.mjs:119 if (me.offscreenRegistered && value) { … }container.Base#afterSetThemepropagates to live items on a change and leaves construction tocreateItem, so these fire on a theme toggle and never on first render. That asymmetry is why the defect survives casual use: it works for anyone who interacts with it and fails for everyone who only loads the page.Half two — the name is not the answer.
src/Main.mjs:1199states the contract in the engine's own words:Measured:
resources/scss/theme-cyberpunk/Global.scssdeclares--neo-background-color: #0d1117and--neo-color-scheme: dark, and'neo-theme-cyberpunk'.includes('dark')isfalse. All five shipped themes declare the token, one declaration each, no disagreement.The Architectural Reality
Two in-tree precedents, both correct, both reachable from these files:
src/component/wrapper/Mermaid.mjs:39— athemeMapconfig mapping all five shipped themes onto the library's own names, cyberpunk included. Being a config rather than a constant lets a consumer extend it for a theme Neo does not ship.src/component/wrapper/MonacoEditor.mjsat #18570's head — resolves throughgetTheme()and maps through athemeMap, with the resolver kept pure so the creation path can build a correct instance instead of repainting one.Do not "fix" this by exposing the canonical reader to the App Worker. That prescription was already raised and superseded on #18432: "The author's pre-implementation correction supersedes the original worker-side map prescription. The schemes already exist in component theme declarations, and the value is needed by
Main.windowOpenon the main thread where computed CSS is available."Neo.Main#resolveThemeColorScheme(src/Main.mjs:1208) is@protectedand absent from theappremote manifest, and the reason is sound: the token lives in CSS on the main thread, so a worker-side read is an async round trip. Both call sites here need the answer synchronously at registration —Sparkline.mjs:190builds aregister()payload — so an async resolution would reintroduce exactly the creation-time ordering hazard #18355 removed by deleting itstimeout(150).The declared map is the right answer for a worker-side consumer. The canonical token is the right answer for the main thread. Both already exist; this ticket adopts the first.
The Fix
Per component, mirroring
MonacoEditorat #18570:getTheme()rather than thethemeconfig, at the hook and at the registration/ready site.themeMapconfig rather than a substring test.value &&/me.theme?.guards that exist only because the config was expected to carry the answer.Contract Ledger Matrix
SharedCanvas#afterSetIsCanvasReadysrc/app/SharedCanvas.mjs:63getTheme()+themeMap'light'null?.includes()→undefined→'light'SharedCanvas#afterSetTheme:124valueSparkline#afterSetThemesrc/component/Sparkline.mjs:119offscreenRegistered && valueSparklinerenderer registration:190register()payload'light'as todaythemeMapconfig (new, ×2)Mermaid.mjs:39precedentdarkDecision Record impact
none— two consumers call the wrong accessor and guess where a declared answer exists. No wire format, no new API, no ADR authority touched.Acceptance Criteria
'dark'in the first payload it sends, with no theme change in between. This is the half that fails today; a toggle-only witness would pass against the current code.⚠️ Corrected during implementation, and the correction is a narrowing. This AC first said "render dark on first paint". The rendered pixel is unreachable by construction, not merely unreached:
main/DomAccess.mjs:944hands the node to the worker withtransferControlToOffscreen(), after which the owning thread cannot read it. The registration payload is the last value the component controls and is exactly the value that was wrong, so it is the honest boundary. Recorded here rather than quietly asserted at a lower bar.neo-theme-cyberpunkrenders dark in both components. This is the arm that distinguishes a map from a substring test, and it reds if anyone reintroducesincludes('dark').themeconfig for this decision any more:grep -n "theme?.includes\|value.includes('dark')" src/app/SharedCanvas.mjs src/component/Sparkline.mjsreturns zero.Out of Scope
component/Base.mjs#getTheme()and theme propagation — the resolver is correct and already returns the right answer to both callers.resolveThemeColorSchemeto the App Worker — superseded on #18432, and the synchronous-registration constraint above makes it worse here than there.MonacoEditor— repaired by #18570; this ticket is the other two consumers.--neo-color-schemetoken or its main-thread reader.Avoided Traps
themedown so the config stops being null. #18111 records the null as deliberate and removed exactly that behaviour.Sparkline.mjs:190builds a synchronousregister()payload; an await there reintroduces the ordering hazard #18355 removed.includes('dark')with more names. The map is the point — a two-way name guess cannot express a theme whose name carries nothing, which is the whole finding.Related
MonacoEditor, and the fix this ticket mirrors.--neo-color-schemeas the declared truth, and superseded the worker-side prescription.getTheme()and the null-by-design contract.includes('dark')was first authored, when the shipped themes were only light and dark.Sweeps. Live latest-20 open sweep at 2026-09-09T23:41:02Z — no equivalent; nearest are #18569 (the same defect in a third component, being fixed) and #18571 (portal theme propagation, a different layer). All-state search on the problem's nouns returned #18432, #14681, #8727, all closed and all this feature's origin rather than duplicates. A2A claim sweep — no open claim on canvas or sparkline theming. Own-assignment sweep — no same-surface hit. Memory Core sweep on the problem's nouns surfaced #18432's superseded prescription, which is why the Out of Scope section names it.
Origin Session ID: 206b8400-7fe8-472e-8018-446e550b784b
Retrieval Hint:
query_raw_memories("theme darkness cannot be inferred from the name cyberpunk themeMap null by design")· anchors areSharedCanvas.mjs:63/:124,Sparkline.mjs:119/:190, andMermaid.mjs:39for the shape.— Vega (Opus 5, Claude Code) 🌿