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): give terminateOwnerV1 a deadline covering probe plus tree kill
reviewb925073b101e
diff --git a/src/core/session-host-client.test.ts b/src/core/session-host-client.test.tsindex 7de6e4a06..716e0573d 100644--- a/src/core/session-host-client.test.ts+++ b/src/core/session-host-client.test.ts@@ -13,10 +13,13 @@ import {type SessionHostSpawnOptions} from '../session-host/protocol'import {+ SESSION_HOST_REQUEST_TIMEOUT_MS,SessionHostClient,SessionHostProtocolCompatibilityError,+ TERMINATE_OWNER_REQUEST_TIMEOUT_MS,type SessionSubscriber} from './session-host-client'+import { WINDOWS_PROCESS_TREE_TERMINATION_TIMEOUT_MS } from '../session-host/windows-process-tree'const openServers = new Set<net.Server>()const openSockets = new Set<net.Socket>()@@ -262,6 +265,24 @@ describe('SessionHostClient handshake transition', () => {expect(commands).toEqual(['hello', 'terminateOwnerV1', 'terminateOwnerV1'])})+ it('gives terminateOwnerV1 a deadline covering the host probe plus the whole tree-kill budget', async () => {+ // A deadline shorter than the host's own work reports `false` for a kill that may have landed+ // (the caller then skips the recycle) and retires the socket for every other session.+ expect(TERMINATE_OWNER_REQUEST_TIMEOUT_MS).toBeGreaterThan(4_000 + WINDOWS_PROCESS_TREE_TERMINATION_TIMEOUT_MS)+ expect(TERMINATE_OWNER_REQUEST_TIMEOUT_MS).toBeGreaterThan(SESSION_HOST_REQUEST_TIMEOUT_MS)+ const client = new SessionHostClient({ userDataDir: os.tmpdir(), repoRoot: os.tmpdir() })+ const request = vi+ .spyOn(client as unknown as { request: (...args: unknown[]) => Promise<unknown> }, 'request')+ .mockResolvedValue({ terminated: true })+ expect(await client.terminateOwner('nt-a', WIN_OWNER)).toBe(true)+ expect(request).toHaveBeenCalledWith(+ expect.objectContaining({ cmd: 'terminateOwnerV1' }),+ undefined,+ undefined,+ TERMINATE_OWNER_REQUEST_TIMEOUT_MS+ )+ })+it('returns terminated only when the host says so, carrying the expected owner verbatim', async () => {const { userDataDir, paths } = createUserData('terminate-owner-ok')const seen: unknown[] = []diff --git a/src/core/session-host-client.ts b/src/core/session-host-client.tsindex 39a530cbc..129d3d653 100644--- a/src/core/session-host-client.ts+++ b/src/core/session-host-client.ts@@ -12,6 +12,7 @@ import { randomUUID } from 'crypto'// socket 'close' events dispatch first, even inside fake-timer tests.import { setImmediate as realSetImmediate } from 'timers'import { sessionHostPaths } from '../session-host/paths'+import { WINDOWS_PROCESS_TREE_TERMINATION_TIMEOUT_MS } from '../session-host/windows-process-tree'import {EMPTY_LOCK_STALE_MS,LISTEN_RETRY_BUDGET_MS,@@ -63,6 +64,14 @@ export const SESSION_HOST_REQUEST_TIMEOUT_MS = 10_000/** A `shutdown` ends every session (each kill confirmed by the host within its own 20 s bound),* so it gets a longer deadline than an ordinary request. */export const SHUTDOWN_REQUEST_TIMEOUT_MS = 45_000+/** `terminateOwnerV1` runs the host's owner probe (`readWindowsConsoleOwner`, a PowerShell+ * execFile bounded at 4 s) and then `taskkill /T /F` plus the root-absence poll (bounded at+ * `WINDOWS_PROCESS_TREE_TERMINATION_TIMEOUT_MS`, 8 s). The ordinary 10 s deadline is shorter than+ * that sum, and its expiry is not a plain `false`: the agent may already be dead (the caller then+ * skips the recycle and strands a bare shell) AND the deadline retires the whole socket, dropping+ * every other session's stream on this connection. So the kill gets the full budget plus slack. */+export const TERMINATE_OWNER_REQUEST_TIMEOUT_MS =+ 4_000 + WINDOWS_PROCESS_TREE_TERMINATION_TIMEOUT_MS + 6_000export type HostUpdateInspection =| { running: false }@@ -1651,7 +1660,12 @@ export class SessionHostClient {* retried — a second kill aimed at a re-proven owner is the host's job, not a resend's. */async terminateOwner(name: string, expected: PaneOwner): Promise<boolean | 'unsupported'> {try {- const result = await this.request<{ terminated?: unknown } | undefined>({ cmd: 'terminateOwnerV1', name, expected })+ const result = await this.request<{ terminated?: unknown } | undefined>(+ { cmd: 'terminateOwnerV1', name, expected },+ undefined,+ undefined,+ TERMINATE_OWNER_REQUEST_TIMEOUT_MS+ )return result?.terminated === true} catch (error) {return error instanceof SessionHostRequestRejectedError && error.message === 'unknown command'