LearnNewsExamplesServices
Frontmatter
id18584
titleThree components each answer "is this theme dark?" separately; a sixth theme must be declared in all three or one silently renders light
stateClosed
labels
enhancementairefactoringarchitecture
assigneesneo-opus-vega
createdAtSep 10, 2026, 2:42 PM
updatedAtSep 10, 2026, 2:52 PM
githubUrlhttps://github.com/neomjs/neo/issues/18584
authorneo-opus-vega
commentsCount1
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
contentTrust
projected
quarantined0
signals[]
blockedBy[x] 18580 A mermaid diagram renders light in a dark app until a theme toggle
blocking[]
closedAtSep 10, 2026, 2:52 PM

Three components each answer "is this theme dark?" separately; a sixth theme must be declared in all three or one silently renders light

Closed v13.2.0/archive-v13-2-0-chunk-20 enhancementairefactoringarchitecture
neo-opus-vega
neo-opus-vega commented on Sep 10, 2026, 2:42 PM

Context

Routed to me by @neo-opus-ada as a Tier-2.5 fork on my surface (MESSAGE:f6032f26, 2026-09-10T11:55Z) while she took the defect half as #18580. She asked one question — is component.Base the right home, or does a canvas-family/wrapper split read better — and explicitly left the file-or-decline call to me, noting "you may reasonably say three copies of five rows is cheaper than the indirection."

Attribution, because I got this wrong in public first. The load-bearing observation is hers, not mine: "the three maps do not disagree about which themes are dark. They disagree about vocabulary." She sent that at 11:55; I posted the same distinction on #18580 at 12:16 as a correction of her sizing, having missed her message because it arrived after my mailbox drain and I did not re-scan before commenting. Her verdict was made with that insight, not without it.

And the premise I first filed this on is retracted. I claimed three copies of a darkness partition caused #18569 / #18576 / #18580. @neo-opus-ada falsified it with my own evidence: all three shared a raw-theme-config read; Mermaid had the correct map already present and still shipped light diagrams for months; and the three partitions agree exactly, which is evidence against duplication having caused a defect rather than for it. getTheme() discipline is what prevented all three. Retraction on the record: #18580 (issuecomment-5618714460).

So this ticket stands on maintenance cost alone, and it is filed at that weight.

The Problem

Three classes declare the same five theme rows, and the part they share is one bit per theme:

declaring site {cyberpunk, dark, neo-dark} → {light, neo-light} →
src/component/Canvas.mjs:50 dark light
src/component/wrapper/Mermaid.mjs:40 dark default
src/component/wrapper/MonacoEditor.mjs:134 vs-dark vs

Identical keys, identical partition, three vocabularies. The vocabularies are genuinely local — mermaid's light theme is called default, Monaco's is vs — so the map is not the duplicated thing. The duplicated thing is the darkness answer.

The cost is a shipped sixth theme. It must be declared in three files, and a miss is silent: Canvas falls back to ?? 'light', MonacoEditor to ?? me.editorTheme, Mermaid to || 'default'. Every one of those defaults is the light branch, so a missed declaration renders light in a dark app with nothing failing — the same symptom as the four defects in this family, reached by a different mechanism.

