Context
src/component/wrapper/Mermaid.mjs is the fourth component found carrying the defect #18569 fixed for MonacoEditor and #18576 fixed for SharedCanvas / Sparkline: it resolves its theme from the raw theme config, which is null by design for any component that inherits one.
It is also the class both reviewers cited as the correct precedent while fixing the other three — @neo-opus-grace in her #18570 response and @neo-opus-vega in #18576. Each read its themeMap for the shape they came for; neither opened the lookup two tokens away. The sentence worth keeping is Vega's: reading a sibling for the shape you came for is not auditing the sibling. A precedent cited by two reviewers is not thereby audited.
Measured on dev by @neo-opus-grace on the dark portal tutorial route, rather than read:
| observed |
value |
document.body |
neo-theme-neo-dark |
| rendered node fill |
rgb(236, 236, 255) |
| label colour |
rgb(51, 51, 51) |
| generated style block |
…fill:#333; |
That is mermaid's default palette — near-white nodes, #333 text — in a dark app.
Live latest-open sweep: checked latest 20 open issues at 2026-09-10T11:50:30Z; no equivalent found. A2A in-flight claim sweep: 30 messages, all read-states, no [lane-claim]/[lane-intent] on this scope. Memory Core rationale sweep: "diagram renders light colours inside a dark themed app, theme map duplicated across components" — surfaced #8754 (2026-01-17, the original theme-aware mermaid work, which centralised the map in the addon and was later moved into the component) and the #18570 round; neither covers this lookup. Own-assignment sweep: 12 open, no same-surface hit. Epic-layer sweep: N/A, not an epic filing. Structure Map Gate: N/A — src/component/** is Body, not an ai/ / Agent OS / placement filing.
The Problem
render() builds the diagram's front-matter config from me.theme:
theme = me.mermaidTheme || me.themeMap[me.theme] || 'default',
themeMap[null] is undefined, so the || chain falls through to 'default', which is mermaid's light theme.
The failure is asymmetric, which is why it survived four passes over this file. render() has three triggers:
| trigger |
me.theme at call time |
result |
afterSetMounted:74 — first render |
null for an inheriting child |
light, always |
afterSetTheme:86 — live toggle |
the new value, just assigned |
correct |
afterSetValue:98 — new diagram code |
null for an inheriting child |
light, always |
So anyone who touches the theme switcher sees it work. container.Base#afterSetTheme stamps live items only on a change and leaves construction to createItem, so a child inside a themed scope carries no theme of its own — #18106 records that as deliberate and added getTheme() as the accessor that answers anyway.
Markdown#afterSetTheme:114 pushes the theme down to children on change only, so it does not cover the construction path either.
The Architectural Reality
src/component/wrapper/Mermaid.mjs:133 — the defective lookup.
src/component/Base.mjs:1522 — getTheme(), which walks own-config → own-cls → parent chain → app default.
src/component/wrapper/MonacoEditor.mjs:385 — resolveEditorTheme(), the corrected precedent: me.themeMap[theme] ?? me.editorTheme where theme = me.useThemeAwareness && me.getTheme().
src/component/Canvas.mjs — resolveColorScheme(), the same shape for the canvas family.
Mermaid is now the only one of the four with a declared map and no named resolver. That asymmetry is the reason it reads as correct: the map is the part a reviewer looks at, and it was never the broken half.
The five-row duplication is deliberately not in scope here — see Out of Scope.
The Fix
src/component/wrapper/Mermaid.mjs — add resolveTheme(), mirroring resolveEditorTheme() / resolveColorScheme(), resolving through getTheme(); render() calls it. The docblock carries the invariant (never the theme config, and why), because its absence here is what let two reviewers cite this file as exemplary.
test/playwright/unit/component/MermaidTheme.spec.mjs — new spec, sibling-lift from CanvasColorScheme.spec.mjs (flat unit/component/, matching Sparkline.spec.mjs and GetTheme.spec.mjs; no new directory, so structural pre-flight takes the Stage 1 fast path).
The arm must empty the theme config explicitly before asserting, or it cannot fail on the resolution axis — createItem populates an inherited theme on the unit tier's construction path, so a resolver reading the config would answer correctly there and the arm would witness only the mapping. That trap is #18576's, recorded in CanvasColorScheme.spec.mjs, and it applies unchanged here.
Contract Ledger
| Target Surface |
Source of Authority |
Proposed Behavior |
Fallback |
Docs |
Evidence |
Neo.component.wrapper.Mermaid#resolveTheme() (new, @protected) |
component.Base#getTheme() (src/component/Base.mjs:1522, established by #18106) |
Returns mermaidTheme when explicitly set, else themeMap[getTheme()], else 'default'. The override is guarded by ` |
|
, not ??— under??an emptymermaidThemewould win and emittheme: `, which renders nothing |
'default' for a theme the map does not carry, so shipping a sixth theme cannot repaint an app |
Neo.component.wrapper.Mermaid#themeMap (existing config) |
unchanged |
unchanged — the five shipped rows |
unchanged |
unchanged |
Existing rows asserted per-theme by the new spec |
Neo.component.wrapper.Mermaid#mermaidTheme (existing config) |
unchanged |
unchanged — an explicit value still wins over resolution |
unchanged |
unchanged |
Asserted by an override arm |
Decision Record impact: none. No ADR authority is touched. Aligned with the getTheme() accessor established by #18106 and the resolver precedent set by #18570 / #18577.
Acceptance Criteria
Out of Scope
- Collapsing the five-row map into one source. Three copies now declare the same five theme rows —
component/Canvas.mjs:50, wrapper/Mermaid.mjs:40, wrapper/MonacoEditor.mjs:134 — across four consumer classes. That is real and worth doing, but it is an architectural change on @neo-opus-vega's surface with her stated shape (a worker-side theme→scheme source, each consumer mapping its own vocabulary locally) and it is being routed to her separately. Bundling it here would put a one-token defect fix behind a three-file refactor.
- Exposing the canonical
--neo-color-scheme reader to the App Worker. Settled as the wrong fix, twice — see Avoided Traps.
#18571, the upstream portal theme propagation bug. Related surface, different mechanism.
Avoided Traps
Rejected: read the canonical --neo-color-scheme token instead of a hardcoded map. Every theme declares it (resources/scss/theme-*/Global.scss, all five verified), and Neo.Main#resolveThemeColorScheme:1208 reads it — so a shared map looks like duplicated knowledge that CSS already owns. It is not available here. That reader calls getComputedStyle() at Main.mjs:1211: main-thread only, and @protected / absent from the app remote manifest. @neo-opus-grace filed the worker-side-map prescription as #18432 and then publicly superseded it before implementing, for this reason; @neo-opus-vega re-derived and confirmed it against #18570. Her argument is stronger than the original: Sparkline.mjs:190 builds a synchronous register() payload and resolveEditorTheme must stay pure for getInitialOptions, so an async remote read would reintroduce the ordering hazard #18355 removed. The declared map and the declared token are two correct answers to two different questions. Recorded here so a fifth session does not re-derive it a third time.
Rejected: generate the map from the SCSS at build time. Would make CSS the single source and stay synchronous in the worker, but buys ~10 lines of map at the cost of a build step and a generated artifact in the dependency graph. Negative ROI against the Accretion Defense until a sixth theme actually ships.
Rejected: fix the lookup inline without a named resolver. One token, no new surface — but it leaves Mermaid the only one of the four with a declared map and no resolver, which is exactly the asymmetry that made two reviewers read this file as exemplary. The docblock is the artifact that stops the fifth re-derivation.
Related
#18569 / #18570 — the same defect in MonacoEditor, and the getTheme() precedent.
#18576 / #18577 — the same defect in SharedCanvas / Sparkline, and the spec shape this lifts from.
#18106 — established getTheme() as the accessor for inherited themes.
#18432 — supersedes the worker-side-map-from-CSS prescription.
#18571 — upstream portal theme propagation; adjacent, not blocking.
#18578 — the arm-cannot-fail lesson AC-8 encodes.
#8754 — the original theme-aware mermaid implementation (2026-01-17).
Retrieval Hint: "mermaid resolves theme from raw config null by design getTheme inheriting child"
Context
src/component/wrapper/Mermaid.mjsis the fourth component found carrying the defect#18569fixed forMonacoEditorand#18576fixed forSharedCanvas/Sparkline: it resolves its theme from the rawthemeconfig, which isnullby design for any component that inherits one.It is also the class both reviewers cited as the correct precedent while fixing the other three — @neo-opus-grace in her
#18570response and @neo-opus-vega in#18576. Each read itsthemeMapfor the shape they came for; neither opened the lookup two tokens away. The sentence worth keeping is Vega's: reading a sibling for the shape you came for is not auditing the sibling. A precedent cited by two reviewers is not thereby audited.Measured on
devby @neo-opus-grace on the dark portal tutorial route, rather than read:document.bodyneo-theme-neo-darkrgb(236, 236, 255)rgb(51, 51, 51)…fill:#333;That is mermaid's
defaultpalette — near-white nodes,#333text — in a dark app.Live latest-open sweep: checked latest 20 open issues at 2026-09-10T11:50:30Z; no equivalent found. A2A in-flight claim sweep: 30 messages, all read-states, no
[lane-claim]/[lane-intent]on this scope. Memory Core rationale sweep:"diagram renders light colours inside a dark themed app, theme map duplicated across components"— surfaced#8754(2026-01-17, the original theme-aware mermaid work, which centralised the map in the addon and was later moved into the component) and the#18570round; neither covers this lookup. Own-assignment sweep: 12 open, no same-surface hit. Epic-layer sweep: N/A, not an epic filing. Structure Map Gate: N/A —src/component/**is Body, not anai// Agent OS / placement filing.The Problem
render()builds the diagram's front-matter config fromme.theme:theme = me.mermaidTheme || me.themeMap[me.theme] || 'default',themeMap[null]isundefined, so the||chain falls through to'default', which is mermaid's light theme.The failure is asymmetric, which is why it survived four passes over this file.
render()has three triggers:me.themeat call timeafterSetMounted:74— first rendernullfor an inheriting childafterSetTheme:86— live toggleafterSetValue:98— new diagram codenullfor an inheriting childSo anyone who touches the theme switcher sees it work.
container.Base#afterSetThemestamps live items only on a change and leaves construction tocreateItem, so a child inside a themed scope carries no theme of its own —#18106records that as deliberate and addedgetTheme()as the accessor that answers anyway.Markdown#afterSetTheme:114pushes the theme down to children on change only, so it does not cover the construction path either.The Architectural Reality
src/component/wrapper/Mermaid.mjs:133— the defective lookup.src/component/Base.mjs:1522—getTheme(), which walks own-config → own-cls→ parent chain → app default.src/component/wrapper/MonacoEditor.mjs:385—resolveEditorTheme(), the corrected precedent:me.themeMap[theme] ?? me.editorThemewheretheme = me.useThemeAwareness && me.getTheme().src/component/Canvas.mjs—resolveColorScheme(), the same shape for the canvas family.Mermaid is now the only one of the four with a declared map and no named resolver. That asymmetry is the reason it reads as correct: the map is the part a reviewer looks at, and it was never the broken half.
The five-row duplication is deliberately not in scope here — see Out of Scope.
The Fix
src/component/wrapper/Mermaid.mjs— addresolveTheme(), mirroringresolveEditorTheme()/resolveColorScheme(), resolving throughgetTheme();render()calls it. The docblock carries the invariant (never thethemeconfig, and why), because its absence here is what let two reviewers cite this file as exemplary.test/playwright/unit/component/MermaidTheme.spec.mjs— new spec, sibling-lift fromCanvasColorScheme.spec.mjs(flatunit/component/, matchingSparkline.spec.mjsandGetTheme.spec.mjs; no new directory, so structural pre-flight takes the Stage 1 fast path).The arm must empty the
themeconfig explicitly before asserting, or it cannot fail on the resolution axis —createItempopulates an inherited theme on the unit tier's construction path, so a resolver reading the config would answer correctly there and the arm would witness only the mapping. That trap is#18576's, recorded inCanvasColorScheme.spec.mjs, and it applies unchanged here.Contract Ledger
Neo.component.wrapper.Mermaid#resolveTheme()(new,@protected)component.Base#getTheme()(src/component/Base.mjs:1522, established by#18106)mermaidThemewhen explicitly set, elsethemeMap[getTheme()], else'default'. The override is guarded by `, not??— under??an emptymermaidThemewould win and emittheme: `, which renders nothing'default'for a theme the map does not carry, so shipping a sixth theme cannot repaint an appNeo.component.wrapper.Mermaid#themeMap(existing config)Neo.component.wrapper.Mermaid#mermaidTheme(existing config)Decision Record impact:
none. No ADR authority is touched. Aligned with thegetTheme()accessor established by#18106and the resolver precedent set by#18570/#18577.Acceptance Criteria
resolveTheme()resolves throughgetTheme(), never thethemeconfig.neo-theme-cyberpunk→darkincluded.themeconfig explicitly emptied, still resolves the scope's theme.themeis not overruled by the scope it sits in.mermaidThemestill wins over resolution.'default'.addon.rendercarries the resolved theme on the first render, with no theme change in between. The rendered SVG is not the assertion boundary — rendering happens in the Main thread addon — so the emittedcodeis where the component last controls the value, and it is the value that was wrong.me.themereds AC-3 and AC-7, with a byte-identical restore. An arm that cannot fail on the axis it names is the#18578failure, and it is the one this ticket must not repeat.Out of Scope
component/Canvas.mjs:50,wrapper/Mermaid.mjs:40,wrapper/MonacoEditor.mjs:134— across four consumer classes. That is real and worth doing, but it is an architectural change on @neo-opus-vega's surface with her stated shape (a worker-side theme→scheme source, each consumer mapping its own vocabulary locally) and it is being routed to her separately. Bundling it here would put a one-token defect fix behind a three-file refactor.--neo-color-schemereader to the App Worker. Settled as the wrong fix, twice — see Avoided Traps.#18571, the upstream portal theme propagation bug. Related surface, different mechanism.Avoided Traps
Rejected: read the canonical
--neo-color-schemetoken instead of a hardcoded map. Every theme declares it (resources/scss/theme-*/Global.scss, all five verified), andNeo.Main#resolveThemeColorScheme:1208reads it — so a shared map looks like duplicated knowledge that CSS already owns. It is not available here. That reader callsgetComputedStyle()atMain.mjs:1211: main-thread only, and@protected/ absent from theappremote manifest. @neo-opus-grace filed the worker-side-map prescription as#18432and then publicly superseded it before implementing, for this reason; @neo-opus-vega re-derived and confirmed it against#18570. Her argument is stronger than the original:Sparkline.mjs:190builds a synchronousregister()payload andresolveEditorThememust stay pure forgetInitialOptions, so an async remote read would reintroduce the ordering hazard#18355removed. The declared map and the declared token are two correct answers to two different questions. Recorded here so a fifth session does not re-derive it a third time.Rejected: generate the map from the SCSS at build time. Would make CSS the single source and stay synchronous in the worker, but buys ~10 lines of map at the cost of a build step and a generated artifact in the dependency graph. Negative ROI against the Accretion Defense until a sixth theme actually ships.
Rejected: fix the lookup inline without a named resolver. One token, no new surface — but it leaves Mermaid the only one of the four with a declared map and no resolver, which is exactly the asymmetry that made two reviewers read this file as exemplary. The docblock is the artifact that stops the fifth re-derivation.
Related
#18569/#18570— the same defect inMonacoEditor, and thegetTheme()precedent.#18576/#18577— the same defect inSharedCanvas/Sparkline, and the spec shape this lifts from.#18106— establishedgetTheme()as the accessor for inherited themes.#18432— supersedes the worker-side-map-from-CSS prescription.#18571— upstream portal theme propagation; adjacent, not blocking.#18578— the arm-cannot-fail lesson AC-8 encodes.#8754— the original theme-aware mermaid implementation (2026-01-17).Retrieval Hint:
"mermaid resolves theme from raw config null by design getTheme inheriting child"