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): video/web node kinds — factories + serializers
enes2587d7e8f493
diff --git a/src/renderer/state/workspace.media.test.ts b/src/renderer/state/workspace.media.test.tsnew file mode 100644index 000000000..66f7b2e33--- /dev/null+++ b/src/renderer/state/workspace.media.test.ts@@ -0,0 +1,42 @@+import { describe, it, expect } from 'vitest'+import {+ createVideoNode,+ createWebNode,+ isVideoFile,+ nodeStatesToFlow,+ flowToNodeStates+} from './workspace'++describe('video/web nodes', () => {+ it('isVideoFile matches common video extensions, not images', () => {+ expect(isVideoFile('/a/b/clip.mp4')).toBe(true)+ expect(isVideoFile('/a/b/CLIP.WEBM')).toBe(true)+ expect(isVideoFile('movie.mov')).toBe(true)+ expect(isVideoFile('/a/photo.png')).toBe(false)+ expect(isVideoFile('/a/readme.md')).toBe(false)+ })++ it('createVideoNode carries kind video + filePath', () => {+ const n = createVideoNode(0, '/clips/demo.mp4')+ expect(n.type).toBe('video')+ expect(n.data.filePath).toBe('/clips/demo.mp4')+ expect(n.data.title).toBe('demo.mp4')+ })++ it('createWebNode carries url or filePath', () => {+ expect(createWebNode(0, { url: 'http://localhost:3000' }).data.url).toBe('http://localhost:3000')+ expect(createWebNode(0, { filePath: '/tmp/p.html' }).data.filePath).toBe('/tmp/p.html')+ })++ it('serializer round-trip preserves video/web kind + url + filePath', () => {+ const flow = [+ createVideoNode(0, '/clips/demo.mp4'),+ createWebNode(1, { url: 'http://localhost:5173' })+ ]+ const round = nodeStatesToFlow(flowToNodeStates(flow))+ const v = round.find((n) => n.type === 'video')!+ const w = round.find((n) => n.type === 'web')!+ expect(v.data.filePath).toBe('/clips/demo.mp4')+ expect(w.data.url).toBe('http://localhost:5173')+ })+})diff --git a/src/renderer/state/workspace.ts b/src/renderer/state/workspace.tsindex 345b37acd..7dccb7d79 100644--- a/src/renderer/state/workspace.ts+++ b/src/renderer/state/workspace.ts@@ -21,6 +21,8 @@ const GROUP_SIZE = { width: 520, height: 360 }const EDITOR_SIZE = { width: 660, height: 460 }const DIFF_SIZE = { width: 860, height: 500 }const DINO_SIZE = { width: 600, height: 200 }+const VIDEO_SIZE = { width: 640, height: 420 }+const WEB_SIZE = { width: 720, height: 520 }/** Height of a node when collapsed (header only). */export const COLLAPSED_HEIGHT = 40@@ -52,6 +54,8 @@ export interface NodeData {cwd?: stringtext?: stringfilePath?: string+ /** web-only: live URL to load in the web (webview) node. */+ url?: stringdiffStaged?: booleancommitOid?: string/** dino-only: best score reached in the T-Rex Runner game. */@@ -305,6 +309,62 @@ export function createEditorNode(}}+const VIDEO_EXTS = ['mp4', 'webm', 'mov', 'm4v', 'mkv', 'ogv', 'avi']++/** True when a path looks like a playable video file (by extension). */+export function isVideoFile(path: string): boolean {+ const ext = path.split('.').pop()?.toLowerCase() ?? ''+ return VIDEO_EXTS.includes(ext)+}++/** Creates a video player node for a local video file (streamed via nt-media://). */+export function createVideoNode(+ index: number,+ filePath: string,+ center?: { x: number; y: number }+): CanvasNode {+ return {+ id: nextId('video'),+ type: 'video',+ position: placeAt(center, index, VIDEO_SIZE.width, VIDEO_SIZE.height),+ width: VIDEO_SIZE.width,+ height: VIDEO_SIZE.height,+ style: { width: VIDEO_SIZE.width, height: VIDEO_SIZE.height },+ data: {+ title: filePath.split('/').pop() || 'video',+ color: '#bf5af2',+ group: null,+ filePath+ }+ }+}++/** Creates a web (webview) node showing a live URL or a local html file. */+export function createWebNode(+ index: number,+ src: { url?: string; filePath?: string },+ center?: { x: number; y: number }+): CanvasNode {+ const title = src.url+ ? src.url.replace(/^https?:\/\//, '').slice(0, 40)+ : src.filePath?.split('/').pop() || 'web'+ return {+ id: nextId('web'),+ type: 'web',+ position: placeAt(center, index, WEB_SIZE.width, WEB_SIZE.height),+ width: WEB_SIZE.width,+ height: WEB_SIZE.height,+ style: { width: WEB_SIZE.width, height: WEB_SIZE.height },+ data: {+ title,+ color: '#6ac4dc',+ group: null,+ ...(src.url ? { url: src.url } : {}),+ ...(src.filePath ? { filePath: src.filePath } : {})+ }+ }+}+/** Creates a diff editor node for a changed file (relative path + repo cwd). */export function createDiffNode(index: number,@@ -625,6 +685,7 @@ export function nodeStatesToFlow(states: CanvasNodeState[]): CanvasNode[] {cwd: n.cwd,text: n.text,filePath: n.filePath,+ url: n.url,diffStaged: n.diffStaged,commitOid: n.commitOid,highScore: n.highScore,@@ -649,9 +710,13 @@ export function flowToNodeStates(nodes: CanvasNode[]): CanvasNodeState[] {? EDITOR_SIZE: kind === 'diff'? DIFF_SIZE- : kind === 'dino'- ? DINO_SIZE- : TERMINAL_SIZE+ : kind === 'video'+ ? VIDEO_SIZE+ : kind === 'web'+ ? WEB_SIZE+ : kind === 'dino'+ ? DINO_SIZE+ : TERMINAL_SIZEreturn nodes// Remote terminals are transient to a live relay connection — never persist them (their// connectionId is dead after a restart, and they'd otherwise reattach to a stray local tmux).@@ -681,6 +746,7 @@ export function flowToNodeStates(nodes: CanvasNode[]): CanvasNodeState[] {cwd: n.data.cwd,text: n.data.text,filePath: n.data.filePath,+ url: n.data.url,diffStaged: n.data.diffStaged,commitOid: n.data.commitOid,highScore: n.data.highScore,diff --git a/src/shared/types.ts b/src/shared/types.tsindex f750e1f77..efdbc12c2 100644--- a/src/shared/types.ts+++ b/src/shared/types.ts@@ -38,7 +38,7 @@ export interface PtyCreateResult {}// 'subagent' and 'loop' are render-only (ephemeral hook-driven viz) and never persisted.-export type NodeKind = 'terminal' | 'sticky' | 'group' | 'editor' | 'diff' | 'subagent' | 'loop' | 'dino'+export type NodeKind = 'terminal' | 'sticky' | 'group' | 'editor' | 'diff' | 'video' | 'web' | 'subagent' | 'loop' | 'dino'/** Persisted state of a single canvas node (terminal, sticky note, group frame, or editor). */export interface CanvasNodeState {@@ -78,6 +78,8 @@ export interface CanvasNodeState {highScore?: number// editor / difffilePath?: string+ /** web-only: when set, the web node loads this live URL (else it loads `filePath` as local html). */+ url?: string/** diff-only: true = staged diff (HEAD vs index), false = unstaged (index vs working). */diffStaged?: boolean/** diff-only: when set, the diff shows parent (<oid>^) vs commit (<oid>) for a file from history. */