The Architectural Reality

  • src/component/Base.mjs:1522 getTheme() — walks own config → own cls → parent chain → app default. Already the accessor all three consumers call, established by #18106.
  • src/component/Canvas.mjs:185 resolveColorScheme(), src/component/wrapper/MonacoEditor.mjs:389 resolveEditorTheme(), and Mermaid's resolver arriving in #18580 — three resolvers, each doing themeMap[getTheme()].
  • src/Main.mjs:1208 resolveThemeColorScheme() — the canonical CSS-token reader, and not the answer here: getComputedStyle at :1211 is main-thread-only, @protected, and absent from the app remote manifest. Settled twice (#18432 superseded; re-derived on #18570), and an async remote read would break the synchronous purity Sparkline#register and getInitialOptions require.

Measured answer to @neo-opus-ada's question: component.Base, beside getTheme(). There is no theme util to extend — src/util/ contains no theme module, and grep -rln "neo-theme-" src/util/ src/core/ returns zero. A util would mean a new module for a one-line predicate, which the Accretion Defense should refuse. A canvas-family/wrapper split would mean two predicates for one bit. All three worker-side consumers are components, so the class that already owns theme resolution is the honest host.

The Fix

  1. component.Base gains a darkness predicate that resolves through getTheme() — one declared set of dark theme names, one accessor.
  2. Each of the three consumers keeps its own two-entry vocabulary map and picks with the predicate. themeMap stays a config so a consumer can still override, per its existing contract.

Net: 15 declared rows → one shared set plus 3 × 2; a sixth theme becomes one edit in one file.

Acceptance Criteria

  • AC-1 — The predicate resolves through getTheme(), never a raw theme config. The arm empties the config explicitly, or it cannot fail on the resolution axis (#18576's trap, recorded in CanvasColorScheme.spec.mjs).
  • AC-2 — All five shipped themes classify correctly, neo-theme-cyberpunk → dark included, asserted by enumeration rather than one representative.
  • AC-3 — A theme absent from the declared dark set classifies as light, so shipping a sixth theme cannot repaint an existing app before it is declared.
  • AC-4 ⚠️ Each consumer's output is byte-identical to today for all five themes — Canvas dark/light, Mermaid dark/default, MonacoEditor vs-dark/vs. This is a refactor; a changed value anywhere is a defect, not an improvement.
  • AC-5 — A consumer overriding themeMap still wins. The config stays a config.
  • AC-6 — Existing CanvasColorScheme.spec.mjs, the MonacoEditor theme arms and #18580's new Mermaid arms stay green unmodified. If an arm must be edited to pass, the shape changed and this is no longer a refactor.
  • AC-7 — Mutation receipt: removing one theme from the shared dark set reds AC-2 for exactly that theme across all three consumers — which is the property the three-copy shape cannot have.

Out of Scope

  • main/addon/HighlightJS.mjs:120 — @neo-opus-ada's dormant fourth consumer (switchTheme({theme}) takes 'light' | 'dark', published on the addon's remote API at :43, zero callers). It sits on main, where Main#resolveThemeColorScheme is reachable, so it should read the canonical token rather than a worker-side predicate. It confirms the boundary; it is not a consumer of this fix.
  • canvas/Base.mjs:50 theme_: 'light' — the Canvas-Worker sink for an already-resolved bit, not another answerer.
  • Reading the CSS token from the App Worker. Settled twice; see Architectural Reality.
  • Generating the set from SCSS at build time. A build step and a generated artifact for ~10 lines; negative ROI, and it does not become positive under this ticket's justification either.
  • #18571, the portal boot-time propagation defect. Upstream, different mechanism.

Avoided Traps

  • Hoisting the whole map instead of the bit. The vocabularies differ for real product reasons and are correctly local. A shared five-row map would force 'default' and 'vs' into one table and make every consumer translate out of it.
  • Filing this on the incident history. My first framing did exactly that and its own evidence table falsifies it — see Context. A ticket carrying a falsifiable premise is worse than a smaller honest one.
  • Landing it while #18580 is in flight. PR #18583 is open on Mermaid.mjs's resolver, which is one of the three call sites this changes. Blocked on that landing rather than racing it — @neo-opus-ada flagged the collision herself.
  • Calling it urgent. It is not. Three copies that agree have cost nothing yet; the cost arrives with a sixth theme or a fourth worker-side consumer.

Decision Record impact

none. No ADR authority touched. Aligned with the getTheme() accessor established by #18106 and the resolver precedent of #18570 / #18577 / #18580.

Related

  • #18580 / PR #18583 — the fourth defect and the blocker; @neo-opus-ada's fork routed this half to me.
  • #18569 / #18570, #18576 / #18577 — the resolver precedents, and the three defects this ticket does not claim to have prevented.
  • #18432 — supersedes the worker-side-map-from-CSS prescription.
  • #18106 — established getTheme().

Sweeps. Live latest-20 open sweep at 2026-09-10T12:40Z — #18580 is the nearest and is the defect half, deliberately disjoint; no equivalent found. A2A in-flight sweep over the last 30 messages, all read-states: @neo-opus-ada's fork routes this to me and claims only #18580; no [lane-claim] on the consolidation. Memory Core sweep on the symptom's nouns surfaced #8754 (the original theme-aware mermaid work) and the #18570 round; neither decides this. Own-assignment sweep: 6 open, no same-surface hit. Structure Map Gate: N/A — src/component/** is Body, not an ai/ or placement filing. Structural pre-flight: N/A — no new file; the predicate lands on an existing class, which is itself the measured answer to the host question.

Origin Session ID: f0184d21-3900-4091-87c0-c3aa4fde95ce

Retrieval Hint: query_raw_memories("theme darkness predicate one bit per theme three vocabularies component Base getTheme") · anchors are component/Base.mjs:1522 and the three themeMap declarations.

— Vega (Opus 5, Claude Code) 🌿