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): clear a WebGL pane's canvas before every frame
rubenluetke10-beepb16087f15824
diff --git a/jarvis/ui/web/frontend/src/components/agentic/terminalRenderer.test.ts b/jarvis/ui/web/frontend/src/components/agentic/terminalRenderer.test.tsindex 6b3b162117..da72ca61dd 100644--- a/jarvis/ui/web/frontend/src/components/agentic/terminalRenderer.test.ts+++ b/jarvis/ui/web/frontend/src/components/agentic/terminalRenderer.test.ts@@ -4,6 +4,7 @@ import type { ITerminalAddon, Terminal } from "@xterm/xterm";import {MAX_WEBGL_PANES,attachTerminalRenderer,+ clearEveryFrame,clearTerminalTextureAtlas,forgetUploadedAtlasPages,resetWebglPaneCount,@@ -205,3 +206,61 @@ describe("an atlas page merge", () => {expect(() => forgetUploadedAtlasPages(term)).not.toThrow();});});++describe("clearEveryFrame", () => {+ /** A terminal whose WebGL renderer records what it drew, and in what order. */+ function drawingTerminal() {+ const calls: string[] = [];+ const gl = {+ COLOR_BUFFER_BIT: 0x4000,+ clearColor: (...rgba: number[]) => calls.push(`clearColor ${rgba.join(",")}`),+ clear: () => calls.push("clear"),+ };+ const renderer = {+ _gl: gl,+ renderRows(start: number, end: number) {+ calls.push(`rows ${start}-${end}`);+ },+ };+ const term = {+ loadAddon() {},+ _core: { _renderService: { _renderer: { value: renderer } } },+ } as unknown as Terminal;+ return { term, renderer, calls };+ }++ it("empties the canvas before every frame, once however often it is applied", () => {+ // A transparent background makes the addon's own "clear" a no-op, so a+ // pane rebuilt behind its curtain showed two frames in the same cells+ // and a cursor left at the top-left corner (2026-09-29).+ const { term, renderer, calls } = drawingTerminal();+ clearEveryFrame(term);+ clearEveryFrame(term);++ renderer.renderRows(0, 23);+ renderer.renderRows(4, 4);++ expect(calls).toEqual([+ "clearColor 0,0,0,0",+ "clear",+ "rows 0-23",+ "clearColor 0,0,0,0",+ "clear",+ "rows 4-4",+ ]);+ });++ it("is applied to every pane that draws with WebGL", () => {+ const { term, renderer, calls } = drawingTerminal();+ attachTerminalRenderer(term, undefined, deps());++ renderer.renderRows(0, 1);++ expect(calls[1]).toBe("clear");+ });++ it("leaves a terminal without the addon's internals alone", () => {+ const { term } = fakeTerminal();+ expect(() => clearEveryFrame(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 29f9297a07..002421f818 100644--- a/jarvis/ui/web/frontend/src/components/agentic/terminalRenderer.ts+++ b/jarvis/ui/web/frontend/src/components/agentic/terminalRenderer.ts@@ -140,6 +140,53 @@ export function forgetUploadedAtlasPages(term: Terminal): void {}+/** The slice of the WebGL renderer that draws a frame. Not public API either. */+interface WebglRendererInternals {+ _core?: {+ _renderService?: {+ _renderer?: {+ value?: {+ _gl?: WebGL2RenderingContext;+ renderRows?: (start: number, end: number) => void;+ __clearsEveryFrame?: boolean;+ };+ };+ };+ };+}++/**+ * Make `term`'s WebGL renderer empty its canvas before it draws each frame.+ *+ * The addon never calls `gl.clear`: it "clears" by painting one rectangle the+ * size of the screen in the theme's background colour, then draws every row+ * over it. A pane's background is transparent (alpha 0, so the glass shell+ * behind it shows through), and with alpha blending that rectangle paints+ * nothing — the previous frame stays in the drawing buffer wherever the+ * browser has not wiped it. It does not wipe a canvas it never presented, and+ * a pane rebuilding behind its curtain (`visibility: hidden` after a reload+ * or a workspace switch) is exactly that: the replayed screen, the reset, the+ * agent's repaint were drawn on top of each other, and the pane was revealed+ * with two readable texts in the same cells and a cursor left at the top-left+ * corner (2026-09-29). Every frame redraws the whole model, so a real clear+ * first loses nothing.+ */+export function clearEveryFrame(term: Terminal): void {+ const renderer = (term as unknown as WebglRendererInternals)._core?._renderService?._renderer+ ?.value;+ const gl = renderer?._gl;+ const renderRows = renderer?.renderRows;+ if (!renderer || !gl || typeof renderRows !== "function" || renderer.__clearsEveryFrame) {+ return;+ }+ renderer.__clearsEveryFrame = true;+ renderer.renderRows = function (this: unknown, start: number, end: number) {+ gl.clearColor(0, 0, 0, 0);+ gl.clear(gl.COLOR_BUFFER_BIT);+ renderRows.call(this, start, end);+ };+}+/*** 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@@ -204,6 +251,7 @@ export function attachTerminalRenderer(try {webgl = deps.createWebgl();term.loadAddon(webgl);+ clearEveryFrame(term);webglPanes += 1;webglTerminals.add(term);counted = true;