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(media): route audio to players and retain remote files for seeking
review129450dde3cb
diff --git a/CLAUDE.md b/CLAUDE.mdindex f108819c7..d2fb92d7f 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -4685,3 +4685,15 @@ sessions is a hazard whatever kills it; this removes the hazard, not a proven cafollow-up note rather than same-PR work — but flag it so it isn't forgotten.When a change is genuinely desktop-only (native menus, auto-update, Keychain), say so; thepoint is to make the call consciously, not to leave the other surfaces to rot.++## Media playback lifetime (#680)++Audio routes through `isMediaFile` to the existing persisted `video` kind and native audio controls.+Legacy audio editor nodes migrate on load. Desktop uses the existing local/SSH allowlist; Server+and relay retain their explicit media transport degradation. Native mobile does not consume these+React nodes; its own player/IME behavior requires a separate device check.++Remote cache entries requested in this run are retained until exit, including cache hits; pruning+waits are coordinated with a concurrent cache reader. The 20-entry cap is soft for retained files,+so disk use may grow in a long run; prior-run entries are eligible again after restart. `mediaRange`+handles suffix ranges and rejects unsatisfiable ones without weakening the serve-time path jail.diff --git a/CONTRIBUTING.md b/CONTRIBUTING.mdindex 0223794bd..aee2f2fea 100644--- a/CONTRIBUTING.md+++ b/CONTRIBUTING.md@@ -690,3 +690,6 @@ Two files, two audiences:**If you change or discover something other contributors must know, update this file too.** Aninvariant that only lives in a commit message is one refactor away from being violated by someonewho never saw it.++- Media URLs live for the app run. Remote cache pruning must keep files already handed to+ players; the cache cap is soft until restart. Use the existing `video` node for audio too.diff --git a/src/core/media-range.test.ts b/src/core/media-range.test.tsnew file mode 100644index 000000000..77d766eb5--- /dev/null+++ b/src/core/media-range.test.ts@@ -0,0 +1,20 @@+import { describe, expect, it } from 'vitest'+import { mediaRange } from './media-range'++describe('media byte ranges', () => {+ it.each([+ ['bytes=2-5', 2, 5], ['bytes=2-', 2, 9], ['bytes=2-99', 2, 9],+ ['bytes=-3', 7, 9], ['bytes=-99', 0, 9]+ ])('%s selects the intended bytes', (header, start, end) => {+ expect(mediaRange(header as string, 10)).toEqual({ kind: 'partial', start, end })+ })+ it.each(['bytes=10-', 'bytes=-0'])('%s cannot be satisfied', (header) => {+ expect(mediaRange(header, 10)).toEqual({ kind: 'unsatisfiable' })+ })+ it('an empty file cannot satisfy a range', () => {+ expect(mediaRange('bytes=0-', 0)).toEqual({ kind: 'unsatisfiable' })+ })+ it.each([null, 'bytes=8-2', 'bytes=-', 'bytes=0-1,3-4', 'xbytes=1-3', 'bytes=99999999999999999-'])('ignores malformed/unsupported %s', (header) => {+ expect(mediaRange(header, 10)).toEqual({ kind: 'full' })+ })+})diff --git a/src/core/media-range.ts b/src/core/media-range.tsnew file mode 100644index 000000000..18236b53c--- /dev/null+++ b/src/core/media-range.ts@@ -0,0 +1,21 @@+/** One HTTP byte range. Unsupported/malformed ranges are ignored (serve 200), while a valid+ * but unsatisfiable range returns 416. Never pass reversed or unsafe offsets to fs streams. */+export function mediaRange(header: string | null, size: number):+ | { kind: 'full' }+ | { kind: 'unsatisfiable' }+ | { kind: 'partial'; start: number; end: number } {+ const m = header && /^bytes=(\d*)-(\d*)$/.exec(header.trim())+ if (!m || (!m[1] && !m[2])) return { kind: 'full' }+ const first = m[1] ? Number(m[1]) : undefined+ const last = m[2] ? Number(m[2]) : undefined+ if ((first !== undefined && !Number.isSafeInteger(first)) ||+ (last !== undefined && !Number.isSafeInteger(last))) return { kind: 'full' }+ if (first !== undefined && last !== undefined && last < first) return { kind: 'full' }+ if (size === 0 || (first !== undefined && first >= size) ||+ (first === undefined && last === 0)) return { kind: 'unsatisfiable' }+ return {+ kind: 'partial',+ start: first ?? Math.max(0, size - last!),+ end: first === undefined ? size - 1 : Math.min(last ?? size - 1, size - 1)+ }+}diff --git a/src/core/remote-ssh/media-cache.test.ts b/src/core/remote-ssh/media-cache.test.tsindex fe06c2628..7c6c07a21 100644--- a/src/core/remote-ssh/media-cache.test.ts+++ b/src/core/remote-ssh/media-cache.test.ts@@ -40,3 +40,9 @@ describe('mediaCachePruneList', () => {expect(MEDIA_CACHE_KEEP).toBeGreaterThan(0)})})++it('retains session media even when older than the cache cap', () => {+ const entries = [{ name: 'playing', mtimeMs: 1 }, { name: 'old', mtimeMs: 2 }, { name: 'new', mtimeMs: 3 }]+ expect(mediaCachePruneList(entries, 'new', 1, new Set(['playing']))).toEqual(['old'])+ expect(mediaCachePruneList(entries, 'new', 1)).toEqual(['old', 'playing'])+})diff --git a/src/core/remote-ssh/media-cache.ts b/src/core/remote-ssh/media-cache.tsindex 12f20efd0..6098483f9 100644--- a/src/core/remote-ssh/media-cache.ts+++ b/src/core/remote-ssh/media-cache.ts@@ -25,11 +25,13 @@ export const MEDIA_CACHE_KEEP = 20export function mediaCachePruneList(entries: readonly { name: string; mtimeMs: number }[],except: string,- keep: number = MEDIA_CACHE_KEEP+ keep: number = MEDIA_CACHE_KEEP,+ retained: ReadonlySet<string> = new Set()): string[] {return entries.filter((e) => e.name !== except).sort((a, b) => b.mtimeMs - a.mtimeMs).slice(Math.max(0, keep - 1)).map((e) => e.name)+ .filter((name) => !retained.has(name))}diff --git a/src/main/media-protocol.range.test.ts b/src/main/media-protocol.range.test.tsnew file mode 100644index 000000000..d4000fdd4--- /dev/null+++ b/src/main/media-protocol.range.test.ts@@ -0,0 +1,27 @@+import { afterEach, expect, it, vi } from 'vitest'+import { mkdtemp, writeFile, rm } from 'node:fs/promises'+import { tmpdir } from 'node:os'+import { join } from 'node:path'+const protocol = vi.hoisted(() => ({ handle: vi.fn() }))+vi.mock('electron', () => ({ protocol, app: { getPath: () => '/nonexistent-media-fixture' } }))+import { allowMediaPath, initMediaProtocol } from './media-protocol'+const dirs: string[] = []+afterEach(async () => { await Promise.all(dirs.splice(0).map((d) => rm(d, { recursive: true, force: true }))) })+it('serves real suffix bytes and refuses an unallowlisted path before handling a range', async () => {+ const dir = await mkdtemp(join(tmpdir(), 'nt-range-')); dirs.push(dir)+ const file = join(dir, 'clip.mp4')+ await writeFile(file, '0123456789')+ initMediaProtocol()+ const handle = protocol.handle.mock.calls.at(-1)![1] as (r: Request) => Promise<Response>+ const url = allowMediaPath(file)+ const response = await handle(new Request(url, { headers: { range: 'bytes=-3' } }))+ expect(response.status).toBe(206)+ expect(response.headers.get('content-range')).toBe('bytes 7-9/10')+ expect(await response.text()).toBe('789')+ const bad = await handle(new Request(url, { headers: { range: 'bytes=10-' } }))+ expect(bad.status).toBe(416)+ const reversed = await handle(new Request(url, { headers: { range: 'bytes=8-2' } }))+ expect(reversed.status).toBe(200)+ expect(await reversed.text()).toBe('0123456789')+ expect((await handle(new Request(`${url}.unknown`, { headers: { range: 'bytes=0-' } }))).status).toBe(404)+})diff --git a/src/main/media-protocol.ts b/src/main/media-protocol.tsindex f31214a70..8fd105fdd 100644--- a/src/main/media-protocol.ts+++ b/src/main/media-protocol.ts@@ -4,6 +4,7 @@import { createReadStream, mkdirSync, writeFileSync, promises as fsp } from 'fs'import { join, normalize, sep } from 'path'import { app, protocol } from 'electron'+import { mediaRange } from '../core/media-range'export const MEDIA_SCHEME = 'nt-media'@@ -163,19 +164,15 @@ export function initMediaProtocol(): void {}// Agent-authored HTML gets a restrictive CSP; video/image files get none (unchanged).const isAgentHtml = abs.startsWith(agentWebDir() + sep)- const range = req.headers.get('range')- const m = range && /bytes=(\d*)-(\d*)/.exec(range)- if (m) {- const start = m[1] ? parseInt(m[1], 10) : 0- let end = m[2] ? parseInt(m[2], 10) : size - 1- // Unsatisfiable range → 416 (NaN/negative start or start past EOF).- if (!Number.isFinite(start) || start < 0 || start >= size) {- return new Response('Range Not Satisfiable', {- status: 416,- headers: { 'Content-Range': `bytes */${size}` }- })- }- end = Math.min(end, size - 1)+ const range = mediaRange(req.headers.get('range'), size)+ if (range.kind === 'unsatisfiable') {+ return new Response('Range Not Satisfiable', {+ status: 416,+ headers: { 'Content-Range': `bytes */${size}` }+ })+ }+ if (range.kind === 'partial') {+ const { start, end } = rangeconst stream = createReadStream(abs, { start, end })stream.on('error', () => stream.destroy())const headers: Record<string, string> = {diff --git a/src/main/remote-ssh/ssh-project.test.ts b/src/main/remote-ssh/ssh-project.test.tsindex 4ae20ed19..aa37843a1 100644--- a/src/main/remote-ssh/ssh-project.test.ts+++ b/src/main/remote-ssh/ssh-project.test.ts@@ -894,6 +894,34 @@ describe('SshProjectManager', () => {expect((await fs.readdir(dir)).filter((file) => file.endsWith('.part'))).toEqual([])})+ it('keeps an open media file seekable after more than twenty later downloads', async () => {+ const dir = await destDir()+ const mgr = new SshProjectManager({+ userDataDir: '/ud',+ spawnMaster: vi.fn(() => ({ kill: vi.fn(), on: vi.fn() })),+ run: vi.fn(async (args: string[]) => ({+ code: args.at(-1)?.includes('test -d') ? 1 : 0,+ stdout: args.at(-1)?.includes('wc -c') ? '4' : '/home/u'+ })),+ runScp: vi.fn(async (args: string[]) => {+ await fs.writeFile(args.at(-1)!, 'data')+ return { code: 0 }+ }),+ getHook: () => ({ port: 1, token: 't', version: '1' }),+ onStatus: vi.fn()+ })+ await mgr.connect('p1', conn, '/srv/repo')+ const first = await mgr.cacheMediaFile('p1', '/srv/first.mp3', dir)+ expect(first.ok).toBe(true)+ // Await the real pruner to make deletion observable, without timing sleeps.+ for (let i = 0; i < 22; i++) {+ const next = await mgr.cacheMediaFile('p1', `/srv/clip-${i}.mp4`, dir)+ expect(next.ok).toBe(true)+ if (next.ok) await (mgr as unknown as { pruneMediaCache(d: string, n: string): Promise<void> }).pruneMediaCache(dir, path.basename(next.localPath))+ }+ expect(first.ok && await fs.readFile(first.localPath, 'utf8')).toBe('data')+ })+it('does not replace a cache entry when checking it fails for a reason other than absence', async () => {const dir = await destDir()const runScp = vi.fn(async () => ({ code: 0 }))diff --git a/src/main/remote-ssh/ssh-project.ts b/src/main/remote-ssh/ssh-project.tsindex 952aa10ec..6120b852a 100644--- a/src/main/remote-ssh/ssh-project.ts+++ b/src/main/remote-ssh/ssh-project.ts@@ -1267,6 +1267,10 @@ export class SshProjectManager {throw new Error('Could not reserve a download destination.')}+ // URLs remain allowlisted until quit, so their cache files must live just as long.+ private readonly retainedMedia = new Set<string>()+ private readonly mediaPrunes = new Map<string, Promise<void>>()+/*** Pull a remote FILE into the local media cache (for nt-media:// playback) and resolve its* cached absolute path. The entry is keyed by (host, remote path), see remoteMediaCacheName ,@@ -1294,6 +1298,10 @@ export class SshProjectManager {childArgs(c.conn, c.controlPath, `wc -c < ${quoteRemotePath(remotePath)}`))const remoteSize = sizeProbe.code === 0 ? parseInt(sizeProbe.stdout.trim(), 10) : NaN+ // Pin before reading. A prune already in flight must settle before stat/reuse, or it+ // could unlink the file just after we hand its URL to the player.+ this.retainedMedia.add(path.basename(dest))+ await this.mediaPrunes.get(dest)let cachedSize = -1try {cachedSize = (await fs.stat(dest)).size@@ -1332,17 +1340,21 @@ export class SshProjectManager {}}- /** Best-effort, bounded cache: keep the newest MEDIA_CACHE_KEEP entries. An evicted entry that- * is still playing in an open node stops being seekable, acceptable for a 20-deep cache of a- * convenience copy; the node re-fetches on next open. */+ /** The cap is soft for this run: an open player's next seek must still find its file.+ * Prior-run entries are eligible again after restart. */private async pruneMediaCache(cacheDir: string, except: string): Promise<void> {try {const names = (await fs.readdir(cacheDir)).filter((n) => !n.endsWith('.part'))const entries = await Promise.all(names.map(async (n) => ({ name: n, mtimeMs: (await fs.stat(path.join(cacheDir, n))).mtimeMs })))- for (const n of mediaCachePruneList(entries, except)) {- await fs.rm(path.join(cacheDir, n), { force: true }).catch(() => {})+ for (const n of mediaCachePruneList(entries, except, undefined, this.retainedMedia)) {+ if (this.retainedMedia.has(n)) continue+ const file = path.join(cacheDir, n)+ if (this.mediaPrunes.has(file)) continue+ const removal = fs.rm(file, { force: true }).catch(() => {})+ this.mediaPrunes.set(file, removal)+ try { await removal } finally { this.mediaPrunes.delete(file) }}} catch {// pruning is best-effort, a fat cache is a nuisance, not a faultdiff --git a/src/renderer/bridge/stubs.ts b/src/renderer/bridge/stubs.tsindex cc48eb0aa..da0dce51a 100644--- a/src/renderer/bridge/stubs.ts+++ b/src/renderer/bridge/stubs.ts@@ -198,7 +198,7 @@ export function buildStubApi(): Omit<// the project's ControlMaster). Resolve a typed refusal instead of rejecting so the// VideoNode shows the reason rather than a generic load failure.allowSsh: (): Promise<{ ok: false; error: string }> =>- Promise.resolve({ ok: false, error: 'Playing videos from an SSH host is not available in the browser.' }),+ Promise.resolve({ ok: false, error: 'Playing media from an SSH host is not available in the browser.' }),writeHtml: U('media.writeHtml')},browser: {diff --git a/src/renderer/canvas/Canvas.tsx b/src/renderer/canvas/Canvas.tsxindex 9cbed6b7a..e42c67407 100644--- a/src/renderer/canvas/Canvas.tsx+++ b/src/renderer/canvas/Canvas.tsx@@ -597,7 +597,7 @@ import {nodeSshFor,createVideoNode,createWebNode,- isVideoFile,+ isMediaFile,duplicateNode,flowToNodeStates,addSelectionToGroup,@@ -4184,7 +4184,7 @@ export function Canvas() {setNodes((ns) => [...ns.map((n) => (n.selected ? { ...n, selected: false } : n)),{- ...(isVideoFile(filePath)+ ...(isMediaFile(filePath)? createVideoNode(ns.length, filePath, center ?? viewCenter(), sshFs): createEditorNode(ns.length, filePath, center ?? viewCenter(), sshFs)),selected: truediff --git a/src/renderer/lib/filesNode.ts b/src/renderer/lib/filesNode.tsindex 4cd750a86..4a57a5912 100644--- a/src/renderer/lib/filesNode.ts+++ b/src/renderer/lib/filesNode.ts@@ -16,7 +16,7 @@* the filesystem-owning CORE, not the viewer, which is the rule `terminal/file-links.ts` already* implements and the one to copy.*/-import { isVideoFile } from '../state/workspace'+import { isMediaFile } from '../state/workspace'import { opensInEditor } from './openTarget'import { folderTitle } from './explorerCreate'@@ -188,6 +188,6 @@ export function filterEntries<T extends { name: string }>(entries: T[], query: s*/export function fileOpenTarget(path: string, opts: { remote?: boolean } = {}): 'canvas' | 'os' {if (opts.remote) return 'canvas'- if (isVideoFile(path)) return 'canvas'+ if (isMediaFile(path)) return 'canvas'return opensInEditor(path) ? 'canvas' : 'os'}diff --git a/src/renderer/nodes/VideoNode.media.test.tsx b/src/renderer/nodes/VideoNode.media.test.tsxnew file mode 100644index 000000000..1179000e8--- /dev/null+++ b/src/renderer/nodes/VideoNode.media.test.tsx@@ -0,0 +1,28 @@+// @vitest-environment jsdom+import { act } from 'react'+import { createRoot } from 'react-dom/client'+import { expect, it, vi } from 'vitest'+vi.mock('@xyflow/react', () => ({ Handle: () => null, NodeResizer: () => null, Position: { Top: 'top' }, useReactFlow: () => ({ deleteElements: vi.fn() }) }))+vi.mock('../components/Tooltip', () => ({ Tooltip: ({ children }: { children: unknown }) => children }))+import VideoNode from './VideoNode'+;(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true+it('renders audio controls, clears a stale source and ignores the old request after a file change', async () => {+ const host = document.createElement('div'); document.body.appendChild(host)+ const root = createRoot(host)+ const requests: Array<(url: string) => void> = []+ window.nodeTerminal = { media: { allow: vi.fn(() => new Promise<string>((r) => requests.push(r))) } } as unknown as typeof window.nodeTerminal+ const render = (filePath: string) => act(() => root.render(<VideoNode {...({ id: 'media', data: { filePath }, selected: false } as Parameters<typeof VideoNode>[0])} />))+ render('/a.mp3')+ await act(async () => requests[0]('nt-media://media/a.mp3'))+ expect(host.querySelector('audio')?.getAttribute('src')).toBe('nt-media://media/a.mp3')+ expect(host.querySelector('video')).toBeNull()+ expect(host.querySelector('audio')?.closest('.nopan.nowheel.nodrag')).not.toBeNull()+ render('/b.mp4')+ expect(host.querySelector('audio,video')).toBeNull()+ render('/c.wav')+ await act(async () => requests[1]('nt-media://media/b.mp4'))+ expect(host.querySelector('audio,video')).toBeNull()+ await act(async () => requests[2]('nt-media://media/c.wav'))+ expect(host.querySelector('audio')?.getAttribute('src')).toBe('nt-media://media/c.wav')+ act(() => root.unmount()); host.remove()+})diff --git a/src/renderer/nodes/VideoNode.tsx b/src/renderer/nodes/VideoNode.tsxindex 73b2496cf..546881984 100644--- a/src/renderer/nodes/VideoNode.tsx+++ b/src/renderer/nodes/VideoNode.tsx@@ -3,7 +3,7 @@ import { Tooltip } from '../components/Tooltip'import { IconClose } from '../components/icons'import { Handle, NodeResizer, Position, useReactFlow, type NodeProps } from '@xyflow/react'import { NODE_MIN_SIZES } from '../lib/nodeSizing'-import type { CanvasNode } from '../state/workspace'+import { isAudioFile, type CanvasNode } from '../state/workspace'import { useProjects } from '../state/projects'/**@@ -22,15 +22,19 @@ export default function VideoNode({ id, data, selected }: NodeProps<CanvasNode>)const filePath = (data.filePath as string) ?? ''const fileName = filePath.split('/').pop() || 'video'const remote = !!data.sshFs+ const audio = isAudioFile(filePath)useEffect(() => {+ setSrc('')+ setError('')+ setFetching(false)if (!filePath) returnlet alive = trueif (remote) {// Remote fetch can take a while for a large file — say what the wait is.const projectId = useProjects.getState().activeProjectIdif (!projectId) {- setError('Couldn’t load this video.')+ setError('Couldn’t load this media file.')return}setFetching(true)@@ -45,7 +49,7 @@ export default function VideoNode({ id, data, selected }: NodeProps<CanvasNode>).catch(() => {if (!alive) returnsetFetching(false)- setError('Couldn’t load this video.')+ setError('Couldn’t load this media file.')})return () => {alive = false@@ -57,7 +61,7 @@ export default function VideoNode({ id, data, selected }: NodeProps<CanvasNode>)if (alive) setSrc(url)}).catch(() => {- if (alive) setError('Couldn’t load this video.')+ if (alive) setError('Couldn’t load this media file.')})return () => {alive = false@@ -95,14 +99,18 @@ export default function VideoNode({ id, data, selected }: NodeProps<CanvasNode>)</div><div className="editor-node__body">- <div className="editor-node__image nodrag nowheel">+ <div className="editor-node__image nodrag nowheel nopan">{src ? (- <video- src={src}- controls- preload="metadata"- style={{ width: '100%', height: '100%', objectFit: 'contain' }}- />+ audio ? (+ <audio src={src} controls preload="metadata" style={{ width: '100%' }} />+ ) : (+ <video+ src={src}+ controls+ preload="metadata"+ style={{ width: '100%', height: '100%', objectFit: 'contain' }}+ />+ )) : (<span className="editor-node__loading">{error || (fetching ? 'Fetching from the host…' : 'Loading…')}diff --git a/src/renderer/state/workspace.media.test.ts b/src/renderer/state/workspace.media.test.tsindex 66f7b2e33..135ac82da 100644--- a/src/renderer/state/workspace.media.test.ts+++ b/src/renderer/state/workspace.media.test.ts@@ -40,3 +40,26 @@ describe('video/web nodes', () => {expect(w.data.url).toBe('http://localhost:5173')})})++describe('audio routing', () => {+ it('routes local and remote audio to the existing media node kind', async () => {+ const { isAudioFile, isMediaFile } = await import('./workspace')+ const { fileOpenTarget } = await import('../lib/filesNode')+ for (const path of ['/host/song.mp3', String.raw`C:\Music\SONG.FLAC`, '/host/sound.m4a', '/host/sound.opus']) {+ expect(isAudioFile(path)).toBe(true)+ expect(isMediaFile(path)).toBe(true)+ expect(fileOpenTarget(path)).toBe('canvas')+ expect(fileOpenTarget(path, { remote: true })).toBe('canvas')+ expect(nodeStatesToFlow(flowToNodeStates([createVideoNode(0, path, undefined, true)]))[0].data.filePath).toBe(path)+ }+ expect(isAudioFile('/x.mp4')).toBe(false)+ expect(isMediaFile('/x.txt')).toBe(false)+ })+})++it('repairs a legacy audio editor on reload without changing its identity or SSH ownership', () => {+ const node = nodeStatesToFlow(flowToNodeStates([{ ...createVideoNode(0, '/host/a.mp3', undefined, true), id: 'legacy', type: 'editor' }]))[0]+ expect(node.type).toBe('video')+ expect(node.id).toBe('legacy')+ expect(node.data.sshFs).toBe(true)+})diff --git a/src/renderer/state/workspace.ts b/src/renderer/state/workspace.tsindex 414845aff..78a56ffa5 100644--- a/src/renderer/state/workspace.ts+++ b/src/renderer/state/workspace.ts@@ -939,6 +939,17 @@ export function createEditorNode(const VIDEO_EXTS = ['mp4', 'webm', 'mov', 'm4v', 'mkv', 'ogv', 'avi']+/** Audio uses the existing media node kind; no workspace schema change is needed. */+export function isAudioFile(path: string): boolean {+ return ['mp3', 'wav', 'flac', 'ogg', 'oga', 'opus', 'm4a', 'aac', 'aiff', 'aif', 'weba'].includes(+ path.split('.').pop()?.toLowerCase() ?? ''+ )+}++export function isMediaFile(path: string): boolean {+ return isVideoFile(path) || isAudioFile(path)+}+/** True when a path looks like a playable video file (by extension). */export function isVideoFile(path: string): boolean {const ext = path.split('.').pop()?.toLowerCase() ?? ''@@ -1908,7 +1919,7 @@ export function nodeStatesToFlow(states: CanvasNodeState[]): CanvasNode[] {return {id: n.id,// Default to 'terminal' for nodes saved before the kind field existed.- type: n.kind ?? 'terminal',+ type: n.kind === 'editor' && n.filePath && isAudioFile(n.filePath) ? 'video' : n.kind ?? 'terminal',...((n.kind ?? 'terminal') === 'group' ? { dragHandle: '.group-node__label' } : {}),position: n.position,width: n.size.width,