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(windows): use session host for persistent agent sessions
Lokidon584d1f237dbc
diff --git a/src/core/pty-manager.ts b/src/core/pty-manager.tsindex 4764098c7..f936b5e3a 100644--- a/src/core/pty-manager.ts+++ b/src/core/pty-manager.ts@@ -360,15 +360,13 @@ ${leadPaneHookLines(leadPaneWidth)}`* through the now-resolved tmux.*/function findTmux(resourcesPath?: string): string | null {- // Windows has none of `tmuxCandidatePaths`' targets (Homebrew, MacPorts, Nix, the distro- // `/usr/bin` family — all POSIX filesystem layouts) and no bundled tmux (macOS-only, see- // `bundledTmuxPath`'s doc comment; `scripts/build-tmux.mjs` never runs for a Windows package).- // Walking either list would just be `existsSync` calls against paths that can never resolve on- // this platform — skip straight to the PATH probe, the one route that can find a real tmux a- // Windows user installed themselves (WSL's own tmux is a different filesystem entirely and is- // never on the Windows PATH; MSYS2/Cygwin tmux, if the user put it there, is).+ // Windows has no native tmux. Even when a tmux-compatible executable is present on PATH (for+ // example psmux, MSYS2, or Cygwin), it is not a safe persistence backend for this application:+ // its process and console semantics differ from the Unix tmux contract used by the control+ // client. The packaged session host owns the Windows PTY and provides the equivalent attach,+ // capture, send, and restart behavior without opening helper consoles.if (os.platform() === 'win32') {- return findInPathString('tmux', shellPathNow() ?? process.env.PATH)+ return null}// BOTH lookups inside the guard: `os.homedir()` throws the same SystemError as `userInfo()` when// there is no passwd entry and no $HOME (some containers), and a thrown probe here would take@@ -2884,7 +2882,9 @@ export class PtyManager {// terminal, and every other agent, sees the PATH it always saw. The launcher itself falls back// to the bare CLI, so a session that gets the PATH but no identity is still a working session.if (options.agentId && hasSharedIdentity(options.agentId as AgentId) && !options.sshRemote) {- env.PATH = `${codexLauncherDir()}${path.delimiter}${env.PATH ?? ''}`+ // Windows exposes the inherited variable as `Path`; reading only the POSIX spelling+ // silently drops the user's PATH and leaves the managed launcher unable to find `codex`.+ env.PATH = `${codexLauncherDir()}${path.delimiter}${env.PATH ?? env.Path ?? ''}`}// Managed Claude account: the whole session runs under the account's private configdiff --git a/src/core/windows-session-persistence.test.ts b/src/core/windows-session-persistence.test.tsnew file mode 100644index 000000000..62d6dcb04--- /dev/null+++ b/src/core/windows-session-persistence.test.ts@@ -0,0 +1,26 @@+import { readFileSync } from 'node:fs'+import { join } from 'node:path'+import { describe, expect, it } from 'vitest'++const manager = readFileSync(join(__dirname, 'pty-manager.ts'), 'utf8')+const terminal = readFileSync(join(__dirname, '..', 'renderer', 'nodes', 'TerminalNode.tsx'), 'utf8')++describe('Windows persistent-session integration', () => {+ it('always routes Windows sessions to the packaged session host', () => {+ expect(manager).toMatch(+ /if \(os\.platform\(\) === 'win32'\) \{[\s\S]{0,500}?return null\s*\}/+ )+ expect(manager).toContain("sessionHostSupported() ? 'session-host' : null")+ })++ it('preserves the inherited Windows Path when prepending the Codex launcher', () => {+ expect(manager).toContain("env.PATH ?? env.Path ?? ''")+ })++ it('delivers a fresh launch without probing a session-host pane first', () => {+ expect(terminal).toContain(+ '(!manual && fresh) || isLaunchShell(await queryPaneWithin(() => api.pty.paneCommand(id), RESTART_EXIT_TIMEOUT_MS))'+ )+ expect(terminal).not.toContain('fresh && !sessionPersistent) || isLaunchShell(')+ })+})diff --git a/src/renderer/nodes/TerminalNode.tsx b/src/renderer/nodes/TerminalNode.tsxindex 8dc591ce2..d110efc43 100644--- a/src/renderer/nodes/TerminalNode.tsx+++ b/src/renderer/nodes/TerminalNode.tsx@@ -3443,7 +3443,7 @@ export function TerminalNode({io: { write: (d: string) => transport.write(sid, d), onData: (cb: (data: string) => void) => transport.onData(sid, cb) },// A fresh shell is known at spawn; subsequent/manual deliveries must recheck the pane.shellReady: async (manual: boolean) =>- (!manual && fresh && !sessionPersistent) || isLaunchShell(await queryPaneWithin(() => api.pty.paneCommand(id), RESTART_EXIT_TIMEOUT_MS)),+ (!manual && fresh) || isLaunchShell(await queryPaneWithin(() => api.pty.paneCommand(id), RESTART_EXIT_TIMEOUT_MS)),killLine: getTerminalKillLine(),cleanup: (cancel: () => void) => { cleanups.push(cancel) }}