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
// Renders the nodeterm app icon into build/icon.png (1024x1024, loaded at runtime), the Linux
// icon set build/icons/<N>x<N>.png, 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, LINUX_ICON_SIZES, 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
// tile at ~824px inside the 1024 canvas (≈100px margin) with a ~185px corner radius.
const svg = `<svg xmlns="http://www.w3.org/2000/svg" width="1024" height="1024" viewBox="0 0 1024 1024">
<defs>
<linearGradient id="tile" x1="0" y1="0" x2="0" y2="1">
<stop offset="0" stop-color="#2a2a30"/>
<stop offset="1" stop-color="#0b0b0e"/>
</linearGradient>
<linearGradient id="mark" x1="0" y1="0" x2="1" y2="1">
<stop offset="0" stop-color="#a38dff"/>
<stop offset="1" stop-color="#7a4bd0"/>
</linearGradient>
</defs>
<!-- black terminal window -->
<rect x="100" y="100" width="824" height="824" rx="185" fill="url(#tile)"/>
<rect x="101" y="101" width="822" height="822" rx="184" fill="none"
stroke="#ffffff" stroke-opacity="0.07" stroke-width="2"/>
<!-- window dots (top-left) -->
<g fill="#50505a">
<circle cx="186" cy="190" r="15"/>
<circle cx="232" cy="190" r="15"/>
<circle cx="278" cy="190" r="15"/>
</g>
<!-- nodeterm mark, in our purple -->
<g transform="translate(512 528) scale(12) translate(-26.5 -24)"
stroke-linecap="round" stroke-linejoin="round">
<path d="M13 12 L31 24 L13 36" fill="none" stroke="url(#mark)" stroke-width="5"/>
<circle cx="13" cy="12" r="3.6" fill="#a38dff"/>
<circle cx="13" cy="36" r="3.6" fill="#a38dff"/>
<circle cx="31" cy="24" r="3.6" fill="#ffffff"/>
<rect x="33.5" y="32.5" width="10.5" height="5" rx="2.5" fill="#a38dff"/>
</g>
</svg>`
mkdirSync('build', { recursive: true })
const png = await sharp(Buffer.from(svg)).png().toBuffer()
writeFileSync('build/icon.png', png)
console.log('wrote build/icon.png (1024x1024)')
// --- Linux icon set (one PNG per hicolor size) ---
//
// package.json's linux.icon points at this DIRECTORY, not at build/icon.png: given a single PNG
// electron-builder installs it as-is under hicolor/<its size>/apps/, and 1024x1024 is not a size
// the hicolor theme declares, so no desktop could find the icon (issue #1421). build/icon.png
// itself stays — the tray and the window icon load it at runtime (extraResources).
mkdirSync('build/icons', { recursive: true })
for (const size of LINUX_ICON_SIZES) {
writeFileSync(
`build/icons/${size}x${size}.png`,
await sharp(Buffer.from(svg)).resize(size, size).png().toBuffer()
)
}
console.log(`wrote build/icons/ (${LINUX_ICON_SIZES.join('/')}px)`)
// --- Windows .ico (multi-resolution) ---
//
// electron-builder's `win.icon` expects a real ICO container, not a PNG wearing a `.ico`
// extension — Explorer, the taskbar and "Programs and Features" each pick a frame by SIZE,
// and a single-frame file gets stretched/blurred everywhere but the one size it matches.
// NSIS additionally requires a 256px frame to be present.
//
// Windows Vista+ accepts PNG-compressed frames packed directly inside an ICO container (no
// BMP/DIB re-encoding required), so this renders the same SVG mark at each standard size and
// writes a small hand-rolled ICO container around the PNGs — no extra npm dependency for
// something this documented (MS-ICO: a 6-byte ICONDIR header, then one 16-byte ICONDIRENTRY
// per frame, then the frame bytes back to back).
const ICO_SIZES = [16, 24, 32, 48, 64, 128, 256]
/** Pack PNG buffers (one per size, same order as `sizes`) into a Windows ICO file buffer. */
function packIco(sizes, pngBuffers) {
const HEADER_BYTES = 6
const ENTRY_BYTES = 16
const dir = Buffer.alloc(HEADER_BYTES)
dir.writeUInt16LE(0, 0) // reserved, must be 0
dir.writeUInt16LE(1, 2) // image type: 1 = icon
dir.writeUInt16LE(sizes.length, 4) // frame count
const entries = []
let offset = HEADER_BYTES + ENTRY_BYTES * sizes.length
for (let i = 0; i < sizes.length; i++) {
const size = sizes[i]
const data = pngBuffers[i]
const entry = Buffer.alloc(ENTRY_BYTES)
// Width/height are single bytes; the ICO format's documented escape is 0 == 256px.
entry.writeUInt8(size >= 256 ? 0 : size, 0)
entry.writeUInt8(size >= 256 ? 0 : size, 1)
entry.writeUInt8(0, 2) // color count: 0 = no palette (true color)
entry.writeUInt8(0, 3) // reserved, must be 0
entry.writeUInt16LE(1, 4) // color planes
entry.writeUInt16LE(32, 6) // bits per pixel (32 = RGBA)
entry.writeUInt32LE(data.length, 8) // size of this frame's data
entry.writeUInt32LE(offset, 12) // offset of this frame's data from file start
entries.push(entry)
offset += data.length
}
return Buffer.concat([dir, ...entries, ...pngBuffers])
}
const icoFrames = await Promise.all(
ICO_SIZES.map((size) => sharp(Buffer.from(svg)).resize(size, size).png().toBuffer())
)
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(' ')})`)