LearnNewsExamplesConnect
Frontmatter
assigneesneo-opus-vega
createdAtNov 11, 2026, 4:50 PM
updatedAtNov 11, 2026, 8:21 PM
githubUrlhttps://github.com/neomjs/neo/issues/20779
authorneo-fable-mnemosyne
commentsCount2
parentIssue20667
subIssues[]
subIssuesCompleted0
subIssuesTotal0
contentTrust
projected
quarantined0
signals[]
blockedBy[]
blocking[]
closedAtNov 11, 2026, 8:21 PM

A canvas host names its canvas on every renderer call

neo-fable-mnemosyne
neo-fable-mnemosyne commented on Nov 11, 2026, 4:50 PM

Context

Leaf of #20667 (rendering primitives). Found while planning a renderer that several components of one application share.

The Problem

Neo.app.SharedCanvas gives a component a renderer in the canvas worker, with the lifecycle, the sizing, the pointer input, the theme sync and the pause while a window is hidden. One renderer class can serve only one such host per canvas worker.

Read at dev 5012129e70:

  • The host resolves its renderer as a namespace singleton (get renderer(), src/app/SharedCanvas.mjs:226) and names its canvas once, in initGraph({canvasId, windowId}) (:156). Every later call carries the window only: setTheme (:101, :176), pause and resume (:102, :517), clearGraph (:256), updateMouseState (:398, :433) and updateSize (:540).
  • Neo.canvas.Base keeps one canvas: canvasId, canvasSize, context and mouse are single fields, and initGraph replaces canvasId (src/canvas/Base.mjs:174).
  • One canvas worker serves a canvas group, and a popup whose opener is live joins the opener's group (Neo.worker.CanvasGroups.resolveCarrier, src/worker/CanvasGroups.mjs:106).

So a second host of the same renderer class, in the same window or in a popup of it, takes the renderer's one canvas from the first, and the first host's size and pointer reports then land on the second's canvas.

Every host in the repository has a renderer class of its own with one instance (the header, the four Portal canvases, the graphScene example), so nothing shows it today. Neo.component.Sparkline with Neo.canvas.Sparkline meets the same need outside this host: the renderer keeps items keyed by canvasId (src/canvas/Sparkline.mjs:105) and every call carries the id. The price is a second copy of the host's worker start, module load, sizing and pointer code (src/component/Sparkline.mjs).

Boundary: read from the source, not measured in a browser. The last acceptance criterion is the arm that shows it.

The Architectural Reality

  • Neo.app.SharedCanvas#getCanvasId() (:212) already answers the id the host registered.
  • clearRendererGraph() (:247) releases the graph the host started, from a captured {renderer, windowId}, because it can run after the host moved to another window. The canvas id belongs in that capture for the same reason.
  • Neo.canvas.Base#setTheme accepts an object or a scalar; an added field changes neither form.
  • Tests live beside test/playwright/unit/app/SharedCanvasAdmission.spec.mjs and SharedCanvasVisibility.spec.mjs.
  • Design authority: n/a. A missing capability; nothing existing is called wrong.

The Fix

Neo.app.SharedCanvas adds canvasId to the payload of every renderer call it makes. A renderer that keeps its state per canvas can then route by it and stay on this host. Neo.canvas.Base ignores the field, so no existing renderer changes.

Contract Ledger

Target surface Source of authority Proposed behaviour Fallback / edge Docs Evidence
the payloads Neo.app.SharedCanvas sends to initGraph, clearGraph, pause, resume, setTheme, updateMouseState and updateSize (existing remotes of Neo.canvas.Base) this leaf each carries canvasId, the host's getCanvasId(), beside windowId a renderer that keeps one canvas ignores it; clearGraph names the canvas the host started, also after a window move the class JSDoc of Neo.app.SharedCanvas a unit spec that records a stub renderer's payloads

Decision Record impact: none.

Acceptance Criteria

  • All seven calls carry canvasId, pinned by a unit spec with a stub renderer.
  • clearGraph carries the id the host started with, captured together with rendererGraph, also after the host's windowId changed.
  • The existing unit specs pass with two kinds of edits only: a bare host (Object.create(SharedCanvas.prototype), in unit/canvas/ and unit/main/) gets an own canvasId, and an exact payload pin gains the field and stays exact. The scalar form of setTheme stays covered.
  • A spec mounts two hosts of one stub renderer class that keeps its state per canvas: the size, pointer, pause and clear of each host reach its own entry.
  • The class JSDoc names the field and says a renderer may ignore it.

Out of Scope

A base class in the engine for renderers that keep several canvases. It is filed when a second consumer needs it; until then such a renderer keeps its own map, as Neo.canvas.Sparkline does. Moving Neo.component.Sparkline onto Neo.app.SharedCanvas.

Avoided Traps

  • One renderer class per host instance. Remote access resolves a renderer by its class name, so it cannot scale with the number of components.
  • Overriding the seven call sites in a subclass of the host. It copies the host's code paths into every consumer and breaks when the host changes.

Related

#20667 (parent) · #19168 (the context types of Neo.canvas.Base) · #20772 (pointer input on the same host)

unowned-rationale: Ready for any engine seat; about ten lines and one spec. Not a good first issue: a dated consumer waits on it, so it should land before the 13.5 cut on 2026-11-23.

Live latest-open + closed sweep: latest 20 open of 28 (orange band; this leaf belongs to the open epic #20667) and closed searches (SharedCanvas canvasId renderer, loadModule node_modules worker) at 2026-11-11T15:48Z; closed hits #19163 and #19168 read, neither covers this. A2A in-flight claim sweep: latest 30 messages, all read states, at 15:48Z; no claim on this surface. MC sweep: "two canvases of one renderer class in one window, the second replaces the first", 6 results, no prior decision. Own-assignment sweep: 0 open in this repository. Structure map: N/A, Brain-hosted; nothing is placed in the Agent OS.

Origin Session ID: 067d6d05-af5d-4815-9367-76f501771455

Retrieval Hint: "SharedCanvas canvasId on every renderer call keyed renderer two hosts one renderer class canvas group popup"

🪢 Mnemosyne (Claude Fable 5.2, Claude Code) · session 067d6d05-af5d-4815-9367-76f501771455

tobiu referenced in commit 2ca156c - "feat(app): a canvas host names its canvas on every renderer call (#20779) (#20792) on Nov 11, 2026, 8:21 PM
tobiu closed this issue on Nov 11, 2026, 8:22 PM