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(wallpaper): keep the most recent imported image when a preset is chosen
iceclatterWTe004f5881c62
diff --git a/src/core/wallpaper.test.ts b/src/core/wallpaper.test.tsindex 28e2d9673..0c752cabe 100644--- a/src/core/wallpaper.test.ts+++ b/src/core/wallpaper.test.ts@@ -3,6 +3,7 @@ import { tmpdir } from 'node:os'import path from 'node:path'import { afterEach, describe, expect, it } from 'vitest'import { existsSync, readdirSync } from 'node:fs'+import { wallpapersToKeep } from '../shared/wallpaper'import { cachedImagePath, importWallpaper, pruneWallpaperCache, scanStills } from './wallpaper'const HASH = 'a'.repeat(40)@@ -75,6 +76,16 @@ describe('pruneWallpaperCache', () => {expect(readdirSync(root).sort()).toEqual([keep, thumb, temp, 'notes.txt'].sort())})+ it('choosing a preset keeps the most recent imported image (visual QA H6)', async () => {+ root = mkdtempSync(path.join(tmpdir(), 'wp-cache-'))+ const recent = `${'e'.repeat(40)}.png`+ const older = `${'f'.repeat(40)}.png`+ for (const f of [recent, older]) put(f, 10)+ const next = { kind: 'preset', id: 'gradient:sunrise' }+ await pruneWallpaperCache(wallpapersToKeep({ desktopWallpaper: next, recentWallpaperImage: path.join(root, recent) }), root)+ expect(readdirSync(root)).toEqual([recent])+ })+it('a missing cache dir is not an error', async () => {await expect(pruneWallpaperCache([], path.join(tmpdir(), 'no-such-wp-cache-xyz'))).resolves.toBeUndefined()expect(existsSync(path.join(tmpdir(), 'no-such-wp-cache-xyz'))).toBe(false)diff --git a/src/core/wallpaper.ts b/src/core/wallpaper.tsindex 1d0ddefe6..d5af840c6 100644--- a/src/core/wallpaper.ts+++ b/src/core/wallpaper.ts@@ -6,6 +6,7 @@ import { promisify } from 'node:util'import { IPC } from '../shared/ipc'import {normalizeWallpaper,+ wallpapersToKeep,type DesktopWallpaper,type WallpaperStill} from '../shared/wallpaper'@@ -303,16 +304,20 @@ let currentWallpaper: () => unknown = () => undefined* actually chose — a failed read is not evidence the choice went away. Only a SAVED change prunes.*/export function registerWallpaperIpc(settings: {- get: () => { desktopWallpaper?: unknown }- onChange: (cb: (s: { desktopWallpaper?: unknown }) => void) => unknown+ get: () => { desktopWallpaper?: unknown; recentWallpaperImage?: unknown }+ onChange: (cb: (s: { desktopWallpaper?: unknown; recentWallpaperImage?: unknown }) => void) => unknown}): void {currentWallpaper = () => settings.get().desktopWallpaper- let last = JSON.stringify(currentWallpaper() ?? null)+ // The user's most recent import is kept too (`wallpapersToKeep`): choosing a preset must not+ // delete the image the "Your image" tile still offers.+ const key = (s: { desktopWallpaper?: unknown; recentWallpaperImage?: unknown }): string =>+ JSON.stringify(wallpapersToKeep(s))+ let last = key(settings.get())settings.onChange((s) => {- const next = JSON.stringify(s.desktopWallpaper ?? null)+ const next = key(s)if (next === last) returnlast = next- void pruneWallpaperCache([s.desktopWallpaper])+ void pruneWallpaperCache(wallpapersToKeep(s))})platform().handle(IPC.wallpaperListStills, () => listStills())platform().handle(IPC.wallpaperLoad, (value: unknown) => loadWallpaper(value))diff --git a/src/renderer/components/settings/sections/AppearanceSection.tsx b/src/renderer/components/settings/sections/AppearanceSection.tsxindex 7e63efbc0..6b3c559b8 100644--- a/src/renderer/components/settings/sections/AppearanceSection.tsx+++ b/src/renderer/components/settings/sections/AppearanceSection.tsx@@ -13,6 +13,8 @@ import {GRADIENT_WALLPAPERS,NO_WALLPAPER,normalizeWallpaper,+ recentWallpaperImage,+ wallpaperChoice,sameWallpaper,type DesktopWallpaper,type WallpaperStill@@ -268,6 +270,9 @@ function WallpaperTile({*/function WallpaperPicker(): React.JSX.Element {const value = normalizeWallpaper(useSettings((s) => s.settings.desktopWallpaper))+ const recent = recentWallpaperImage(useSettings((s) => s.settings.recentWallpaperImage))+ // The tile offers the current image, else the last one imported (kept when a preset is chosen).+ const yourImage = value.kind === 'image' ? value : recentconst update = useSettings((s) => s.update)const [stills, setStills] = useState<WallpaperStill[] | null>(null)const [error, setError] = useState<string | null>(null)@@ -283,7 +288,7 @@ function WallpaperPicker(): React.JSX.Element {}, [])const pick = (w: DesktopWallpaper): void => {setError(null)- update({ desktopWallpaper: w })+ update(wallpaperChoice(value, w))}const chooseImage = async (): Promise<void> => {setError(null)@@ -329,8 +334,8 @@ function WallpaperPicker(): React.JSX.Element {onClick={() => pick({ kind: 'preset', id: g.id })}/>))}- {value.kind === 'image' && (- <WallpaperTile label="Your image" selected onClick={() => {}}>+ {yourImage && (+ <WallpaperTile label="Your image" selected={is(yourImage)} onClick={() => pick(yourImage)}>Your image</WallpaperTile>)}diff --git a/src/shared/types.ts b/src/shared/types.tsindex 868adba83..77a8c18f6 100644--- a/src/shared/types.ts+++ b/src/shared/types.ts@@ -1425,6 +1425,9 @@ export interface Settings {/** Desktop wallpaper behind the canvas (Liquid Glass appearance). Opt-in; `none` draws the* canvas exactly as before. Hand-editable: read through `normalizeWallpaper` (shared/wallpaper). */desktopWallpaper: import('./wallpaper').DesktopWallpaper+ /** The most recent imported wallpaper image's cache path, kept after switching to a preset so the+ * "Your image" tile stays and the cache prune keeps its file (`recentWallpaperImage`). */+ recentWallpaperImage: string | null/** Weight for normal text. xterm's own default is `normal` (400). */fontWeight: number/** Weight for BOLD text. xterm's own default is `bold` (700). Lowering it is how you keep bold@@ -1869,6 +1872,7 @@ export const DEFAULT_SETTINGS: Settings = {windowTitleActiveSession: false,terminalTheme: 'nodeterm-dark',desktopWallpaper: { kind: 'none' },+ recentWallpaperImage: null,fontWeight: 400,fontWeightBold: 700,drawBoldTextInBrightColors: true,diff --git a/src/shared/wallpaper.test.ts b/src/shared/wallpaper.test.tsindex c7516a70b..0845c4aea 100644--- a/src/shared/wallpaper.test.ts+++ b/src/shared/wallpaper.test.ts@@ -1,5 +1,12 @@import { describe, expect, it } from 'vitest'-import { defaultWallpaper, GRADIENT_WALLPAPERS, normalizeWallpaper } from './wallpaper'+import {+ defaultWallpaper,+ GRADIENT_WALLPAPERS,+ normalizeWallpaper,+ recentWallpaperImage,+ wallpaperChoice,+ wallpapersToKeep+} from './wallpaper'describe('defaultWallpaper (Liquid Glass chosen with no wallpaper)', () => {it('takes the first still (the scan puts Sonoma Horizon first)', () => {@@ -11,3 +18,20 @@ describe('defaultWallpaper (Liquid Glass chosen with no wallpaper)', () => {expect(normalizeWallpaper(w)).toEqual(w)})})++describe('recent wallpaper image (choosing a preset keeps the last import)', () => {+ const img = { kind: 'image', path: '/ud/wallpapers/' + 'a'.repeat(40) + '.png' } as const+ const sunrise = { kind: 'preset', id: GRADIENT_WALLPAPERS[0].id } as const+ it('leaving an image for a preset records it as the recent image', () => {+ expect(wallpaperChoice(img, sunrise)).toEqual({ desktopWallpaper: sunrise, recentWallpaperImage: img.path })+ })+ it('choosing an image records it; preset to preset leaves the recent image alone', () => {+ expect(wallpaperChoice(sunrise, img)).toEqual({ desktopWallpaper: img, recentWallpaperImage: img.path })+ expect(wallpaperChoice(sunrise, { kind: 'none' })).toEqual({ desktopWallpaper: { kind: 'none' } })+ })+ it('the prune keeps both the choice and the recent image; junk is ignored', () => {+ expect(wallpapersToKeep({ desktopWallpaper: sunrise, recentWallpaperImage: img.path })).toEqual([sunrise, img])+ expect(recentWallpaperImage(42)).toBeNull()+ expect(recentWallpaperImage('')).toBeNull()+ })+})diff --git a/src/shared/wallpaper.ts b/src/shared/wallpaper.tsindex 5a1688af2..334abbbcf 100644--- a/src/shared/wallpaper.ts+++ b/src/shared/wallpaper.ts@@ -116,3 +116,28 @@ export function sameWallpaper(a: DesktopWallpaper, b: DesktopWallpaper): booleanif (a.kind === 'image') return a.path === (b as { path: string }).pathreturn true}++/**+ * The user's most recent imported image (`settings.recentWallpaperImage`), kept across a switch to+ * a preset so browsing presets never destroys it: the "Your image" tile stays and the cache prune+ * keeps its file. Hand-editable, so it is re-validated like the wallpaper itself.+ */+export function recentWallpaperImage(v: unknown): DesktopWallpaper | null {+ const w = normalizeWallpaper({ kind: 'image', path: v })+ return w.kind === 'image' ? w : null+}++/** The settings patch for choosing `next` while `current` is on screen: an image being chosen, or+ * one being left, becomes the recent image. */+export function wallpaperChoice(+ current: DesktopWallpaper,+ next: DesktopWallpaper+): { desktopWallpaper: DesktopWallpaper; recentWallpaperImage?: string } {+ const image = next.kind === 'image' ? next : current.kind === 'image' ? current : null+ return image ? { desktopWallpaper: next, recentWallpaperImage: image.path } : { desktopWallpaper: next }+}++/** What a saved settings change must keep in the wallpaper cache: the choice and the recent image. */+export function wallpapersToKeep(s: { desktopWallpaper?: unknown; recentWallpaperImage?: unknown }): unknown[] {+ return [s.desktopWallpaper, recentWallpaperImage(s.recentWallpaperImage)]+}