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): recognise pwsh/powershell/cmd/nu as shells in isShellCommand
review449fe224d5cf
diff --git a/src/core/agents/pane-owner.ts b/src/core/agents/pane-owner.tsindex dfc151128..4b3d231e5 100644--- a/src/core/agents/pane-owner.ts+++ b/src/core/agents/pane-owner.ts@@ -7,7 +7,7 @@* - measured on this host, a pane running the fake agent `…/fakebin/claude --resume x` (a* `#!/usr/bin/env node` script) reports `#{pane_current_command}` = `node`. Every npm-installed* agent CLI has that shape, so a name gate cannot tell claude from any other node process.- * - `isShellCommand` (`src/shared/agents/pane.ts`) is a SEVEN-name allowlist, so `!isShellCommand`+ * - `isShellCommand` (`src/shared/agents/pane.ts`) was then a SEVEN-name allowlist, so `!isShellCommand`* — the old "this pane is an agent" gate — is true for `nu`, `pwsh`, `xonsh`, `elvish`, `ssh`* and `python`. Text delivered there executes, because `sendText` appends Enter.*diff --git a/src/core/trigger-delivery.test.ts b/src/core/trigger-delivery.test.tsindex 3ccbb4a7e..c598c594e 100644--- a/src/core/trigger-delivery.test.ts+++ b/src/core/trigger-delivery.test.ts@@ -121,6 +121,18 @@ describe('trigger delivery — immediate outcomes', () => {expect(w.sent).toHaveLength(1)})+ it('a plain terminal on the Windows session host delivers into pwsh.exe / cmd.exe', async () => {+ const w = world()+ w.nodes.set('term-tgt-1', {}) // no agentId+ for (const pane of ['pwsh.exe', 'cmd.exe']) {+ w.pane = pane+ expect((await w.delivery.fire(row())).outcome, pane).toBe('fired')+ }+ w.pane = 'node.exe'+ expect((await w.delivery.fire(row())).outcome).toBe('missed')+ expect(w.sent).toHaveLength(2)+ })+it('a busy agent target queues; an unknown agent state queues too', async () => {const w = world()w.state = 'working'diff --git a/src/renderer/lib/sessionRename.test.ts b/src/renderer/lib/sessionRename.test.tsindex 39922814e..fb44d6f22 100644--- a/src/renderer/lib/sessionRename.test.ts+++ b/src/renderer/lib/sessionRename.test.ts@@ -43,6 +43,14 @@ describe('pushSessionRename', () => {}})+ it('recognizes the Windows session host\'s shells — never types `/rename` into PowerShell or cmd', async () => {+ for (const pane of ['cmd.exe', 'pwsh.exe', 'PowerShell.exe']) {+ const x = io([pane])+ await expect(pushSessionRename(x, 'n1', 'x', 'was'), pane).resolves.toBe(false)+ expect(x.sent, pane).toEqual([])+ }+ })+it('waits for the CLI to boot, then writes once', async () => {const x = io(['zsh', 'zsh', 'node'])await expect(pushSessionRename(x, 'n1', 'Later', 'Earlier')).resolves.toBe(true)diff --git a/src/renderer/nodes/TerminalNode.tsx b/src/renderer/nodes/TerminalNode.tsxindex 7a49858f8..7c4e4ba20 100644--- a/src/renderer/nodes/TerminalNode.tsx+++ b/src/renderer/nodes/TerminalNode.tsx@@ -4327,7 +4327,7 @@ export function TerminalNode({// brand new either way — tmux respawned it, whether from the deep "pause & end session"// recycle or from a genuine reboot that took a shallow-paused session's tmux with it.// The later Resume's pane-recognition (see `decideWakeResume`) would otherwise refuse a- // user whose default shell sits outside the `isShellCommand` allowlist (nu/xonsh/pwsh)+ // user whose default shell sits outside the `isShellCommand` allowlist (xonsh/elvish/…)// forever: a PAUSED chip that can never resume, with a live conversation on disk. Record// what this fresh pane actually is, the same way the exit half does — replacing any// stale record a pre-reboot shallow pause left behind, which described a pane that nodiff --git a/src/renderer/state/agentStatus.ts b/src/renderer/state/agentStatus.tsindex 3ee369b4e..f863f94ad 100644--- a/src/renderer/state/agentStatus.ts+++ b/src/renderer/state/agentStatus.ts@@ -121,10 +121,10 @@ export interface AgentNodeStatus {* moment of hibernation, persisted beside the flag, and dropped with it.** The wake refuses to type a launch line into a pane it does not recognize as a shell, and its- * allowlist (`isShellCommand`) knows zsh/bash/fish/… but not `nu`, `xonsh` or `pwsh`. The EXIT+ * allowlist (`isShellCommand`) knows zsh/bash/fish/pwsh/cmd/nu/… but not `xonsh` or `elvish`. The EXIT* half has a second, allowlist-free signal for exactly those users (the foreground command* stopped being the CLI, twice in a row) — so without this the wake is STRICTER than the exit,- * and a `nu` user could be hibernated and then never woken: the chip would refuse forever.+ * and an `xonsh` user could be hibernated and then never woken: the chip would refuse forever.* Remembering what we exited TO closes that gap, and it is narrow by construction: it permits* one specific string, on one specific node, recorded by us.*diff --git a/src/renderer/terminal/agent-liveness.test.ts b/src/renderer/terminal/agent-liveness.test.tsindex 272964ed7..e2e39dd6d 100644--- a/src/renderer/terminal/agent-liveness.test.ts+++ b/src/renderer/terminal/agent-liveness.test.ts@@ -16,6 +16,12 @@ describe('looksDropped', () => {expect(looksDropped({ ...base, pane })).toBe(true)})+ it('accepts the Windows session host\'s shell image names', () => {+ for (const pane of ['pwsh.exe', 'cmd.exe', 'powershell.exe', 'C:\\Windows\\System32\\cmd.exe'])+ expect(looksDropped({ ...base, pane })).toBe(true)+ expect(looksDropped({ ...base, pane: 'node.exe' })).toBe(false)+ })+// The signal's other half: something is still running in there.it('is silent while the agent still owns the pane', () => {for (const pane of ['claude', 'node', 'vim', 'npm'])diff --git a/src/renderer/terminal/agent-restart.ts b/src/renderer/terminal/agent-restart.tsindex 0e141d5d4..3321ba164 100644--- a/src/renderer/terminal/agent-restart.ts+++ b/src/renderer/terminal/agent-restart.ts@@ -332,7 +332,7 @@ export async function performExitPhase(d: {if (gone()) return 'not-eligible' // stop polling a pane that no longer exists// Two ways to know the CLI let go of the pane. The allowlist is the confident one and is// taken immediately. The other — "the foreground command is no longer what it was before the- // exit" — covers the shells the allowlist cannot know (`nu`, `xonsh`, `pwsh`, anything the+ // exit" — covers the shells the allowlist cannot know (`xonsh`, `elvish`, anything the// user set as `defaultShell`), where waiting for a listed shell would time out with the agent// already quit and never resumed. It is required on two CONSECUTIVE polls: a single changed// reading can be a momentary foreground child of a still-running CLI, and typing the resumediff --git a/src/renderer/terminal/cold-self-heal.test.ts b/src/renderer/terminal/cold-self-heal.test.tsindex 6df8441d5..f3242ef17 100644--- a/src/renderer/terminal/cold-self-heal.test.ts+++ b/src/renderer/terminal/cold-self-heal.test.ts@@ -1,4 +1,5 @@import { describe, it, expect } from 'vitest'+import { isShellCommand } from '@shared/agents/pane'import { coldSelfHealVerdict, COLD_SELF_HEAL_MAX_AGE_S } from './cold-self-heal'/** A shell allowlist of the shape `isShellCommand` uses; the real one is injected in production. */@@ -49,6 +50,13 @@ describe('coldSelfHealVerdict', () => {)})+ it('with the production predicate, a Windows shell image name reads as a shell', () => {+ expect(coldSelfHealVerdict({ ...base, isShell: isShellCommand, paneCommand: 'pwsh.exe' })).toBe('cold')+ expect(coldSelfHealVerdict({ ...base, isShell: isShellCommand, paneCommand: 'claude.exe' })).toBe(+ 'pane-not-a-shell'+ )+ })+it('an UNREADABLE pane refuses too — never "nothing is running in it"', () => {expect(coldSelfHealVerdict({ ...base, paneCommand: null })).toBe('pane-not-a-shell')expect(coldSelfHealVerdict({ ...base, paneCommand: '' })).toBe('pane-not-a-shell')diff --git a/src/renderer/terminal/wake-identity.test.ts b/src/renderer/terminal/wake-identity.test.tsindex c210c5953..c28a484f3 100644--- a/src/renderer/terminal/wake-identity.test.ts+++ b/src/renderer/terminal/wake-identity.test.ts@@ -130,11 +130,12 @@ describe('decideWakeResume — may we type the resume line into this pane?', ()).toBe('agent-running')})- it('keeps the allowlist-free recognition for nu / xonsh / pwsh users', () => {+ it('keeps the allowlist-free recognition for xonsh / elvish users', () => {// The exit half accepts a shell its allowlist does not know; without this the wake would be// STRICTER than the exit that produced it and such a user would be hibernated and never woken.- const nu = owner({ command: 'nu', argv: ['nu'] })- const nuRecord: WakeContext = { command: 'nu', panePid: 3182371, paneId: '%0' }+ // (`nu` and `pwsh` have since joined the allowlist, so `xonsh` is what exercises this path.)+ const nu = owner({ command: 'xonsh', argv: ['xonsh'] })+ const nuRecord: WakeContext = { command: 'xonsh', panePid: 3182371, paneId: '%0' }expect(decideWakeResume({ owner: nu, recorded: nuRecord, exitedByUs: true, agentId: 'claude' })).toBe('resume')@@ -171,6 +172,17 @@ describe('decideWakeResume — may we type the resume line into this pane?', ()decideWakeResume({ owner: LOCAL_SHELL, recorded: null, exitedByUs: false, agentId: 'claude' })).toBe('resume')})+ it('resumes into a Windows session-host shell (image names: pwsh.exe / cmd.exe)', () => {+ // The session host reports the console owner's image name. Before `isShellCommand` knew+ // these, a PAUSED / dropped node on Windows answered 'context-changed' forever.+ for (const command of ['pwsh', 'pwsh.exe', 'cmd.exe', 'powershell.exe']) {+ const win = owner({ command, argv: [command] })+ expect(+ decideWakeResume({ owner: win, recorded: null, exitedByUs: false, agentId: 'claude' }),+ command+ ).toBe('resume')+ }+ })it('still refuses a pane that is not a shell', () => {expect(decideWakeResume({ owner: SSH_TO_AGENT, recorded: null, exitedByUs: false, agentId: 'claude' })diff --git a/src/shared/agents/pane-owner-predicate.ts b/src/shared/agents/pane-owner-predicate.tsindex 2273cbabc..28e0823f1 100644--- a/src/shared/agents/pane-owner-predicate.ts+++ b/src/shared/agents/pane-owner-predicate.ts@@ -219,7 +219,7 @@ export function binariesFor(** The old gate asked a persisted field what the pane SHOULD be running. `agentId` is durable and* outlives the CLI, so a plain terminal whose claude exited weeks ago still read as an agent — and- * `isShellCommand` is a SEVEN-NAME allowlist (zsh/bash/sh/fish/dash/ksh/tcsh), so `nu`, `pwsh`,+ * `isShellCommand` was then a SEVEN-NAME allowlist (zsh/bash/sh/fish/dash/ksh/tcsh), so `nu`, `pwsh`,* `xonsh`, `ssh` and `python` all fell through its negation and were admitted as agents. Text* delivered to any of those EXECUTES, because sendText appends Enter.*diff --git a/src/shared/agents/pane.test.ts b/src/shared/agents/pane.test.tsindex c75a6841b..c5961aa7f 100644--- a/src/shared/agents/pane.test.ts+++ b/src/shared/agents/pane.test.ts@@ -1,5 +1,5 @@import { describe, it, expect } from 'vitest'-import { isShellCommand } from './pane'+import { isLaunchShell, isShellCommand } from './pane'describe('isShellCommand', () => {it('recognises plain and login shells', () => {@@ -21,4 +21,26 @@ describe('isShellCommand', () => {expect(isShellCommand(undefined)).toBe(false)expect(isShellCommand('')).toBe(false)})++ it('recognises the Windows session host\'s image names (any case, .exe, full path)', () => {+ expect(isShellCommand('pwsh.exe')).toBe(true)+ expect(isShellCommand('pwsh')).toBe(true)+ expect(isShellCommand('PowerShell.EXE')).toBe(true)+ expect(isShellCommand('C:\\Windows\\System32\\cmd.exe')).toBe(true)+ expect(isShellCommand('C:\\Program Files\\Git\\bin\\bash.exe')).toBe(true)+ expect(isShellCommand('nu')).toBe(true)+ })++ it('still rejects agent CLIs and other programs under the Windows normalisation', () => {+ expect(isShellCommand('node.exe')).toBe(false)+ expect(isShellCommand('claude.exe')).toBe(false)+ expect(isShellCommand('C:\\Users\\me\\AppData\\Roaming\\npm\\codex.cmd')).toBe(false)+ expect(isShellCommand('vim')).toBe(false)+ expect(isShellCommand('ssh')).toBe(false)+ })++ it('isLaunchShell is the same predicate', () => {+ for (const c of ['zsh', '-bash', 'pwsh.exe', 'cmd', 'POWERSHELL.EXE', 'node', null, ''])+ expect(isLaunchShell(c)).toBe(isShellCommand(c))+ })})diff --git a/src/shared/agents/pane.ts b/src/shared/agents/pane.tsindex 2dcbeb00a..92fa77c8f 100644--- a/src/shared/agents/pane.ts+++ b/src/shared/agents/pane.ts@@ -3,28 +3,44 @@// question of the same `#{pane_current_command}` answer.// NOT a way to ask "is this an agent pane?". `!isShellCommand(cmd)` was that gate once, and it is-// wrong in both directions: the list below is SEVEN names, so `nu`, `pwsh`, `xonsh`, `elvish`,-// `ssh` and `python` all negate to "agent", and `#{pane_current_command}` answers `node` for every+// wrong in both directions: the list below is a fixed allowlist, so `xonsh`, `elvish`, `ssh` and+// `python` all negate to "agent", and `#{pane_current_command}` answers `node` for every// npm-installed agent CLI anyway. That question is now `isAgentPane`// (`./pane-owner-predicate.ts`), which reads the pane's foreground process group from the kernel.//-// This one stays, unchanged, because its callers ask a genuinely different question — "has the CLI-// let go of the pane?" — for which a shell allowlist IS the right shape: an unrecognised command is-// simply "not yet", and the poll goes round again.+// This one stays because its callers ask a genuinely different question — "has the CLI let go of+// the pane?" — for which a shell allowlist IS the right shape: an unrecognised command is simply+// "not yet", and the poll goes round again. Recognition is POSITIVE only: widening the set can only+// turn a "not yet" into "a shell owns it", never the reverse.+//+// The Windows session host reports its pane owner as the process image name (`pwsh.exe`,+// `powershell.exe`, `cmd.exe`, sometimes a full `C:\…\cmd.exe`), so the answer is normalised+// before the lookup: leading login '-', either path separator, case, and a trailing `.exe` (which+// also covers Git Bash's `bash.exe` / `sh.exe`). tmux's answers (`-zsh`, `/bin/sh`, `bash`) are+// already in normal form, so they read exactly as before.-/** Foreground commands that mean "the CLI is gone, a shell owns the pane". Login shells- * report as '-zsh'; tmux may report a full path. */-const SHELLS = new Set(['zsh', 'bash', 'sh', 'fish', 'dash', 'ksh', 'tcsh'])+/** Foreground commands that mean "the CLI is gone, a shell owns the pane". */+const SHELLS = new Set([+ 'zsh',+ 'bash',+ 'sh',+ 'fish',+ 'dash',+ 'ksh',+ 'tcsh',+ 'nu',+ 'pwsh',+ 'powershell',+ 'cmd'+])export function isShellCommand(cmd: string | null | undefined): boolean {if (!cmd) return false- const base = cmd.replace(/^-/, '').split('/').pop() ?? ''+ const base = (cmd.replace(/^-/, '').split(/[\\/]/).pop() ?? '').toLowerCase().replace(/\.exe$/, '')return SHELLS.has(base)}-/** Launch/retry gate, including native Windows shells. Unknown foregrounds are never writable. */-export function isLaunchShell(cmd: string | null | undefined): boolean {- if (isShellCommand(cmd)) return true- const base = cmd?.split(/[\\/]/).pop()?.toLowerCase().replace(/\.exe$/, '')- return base === 'pwsh' || base === 'powershell' || base === 'cmd'-}+/** Launch/retry gate. Kept as a name for its callers; it is now exactly `isShellCommand`, which+ * absorbed the native Windows shells this used to add on top. Unknown foregrounds are never+ * writable. */+export const isLaunchShell = isShellCommand