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(packaging): hand-pack the macOS .icns — wrong-sized frames painted rainbow noise in the app launcher
enes72fa4884d93c
diff --git a/.gitignore b/.gitignoreindex df049b28f..f9110b388 100644--- a/.gitignore+++ b/.gitignore@@ -9,6 +9,7 @@ dist/build/icon.pngbuild/icon.ico+build/icon.icns# bundled tmux — a ~2MB universal binary, built by scripts/build-tmux.mjs (the source of truth)# and copied into the app by electron-builder's mac extraResources. Never committed.diff --git a/CLAUDE.md b/CLAUDE.mdindex 02c7df57c..51732dfc8 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -2088,7 +2088,7 @@ Built with **electron-builder** (config in the `package.json` `build` block: appnode-pty, output `dist/`). The app icon is generated from the nodeterm mark by`scripts/make-icon.mjs` (sharp → `build/icon.png` 1024² + multi-resolution `build/icon.ico`for Windows, both gitignored — regenerated by `make-icon`, which every dist script runs first);-electron-builder derives the `.icns` from the PNG. Scripts: `npm run make-icon`, `npm run dist`+the same script hand-packs `build/icon.icns` (size-checked frames — issue #369) and `build/icon.ico`, which electron-builder embeds as-is. Scripts: `npm run make-icon`, `npm run dist`(local **unsigned** arm64 `.dmg` smoke test), `npm run dist:win` (unsigned x64 NSIS installer +zip, `--publish never`). Production release signing/notarization and the update-feed hosting arehandled outside this repo.diff --git a/package.json b/package.jsonindex 2bf8c3271..7228890b7 100644--- a/package.json+++ b/package.json@@ -75,7 +75,7 @@},"mac": {"category": "public.app-category.developer-tools",- "icon": "build/icon.png",+ "icon": "build/icon.icns","hardenedRuntime": true,"gatekeeperAssess": false,"entitlements": "build/entitlements.mac.plist",diff --git a/scripts/icon-pack.d.mts b/scripts/icon-pack.d.mtsnew file mode 100644index 000000000..c6d207ef4--- /dev/null+++ b/scripts/icon-pack.d.mts@@ -0,0 +1,4 @@+// Type surface of icon-pack.mjs for the vitest suite (src/main/icon-pack.test.ts); the script+// itself stays plain .mjs so `npm run make-icon` needs no build step.+export declare const ICNS_FRAMES: Array<{ type: string; px: number }>+export declare function packIcns(frames: Map<string, Buffer>): Bufferdiff --git a/scripts/icon-pack.mjs b/scripts/icon-pack.mjsnew file mode 100644index 000000000..684506952--- /dev/null+++ b/scripts/icon-pack.mjs@@ -0,0 +1,61 @@+// Pure icon-container packers, shared by scripts/make-icon.mjs and pinned by+// src/main/icon-pack.test.ts.+//+// The .icns is packed BY HAND (like the .ico below it in make-icon.mjs) since issue #369:+// electron-builder's PNG→icns converter shipped wrong-sized payloads — ic13 (nominally+// 128pt@2x = 256px) held the 512px frame and ic14 (256pt@2x = 512px) held the 1024px one.+// A consumer that trusts the TYPE's nominal size and decodes into a buffer of that stride+// paints rainbow noise, which is exactly how the app icon rendered in macOS's app+// launcher. Packing our own container with a size check makes that class of skew+// unshippable.++/** Apple's iconutil frame table: icns OSType → the pixel size that type MUST carry.+ * icp4/icp5 are the 1x small sizes; ic11–ic14 are the @2x (retina) variants; PNG payloads+ * are legal for all of them. */+export const ICNS_FRAMES = [+ { type: 'icp4', px: 16 }, // 16pt @1x+ { type: 'icp5', px: 32 }, // 32pt @1x+ { type: 'ic07', px: 128 }, // 128pt @1x+ { type: 'ic08', px: 256 }, // 256pt @1x+ { type: 'ic09', px: 512 }, // 512pt @1x+ { type: 'ic10', px: 1024 }, // 512pt @2x+ { type: 'ic11', px: 32 }, // 16pt @2x+ { type: 'ic12', px: 64 }, // 32pt @2x+ { type: 'ic13', px: 256 }, // 128pt @2x+ { type: 'ic14', px: 512 } // 256pt @2x+]++const PNG_MAGIC = Buffer.from([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a])++/** Width/height straight out of a PNG's IHDR (bytes 16..24). */+function pngDims(png) {+ if (!png.subarray(0, 8).equals(PNG_MAGIC)) throw new Error('frame is not a PNG')+ return { w: png.readUInt32BE(16), h: png.readUInt32BE(20) }+}++/**+ * Pack PNG frames (Map of icns type → PNG buffer, one per ICNS_FRAMES entry) into an .icns+ * container: 'icns' + total length, then per frame OSType + length(+8) + payload.+ * Refuses a missing frame and any frame whose PNG dimensions disagree with its type — the+ * skew that shipped as issue #369 must fail the build, not the user's dock.+ */+export function packIcns(frames) {+ const chunks = []+ for (const { type, px } of ICNS_FRAMES) {+ const png = frames.get(type)+ if (!png) throw new Error(`packIcns: missing frame for ${type} (${px}px)`)+ const { w, h } = pngDims(png)+ if (w !== px || h !== px) {+ throw new Error(`packIcns: ${type} must carry ${px}x${px}, got ${w}x${h}`)+ }+ const header = Buffer.alloc(8)+ header.write(type, 0, 'ascii')+ header.writeUInt32BE(8 + png.length, 4)+ chunks.push(header, png)+ }+ const body = Buffer.concat(chunks)+ const head = Buffer.alloc(8)+ head.write('icns', 0, 'ascii')+ head.writeUInt32BE(8 + body.length, 4)+ return Buffer.concat([head, body])+}diff --git a/scripts/make-icon.mjs b/scripts/make-icon.mjsindex 5c26f1724..ac0fe9a2e 100644--- a/scripts/make-icon.mjs+++ b/scripts/make-icon.mjs@@ -1,12 +1,14 @@-// Renders the nodeterm app icon into build/icon.png (1024x1024) and the multi-resolution-// build/icon.ico used by Windows packaging (both gitignored — regenerated by `npm run-// make-icon`, which every dist script runs first). electron-builder derives the macOS-// .icns from the PNG and hands the ICO to NSIS/the exe resource editor as-is.+// Renders the nodeterm app icon into build/icon.png (1024x1024, the Linux icon), the+// multi-resolution build/icon.ico used by Windows packaging, and the multi-resolution+// build/icon.icns used by macOS packaging (all gitignored — regenerated by `npm run+// make-icon`, which every dist script runs first). electron-builder embeds the ICNS and+// ICO as-is; deriving the .icns from the PNG is exactly what shipped issue #369.//// Design: a black macOS-Terminal-style window (dark rounded square + window dots),// with the nodeterm node-graph mark in our purple inside it.import { mkdirSync, writeFileSync } from 'fs'import sharp from 'sharp'+import { ICNS_FRAMES, packIcns } from './icon-pack.mjs'// macOS app icons leave a transparent margin around a rounded-square tile so they// sit at the same visual size as system icons in the Dock. Apple's grid puts the@@ -100,3 +102,22 @@ const icoFrames = await Promise.all()writeFileSync('build/icon.ico', packIco(ICO_SIZES, icoFrames))console.log(`wrote build/icon.ico (${ICO_SIZES.join('/')}px frames)`)++// --- macOS .icns (multi-resolution) ---+//+// Packed by hand since issue #369: deriving the .icns from icon.png let electron-builder's+// converter ship wrong-sized payloads (the 512px frame in ic13's 256px slot, 1024px in+// ic14's 512px one), which macOS's app launcher painted as rainbow noise. packIcns+// (scripts/icon-pack.mjs, pinned by src/main/icon-pack.test.ts) refuses any frame whose+// dimensions disagree with its type, so that skew now fails the build instead of shipping.+// package.json's mac.icon points at this file; electron-builder embeds it as-is.+const icnsFrames = new Map(+ await Promise.all(+ ICNS_FRAMES.map(async ({ type, px }) => [+ type,+ await sharp(Buffer.from(svg)).resize(px, px).png().toBuffer()+ ])+ )+)+writeFileSync('build/icon.icns', packIcns(icnsFrames))+console.log(`wrote build/icon.icns (${ICNS_FRAMES.map((f) => `${f.type}=${f.px}`).join(' ')})`)diff --git a/src/main/icon-pack.test.ts b/src/main/icon-pack.test.tsnew file mode 100644index 000000000..715d8f341--- /dev/null+++ b/src/main/icon-pack.test.ts@@ -0,0 +1,87 @@+import { describe, expect, it } from 'vitest'+import sharp from 'sharp'+import { ICNS_FRAMES, packIcns } from '../../scripts/icon-pack.mjs'++// Issue #369: the shipped icon.icns (derived by electron-builder from build/icon.png) carried+// WRONG-SIZED payloads — ic13 (nominally 128pt@2x = 256px) held the 512px PNG and ic14 (256pt@2x+// = 512px) held the 1024px one. A consumer that trusts the TYPE's nominal size and decodes into a+// buffer of that stride renders exactly the rainbow noise the report shows. The fix is packing the+// icns ourselves (as make-icon already does for the Windows .ico), with the packer REFUSING any+// frame whose PNG dimensions disagree with its type.++async function framesFor(table: Array<{ type: string; px: number }>): Promise<Map<string, Buffer>> {+ const frames = new Map<string, Buffer>()+ for (const { type, px } of table) {+ frames.set(+ type,+ await sharp({ create: { width: px, height: px, channels: 4, background: '#7a4bd0' } })+ .png()+ .toBuffer()+ )+ }+ return frames+}++/** Parse an icns container into type → payload. */+function parseIcns(buf: Buffer): Map<string, Buffer> {+ expect(buf.subarray(0, 4).toString('ascii')).toBe('icns')+ expect(buf.readUInt32BE(4)).toBe(buf.byteLength)+ const out = new Map<string, Buffer>()+ let off = 8+ while (off < buf.byteLength) {+ const type = buf.subarray(off, off + 4).toString('ascii')+ const len = buf.readUInt32BE(off + 4)+ out.set(type, buf.subarray(off + 8, off + len))+ off += len+ }+ return out+}++const pngSize = (png: Buffer) => ({ w: png.readUInt32BE(16), h: png.readUInt32BE(20) })++describe('ICNS_FRAMES', () => {+ it("is Apple's iconutil table — every type carries its own pixel size, retina types included", () => {+ expect(Object.fromEntries(ICNS_FRAMES.map((f) => [f.type, f.px]))).toEqual({+ icp4: 16,+ icp5: 32,+ ic07: 128,+ ic08: 256,+ ic09: 512,+ ic10: 1024,+ ic11: 32,+ ic12: 64,+ ic13: 256,+ ic14: 512+ })+ })+})++describe('packIcns', () => {+ it('packs a valid container whose every payload matches its type\'s nominal size', async () => {+ const frames = await framesFor(ICNS_FRAMES)+ const parsed = parseIcns(packIcns(frames))+ expect([...parsed.keys()].sort()).toEqual(ICNS_FRAMES.map((f) => f.type).sort())+ for (const { type, px } of ICNS_FRAMES) {+ const payload = parsed.get(type)!+ expect(payload.subarray(0, 8)).toEqual(Buffer.from([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]))+ expect(pngSize(payload)).toEqual({ w: px, h: px })+ }+ })++ it('REFUSES a frame whose PNG dimensions disagree with its type (the shipped ic13/ic14 bug)', async () => {+ const frames = await framesFor(ICNS_FRAMES)+ frames.set(+ 'ic13',+ await sharp({ create: { width: 512, height: 512, channels: 4, background: '#000' } })+ .png()+ .toBuffer()+ )+ expect(() => packIcns(frames)).toThrow(/ic13.*256.*512/)+ })++ it('REFUSES a missing frame — every type in the table must be present', async () => {+ const frames = await framesFor(ICNS_FRAMES)+ frames.delete('icp5')+ expect(() => packIcns(frames)).toThrow(/icp5/)+ })+})