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
feat(canvas): curated glyph icons for nodes (#973)
ezwep009c10a1428c
diff --git a/CLAUDE.md b/CLAUDE.mdindex 44236ded1..4bfe5ca7e 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -253,7 +253,7 @@ Fire-time `TriggerArmStore.isArmed` re-ask everywhere; every rule test-pinned. Tmachine-local, content-bound `core/trigger-arm-store.ts` (a spec that arrives or CHANGES via gitreads as disarmed until armed on this machine). A node's `data`carries `title, color, group, tags, collapsed, expandedHeight, shell, cwd, text,-initialCommand, filePath, diffStaged`, `icon` (a user-chosen emoji or picture — see **Node icons**+initialCommand, filePath, diffStaged`, `icon` (a user-chosen emoji, glyph or picture — see **Node icons**below), `agentId` (which agent CLI a terminal node runs —persisted), and `accountId` (which managed Claude account a terminal node runs under — resolvedat creation, changed ONLY by the explicit account-switch actions, persisted; see **Managed Claude accounts**). `nodeStatesToFlow` defaults a@@ -5824,10 +5824,10 @@ tokens `--danger --warn --caution --success --agent-working`, which the light thproject files at creation), kanban label chips (own palette), presence colours, the onboardingscenes, the notch HUD's own stylesheet.-## Node icons (emoji or picture)+## Node icons (emoji, glyph or picture)-A node may carry `data.icon` (`NodeIcon` in `@shared/node-icon`): `{type:'emoji', value}` or-`{type:'image', path}`. Absent = the node draws exactly as it did before the feature, which is the+A node may carry `data.icon` (`NodeIcon` in `@shared/node-icon`): `{type:'emoji', value}`,+`{type:'lucide', name}` or `{type:'image', path}`. Absent = the node draws exactly as it did before the feature, which is thedegrade every failure path falls back to. Set from the node right-click menu ("Set icon…", hideablelike Colors — id `icon`), from the icon itself in the terminal node header, and from the kanban cardmodal's header slot; drawn by the one `NodeIconView` on all four surfaces that list a node (canvas@@ -5837,6 +5837,20 @@ kind, deliberately: offering it on an editor or a group frame would persist a vawhich is the "looks like it worked" failure this file warns about elsewhere. Extending it to stickyor browser nodes means adding the draw and the set together, in one change.+- **Glyphs (issue #291) are a closed allowlist, `NODE_GLYPHS`** — shell, git repo, database, server,+ … with a label each (tooltip / accessible name, never stored). It is typed as a SUBSET of the+ project icon's `LUCIDE_ICON_IDS`, so a glyph draws from the one `LUCIDE_ICONS` map `ProjectGlyph`+ owns; a new glyph needs an id already in that map (or added to both). The name is matched exactly —+ a name outside the list, a newer build's glyph, is no icon, and an OLDER build drops it on its next+ save of a shared project.json (its `normalizeNodeIcon` does not know the variant). Picked from the+ same dialog as emoji, drawn in `currentColor`. Agent nodes are terminal nodes, so they are offered+ a glyph like any icon: it sits beside the agent's own identity, it does not replace it. No+ auto-suggest (cwd is git → git glyph, pane command `psql` → database): an icon written without the+ user choosing it would land in the git-shared file.+- **The icon survives a close/reopen.** Both reopen paths carry it re-validated — `withCosmetics`+ (⇧⌘T and the sidebar history both end there) and `stateToReopenSnapshot` (the persisted twin is+ read from hand-editable workspace.json). Before, `icon` was not a cosmetic key and a reopened+ session came back bare.- **`.nodeterm/project.json` is hostile input, so the icon is validated at BOTH serializer seams.**`normalizeNodeIcon` runs in `nodeStatesToFlow` (a cloned file becoming live state) *and* in`flowToNodeStates` (live state becoming the next reader's file — live node data is reachable by adiff --git a/src/renderer/components/NodeIcon.test.tsx b/src/renderer/components/NodeIcon.test.tsxnew file mode 100644index 000000000..6dbde8a6c--- /dev/null+++ b/src/renderer/components/NodeIcon.test.tsx@@ -0,0 +1,86 @@+import { readFileSync } from 'node:fs'+import { join } from 'node:path'+import { renderToStaticMarkup } from 'react-dom/server'+import { describe, expect, it } from 'vitest'+import { NODE_GLYPHS } from '@shared/node-icon'+import { NodeIconView } from './NodeIcon'+import { ProjectGlyph, lucideIcon } from './ProjectGlyph'++// Issue #291: a glyph icon draws through the one NodeIconView every listing surface uses.+describe('NodeIconView glyphs', () => {+ it('draws every curated glyph as an svg in the icon box', () => {+ for (const glyph of NODE_GLYPHS) {+ const html = renderToStaticMarkup(+ <NodeIconView icon={{ type: 'lucide', name: glyph.id }} size={15} />+ )+ expect(html, glyph.id).toMatch(/^<span class="node-icon"[^>]*><svg/)+ expect(html).toContain('width:15px')+ }+ })++ it('draws nothing for a name outside the allowlist, same as an unreadable image', () => {+ expect(renderToStaticMarkup(<NodeIconView icon={{ type: 'lucide', name: 'skull' }} />)).toBe('')+ })++ // The canvas header is the other surface the issue names. TerminalNode is too large to mount+ // here, so pin that its header icon is this same component and not a per-surface copy.+ // The header's icon BUTTON is conditional; it must be gated on the normalized icon, or an+ // invalid stored value leaves an empty button (and a flex gap) in the header.+ it('gates the terminal header icon button on the normalized icon', () => {+ const src = readFileSync(join(__dirname, '..', 'nodes', 'TerminalNode.tsx'), 'utf8').replace(/\r\n/g, '\n')+ const header = src.slice(src.indexOf('<div className="term-node__header">'))+ expect(header).toMatch(/\{headerIcon \? \(\s*<button\s+className="term-node__icon nodrag"/)+ expect(src).toMatch(/const headerIcon = normalizeNodeIcon\(data\.icon\)/)+ })++ it('is what the terminal node header renders', () => {+ const src = readFileSync(join(__dirname, '..', 'nodes', 'TerminalNode.tsx'), 'utf8').replace(/\r\n/g, '\n')+ const header = src.slice(src.indexOf('<div className="term-node__header">'))+ expect(header).toMatch(/<NodeIconView icon=\{headerIcon\}/)+ })+})++// Codex review of #291: persisted icons reach NodeIconView WITHOUT passing through+// `nodeStatesToFlow` (an inactive project's rows in `buildSessionList`, kanban, a relay mirror).+// A bracket lookup on a plain object map answers `__proto__` / `constructor` / `toString` with an+// inherited value, and React throws rendering it — taking the whole sidebar down.+describe('NodeIconView at the render boundary', () => {+ const hostile = ['__proto__', 'constructor', 'toString', 'hasOwnProperty', 'valueOf']++ it('draws nothing, and does not throw, for a prototype key', () => {+ for (const name of hostile) {+ expect(() => renderToStaticMarkup(<NodeIconView icon={{ type: 'lucide', name }} />), name).not.toThrow()+ expect(renderToStaticMarkup(<NodeIconView icon={{ type: 'lucide', name }} />), name).toBe('')+ }+ })++ it('draws nothing for a project-only glyph outside NODE_GLYPHS', () => {+ // `heart` is in LUCIDE_ICON_IDS (projects) but not a node glyph.+ expect(renderToStaticMarkup(<NodeIconView icon={{ type: 'lucide', name: 'heart' }} />)).toBe('')+ })++ it('normalizes the other kinds too: a hostile image path draws nothing', () => {+ expect(+ renderToStaticMarkup(<NodeIconView icon={{ type: 'image', path: '/home/u/.ssh/id_rsa' }} />)+ ).toBe('')+ expect(renderToStaticMarkup(<NodeIconView icon={{ type: 'emoji', value: 'ab' }} />)).toContain('>a<')+ })+})++describe('lucideIcon / ProjectGlyph prototype keys', () => {+ it('answers only own entries of the map', () => {+ expect(lucideIcon('database')).toBeTruthy()+ for (const name of ['__proto__', 'constructor', 'toString', 'hasOwnProperty']) {+ expect(lucideIcon(name), name).toBeUndefined()+ }+ })++ it('a project glyph with a prototype-key name falls back instead of throwing', () => {+ for (const name of ['__proto__', 'constructor', 'toString']) {+ const render = (): string =>+ renderToStaticMarkup(<ProjectGlyph icon={{ type: 'lucide', name }} name="Proj" color="#123" />)+ expect(render, name).not.toThrow()+ expect(render()).toContain('>P<')+ }+ })+})diff --git a/src/renderer/components/NodeIcon.tsx b/src/renderer/components/NodeIcon.tsxindex 7fdd2936a..4dfae5216 100644--- a/src/renderer/components/NodeIcon.tsx+++ b/src/renderer/components/NodeIcon.tsx@@ -9,8 +9,9 @@* decoration — it must never occupy space it cannot fill, and it must never announce its own* failure in a header that is already carrying six chips.*/-import type { NodeIcon } from '@shared/node-icon'+import { normalizeNodeIcon, type NodeIcon } from '@shared/node-icon'import { useNodeIconSrc } from '../lib/nodeIconImage'+import { lucideIcon } from './ProjectGlyph'export interface NodeIconViewProps {icon?: NodeIcon@@ -23,11 +24,16 @@ export interface NodeIconViewProps {}export function NodeIconView({- icon,+ icon: raw,size = 14,className,projectId}: NodeIconViewProps): React.JSX.Element | null {+ // Normalized HERE, at the render boundary, not only at the serializer seams: persisted icons+ // also reach this component without crossing `nodeStatesToFlow` — an inactive project's rows in+ // the sessions sidebar (`buildSessionList` reads its stored nodes), the kanban board, a relay+ // mirror. Cheap, pure, and it answers the same way the seams do: invalid → no icon.+ const icon = normalizeNodeIcon(raw)// Called unconditionally (hook rules) — it answers null for an emoji icon and for no icon.const src = useNodeIconSrc(icon, projectId)if (!icon) return null@@ -43,6 +49,18 @@ export function NodeIconView({</span>)}+ if (icon.type === 'lucide') {+ // Drawn in `currentColor`, so it reads as part of the title line it sits on; the node's color+ // stays with the swatch beside it. `icon` is normalized above, so the name is a NODE_GLYPHS id;+ // `lucideIcon` is an own-property lookup regardless, and a miss draws nothing.+ const Glyph = lucideIcon(icon.name)+ if (!Glyph) return null+ return (+ <span className={cls} style={{ width: size, height: size }} aria-hidden>+ <Glyph width="100%" height="100%" strokeWidth={2} aria-hidden="true" />+ </span>+ )+ }if (!src) return nullreturn (<span className={cls} style={{ width: size, height: size }} aria-hidden>diff --git a/src/renderer/components/NodeIconPicker.test.tsx b/src/renderer/components/NodeIconPicker.test.tsxindex cdd1d67b1..184606425 100644--- a/src/renderer/components/NodeIconPicker.test.tsx+++ b/src/renderer/components/NodeIconPicker.test.tsx@@ -19,6 +19,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'import { NodeIconDialogHost, nodeIconDialog, type NodeIconChoice } from './NodeIconPicker'import { useProjects } from '../state/projects'import { popDialog, pushDialog, resetDialogStack } from './dialog-stack'+import { NODE_GLYPHS, type NodeIcon } from '@shared/node-icon'// React refuses act() outside a configured test environment without this flag.;(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true@@ -217,3 +218,61 @@ describe('NodeIconPicker escape', () => {await expect(choice).resolves.toBeUndefined()})})++// Issue #291: the curated glyph grid. Picking one resolves the SAME value the validator keeps, and+// the current glyph is marked so the dialog shows what the node wears.+describe('NodeIconPicker glyphs', () => {+ let root: Root | undefined+ let host: HTMLElement++ const open = async (icon?: NodeIcon): Promise<{ choice: Promise<NodeIconChoice> }> => {+ host = document.createElement('div')+ document.body.appendChild(host)+ useProjects.setState({ activeProjectId: 'p1', getProject: () => PROJECT } as never)+ const choice = nodeIconDialog({ nodeId: 'n1', title: 'Build', icon })+ root = createRoot(host)+ await act(async () => {+ root!.render(<NodeIconDialogHost />)+ })+ return { choice }+ }++ afterEach(async () => {+ await act(async () => root?.unmount())+ root = undefined+ host?.remove()+ resetDialogStack()+ })++ it('offers every curated glyph as a named button', async () => {+ const { choice } = await open()+ for (const glyph of NODE_GLYPHS) {+ const button = document.querySelector(`button[aria-label="${glyph.label}"]`)+ expect(button, glyph.id).toBeTruthy()+ expect(button!.querySelector('svg')).toBeTruthy()+ }+ document.body.dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape', bubbles: true }))+ await choice+ })++ it('resolves the picked glyph as a lucide icon', async () => {+ const { choice } = await open()+ const git = NODE_GLYPHS.find((g) => g.id === 'folder-git')!+ await act(async () => {+ document+ .querySelector(`button[aria-label="${git.label}"]`)!+ .dispatchEvent(new MouseEvent('click', { bubbles: true }))+ })+ await expect(choice).resolves.toEqual({ type: 'lucide', name: 'folder-git' })+ })++ it('marks the glyph the node already wears', async () => {+ const { choice } = await open({ type: 'lucide', name: 'database' })+ const db = NODE_GLYPHS.find((g) => g.id === 'database')!+ const button = document.querySelector(`button[aria-label="${db.label}"]`)!+ expect(button.className).toContain('is-current')+ expect(button.getAttribute('aria-pressed')).toBe('true')+ document.body.dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape', bubbles: true }))+ await choice+ })+})diff --git a/src/renderer/components/NodeIconPicker.tsx b/src/renderer/components/NodeIconPicker.tsxindex 6cf6be9f9..abc8552a9 100644--- a/src/renderer/components/NodeIconPicker.tsx+++ b/src/renderer/components/NodeIconPicker.tsx@@ -1,6 +1,6 @@/**- * Choosing a node's icon: an emoji from a small palette, any character typed by hand, or an image- * file from disk.+ * Choosing a node's icon: a curated glyph (shell, git, database, … — issue #291), an emoji from a+ * small palette, any character typed by hand, or an image file from disk.** Driven by the promise-based singleton `nodeIconDialog()` — the same shape as `promptDialog()` —* so every surface that can set an icon (the node context menu, the node header, the kanban card@@ -27,6 +27,7 @@ import { create } from 'zustand'import {iconFileName,localIconCwd,+ NODE_GLYPHS,type NodeIcon,nodeIconMime,normalizeNodeIcon,@@ -37,6 +38,7 @@ import { browserThumbnailDeps, downscaleIconImage } from '../lib/nodeIconThumbnaimport { useProjects } from '../state/projects'import { sessionForProject } from '../session/session'import { useDialogStack } from './dialog-stack'+import { NodeIconView } from './NodeIcon'/*** A small, deliberately opinionated palette rather than a full emoji keyboard. Grouped by what@@ -223,6 +225,29 @@ function NodeIconPicker({<div className="confirm-overlay" onClick={() => onDone(undefined)}><div className="confirm node-icon-dialog" onClick={(e) => e.stopPropagation()}><p className="confirm__msg">Icon for {title || 'this node'}</p>+ {/* What the node IS, first: a glyph names the kind of session (issue #291), where the+ emoji below names a mood. Drawn by the same NodeIconView the header and sidebar use,+ so the button shows exactly what the node will wear. */}+ <div className="node-icon-dialog__grid">+ {NODE_GLYPHS.map((glyph) => {+ const current = icon?.type === 'lucide' && icon.name === glyph.id+ return (+ <button+ key={glyph.id}+ type="button"+ className={`node-icon-dialog__swatch node-icon-dialog__swatch--glyph${+ current ? ' is-current' : ''+ }`}+ title={glyph.label}+ aria-label={glyph.label}+ aria-pressed={current}+ onClick={() => onDone({ type: 'lucide', name: glyph.id })}+ >+ <NodeIconView icon={{ type: 'lucide', name: glyph.id }} size={18} />+ </button>+ )+ })}+ </div><div className="node-icon-dialog__grid">{PALETTE.map((e) => (<buttondiff --git a/src/renderer/components/ProjectGlyph.tsx b/src/renderer/components/ProjectGlyph.tsxindex 949caad9d..933ca67d0 100644--- a/src/renderer/components/ProjectGlyph.tsx+++ b/src/renderer/components/ProjectGlyph.tsx@@ -48,9 +48,10 @@ import {* so the bundler tree-shakes the rest of lucide's ~1k glyphs out; keyed by the same kebab ids as* `LUCIDE_ICON_IDS` (@shared/project-icon), which is the closed allowlist `sanitizeProjectIcon`* enforces AND the picker grid. An `icon.name` that isn't a key here degrades to the fallback- * (belt-and-braces — a sanitized icon's name is always a key).+ * (belt-and-braces — a sanitized icon's name is always a key). Also what `NodeIconView` draws a+ * node glyph from (`NODE_GLYPHS` is a subset of these ids) — one lucide table, not two.*/-const LUCIDE_ICONS: Record<string, LucideIcon> = {+export const LUCIDE_ICONS: Record<string, LucideIcon> = {folder: Folder,'folder-git': FolderGit,code: Code,@@ -93,6 +94,16 @@ const LUCIDE_ICONS: Record<string, LucideIcon> = {sparkles: Sparkles}+/**+ * The lucide component for an allowlisted id, or undefined. OWN entries only: `LUCIDE_ICONS` is a+ * plain object, so `LUCIDE_ICONS['__proto__']` / `['constructor']` / `['toString']` answer with an+ * inherited value — truthy, not a component — and React throws rendering it. The name comes from a+ * persisted file, so the lookup itself has to be safe, not just the validator in front of it.+ */+export function lucideIcon(name: string): LucideIcon | undefined {+ return Object.prototype.hasOwnProperty.call(LUCIDE_ICONS, name) ? LUCIDE_ICONS[name] : undefined+}+export interface ProjectGlyphProps {/** The project's icon, when it has one. Absent → render the site's pre-icon fallback. */icon?: ProjectIcon@@ -153,7 +164,7 @@ export function ProjectGlyph({}if (icon?.type === 'lucide') {- const Icon = LUCIDE_ICONS[icon.name]+ const Icon = lucideIcon(icon.name)if (Icon) {return (<spandiff --git a/src/renderer/components/SessionRow.test.tsx b/src/renderer/components/SessionRow.test.tsxindex 649d3e13e..f63be0d3d 100644--- a/src/renderer/components/SessionRow.test.tsx+++ b/src/renderer/components/SessionRow.test.tsx@@ -38,3 +38,31 @@ describe('SessionRow status age', () => {expect(html).toContain('Entered this state 5m ago')})})++// Issue #291: the icon shows wherever the node is listed — the sidebar row draws it through the+// same NodeIconView as the canvas header.+describe('SessionRow icon', () => {+ const render = (icon: SessionRowVM['icon']): string =>+ renderToStaticMarkup(+ <SessionRow+ row={{ ...row, icon }}+ onClick={vi.fn()}+ onClose={vi.fn()}+ onRename={vi.fn()}+ onAiName={vi.fn()}+ onContextMenu={vi.fn()}+ onDragStart={vi.fn()}+ onDragEnd={vi.fn()}+ />+ )++ it('draws a glyph icon as an svg inside the row icon slot', () => {+ const html = render({ type: 'lucide', name: 'database' })+ expect(html).toMatch(/<span class="node-icon ss-row__icon"[^>]*><svg[^>]*lucide-database/)+ })++ it('draws nothing for a glyph name the allowlist does not know', () => {+ const html = render({ type: 'lucide', name: 'skull' } as SessionRowVM['icon'])+ expect(html).not.toContain('ss-row__icon')+ })+})diff --git a/src/renderer/components/kanban/CardModal.test.tsx b/src/renderer/components/kanban/CardModal.test.tsxindex 12a3f4029..d29979891 100644--- a/src/renderer/components/kanban/CardModal.test.tsx+++ b/src/renderer/components/kanban/CardModal.test.tsx@@ -120,6 +120,45 @@ describe('CardModal', () => {document.body.innerHTML = ''})+ // #291 review: the header slot decided smiley-vs-icon on the RAW stored value, while+ // NodeIconView normalizes — so an invalid stored icon drew an empty, un-muted slot.+ it('shows the smiley "Set icon" slot for an icon that fails validation', () => {+ const icon = (value: unknown): HTMLButtonElement => {+ const root = createRoot(host)+ act(() =>+ root.render(+ <CardModal+ session={{ id: 'n1', title: 'db', color: '#fff', kind: 'sticky', text: '', spawn: {}, icon: value as never }}+ columnTitle="To Do"+ board={board}+ onChangeBoard={vi.fn()}+ onClose={vi.fn()}+ onOpenCanvas={vi.fn()}+ onRename={vi.fn()}+ onEditSticky={vi.fn()}+ onSetIcon={vi.fn()}+ onBrowserNav={vi.fn()}+ />+ )+ )+ const button = document.body.querySelector<HTMLButtonElement>('.kanban-modal__icon')!+ const snapshot = button.cloneNode(true) as HTMLButtonElement+ act(() => root.unmount())+ return snapshot+ }+ for (const bad of [{ type: 'lucide', name: '__proto__' }, { type: 'lucide', name: 'heart' }, { type: 'image', path: '/etc/passwd' }]) {+ const button = icon(bad)+ expect(button.title, JSON.stringify(bad)).toBe('Set icon')+ expect(button.className).toContain('kanban-modal__icon--empty')+ expect(button.querySelector('svg'), 'the smiley').toBeTruthy()+ expect(button.querySelector('.node-icon')).toBeNull()+ }+ const good = icon({ type: 'lucide', name: 'database' })+ expect(good.title).toBe('Change icon')+ expect(good.className).not.toContain('kanban-modal__icon--empty')+ expect(good.querySelector('.node-icon svg')).toBeTruthy()+ })+it('writes through raw textarea value on sticky note edit (including whitespace and newlines)', () => {const session: KanbanSession = {id: 'node-sticky-1',diff --git a/src/renderer/components/kanban/CardModal.tsx b/src/renderer/components/kanban/CardModal.tsxindex 870a3a005..0d72b5a13 100644--- a/src/renderer/components/kanban/CardModal.tsx+++ b/src/renderer/components/kanban/CardModal.tsx@@ -15,7 +15,7 @@ import {import { NodeIconView } from '../NodeIcon'import { nodeIconDialog } from '../NodeIconPicker'import { applyIconChoice } from '../../lib/nodeIconChoice'-import type { NodeIcon } from '@shared/node-icon'+import { normalizeNodeIcon, type NodeIcon } from '@shared/node-icon'import { ContextMeter } from '../ContextMeter'import { isRemoteSessionNode } from '@shared/worktree'import { AccountChip, useAccountChip } from '../AccountChip'@@ -107,6 +107,9 @@ interface CardModalProps {* canvas node shows (the node itself is hidden under the board). */export function CardModal({ session, columnTitle, board, onChangeBoard, onClose, portsProjectId, onOpenCanvas, onRename, onEditSticky, onBrowserNav, onSetIcon, onOpenIssue, mentionables, team, onTravel }: CardModalProps) {const { api } = useSession()+ // The header slot decides "icon or smiley" on the NORMALIZED value, the answer NodeIconView+ // itself gives — on the raw one, an invalid stored icon drew an empty, un-muted slot.+ const sessionIcon = normalizeNodeIcon(session.icon)const idRef = useRef<string>()if (!idRef.current) idRef.current = nextDialogId()const id = idRef.current@@ -340,17 +343,17 @@ export function CardModal({ session, columnTitle, board, onChangeBoard, onClose,><span className="kanban-card__nodedot" style={{ background: session.color }} /><button- className={`kanban-modal__icon${session.icon ? '' : ' kanban-modal__icon--empty'}`}- title={session.icon ? 'Change icon' : 'Set icon'}+ className={`kanban-modal__icon${sessionIcon ? '' : ' kanban-modal__icon--empty'}`}+ title={sessionIcon ? 'Change icon' : 'Set icon'}onClick={() =>void nodeIconDialog({nodeId: session.id,title: session.title,- icon: session.icon+ icon: sessionIcon}).then((choice) => applyIconChoice(choice, onSetIcon))}>- {session.icon ? <NodeIconView icon={session.icon} size={16} /> : <IconSmiley />}+ {sessionIcon ? <NodeIconView icon={sessionIcon} size={16} /> : <IconSmiley />}</button>{editingTitle ? (<inputdiff --git a/src/renderer/lib/closedHistory.test.ts b/src/renderer/lib/closedHistory.test.tsindex 7239efe01..a4c40e730 100644--- a/src/renderer/lib/closedHistory.test.ts+++ b/src/renderer/lib/closedHistory.test.ts@@ -73,6 +73,28 @@ describe('stateToReopenSnapshot', () => {expect(snap.data.agentId).toBe('claude')})+ // The persisted twin lives in workspace.json — hand-editable — so the icon is re-validated+ // here rather than trusted: a reopened session keeps its icon, a garbage one is dropped.+ it('carries the node icon through, and drops one that fails validation', () => {+ const entry = (icon: unknown): ClosedSessionEntry => ({+ id: 'e1', closedAt: 1,+ node: {+ id: 'n1', kind: 'terminal', position: { x: 0, y: 0 }, size: { width: 10, height: 10 },+ title: 'db', color: '#fff', group: null, icon: icon as never+ },+ absolutePosition: { x: 0, y: 0 }+ })+ expect(stateToReopenSnapshot(entry({ type: 'lucide', name: 'database' })).data.icon).toEqual({+ type: 'lucide',+ name: 'database'+ })+ expect(stateToReopenSnapshot(entry({ type: 'emoji', value: '\u{1F680}' })).data.icon).toEqual({+ type: 'emoji',+ value: '\u{1F680}'+ })+ expect(stateToReopenSnapshot(entry({ type: 'lucide', name: 'nope' })).data.icon).toBeUndefined()+ })+it('omits parentId/extent when the node was never parented', () => {const entry: ClosedSessionEntry = {id: 'e1', closedAt: 1,diff --git a/src/renderer/lib/closedHistory.ts b/src/renderer/lib/closedHistory.tsindex 2e020df54..7316153fd 100644--- a/src/renderer/lib/closedHistory.ts+++ b/src/renderer/lib/closedHistory.ts@@ -3,6 +3,7 @@ import { canChat, createdAgentId } from '@shared/agents/config'import { flowToNodeStates, type CanvasNode } from '@renderer/state/workspace'import { snapshotNode, type ReopenNodeSnapshot, type RestorableNodeKind } from './reopenNode'import { absolutePosition, type FocusableNode } from './nodeFocus'+import { normalizeNodeIcon } from '@shared/node-icon'/*** Builds one `ClosedSessionEntry` per node in `deletedIds` that `snapshotNode` would also accept@@ -136,6 +137,8 @@ export function stateToReopenSnapshot(entry: ClosedSessionEntry): ReopenNodeSnaptags: n.tags,collapsed: n.collapsed,hideFanout: n.hideFanout,+ // Re-validated, not copied: this entry was read from hand-editable workspace.json.+ icon: normalizeNodeIcon(n.icon),shell: n.shell,cwd: n.cwd,text: n.text,diff --git a/src/renderer/lib/reopenNode.test.ts b/src/renderer/lib/reopenNode.test.tsindex a9238eb52..c46228d25 100644--- a/src/renderer/lib/reopenNode.test.ts+++ b/src/renderer/lib/reopenNode.test.ts@@ -117,6 +117,20 @@ describe('recreateNodeFromSnapshot', () => {expect(node).toBeNull()})+ // ⇧⌘T used to bring a session back without its icon: `icon` was not a cosmetic key.+ it('carries the node icon over, re-validated', () => {+ const withIcon = (icon: unknown) =>+ recreateNodeFromSnapshot(+ snap({ type: 'terminal', data: { title: 'db', color: '#fff', group: null, icon: icon as never } }),+ baseCtx()+ )+ expect(withIcon({ type: 'lucide', name: 'database' })!.data.icon).toEqual({+ type: 'lucide',+ name: 'database'+ })+ expect(withIcon({ type: 'lucide', name: 'nope' })!.data.icon).toBeUndefined()+ })+it('recreates a dino node carrying its high score', () => {const node = recreateNodeFromSnapshot(snap({ type: 'dino', data: { title: 'Dino', color: '#a2a2a2', group: null, highScore: 42 } }),diff --git a/src/renderer/lib/reopenNode.ts b/src/renderer/lib/reopenNode.tsindex cbd59a23c..14c50fb47 100644--- a/src/renderer/lib/reopenNode.ts+++ b/src/renderer/lib/reopenNode.ts@@ -16,6 +16,7 @@ import {isAccountLoginNode} from '@renderer/state/workspace'import { absolutePosition, type FocusableNode } from './nodeFocus'+import { normalizeNodeIcon } from '@shared/node-icon'export type RestorableNodeKind = Exclude<NodeKind, 'group' | 'subagent' | 'loop'>@@ -108,6 +109,11 @@ function withCosmetics(node: CanvasNode, data: NodeData): CanvasNode {const value = data[key]if (value !== undefined) (cosmetics as Record<string, unknown>)[key] = value}+ // The icon is a cosmetic too, but not a plain copy: a persisted snapshot comes from+ // workspace.json, which is hand-editable, so it crosses the same validator hydration uses.+ // Without this a reopened session came back without the icon it was closed with.+ const icon = normalizeNodeIcon(data.icon)+ if (icon) cosmetics.icon = iconreturn { ...node, data: { ...node.data, ...cosmetics } }}diff --git a/src/renderer/nodes/TerminalNode.tsx b/src/renderer/nodes/TerminalNode.tsxindex 2c2a87755..0784f3249 100644--- a/src/renderer/nodes/TerminalNode.tsx+++ b/src/renderer/nodes/TerminalNode.tsx@@ -310,7 +310,7 @@ import { MaximizeButton } from './MaximizeButton'import { NodeIconView } from '../components/NodeIcon'import { nodeIconDialog } from '../components/NodeIconPicker'import { applyIconChoice } from '../lib/nodeIconChoice'-import type { NodeIcon } from '@shared/node-icon'+import { normalizeNodeIcon } from '@shared/node-icon'import { connectHostAttachment } from '../lib/sshAttachments'import { projectMayDialSsh } from '../session/relay-ssh'import { waitForSshRemote } from '../lib/sshRemoteWait'@@ -5784,6 +5784,10 @@ export function TerminalNode({// The experimental shared glyph renderer paints text on a canvas BELOW the nodes, so a glass// tint would sit on top of every glyph: glass stands down while a grid is mounted.const glassOn = glassVars !== null && !glyphMounted+ // The header's icon button is conditional, so it is gated on the NORMALIZED icon — the same+ // answer NodeIconView gives. Gated on the raw value, an invalid stored icon left an empty button+ // (and a flex gap) between the color swatch and the title.+ const headerIcon = normalizeNodeIcon(data.icon)return (<>{/* Sibling of the root: .term-node is overflow:hidden and would clip the half-pill. */}@@ -5872,7 +5876,7 @@ export function TerminalNode({}}/>)}- {data.icon ? (+ {headerIcon ? (<buttonclassName="term-node__icon nodrag"title="Change icon"@@ -5881,13 +5885,13 @@ export function TerminalNode({void nodeIconDialog({nodeId: id,title: (data.title as string) ?? '',- icon: data.icon as NodeIcon+ icon: headerIcon}).then((choice) =>applyIconChoice(choice, (icon) => updateNodeData(id, { icon })))}}>- <NodeIconView icon={data.icon as NodeIcon} size={15} />+ <NodeIconView icon={headerIcon} size={15} /></button>) : null}{editingTitle ? (diff --git a/src/renderer/state/workspace.test.ts b/src/renderer/state/workspace.test.tsindex 67db51d95..909d1dc0f 100644--- a/src/renderer/state/workspace.test.ts+++ b/src/renderer/state/workspace.test.ts@@ -665,6 +665,20 @@ describe('node icon serialization', () => {expect(nodeStatesToFlow(states)[0].data.icon).toEqual(icon)})+ it('round-trips a glyph icon (#291)', () => {+ const icon = { type: 'lucide', name: 'folder-git' }+ const states = flowToNodeStates([withIcon(icon)])+ expect(states[0].icon).toEqual(icon)+ expect(nodeStatesToFlow(states)[0].data.icon).toEqual(icon)+ })++ it('drops a glyph outside the allowlist on the way in AND out (#291)', () => {+ const junk = { type: 'lucide', name: 'not-a-glyph' }+ expect(flowToNodeStates([withIcon(junk)])[0].icon).toBeUndefined()+ // eslint-disable-next-line @typescript-eslint/no-explicit-any+ expect(nodeStatesToFlow([stateWithIcon(junk) as any])[0].data.icon).toBeUndefined()+ })+it('leaves a node without one undefined, so an untouched canvas serializes as it always did', () => {expect(flowToNodeStates([withIcon(undefined)])[0].icon).toBeUndefined()})diff --git a/src/renderer/styles.css b/src/renderer/styles.cssindex 195b5f225..a4ff0308f 100644--- a/src/renderer/styles.css+++ b/src/renderer/styles.css@@ -14835,6 +14835,10 @@ body.focus-mode .dock:hover {text-align: center;}+.node-icon svg {+ display: block;+}+.node-icon img {width: 100%;height: 100%;@@ -14919,6 +14923,16 @@ body.focus-mode .dock:hover {background: color-mix(in srgb, var(--accent) 35%, transparent);}+/* A glyph swatch (issue #291) draws an svg in `currentColor`, so it needs the text color a+ button does not inherit, and centering the emoji swatches get from their line box. */+.node-icon-dialog__swatch--glyph {+ display: flex;+ align-items: center;+ justify-content: center;+ color: var(--text);+ padding: 5px 0;+}+.node-icon-dialog__row {display: flex;gap: 8px;diff --git a/src/shared/node-icon.test.ts b/src/shared/node-icon.test.tsindex 214818980..7c788765f 100644--- a/src/shared/node-icon.test.ts+++ b/src/shared/node-icon.test.ts@@ -2,11 +2,13 @@ import { describe, expect, it } from 'vitest'import {iconFileName,localIconCwd,+ NODE_GLYPHS,nodeIconMime,normalizeNodeIcon,portableIconPath,resolveIconPath} from './node-icon'+import { LUCIDE_ICON_IDS } from './project-icon'// The value under test arrives from `.nodeterm/project.json` — git-shared, hand-editable, and on// an SSH project a file on someone else's host. Every case below is a thing that file can say.@@ -292,3 +294,46 @@ describe('localIconCwd', () => {expect(localIconCwd(undefined)).toBeUndefined()})})++// Issue #291: a curated glyph set — shell, git, database, … — beside emoji and image. Same file,+// same hostility: the name is an allowlist key, never a free lucide export name.+describe('glyph icons', () => {+ it('keeps every curated glyph', () => {+ for (const glyph of NODE_GLYPHS) {+ expect(normalizeNodeIcon({ type: 'lucide', name: glyph.id })).toEqual({+ type: 'lucide',+ name: glyph.id+ })+ }+ })++ it('offers the kinds the issue names', () => {+ const ids = NODE_GLYPHS.map((g) => g.id)+ for (const id of ['terminal', 'folder-git', 'database', 'server', 'file-text']) {+ expect(ids).toContain(id)+ }+ })++ it('is a subset of the lucide ids the renderer can draw, with a label each', () => {+ for (const glyph of NODE_GLYPHS) {+ expect(LUCIDE_ICON_IDS as readonly string[]).toContain(glyph.id)+ expect(glyph.label.trim()).not.toBe('')+ }+ expect(new Set(NODE_GLYPHS.map((g) => g.id)).size).toBe(NODE_GLYPHS.length)+ })++ it('drops a name outside the allowlist, so a shared file cannot name an arbitrary export', () => {+ expect(normalizeNodeIcon({ type: 'lucide', name: 'skull' })).toBeUndefined()+ expect(normalizeNodeIcon({ type: 'lucide', name: 'Terminal' })).toBeUndefined()+ expect(normalizeNodeIcon({ type: 'lucide', name: ' terminal' })).toBeUndefined()+ expect(normalizeNodeIcon({ type: 'lucide', name: 42 })).toBeUndefined()+ expect(normalizeNodeIcon({ type: 'lucide' })).toBeUndefined()+ })++ it('keeps only the canonical fields', () => {+ expect(normalizeNodeIcon({ type: 'lucide', name: 'database', color: 'red', path: '/x.png' })).toEqual({+ type: 'lucide',+ name: 'database'+ })+ })+})diff --git a/src/shared/node-icon.ts b/src/shared/node-icon.tsindex 7b65a32d8..b6c3dd83f 100644--- a/src/shared/node-icon.ts+++ b/src/shared/node-icon.ts@@ -1,5 +1,7 @@+import type { LUCIDE_ICON_IDS } from './project-icon'+/**- * A canvas node's user-chosen icon: one emoji/character, or a small image file.+ * A canvas node's user-chosen icon: one emoji/character, a curated glyph, or a small image file.** The value is persisted in `.nodeterm/project.json`, which is git-shared, hand-editable and —* for an SSH project — a file on the remote host. So nothing here trusts its input: every value@@ -67,11 +69,45 @@ export const NODE_ICON_MIME: Record<string, string> = {avif: 'image/avif'}-/** A node's icon: one emoji/character, or an image file beside the project. */+/** A node's icon: one emoji/character, a curated glyph, or an image file beside the project. */export type NodeIcon =| { type: 'emoji'; value: string }+ | { type: 'lucide'; name: string }| { type: 'image'; path: string }+/**+ * The curated glyphs a node icon may be (issue #291): what a terminal IS — a shell, a git repo, a+ * database session — rather than an emoji mood. Stored as `{ type: 'lucide', name }`, the shape a+ * project icon's glyph already has, so one vocabulary covers both.+ *+ * A closed allowlist and a SUBSET of the project icon's `LUCIDE_ICON_IDS` — the type below makes+ * the compiler refuse an id outside it — so the renderer draws a node glyph from the same map a+ * project glyph uses and no second lucide table exists. Order is the picker's grid order. The+ * label is the button's accessible name and tooltip; it is never stored.+ */+export const NODE_GLYPHS: readonly { readonly id: (typeof LUCIDE_ICON_IDS)[number]; readonly label: string }[] = [+ { id: 'terminal', label: 'Shell' },+ { id: 'folder-git', label: 'Git repo' },+ { id: 'database', label: 'Database' },+ { id: 'server', label: 'Server' },+ { id: 'cloud', label: 'Cloud' },+ { id: 'globe', label: 'Web' },+ { id: 'code', label: 'Code' },+ { id: 'braces', label: 'Config' },+ { id: 'file-text', label: 'Docs' },+ { id: 'book', label: 'Notes' },+ { id: 'package', label: 'Build' },+ { id: 'rocket', label: 'Deploy' },+ { id: 'beaker', label: 'Tests' },+ { id: 'bug', label: 'Debug' },+ { id: 'wrench', label: 'Tools' },+ { id: 'cpu', label: 'System' },+ { id: 'shield', label: 'Security' },+ { id: 'key', label: 'Secrets' }+]++const NODE_GLYPH_IDS: ReadonlySet<string> = new Set(NODE_GLYPHS.map((g) => g.id))+/*** Hard ceiling on an emoji's UTF-16 length, applied when `Intl.Segmenter` is unavailable so the* grapheme walk below cannot be the only thing standing between a shared file and a blob. Sized@@ -204,6 +240,12 @@ export function normalizeNodeIcon(raw: unknown): NodeIcon | undefined {const value = firstGrapheme(v.value)return value ? { type: 'emoji', value } : undefined}+ if (v.type === 'lucide') {+ // Exact match only — no trimming or case-folding. The value is written by the picker, so a+ // near miss is a hand edit or a newer build's glyph, and an unrecognized icon is no icon.+ const name = (raw as { name?: unknown }).name+ return typeof name === 'string' && NODE_GLYPH_IDS.has(name) ? { type: 'lucide', name } : undefined+ }if (v.type === 'image') {if (typeof v.path !== 'string') return undefinedconst path = v.path.trim()