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 remote-tracking branch 'origin/main' into HEAD
enesef9f1bfcdeb7
diff --cc src/core/pty-manager.tsindex 5b99a4d10,1a6db86ae..38309f828--- a/src/core/pty-manager.ts+++ b/src/core/pty-manager.ts@@@ -70,12 -70,14 +70,19 @@@ import { machOArch, archMismatch } froimport { writeScrollback, readScrollback, deleteScrollback } from './scrollback-store'import { claudeConfigDirFor } from './claude-config-dir'import { findExecutableSync, findInPathString, resolveShellPath, shellPathNow } from './exec-path'-import { AUTH_ENV_STRIP, accountTmuxEnvArgs, remoteAccountConfigDirAbs } from './claude-accounts-core'+import {+ AUTH_ENV_STRIP,+ accountTmuxEnvArgs,+ isReservedSpawnEnvKey,+ remoteAccountConfigDirAbs+} from './claude-accounts-core'+ import {+ AUTH_ENV_STRIP as CODEX_AUTH_ENV_STRIP,+ codexSessionEnv,+ isCodexScopeRefusal,+ needsCodexAccountScope,+ resolveCodexSessionScope+ } from './codex-accounts-core'import { NODE_ID_MAX, isSafeNodeId } from './remote-safety'import { presenceHub } from './presence/hub'import {diff --cc src/renderer/canvas/Canvas.tsxindex b4f0e573c,d9f62695c..54d90d0b6--- a/src/renderer/canvas/Canvas.tsx+++ b/src/renderer/canvas/Canvas.tsx@@@ -5459,97 -5377,162 +5415,170 @@@ export function Canvas()[commitActiveToStore, writeDisk])- // Cmd/Ctrl+K toggles the command palette; Cmd/Ctrl+, opens settings.- useEffect(() => {- const onKey = (e: KeyboardEvent) => {- if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === 'k') {- e.preventDefault()- setPaletteOpen((v) => !v)- } else if ((e.metaKey || e.ctrlKey) && e.key === ',') {- e.preventDefault()- setSettingsSection(undefined)- setSettingsOpen(true)- } else if ((e.metaKey || e.ctrlKey) && e.shiftKey && e.key.toLowerCase() === 'e') {- e.preventDefault()- setExplorerOpen((v) => !v)- } else if ((e.metaKey || e.ctrlKey) && e.shiftKey && e.key.toLowerCase() === 'g') {- e.preventDefault()- setScOpen((v) => !v)- } else if ((e.metaKey || e.ctrlKey) && e.shiftKey && e.key.toLowerCase() === 'b') {- e.preventDefault()+ // ---- global shortcuts ----+ // The three trailing gestures below are registry-LESS chords (design D2: declared gestures,+ // deliberately not remappable in this PR). The dispatcher hands them the RAW event with no+ // context, so each keeps its OWN guards exactly as today's if-chain branch carried them.+ // Zoom and project-jump are POSITIONAL chords (`e.code`, auto-repeat aware) — fields the+ // dispatcher's structural `GlobalKeyEvent` does not model — and the only dispatch site is the+ // window listener below, which always hands them a real KeyboardEvent.++ // ⌘/Ctrl+0 = back to 100%, Shift+1 = fit everything. `liveZoomShortcutAction` is the whole+ // decision (see `lib/zoomShortcut.ts`), including the typing refusal, and the ⌘0 desktop route+ // below asks the same one, so the two paths can never disagree about when the chord is allowed+ // to move the camera. A null answer means "leave the key alone" — no `preventDefault`, which is+ // what keeps Shift+1 typing a `!` wherever the user is actually typing.+ const zoomGesture = useCallback((raw: GlobalKeyEvent): boolean => {+ const e = raw as KeyboardEvent+ if (zoomShortcutChord(e) === null) return false+ const action = liveZoomShortcutAction(e)+ if (!action) return false+ e.preventDefault()+ if (action === 'zoom-100') zoomTo100()+ else fitAll()+ return true+ }, [zoomTo100, fitAll])++ // Cmd/Ctrl+1-9 jumps to the Nth project — but only when the app actually owns the key (desktop+ // shell, and the digit addresses an open project). `liveProjectJumpTarget` is the same decision+ // the terminals' swallow asks, so the two can't disagree; a null target leaves the key to+ // whatever has focus. `switchProject` no-ops on the active id.+ const projectJumpGesture = useCallback((raw: GlobalKeyEvent): boolean => {+ const e = raw as KeyboardEvent+ if (projectJumpDigit(e) === null) return false+ const targetId = liveProjectJumpTarget(e)+ if (!targetId) return false+ e.preventDefault()+ switchProject(targetId)+ return true+ }, [switchProject])++ const copyGesture = useCallback((e: GlobalKeyEvent): boolean => {+ if (!((e.metaKey || e.ctrlKey) && !e.shiftKey && e.key.toLowerCase() === 'c')) return false+ // Native text selection wins (markdown, editor and terminal keep their normal copy path).+ const tag = (document.activeElement?.tagName || '').toLowerCase()+ if (+ tag === 'input' ||+ tag === 'textarea' ||+ document.activeElement?.getAttribute('contenteditable') === 'true' ||+ document.activeElement?.closest('.monaco-editor, .xterm')+ )+ return false+ const sel = window.getSelection?.()?.toString()+ if (sel) {+ window.nodeTerminal.clipboard.writeText(sel)+ // Claimed, but deliberately WITHOUT preventDefault — exactly as today: the native copy is+ // let through as well.+ return true+ }+ // Nothing selected as text: copy the selected file-backed nodes as FILE REFERENCES, so+ // Finder (or any file-aware app) pastes the actual files.+ //+ // Gated to where it can actually succeed, because the failure path raises a banner that+ // stays until dismissed — and before this feature the keystroke was a silent no-op, which+ // is what every other machine must keep getting. `writeFilesToClipboard` is darwin-gated+ // in main and the browser bridge stub answers false, so on a non-mac renderer (desktop OR+ // Server Edition) this branch could only ever produce that banner, wearing macOS-specific+ // copy on a Linux box. The board is an opaque overlay over the canvas, so a copy there+ // would act on a selection the user cannot see (the canvas-only-shortcut discipline).+ const projects = useProjects.getState()+ if (!isMac || isKanbanOpen(projects.activeProjectId)) return false+ const paths = selectedLocalFilePaths(nodesRef.current, {+ projectIsRelay: !!projects.getProject(projects.activeProjectId ?? '')?.remote+ })+ if (!paths.length) return false+ e.preventDefault()+ void window.nodeTerminal.clipboard+ .writeFiles(paths)+ .then((copied) => {+ setCopyError(+ copied+ ? null+ : 'Copy failed — only existing local files can be copied from the macOS desktop app.'+ )+ })+ .catch(() => setCopyError('Copy failed — the system clipboard is unavailable.'))+ return true+ }, [setCopyError])++ // ONE window keydown for every registry command + the legacy gestures. The deps live in a+ // ref refreshed each render so the listener is registered once; handlers return whether+ // they claimed the chord (an unavailable surface falls through to the platform).+ const globalKeyDeps = useRef<GlobalKeydownDeps | null>(null)+ globalKeyDeps.current = {+ activeElement: () => document.activeElement as unknown as ContextElement | null,+ kanbanOpen: () => isKanbanOpen(useProjects.getState().activeProjectId),+ overrides: activeKeybindingOverrides,+ isMac,+ // Read per keystroke (the deps object is rebuilt each render anyway, but the thunk is what+ // the contract asks for): a policy change takes effect immediately, with no re-registration.+ terminalFirst: () => terminalShortcutPolicy() === 'terminal-first',+ // The notice half. `noteTerminalCapture` re-asks the policy and the once-per-command ledger+ // itself, so this is a plain pass-through — the dispatcher decides that a capture HAPPENED,+ // the lib decides whether it is worth saying.+ onTerminalCapture: noteTerminalCapture,+ handlers: {+ 'app.commandPalette': () => { setPaletteOpen((v) => !v); return true },+ 'app.settings': () => { setSettingsSection(undefined); setSettingsOpen(true); return true },+ 'app.shortcutsPanel': () => { setShortcutsOpen((v) => !v); return true },+ 'view.kanbanToggle': () => {const id = useProjects.getState().activeProjectId- if (id) useViewMode.getState().toggle(id)- } else if ((e.metaKey || e.ctrlKey) && e.shiftKey && e.key.toLowerCase() === 'l') {- e.preventDefault()- toggleSessionsPin()- } else if ((e.metaKey || e.ctrlKey) && e.key === '/') {- e.preventDefault()- setShortcutsOpen((v) => !v)- } else if (zoomShortcutChord(e) !== null) {- // ⌘/Ctrl+0 = back to 100%, Shift+1 = fit everything. `liveZoomShortcutAction` is the- // whole decision (see `lib/zoomShortcut.ts`), and the ⌘0 desktop route below asks the same- // one, so the two paths can never disagree about when the chord is allowed to move the- // camera. A null answer means "leave the key alone" — no `preventDefault`, which is what- // keeps Shift+1 typing a `!` wherever the user is actually typing.- const action = liveZoomShortcutAction(e)- if (action) {- e.preventDefault()- if (action === 'zoom-100') zoomTo100()- else fitAll()- }- } else if (projectJumpDigit(e) !== null) {- // Cmd/Ctrl+1-9 jumps to the Nth project — but only when the app actually owns the key- // (desktop shell, and the digit addresses an open project). `liveProjectJumpTarget`- // is the same decision the terminals' swallow asks, so the two can't disagree; a null- // target leaves the key to whatever has focus. `switchProject` no-ops on the active id.- const targetId = liveProjectJumpTarget(e)- if (targetId) {- e.preventDefault()- switchProject(targetId)- }- } else if ((e.metaKey || e.ctrlKey) && !e.shiftKey && e.key.toLowerCase() === 'c') {- // Native text selection wins (markdown, editor and terminal keep their normal copy path).- const tag = (document.activeElement?.tagName || '').toLowerCase()- if (- tag === 'input' ||- tag === 'textarea' ||- document.activeElement?.getAttribute('contenteditable') === 'true' ||- document.activeElement?.closest('.monaco-editor, .xterm')+ if (!id) return false+ useViewMode.getState().toggle(id)+ return true+ },+ 'panel.explorer': () => { setExplorerOpen((v) => !v); return true },+ 'panel.sourceControl': () => { setScOpen((v) => !v); return true },+ 'panel.sessions': () => { toggleSessionsPin(); return true },+ 'canvas.undo': () => { undo(); return true },+ 'canvas.redo': () => { redo(); return true },+ 'canvas.fitAll': () => { fitAll(); return true },+ 'canvas.tidy': () => { arrangeAllNodes(); return true },+ 'canvas.deleteSelection': deleteSelectionCommand,+ 'node.newTerminal': () => { addTerminal(); return true },+ 'node.newAgent': () => {- // launchableDefaultAgent, not the raw setting: a default naming a since-removed custom- // agent would otherwise type its bare `custom:<uuid>` id into the new node's shell.- addAgentNode(launchableDefaultAgent(useSettings.getState().settings))++ // resolveNewNodeAgent, not the raw setting: this project's own default agent wins++ // (`.nodeterm/settings.json` → agents.defaultAgentId), else the global one, and a default++ // naming a since-removed custom agent is guarded so its bare `custom:<uuid>` id is never++ // typed into the new node's shell (like launchableDefaultAgent).++ addAgentNode(++ resolveNewNodeAgent(++ undefined,++ useProjects.getState().activeProjectId,++ useSettings.getState().settings++ )+ )- return- const sel = window.getSelection?.()?.toString()- if (sel) {- window.nodeTerminal.clipboard.writeText(sel)- return- }- // Nothing selected as text: copy the selected file-backed nodes as FILE REFERENCES, so- // Finder (or any file-aware app) pastes the actual files.- //- // Gated to where it can actually succeed, because the failure path raises a banner that- // stays until dismissed — and before this feature the keystroke was a silent no-op, which- // is what every other machine must keep getting. `writeFilesToClipboard` is darwin-gated- // in main and the browser bridge stub answers false, so on a non-mac renderer (desktop OR- // Server Edition) this branch could only ever produce that banner, wearing macOS-specific- // copy on a Linux box. The board is an opaque overlay over the canvas, so a copy there- // would act on a selection the user cannot see (the canvas-only-shortcut discipline).- const projects = useProjects.getState()- if (!isMac || isKanbanOpen(projects.activeProjectId)) return- const paths = selectedLocalFilePaths(nodesRef.current, {- projectIsRelay: !!projects.getProject(projects.activeProjectId ?? '')?.remote- })- if (!paths.length) return- e.preventDefault()- void window.nodeTerminal.clipboard- .writeFiles(paths)- .then((copied) => {- setCopyError(- copied- ? null- : 'Copy failed — only existing local files can be copied from the macOS desktop app.'- )- })- .catch(() => setCopyError('Copy failed — the system clipboard is unavailable.'))+ return true}+ // node.close / node.toggleMarkdown: main-process intercepted on desktop; deliberately+ // no renderer handler (the browser owns ⌘W in the Server Edition — see bridge/stubs.ts).+ // terminal.* / scm.commit / speech.dictation: owned by their local listeners.+ },+ gestures: {+ // A KEYED dictation shortcut (e.g. "Cmd+Alt+D") toggles dictation. The chord is the+ // registry's first effective `speech.dictation` binding (`dictationBinding()`), so a+ // remap lands here without touching this file. A modifier-only shortcut (the default,+ // "Cmd+Alt") is hold-to-talk instead — matchesShortcut always returns false for that+ // shape (its `key` is null), so this gesture is naturally a no-op for it; see the+ // dedicated hold-mode effect above, which is what fires in that case. The DISABLED case+ // (`''`) needs no guard for the same reason: an empty parse also has a null key.+ // The dispatcher only offers it in plain app focus (not typing / terminal / kanban).+ keyedDictation: (e) => {+ if (!matchesShortcut(e, dictationBinding(), isMac)) return false+ e.preventDefault()+ toggleDictation()+ return true+ },+ zoom: zoomGesture,+ projectJump: projectJumpGesture,+ copy: copyGesture+ }+ }++ useEffect(() => {+ const onKey = (e: KeyboardEvent) => {+ const deps = globalKeyDeps.current+ if (deps) dispatchGlobalKeydown(e, deps)}window.addEventListener('keydown', onKey)return () => window.removeEventListener('keydown', onKey)