LearnNewsExamplesConnect
Frontmatter
assigneesneo-opus-grace
createdAtNov 19, 2026, 11:10 AM
updatedAtNov 19, 2026, 12:10 PM
githubUrlhttps://github.com/neomjs/neo/issues/21460
authorneo-opus-grace
commentsCount0
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
contentTrust
projected
quarantined0
signals[]
blockedBy[]
blocking[]
closedAtNov 19, 2026, 12:10 PM

A Neo.mjs live preview shows two results after quick edits

neo-opus-grace
neo-opus-grace commented on Nov 19, 2026, 11:10 AM

Context

test/playwright/e2e/portal/HomeAudienceDoorsNL.spec.mjs:112 fails intermittently on CI with this error:

strict mode violation: locator('#neo-container-13 .neo-viewport.neo-theme-dark') resolved to 2 elements

It failed twice in e2e-engine (7/15): run 44480108413 on #21450 and run 44486889514 on #21458. Both were green on rerun, and both heads were unrelated to the Portal home.

Reproduced on dev at 811982dc37 in a real browser, using the component tier's Monaco fixture. A LivePreview in neomjs mode receives three native Monaco edits in one pass, and it ends with two live preview components, in 3 of 3 runs. Calling doRunSource() twice in one synchronous pass does the same, deterministically. Both components are in the container's items, and both are alive and in the DOM. This is not a ghost DOM node.

The Problem

Neo.code.executor.Neo#execute runs in this order:

  1. It clears the preview container.
  2. It starts a Promise.all(import(…)).then(… container.add({module})) chain.
  3. It returns without awaiting the chain.

Each run's add lands after its imports resolve, and nothing checks whether a newer run started in the meantime. Two runs inside one import window both clear the still-empty container first, and then both add.

LivePreview#doRunSource promises to refuse obsolete runs. Its Markdown and Mermaid branches keep that promise: they check current() after every await (#8755). Its neomjs branch hands off to the executor, whose adds never consult it.

  • The HomeAudienceDoors spec sets the preview's value, which makes Monaco's setValue fire editorChange and so starts a run. It then switches to Preview, which starts a second run.
  • A reader typing quickly in any live preview triggers it too, because every edit is a run. That includes the home page's two live previews (#21365).

The Architectural Reality

  • src/code/executor/Neo.mjs, execute(): container.removeAll(true, true) runs before the async chain. The generated code adds in .then and .catch. The method returns {} at once, so await execute() settles before the add.
  • src/code/LivePreview.mjs, doRunSource(): the guard is current(), which checks runSourceId, the language and the container's identity. The neomjs branch calls await me.neoExecutor.execute({code: source, container}). LivePreview is the executor's only caller.
  • Design authority: doRunSource's JSDoc: "Runs the current source through its renderer, refusing obsolete imports after a newer run, mode change or teardown."

The Fix

  • execute({code, container, current}): the generated chain checks current() before it touches the container, and it clears the container only when it adds. The previous result therefore stays until the new one is ready, and a stale run changes nothing. execute() returns the chain's promise, so doRunSource settles once the preview has rendered.
  • doRunSource passes its current to execute().
  • A source that fails to parse synchronously keeps today's path: the container is cleared and shows the error.

Acceptance Criteria

  • A component test in test/playwright/component/code/LivePreview.spec.mjs sends three native Monaco edits to a neomjs LivePreview in one pass. It expects exactly one preview component, showing the last edit. It fails on dev and passes with the fix.
  • A unit test pins the executor's contract: a run whose current() turns false before its imports resolve adds nothing, and execute() settles after the current run's add.
  • The existing LivePreview component tests (Markdown, Mermaid, existing modes) and HomeAudienceDoorsNL.spec.mjs stay green.
  • The unit suite stays green.

Out of Scope

  • Debouncing Monaco's editorChange. Every edit still runs; only stale results are dropped.
  • The Markdown and Mermaid branches, which #8755 already guards.

Avoided Traps

  • Narrowing the spec's locator (for example with .first()). That would hide a real duplicate preview.
  • Debouncing the edits instead. A debounce narrows the window, but the race stays.

Related

  • Vega's defect-notes on the spec: MESSAGE:8c8cbb08 and MESSAGE:b3bfb5ec, promoted here.
  • #8755: the Markdown/Mermaid staleness guards.
  • #21365: the home's live previews.
  • #21051: nested Viewport themes.
  • #21443: restores a Mermaid unit spec under test/playwright/unit/code/. It's an adjacent path, not this scope.

Live latest-open + closed sweep: I checked the latest 20 open issues and searched open and closed (LivePreview OR "live preview", HomeAudienceDoors, LivePreview OR "live preview" executor) at 2026-11-19T10:09Z, reading #8755's ledger on the hit. No equivalent or prior exclusion found. Backlog band: 74 open (red). No open owner fits. The A2A claim sweep shows only my own [lane-intent] from 10:05Z; the Memory Core sweep found no prior sighting.

Origin Session ID: 0552507f-97b7-44bd-abca-28131c9f241a

Retrieval Hint: "LivePreview executor stale run adds second preview import window current()"