Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.
Python agent-orchestrationai-agentai-coding-assistantclaude-codecoding-agentcomputer-usedesktop-applocal-firstmcppersonal-jarvisvoice-assistantvoice-coding
fix(ide): re-upload WebGL atlas pages after a shared-atlas merge
rubenluetke10-beep1e8a6ba99e8c
diff --git a/jarvis/ui/web/frontend/src/components/agentic/terminalRenderer.test.ts b/jarvis/ui/web/frontend/src/components/agentic/terminalRenderer.test.tsindex dac5d465da..6b3b162117 100644--- a/jarvis/ui/web/frontend/src/components/agentic/terminalRenderer.test.ts+++ b/jarvis/ui/web/frontend/src/components/agentic/terminalRenderer.test.ts@@ -5,6 +5,7 @@ import {MAX_WEBGL_PANES,attachTerminalRenderer,clearTerminalTextureAtlas,+ forgetUploadedAtlasPages,resetWebglPaneCount,type RendererDeps,type WebglLike,@@ -25,6 +26,14 @@ function fakeTerminal(opts: { refuse?: (addon: ITerminalAddon) => boolean } = {}class FakeWebgl implements WebglLike {disposed = false;private listeners: Array<() => void> = [];+ private mergeListeners: Array<() => void> = [];+ onRemoveTextureAtlasCanvas(listener: () => void) {+ this.mergeListeners.push(listener);+ return { dispose: () => {} };+ }+ mergeAtlasPages() {+ for (const l of [...this.mergeListeners]) l();+ }activate() {}dispose() {this.disposed = true;@@ -155,3 +164,44 @@ describe("clearTerminalTextureAtlas", () => {expect(a.clears()).toBe(1);});});++/** A WebGL-drawn terminal exposing the GPU page copies the addon keeps. */+function glTerminal(pages: number) {+ const textures = Array.from({ length: pages }, (_, i) => ({ version: i + 1 }));+ const refreshed: Array<[number, number]> = [];+ const term = {+ rows: 24,+ loadAddon() {},+ refresh(start: number, end: number) {+ refreshed.push([start, end]);+ },+ _core: { _renderService: { _renderer: { value: { _glyphRenderer: { value: { _atlasTextures: textures } } } } } },+ } as unknown as Terminal;+ return { term, textures, refreshed };+}++describe("an atlas page merge", () => {+ it("makes every WebGL pane re-upload its pages and repaint", async () => {+ const d = deps();+ const a = glTerminal(3);+ const b = glTerminal(3);+ attachTerminalRenderer(a.term, undefined, d);+ attachTerminalRenderer(b.term, undefined, d);++ d.webgls[0].mergeAtlasPages();+ d.webgls[1].mergeAtlasPages();++ // Invalidated synchronously: the merging pane uploads in the same frame.+ expect(a.textures.every((t) => t.version === -1)).toBe(true);+ expect(b.textures.every((t) => t.version === -1)).toBe(true);+ await new Promise((resolve) => requestAnimationFrame(() => resolve(null)));+ // One repaint each, however many panes reported the merge.+ expect(a.refreshed).toEqual([[0, 23]]);+ expect(b.refreshed).toEqual([[0, 23]]);+ });++ it("leaves a terminal without the addon's internals alone", () => {+ const { term } = fakeTerminal();+ expect(() => forgetUploadedAtlasPages(term)).not.toThrow();+ });+});diff --git a/jarvis/ui/web/frontend/src/components/agentic/terminalRenderer.ts b/jarvis/ui/web/frontend/src/components/agentic/terminalRenderer.tsindex 8708ec84ca..29f9297a07 100644--- a/jarvis/ui/web/frontend/src/components/agentic/terminalRenderer.ts+++ b/jarvis/ui/web/frontend/src/components/agentic/terminalRenderer.ts@@ -36,6 +36,19 @@* from coordinates that now point at other glyphs. Seen 2026-09-28: splitting* a new pane (whose mount restates theme and size, each with a clear) turned* the idle rows of three neighbouring panes into glyph soup.+ *+ * And the atlas can reshuffle itself without anyone asking. Once it holds the+ * maximum number of pages it MERGES four of them into one and shifts every+ * later page down an index. Each pane keeps its own GPU copy of every page and+ * decides whether to re-upload by comparing a per-INDEX version number — but+ * after the shift, index i holds a different page whose version can equal the+ * one the pane uploaded for the old page there. The pane then keeps sampling+ * the old texture with the new coordinates: overprinted, half-legible rows.+ * Maximizing and restoring a pane is what fills the atlas fastest (a whole+ * window of new glyphs, then every hidden neighbour repainting at once), which+ * is how it was reported (2026-09-28). Measured in a six-pane harness: 8 merges+ * left 6 panes drawing from a stale page; with {@link forgetUploadedAtlasPages}+ * on every merge, none. So a merge makes every WebGL pane re-upload its pages.*/import { CanvasAddon } from "@xterm/addon-canvas";@@ -57,6 +70,8 @@ export type TerminalRendererKind = "webgl" | "canvas" | "dom";/** The addon surface this module needs — narrowed so tests can hand in fakes. */export interface WebglLike extends ITerminalAddon {onContextLoss: (listener: () => void) => { dispose(): void };+ /** Fires for each page a shared-atlas merge removes (see the module comment). */+ onRemoveTextureAtlasCanvas?: (listener: () => void) => { dispose(): void };}export interface RendererDeps {@@ -71,12 +86,16 @@ const realDeps: RendererDeps = {let webglPanes = 0;+/** One repaint per frame after an atlas merge, however many panes report it. */+let repaintScheduled = false;+/** Terminals currently drawing with WebGL — the ones sharing a glyph atlas. */const webglTerminals = new Set<Terminal>();/** Test hook: forget every pane counted so far. */export function resetWebglPaneCount(): void {webglPanes = 0;+ repaintScheduled = false;webglTerminals.clear();}@@ -94,6 +113,51 @@ export function clearTerminalTextureAtlas(term: Terminal): void {}}+/**+ * The slice of the WebGL addon's internals that holds a pane's GPU copies of+ * the atlas pages. Not public API: every step is optional, so a future addon+ * that renames any of it degrades to doing nothing rather than throwing.+ */+interface GlyphRendererInternals {+ _core?: {+ _renderService?: {+ _renderer?: {+ value?: { _glyphRenderer?: { value?: { _atlasTextures?: Array<{ version: number }> } } };+ };+ };+ };+}++/**+ * Make `term` re-upload every atlas page on its next frame — what the addon+ * itself does when a pane switches atlas (`setAtlas`).+ */+export function forgetUploadedAtlasPages(term: Terminal): void {+ const textures = (term as unknown as GlyphRendererInternals)._core?._renderService?._renderer+ ?.value?._glyphRenderer?.value?._atlasTextures;+ if (!Array.isArray(textures)) return;+ for (const texture of textures) texture.version = -1;+}+++/**+ * An atlas merge just shifted the shared pages: every WebGL pane re-uploads+ * them. Synchronous for the invalidation — the merge happens inside one pane's+ * frame, before that pane uploads — and one repaint per animation frame for+ * everyone else, however many pages and panes reported the same merge.+ */+function handleAtlasMerge(): void {+ for (const term of webglTerminals) forgetUploadedAtlasPages(term);+ if (repaintScheduled) return;+ repaintScheduled = true;+ const repaint = () => {+ repaintScheduled = false;+ for (const term of webglTerminals) term.refresh?.(0, Math.max(0, term.rows - 1));+ };+ if (typeof requestAnimationFrame === "function") requestAnimationFrame(repaint);+ else repaint();+}+export interface AttachedRenderer {/** What is drawing right now — changes from "webgl" to "canvas" on a loss. */readonly kind: TerminalRendererKind;@@ -154,8 +218,10 @@ export function attachTerminalRenderer(webgl = null;}if (webgl) {+ const mergeSubscription = webgl.onRemoveTextureAtlasCanvas?.(handleAtlasMerge);const lossSubscription = webgl.onContextLoss(() => {lossSubscription.dispose();+ mergeSubscription?.dispose();release();try {webgl?.dispose();