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(ssh): swallow probe rejections; drop the cached auto-mode answer on disconnect
enes2b792ec543cc
diff --git a/src/main/remote-ssh/ssh-project.ts b/src/main/remote-ssh/ssh-project.tsindex d7caf3b09..607f072ef 100644--- a/src/main/remote-ssh/ssh-project.ts+++ b/src/main/remote-ssh/ssh-project.ts@@ -223,7 +223,11 @@ export class SshProjectManager {// only ever an optional flag, and the probe's login shell must not delay the connect (and// with it every terminal in the project). It pushes itself into the conn + renderer when// it lands; until then this project's Claude nodes launch with the bare command.- if (entry) void this.probeClaudeAutoPermissionMode(projectId, entry)+ // Swallow any rejection: this is a best-effort optional probe, and an unhandled rejection+ // in the main process is a hard crash (Node's default --unhandled-rejections=throw), not a+ // log line. Internals are already try/catch-guarded, but `this.r.onStatus` (IPC send) can+ // still throw if the window is torn down mid-probe — that must never surface here.+ if (entry) void this.probeClaudeAutoPermissionMode(projectId, entry).catch(() => {})return {controlPath,hookEndpointPath,diff --git a/src/renderer/canvas/Canvas.tsx b/src/renderer/canvas/Canvas.tsxindex 72039a3ef..4a9a575a2 100644--- a/src/renderer/canvas/Canvas.tsx+++ b/src/renderer/canvas/Canvas.tsx@@ -3438,6 +3438,13 @@ export function Canvas() {if (e.claudeAutoPermissionMode !== undefined) {useSshConn.getState().setClaudeAutoPermissionMode(e.projectId, e.claudeAutoPermissionMode)}+ // A repointed server (different host, possibly an older claude CLI) reconnects under the+ // SAME project id. Drop any cached auto-mode answer on disconnect/reconnect so a launch in+ // the gap before the next probe lands degrades to the fail-open bare command instead of+ // reusing the previous host's stale `true`.+ if (e.status === 'disconnected' || e.status === 'reconnecting') {+ useSshConn.getState().invalidateAutoPermissionMode(e.projectId)+ }})}, [])diff --git a/src/renderer/state/sshConn.test.ts b/src/renderer/state/sshConn.test.tsnew file mode 100644index 000000000..50bb312a4--- /dev/null+++ b/src/renderer/state/sshConn.test.ts@@ -0,0 +1,57 @@+import { describe, it, expect, beforeEach } from 'vitest'+import { useSshConn } from './sshConn'++beforeEach(() => {+ useSshConn.setState({ byProject: {}, autoPermByProject: {} })+})++// If a project's SSH server gets repointed to a DIFFERENT host whose claude CLI is older, the+// previous host's cached `true` must not survive the disconnect — otherwise a Claude node created+// before the new probe lands launches `--permission-mode auto` against a CLI that exits 1 on it+// (dead node). A `disconnected` / `reconnecting` status must drop the cached answer so the window+// degrades to "unknown ⇒ bare command" (fail-open), not stale `true`.+describe('useSshConn — auto-permission-mode cache invalidation on disconnect', () => {+ it('stops reporting auto-supported once invalidated after a disconnected status', () => {+ const s = useSshConn.getState()+ s.setConn('p1', { controlPath: '/tmp/cm', claudeAutoPermissionMode: true })+ expect(s.supportsAutoPermissionMode('p1')).toBe(true)++ s.invalidateAutoPermissionMode('p1')++ expect(useSshConn.getState().supportsAutoPermissionMode('p1')).toBe(false)+ })++ it('stops reporting auto-supported once invalidated after a reconnecting status', () => {+ const s = useSshConn.getState()+ s.setConn('p1', { controlPath: '/tmp/cm', claudeAutoPermissionMode: true })+ expect(s.supportsAutoPermissionMode('p1')).toBe(true)++ // Same invalidation path is used for 'reconnecting' as for 'disconnected' — a repointed host+ // may still be mid-reconnect when a launch happens, and the stale answer must already be gone.+ s.invalidateAutoPermissionMode('p1')++ expect(useSshConn.getState().supportsAutoPermissionMode('p1')).toBe(false)+ })++ it('does not disturb other projects’ cached answers', () => {+ const s = useSshConn.getState()+ s.setConn('p1', { controlPath: '/tmp/cm1', claudeAutoPermissionMode: true })+ s.setConn('p2', { controlPath: '/tmp/cm2', claudeAutoPermissionMode: true })++ s.invalidateAutoPermissionMode('p1')++ expect(useSshConn.getState().supportsAutoPermissionMode('p1')).toBe(false)+ expect(useSshConn.getState().supportsAutoPermissionMode('p2')).toBe(true)+ })++ it('keeps the connection coordinates (controlPath etc.) — only the auto-perm answer is dropped', () => {+ const s = useSshConn.getState()+ s.setConn('p1', { controlPath: '/tmp/cm', claudeAutoPermissionMode: true })++ s.invalidateAutoPermissionMode('p1')++ // Unlike clear() (used on project delete), invalidation must not wipe the live conn info —+ // a reconnect on the same project still needs it until setConn() overwrites it.+ expect(useSshConn.getState().getControlPath('p1')).toBe('/tmp/cm')+ })+})diff --git a/src/renderer/state/sshConn.ts b/src/renderer/state/sshConn.tsindex 64b734bed..f0a9b96de 100644--- a/src/renderer/state/sshConn.ts+++ b/src/renderer/state/sshConn.ts@@ -44,6 +44,12 @@ interface SshConnState {/** True ONLY when the remote CLI was probed and is known to accept `--permission-mode auto`.* Not connected / never probed / older CLI all answer false (conservative — omit the flag). */supportsAutoPermissionMode(projectId: string): boolean+ /** Drop the cached probe answer WITHOUT touching the rest of the conn info (unlike `clear()`,+ * which is for project deletion). Call this on a `disconnected` / `reconnecting` status: if the+ * project's SSH server gets repointed to a different host, the previous host's cached `true`+ * must not survive to be served against the new (possibly older) remote CLI — the fail-open+ * design means "unknown" should win until the next probe lands, never a stale "yes". */+ invalidateAutoPermissionMode(projectId: string): voidclear(projectId: string): void}@@ -78,6 +84,14 @@ export const useSshConn = create<SshConnState>((set, get) => ({supportsAutoPermissionMode(projectId) {return get().autoPermByProject[projectId] === true},+ invalidateAutoPermissionMode(projectId) {+ set((s) => {+ if (!(projectId in s.autoPermByProject)) return s+ const next = { ...s.autoPermByProject }+ delete next[projectId]+ return { autoPermByProject: next }+ })+ },clear(projectId) {set((s) => {const next = { ...s.byProject }