Node-based terminal manager for AI coding agents — tmux-backed terminals and parallel agent sessions as draggable nodes on an infinite pan/zoom canvas. macOS, Linux, and a browser Server Edition.
TypeScript adhdagent-orchestrationai-agentscanvasclaude-codecodexcoding-agentsdeveloper-toolselectrongeminilinuxmacosmultiplexeropencodeparallel-agentsterminalterminal-emulatorterminal-multiplexertmuxworkspace-manager
fix(glass): board paints the cached wallpaper on its first frame
iceclatterWT856ce9bbce87
diff --git a/src/renderer/state/wallpaper.test.tsx b/src/renderer/state/wallpaper.test.tsxnew file mode 100644index 000000000..17688e001--- /dev/null+++ b/src/renderer/state/wallpaper.test.tsx@@ -0,0 +1,44 @@+// @vitest-environment jsdom+import { afterEach, describe, expect, it, vi } from 'vitest'+import { createRoot, type Root } from 'react-dom/client'+import { act } from 'react'+import { DEFAULT_SETTINGS } from '@shared/types'+import { useSettings } from './settings'+import { useBoardWallpaperStyle } from './wallpaper'++// A board opens long after the canvas loaded the wallpaper; its first frame must already carry the+// picture, or the board flashes its plain background (black) for a frame on every open.+function Probe({ seen }: { seen: (string | undefined)[] }) {+ seen.push(useBoardWallpaperStyle()?.backgroundImage as string | undefined)+ return null+}++describe('useBoardWallpaperStyle', () => {+ const roots: Root[] = []+ const mount = (seen: (string | undefined)[]): void => {+ const root = createRoot(document.createElement('div'))+ roots.push(root)+ act(() => root.render(<Probe seen={seen} />))+ }+ afterEach(() => {+ act(() => roots.splice(0).forEach((r) => r.unmount()))+ vi.unstubAllGlobals()+ })++ it('a hook mounting after the load paints the wallpaper on its first frame', async () => {+ const load = vi.fn(async () => 'data:image/jpeg;base64,AAAA')+ vi.stubGlobal('nodeTerminal', { wallpaper: { load } })+ useSettings.setState({+ settings: { ...DEFAULT_SETTINGS, appTheme: 'liquid-glass', desktopWallpaper: { kind: 'image', path: 'a.jpg' } }+ })+ const canvas: (string | undefined)[] = []+ mount(canvas) // the canvas: first mount, has to wait for the load+ await act(async () => {})+ expect(canvas.at(-1)).toBe('url("data:image/jpeg;base64,AAAA")')++ const board: (string | undefined)[] = []+ mount(board) // the board, opened later+ expect(board[0]).toBe('url("data:image/jpeg;base64,AAAA")')+ expect(load).toHaveBeenCalledTimes(1)+ })+})diff --git a/src/renderer/state/wallpaper.ts b/src/renderer/state/wallpaper.tsindex 9c695447b..c6917f5b3 100644--- a/src/renderer/state/wallpaper.ts+++ b/src/renderer/state/wallpaper.ts@@ -16,8 +16,12 @@ import { useSettings } from './settings'* URL from core (`wallpaper.load`), cached here by value so a re-render or a round trip through* Settings never re-reads a multi-MB file. A load that fails resolves to null — degrade to the* plain canvas, never to a stale picture.+ *+ * `resolved` holds the settled value synchronously, so a hook mounting after the load (every board+ * open) paints the wallpaper on its FIRST frame instead of one black frame while the promise settles.*/const loaded = new Map<string, Promise<string | null>>()+const resolved = new Map<string, string>()function cacheKey(w: DesktopWallpaper): string {return JSON.stringify(w)@@ -30,6 +34,7 @@ function load(w: DesktopWallpaper): Promise<string | null> {// ponytail: keep only the latest image; a picker session that flips through ten stills would// otherwise pin ten data: URLs in memory for the app run.loaded.clear()+ resolved.clear()p = window.nodeTerminal.wallpaper.load(w).then((url) => (url ? `url("${url}")` : null))@@ -38,7 +43,9 @@ function load(w: DesktopWallpaper): Promise<string | null> {// A miss is not remembered, so the NEXT selection of this wallpaper asks core again instead of// getting the cached null for the rest of the app run. Nothing retries on its own.void p.then((bg) => {- if (bg === null && loaded.get(key) === p) loaded.delete(key)+ if (loaded.get(key) !== p) return+ if (bg === null) loaded.delete(key)+ else resolved.set(key, bg)})}return p@@ -64,7 +71,7 @@ export function useWallpaperBackground(): string | null {// eslint-disable-next-line react-hooks/exhaustive-deps}, [key, sync])if (sync !== undefined) return sync- return async?.key === key ? async.bg : null+ return async?.key === key ? async.bg : (resolved.get(key) ?? null)}/** The wallpaper layers for a `background-image` value: a separate small longhand for the colour —