LearnNewsExamplesConnect
Frontmatter
assigneesalhinawi
createdAtNov 21, 2026, 8:05 AM
updatedAtNov 22, 2026, 11:59 AM
githubUrlhttps://github.com/neomjs/neo/issues/21761
authorneo-opus-ada
commentsCount4
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
contentTrust
projected
quarantined1
signals[]
blockedBy[]
blocking[ ] 21835 An example opens on the theme of the catalog that launched it
closedAtNov 22, 2026, 11:59 AM

Ten examples each carry a copy of one start-theme resolver

Closed v14.0.0/archive-v14-0-0-chunk-6 enhancementhelp wantedgood first issueairefactoring
neo-opus-ada
neo-opus-ada commented on Nov 21, 2026, 8:05 AM

Please comment to claim before starting; check current assignees and linked PRs.

Context

Ten example onStart functions on dev (7cd0d6618e) each carry the same start-theme resolver: the theme ?theme= names when it is configured, else neo-theme-neo-dark when Neo.config.prefersDarkTheme is set and that theme is configured, else themes[0]:

  • examples/board/{basic,cardDesigns,cardEditor,columns,multiSelect,swimlanes,wipLimits}/app.mjs
  • examples/form/validation/app.mjs, examples/gantt/dependencies/app.mjs, examples/grid/tree/app.mjs

A defect-note (Vega, 2026-11-21) named the shape: the choice "has no single home in the engine". The open #21755 would copy the same twelve lines into 15 more app.mjs files; its review asks it not to and links here.

The Problem

Each copy is twelve lines that must stay identical, and each new example that wants the same start copies them again. A change to the rule (another dark theme, another query name) has to find every copy.

The Architectural Reality

Design authority: n/a — this calls no existing behavior wrong; each example keeps the start it has today.

  • src/util/Theme.mjs holds dependency-free theme rules shared by the runtime and source tooling (getThemeNamespace()), so a pure function over config values fits there.
  • Neo.config.prefersDarkTheme is set on the main thread from matchMedia('(prefers-color-scheme: dark)') (src/worker/Manager.mjs); Neo.config.url and Neo.config.themes reach the App worker with it.
  • main.addon.Stylesheet#addGlobalCss stamps themes[0] on the body; a root viewport mirrors its own theme there (container.Viewport#syncBodyTheme).

The Fix

Add resolveStartTheme({prefersDarkTheme, themes, url}) to src/util/Theme.mjs, returning the rule above, with @summary JSDoc. The ten onStart functions import it and pass its result as mainView.theme; their own copies go.

Acceptance Criteria

  • A unit test covers each branch of resolveStartTheme(): a configured ?theme=, an unknown ?theme=, a dark system with and without neo-theme-neo-dark configured, and a light system.
  • The ten examples call it, and none keeps a copy: grep -rln "dark *= *'neo-theme-neo-dark'" examples prints nothing.
  • Each of the ten starts in the same theme as on dev for a light system, a dark system, and ?theme=neo-theme-light.

Out of Scope

  • Whether the other examples should honour the system preference: each example opts in by calling the function.
  • The Portal's stored theme choice (apps/portal/view/ViewportController.mjs).
  • A dark theme other than neo-theme-neo-dark.

Avoided Traps

  • Resolving the start theme for every app inside the engine's boot: it would change the start of every app that does not opt in today.
  • Picking the dark theme by its name containing dark: the engine removed those name heuristics; the function names its theme.

Related

#21755 (the review that found it) · #21704 (theme switchers in the examples).

Live latest-open + closed sweep: latest 20 open, plus open searches "start theme prefersDarkTheme" and "theme query parameter app.mjs" and closed searches "start theme prefersDarkTheme examples" and "start theme resolver" (Out of Scope read on #8727) at 2026-11-21T07:05Z; no equivalent. Open issues: 77 (red band); no open ticket or epic owns example boot code, so this files standalone. A2A claim sweep (last 30, all states), Memory Core sweep ("examples start in the light theme on a system that prefers dark; every app.mjs re-implements the theme choice") and own assignments: no overlap.

unowned-rationale: Ready for a contributor; maintainers provide planning and review.

Retrieval Hint: "examples start theme resolver prefersDarkTheme app.mjs copies util Theme"

alhinawi
alhinawi Nov 21, 2026, 8:11 AM

Claiming this. Plan: add resolveStartTheme({prefersDarkTheme, themes, url}) to src/util/Theme.mjs, switch the ten listed onStart functions over to it, and add a unit test covering the branches in the acceptance criteria.

@github-actions - 2026-11-21T07:12:11Z

Thanks for claiming this, @alhinawi, and welcome back! Assigned to you — you can start now.

Your claim reserves this issue for 3 days (any comment here resets the clock; we still merge the first approve-worthy PR if another lands first or a claim goes quiet).

An automatic reply. How claims work [QUARANTINED_URL: github.com]

  • 2026-11-21T07:12:11Z @github-actions assigned to @alhinawi
alhinawi cross-referenced by PR #21764 on Nov 21, 2026, 8:13 AM
alhinawi referenced in commit 0269186 - "refactor(examples): one start-theme resolver serves the ten copied onStart functions (#21761) on Nov 21, 2026, 8:16 AM
alhinawi referenced in commit 49e4f1b - "refactor(examples): type the url the callers pass, pin its shape, name the module for what it holds (#21761) on Nov 22, 2026, 7:13 AM
tobiu referenced in commit 6072755 - "refactor(examples): one start-theme resolver serves the ten copied onStart functions (#21761) (#21764) on Nov 22, 2026, 11:59 AM
tobiu closed this issue on Nov 22, 2026, 11:59 AM