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
Merge origin/main into feat/terminal-file-url-links
reviewab939d46995b
diff --cc src/renderer/components/kanban/CardModal.test.tsxindex deae68e63,3bff7f009..ee2a342c8--- a/src/renderer/components/kanban/CardModal.test.tsx+++ b/src/renderer/components/kanban/CardModal.test.tsx@@@ -29,29 -30,56 +30,80 @@@ vi.mock('../ContextMeter', () => (ContextMeter: () => null}))- // Mock ModalTerminal and BrowserSurface to keep tests lightweight and focused on CardModal- vi.mock('./ModalTerminal', () => ({- ModalTerminal: ({ nodeId, onOpenFile }: { nodeId: string; onOpenFile?: (file: { path: string; ssh: boolean }) => void }) => (- <div className="kanban-modal__term" data-node-id={nodeId} tabIndex={0}>- Terminal Mock- <button- className="modal-terminal-file-link"- onClick={() => onOpenFile?.({ path: '/project/docs/plan.md', ssh: false })}- >- Open file- </button>- </div>- )- }))+ // Mock ModalTerminal and BrowserSurface to keep tests lightweight and focused on CardModal.+ // The terminal mock counts its MOUNTS and exposes `covered`, so the ⌘M tests can prove the live+ // viewer stays mounted (never unmounted/remounted) while the view is laid over it.+ const termMock = vi.hoisted(() => ({ mounts: 0, unmounts: 0 }))+ vi.mock('./ModalTerminal', async () => {+ const { useEffect } = await import('react')+ return {- ModalTerminal: ({ nodeId, covered }: { nodeId: string; covered?: boolean }) => {++ ModalTerminal: ({++ nodeId,++ covered,++ onOpenFile++ }: {++ nodeId: string++ covered?: boolean++ onOpenFile?: (file: { path: string; projectId: string; ssh: boolean }) => void++ }) => {+ useEffect(() => {+ termMock.mounts+++ return () => {+ termMock.unmounts+++ }+ }, [])+ return (+ <div className="kanban-modal__term" data-node-id={nodeId} data-covered={String(!!covered)} tabIndex={0}>+ Terminal Mock++ <button++ className="modal-terminal-file-link"++ onClick={() => onOpenFile?.({ path: '/project/docs/plan.md', projectId: 'p1', ssh: false })}++ >++ Open file++ </button>+ </div>+ )+ }+ }+ })+vi.mock('./LocalFilePreviewModal', () => ({+ LocalFilePreviewModal: ({ file, onClose }: { file: { path: string }; onClose: () => void }) => (+ <div className="local-file-preview-mock" data-path={file.path}>- <button className="local-file-preview-close" onClick={onClose}>Close preview</button>++ <button className="local-file-preview-close" onClick={onClose}>++ Close preview++ </button>+ </div>+ )+}))++ // The two ⌘M faces, stubbed to record the props they are handed.+ vi.mock('../../nodes/TerminalMarkdownView', () => ({+ TerminalMarkdownView: ({ nodeId, hint }: { nodeId: string; hint: string }) => (+ <div className="md-view-mock" data-node-id={nodeId} data-hint={hint} />+ )+ }))+ vi.mock('../../nodes/ChatPanel', () => ({+ ChatPanel: (p: { nodeId: string; sessionId?: string; cwd?: string; accountId?: string; agentId: string }) => (+ <div+ className="chat-panel-mock"+ data-node-id={p.nodeId}+ data-session-id={p.sessionId}+ data-cwd={p.cwd}+ data-account-id={p.accountId ?? ''}+ data-agent-id={p.agentId}+ />+ )+ }))++ // The wake trigger the header's DROPPED / PAUSED / SLEEPING chips click through, spied so a test can+ // prove the chip reaches the SAME trigger the canvas node's chip uses (not a bespoke resume path).+ const wakeMock = vi.hoisted(() => ({ calls: [] as string[] }))+ vi.mock('../../nodes/TerminalNode', async (importOriginal) => ({+ ...(await importOriginal<typeof import('../../nodes/TerminalNode')>()),+ wakeHibernatedNode: (nodeId: string) => void wakeMock.calls.push(nodeId)+ }))+vi.mock('../../nodes/BrowserSurface', () => ({BrowserSurface: ({ nodeId }: { nodeId: string }) => (<div className="browser-surface" data-node-id={nodeId}>@@@ -81,52 -120,95 +144,142 @@@ describe('CardModal', () =>document.body.innerHTML = ''})+ it('opens a terminal file link in an overlay without leaving the Kanban card', () => {+ const session: KanbanSession = {+ id: 'node-term-preview',+ title: 'Preview docs',+ color: '#0a84ff',+ kind: 'terminal',+ spawn: { cwd: '/project' }+ }+ const onClose = vi.fn()+ const onOpenCanvas = vi.fn()+ const root = createRoot(host)++ act(() =>+ root.render(+ <CardModal++ projectId="p1"+ session={session}+ columnTitle="To Do"+ board={board}+ onChangeBoard={vi.fn()}+ onClose={onClose}+ onOpenCanvas={onOpenCanvas}+ onRename={vi.fn()}+ onEditSticky={vi.fn()}+ onSetIcon={vi.fn()}+ onBrowserNav={vi.fn()}+ />+ )+ )++ act(() => {+ document.body.querySelector<HTMLButtonElement>('.modal-terminal-file-link')!.click()+ })+ const preview = document.body.querySelector<HTMLElement>('.local-file-preview-mock')+ expect(preview?.dataset.path).toBe('/project/docs/plan.md')+ expect(onClose).not.toHaveBeenCalled()+ expect(onOpenCanvas).not.toHaveBeenCalled()++ act(() => {+ document.body.querySelector<HTMLButtonElement>('.local-file-preview-close')!.click()+ })+ expect(document.body.querySelector('.local-file-preview-mock')).toBeNull()+ expect(document.body.querySelector('.kanban-modal')).toBeTruthy()++ act(() => root.unmount())+ })++ // #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+ projectId="p1"+ 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.each([+ { projectName: 'Example project', projectColor: '#32d74b', columnTitle: 'In Progress' },+ { projectName: 'A very long project name with <literal> characters', projectColor: undefined, columnTitle: null },+ { projectName: undefined, projectColor: undefined, columnTitle: 'To Do' }+ ])('shows the owning project in the header: $projectName', ({ projectName, projectColor, columnTitle }) => {+ const root = createRoot(host)+ const session: KanbanSession = {+ id: 'header-note', title: 'Review generated documentation', color: '#ffd60a',+ kind: 'sticky', text: 'Review generated documentation', spawn: {}+ }+ act(() => root.render(+ <CardModal+ projectId="p1"+ session={session}+ projectName={projectName}+ projectColor={projectColor}+ columnTitle={columnTitle}+ board={board}+ onChangeBoard={vi.fn()}+ onClose={vi.fn()}+ onOpenCanvas={vi.fn()}+ onRename={vi.fn()}+ onEditSticky={vi.fn()}+ onSetIcon={vi.fn()}+ onBrowserNav={vi.fn()}+ />+ ))++ const identity = document.body.querySelector<HTMLElement>('.kanban-modal__identity')!+ expect(identity.querySelector<HTMLElement>('.kanban-modal__title')!.title).toBe(session.title)+ const column = identity.querySelector<HTMLElement>('.kanban-modal__column')!+ expect(column.textContent).toBe(columnTitle ?? 'Ungrouped')+ expect(column.title).toBe(columnTitle ?? 'Ungrouped')+ const project = identity.querySelector<HTMLElement>('.kanban-modal__project')+ if (projectName) {+ expect(project!.textContent).toBe(projectName)+ expect(project!.title).toBe(projectName)+ expect(project!.getAttribute('aria-label')).toBe(`Project: ${projectName}`)+ expect(project!.previousElementSibling?.textContent).toBe(session.title)+ expect(project!.nextElementSibling).toBe(column)+ const dot = project!.querySelector<HTMLElement>('.kanban-modal__project-dot')!+ expect(dot.style.background).toBe(projectColor ? 'rgb(50, 215, 75)' : 'currentcolor')+ expect(dot.getAttribute('aria-hidden')).toBe('true')+ } else {+ expect(project).toBeNull()+ }+ act(() => root.unmount())+ })+it('writes through raw textarea value on sticky note edit (including whitespace and newlines)', () => {const session: KanbanSession = {id: 'node-sticky-1',diff --cc src/renderer/components/kanban/CardModal.tsxindex da891dbdd,34419c367..09150078c--- a/src/renderer/components/kanban/CardModal.tsx+++ b/src/renderer/components/kanban/CardModal.tsx@@@ -43,10 -61,16 +61,20 @@@ import { BrowserSurface } from '../../nimport { BrowserDrivingIndicator } from '../../nodes/BrowserDrivingChip'import { NoteMarkdown } from '../NoteMarkdown'import { relativeTime } from '../../lib/relativeTime'+ import { TerminalMarkdownView } from '../../nodes/TerminalMarkdownView'+ import { canChat } from '@shared/agents/config'+ import { effectiveAccountId } from '../../lib/accountChip'+ import { useSettings } from '../../state/settings'+ import { chipFor, commandTooltip } from '../../lib/keybindingOverrides'+import {+ LocalFilePreviewModal,+ type LocalFileTarget+} from './LocalFilePreviewModal'+ import { ChatPanelFallback } from '../../nodes/ChatPanelFallback'++ // Code-split exactly like the canvas node's: ChatPanel carries the markdown renderer, and the+ // card modal must not pull it onto the board's first paint.+ const ChatPanel = lazy(() => import('../../nodes/ChatPanel').then((m) => ({ default: m.ChatPanel })))interface CardModalProps {session: KanbanSession@@@ -449,14 -642,53 +647,54 @@@ export function CardModal({ session, pr{session.kind === 'terminal' ? (// A live SECOND client on the node's session — keyed by node id so switching cards// remounts a fresh viewer.- <ModalTerminal- key={session.id}- nodeId={session.id}- spawn={session.spawn}- searchOpen={searchOpen}- onCloseSearch={() => setSearchOpen(false)}- onOpenFile={setPreviewFile}- />+ <>+ <ModalTerminal+ key={session.id}+ nodeId={session.id}+ spawn={session.spawn}+ searchOpen={searchOpen}+ onCloseSearch={() => setSearchOpen(false)}+ covered={mdOpen}++ onOpenFile={setPreviewFile}+ />+ {/* The ⌘M face is laid OVER the live viewer (the pane anchors it), never swapped+ in for it: ModalTerminal stays mounted, so its co-attach does not detach and+ re-attach — and its grid does not resize — every time the view flips. */}+ {mdOpen &&+ (useChat ? (+ <Suspense fallback={<ChatPanelFallback />}>+ <ChatPanel+ key={session.id}+ nodeId={session.id}+ sessionId={agentSessionId}+ cwd={session.spawn.cwd}+ accountId={accountForReads}+ agentId={createdAgent!}+ // Same resolution as a drop onto this card's live viewer (ModalTerminal):+ // an SSH node uploads over the master its PTY runs on.+ pathsForFiles={(files) =>+ droppedPaths(files, {+ sshRemoteTmux: !!session.spawn.sshRemoteTmux,+ projectId: session.spawn.sshRemoteTmux ? nodeUploadScope(session.spawn.ssh) : ''+ })+ }+ sshProjectId={session.spawn.sshRemoteTmux ? nodeUploadScope(session.spawn.ssh) : undefined}+ onShowTerminal={() => {+ // The picker just opened in the live viewer needs the keyboard.+ requestTerminalFocusOnExit(session.id)+ setMdFor(null)+ }}+ />+ </Suspense>+ ) : (+ <TerminalMarkdownView+ key={session.id}+ nodeId={session.id}+ capture={captureFull}+ hint={mdChip ? `${mdChip} to exit` : 'Exit'}+ />+ ))}+ </>) : isBrowser ? (// A live browser webview seeded with the node's URL; navigation persists back to// the node (the canvas node picks it up on its next mount).@@@ -474,12 -706,9 +712,12 @@@</div>)}</div>- {panelOpen && <BoardLogPanel card={session} />}+ {panelOpen && <BoardLogPanel card={session} mentionables={mentionables} />}</div></div>+ {previewFile && (+ <LocalFilePreviewModal file={previewFile} onClose={() => setPreviewFile(null)} />+ )}</div>,document.body)