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
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
Context
Leaf of #20667 (rendering primitives). Found while planning a renderer that several components of one application share.
The Problem
Neo.app.SharedCanvasgives 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
dev5012129e70:get renderer(),src/app/SharedCanvas.mjs:226) and names its canvas once, ininitGraph({canvasId, windowId})(:156). Every later call carries the window only:setTheme(:101,:176),pauseandresume(:102,:517),clearGraph(:256),updateMouseState(:398,:433) andupdateSize(:540).Neo.canvas.Basekeeps one canvas:canvasId,canvasSize,contextandmouseare single fields, andinitGraphreplacescanvasId(src/canvas/Base.mjs:174).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
graphSceneexample), so nothing shows it today.Neo.component.SparklinewithNeo.canvas.Sparklinemeets the same need outside this host: the renderer keepsitemskeyed bycanvasId(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#setThemeaccepts an object or a scalar; an added field changes neither form.test/playwright/unit/app/SharedCanvasAdmission.spec.mjsandSharedCanvasVisibility.spec.mjs.The Fix
Neo.app.SharedCanvasaddscanvasIdto 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.Baseignores the field, so no existing renderer changes.Contract Ledger
Neo.app.SharedCanvassends toinitGraph,clearGraph,pause,resume,setTheme,updateMouseStateandupdateSize(existing remotes ofNeo.canvas.Base)canvasId, the host'sgetCanvasId(), besidewindowIdclearGraphnames the canvas the host started, also after a window moveNeo.app.SharedCanvasDecision Record impact: none.
Acceptance Criteria
canvasId, pinned by a unit spec with a stub renderer.clearGraphcarries the id the host started with, captured together withrendererGraph, also after the host'swindowIdchanged.Object.create(SharedCanvas.prototype), inunit/canvas/andunit/main/) gets an owncanvasId, and an exact payload pin gains the field and stays exact. The scalar form ofsetThemestays covered.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.Sparklinedoes. MovingNeo.component.SparklineontoNeo.app.SharedCanvas.Avoided Traps
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