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
feat(ssh): make the permission-mode auto gate and account pickers legible on SSH projects
enes29d1b21b28a2
diff --git a/src/main/remote-ssh/ssh-project.test.ts b/src/main/remote-ssh/ssh-project.test.tsindex 77b208c21..36567cff2 100644--- a/src/main/remote-ssh/ssh-project.test.ts+++ b/src/main/remote-ssh/ssh-project.test.ts@@ -165,13 +165,21 @@ describe('SshProjectManager', () => {// would launch `--permission-mode auto` on a CLI that exits 1 on it.const BANNER = 'Welcome — Ubuntu 22.04.3 LTS (GNU/Linux 5.15.0-89-generic)\nkernel 6.8.0-106\n'- /** A manager whose remote claude probe answers with `banner + <markers>version</markers>`. */- function mgrWithClaude(versionOut: string | null) {- const events: { status: string; claudeAutoPermissionMode?: boolean }[] = []+ /** A manager whose remote claude probe answers with `banner + <markers>version</markers>`.+ * Pass an array to script successive probe attempts (retry coverage); the last entry repeats. */+ function mgrWithClaude(versionOut: string | null | (string | null)[], retryDelaysMs?: number[]) {+ const outputs = Array.isArray(versionOut) ? versionOut : [versionOut]+ let probeCalls = 0+ const events: {+ status: string+ claudeAutoPermissionMode?: boolean+ remoteClaudeVersion?: string | null+ }[] = []const run = vi.fn(async (args: string[]) => {const cmd = args.join(' ')if (cmd.includes('__NT_V_START__')) {- return { code: 0, stdout: versionOut === null ? BANNER : `${BANNER}${versionOut}` }+ const out = outputs[Math.min(probeCalls++, outputs.length - 1)]+ return { code: 0, stdout: out === null ? BANNER : `${BANNER}${out}` }}if (cmd.includes('printf %s')) return { code: 0, stdout: '/home/u' }return { code: 0, stdout: '' }@@ -182,13 +190,24 @@ describe('SshProjectManager', () => {run,runScp: vi.fn(async () => ({ code: 0 })),getHook: () => ({ port: 1, token: 't', version: '1' }),- onStatus: (e) => events.push({ status: e.status, claudeAutoPermissionMode: e.claudeAutoPermissionMode })+ onStatus: (e) =>+ events.push({+ status: e.status,+ claudeAutoPermissionMode: e.claudeAutoPermissionMode,+ remoteClaudeVersion: e.remoteClaudeVersion+ }),+ ...(retryDelaysMs ? { probeRetryDelaysMs: retryDelaysMs } : {})})- return { mgr, events, run }+ return { mgr, events, run, probeCallCount: () => probeCalls }}- const probeEvent = (events: { claudeAutoPermissionMode?: boolean }[]) =>- events.find((e) => e.claudeAutoPermissionMode !== undefined)+ const probeEvent = (+ events: { claudeAutoPermissionMode?: boolean; remoteClaudeVersion?: string | null }[]+ ) => events.find((e) => e.claudeAutoPermissionMode !== undefined)++ const probeEvents = (+ events: { claudeAutoPermissionMode?: boolean; remoteClaudeVersion?: string | null }[]+ ) => events.filter((e) => e.claudeAutoPermissionMode !== undefined)it('a login-shell BANNER around an OLD claude never reports auto support (merge blocker)', async () => {const { mgr, events } = mgrWithClaude('__NT_V_START__2.0.30 (Claude Code)__NT_V_END__')@@ -212,6 +231,61 @@ describe('SshProjectManager', () => {expect(probeEvent(events)?.claudeAutoPermissionMode).toBe(true)})+ it('the status event carries the probed remote version (for the tab-menu hint)', async () => {+ const { mgr, events } = mgrWithClaude('__NT_V_START__2.0.30 (Claude Code)__NT_V_END__')+ await mgr.connect('p1', conn)+ await vi.waitFor(() => expect(probeEvent(events)).toBeDefined())+ expect(probeEvent(events)?.remoteClaudeVersion).toBe('2.0.30 (Claude Code)')+ })++ it('a FAILED probe reports version null (distinguishable from "old CLI") and retries', async () => {+ // First attempt: markers absent (claude not found — e.g. a transient PATH/login-shell hiccup);+ // second attempt: a modern CLI. The first answer must land immediately (fail-open `false`,+ // version null) so launch paths never wait on retries, and the retry must upgrade it to `true`.+ const { mgr, events } = mgrWithClaude(+ [null, '__NT_V_START__2.1.90 (Claude Code)__NT_V_END__'],+ [1]+ )+ await mgr.connect('p1', conn)+ await vi.waitFor(() => expect(probeEvents(events).length).toBeGreaterThanOrEqual(2))+ const probes = probeEvents(events)+ expect(probes[0]).toMatchObject({ claudeAutoPermissionMode: false, remoteClaudeVersion: null })+ expect(probes[probes.length - 1]).toMatchObject({+ claudeAutoPermissionMode: true,+ remoteClaudeVersion: '2.1.90 (Claude Code)'+ })+ })++ it('a definite version answer stops the retries (a CLI does not upgrade mid-connection)', async () => {+ const { mgr, events, probeCallCount } = mgrWithClaude(+ '__NT_V_START__2.0.30 (Claude Code)__NT_V_END__',+ [1, 1, 1]+ )+ await mgr.connect('p1', conn)+ await vi.waitFor(() => expect(probeEvent(events)).toBeDefined())+ // Give any (wrong) retry loop time to fire before counting.+ await new Promise((r) => setTimeout(r, 30))+ expect(probeCallCount()).toBe(1)+ })++ it('gives up retrying after the configured attempts when claude never appears', async () => {+ const { mgr, events, probeCallCount } = mgrWithClaude(null, [1, 1])+ await mgr.connect('p1', conn)+ await vi.waitFor(() => expect(probeEvents(events).length).toBeGreaterThanOrEqual(3))+ await new Promise((r) => setTimeout(r, 30))+ expect(probeCallCount()).toBe(3) // initial attempt + 2 retries, then stop+ expect(probeEvents(events).every((e) => e.claudeAutoPermissionMode === false)).toBe(true)+ })++ it('a reused connection returns the probed answer + version with the connect result', async () => {+ const { mgr, events } = mgrWithClaude('__NT_V_START__2.1.90 (Claude Code)__NT_V_END__')+ await mgr.connect('p1', conn)+ await vi.waitFor(() => expect(probeEvent(events)).toBeDefined())+ const res = await mgr.connect('p1', conn)+ expect(res.claudeAutoPermissionMode).toBe(true)+ expect(res.remoteClaudeVersion).toBe('2.1.90 (Claude Code)')+ })+it('connect does NOT wait on the claude probe (it runs after `connected`)', async () => {// The probe's `$SHELL -lc` sources nvm/conda inits and can take seconds; every remote terminal// in the project waits on connect, so the probe must be off that path.diff --git a/src/main/remote-ssh/ssh-project.ts b/src/main/remote-ssh/ssh-project.tsindex 97c966bb6..8a369edf1 100644--- a/src/main/remote-ssh/ssh-project.ts+++ b/src/main/remote-ssh/ssh-project.ts@@ -35,8 +35,17 @@ interface Runners {/** Live loopback hook-server coordinates (injected so the manager stays testable). */getHook: () => { port: number; token: string; version: string }onStatus: (e: SshProjectStatusEvent) => void+ /** Delays between claude-probe retries after a FAILED attempt (claude not found). Injected so+ * tests don't wait on real backoff; production uses PROBE_RETRY_DELAYS_MS. */+ probeRetryDelaysMs?: number[]}+/** Backoff after a FAILED remote claude probe (no markers = claude not found on that attempt).+ * A transient login-shell hiccup (nvm cache warm-up, NFS home, corp wrapper) shouldn't disable+ * `--permission-mode auto` for the whole connection. A DEFINITE version answer never retries —+ * a CLI doesn't change under a live connection; the next connect re-probes anyway. */+const PROBE_RETRY_DELAYS_MS = [5_000, 15_000, 30_000]+interface Conn {conn: SshConnectioncontrolPath: string@@ -52,11 +61,15 @@ interface Conn {/** The project's remote repo cwd (Phase 4). Lets `refForRemoteCwd` route remote git ops to this* connection's master. Undefined when the project has no folder selected. */remoteCwd?: string- /** Does the REMOTE host's claude CLI accept `--permission-mode auto` (>= 2.1.71)? Probed once at- * connect: the remote CLI can be older than the local one, and the local answer must never be- * applied to a remote launch. Undefined/false ⇒ the renderer omits the flag for this project's- * Claude nodes (bare command — today's behavior), never a failed launch. */+ /** Does the REMOTE host's claude CLI accept `--permission-mode auto` (>= 2.1.71)? Probed at+ * connect (with bounded retries when claude wasn't found): the remote CLI can be older than the+ * local one, and the local answer must never be applied to a remote launch. Undefined/false ⇒+ * the renderer omits the flag for this project's Claude nodes (bare command — today's+ * behavior), never a failed launch. */claudeAutoPermissionMode?: boolean+ /** The probed remote `claude --version` output. `null` = the probe ran and found no claude+ * (feeds the tab-menu hint); undefined = not probed yet. */+ remoteClaudeVersion?: string | null}/**@@ -134,6 +147,7 @@ export class SshProjectManager {tmuxConfPath?: stringremoteHome?: stringclaudeAutoPermissionMode?: boolean+ remoteClaudeVersion?: string | null}> {const existing = this.conns.get(projectId)if (existing) {@@ -150,7 +164,8 @@ export class SshProjectManager {hookEndpointPath: existing.hookEndpointPath,tmuxConfPath: existing.tmuxConfPath,remoteHome: existing.remoteHome,- claudeAutoPermissionMode: existing.claudeAutoPermissionMode+ claudeAutoPermissionMode: existing.claudeAutoPermissionMode,+ remoteClaudeVersion: existing.remoteClaudeVersion}}this.r.onStatus({ projectId, status: 'reconnecting' })@@ -233,7 +248,8 @@ export class SshProjectManager {hookEndpointPath,tmuxConfPath,remoteHome,- claudeAutoPermissionMode: entry?.claudeAutoPermissionMode+ claudeAutoPermissionMode: entry?.claudeAutoPermissionMode,+ remoteClaudeVersion: entry?.remoteClaudeVersion}}await new Promise((res) => setTimeout(res, 100))@@ -438,22 +454,43 @@ export class SshProjectManager {* inits — routinely hundreds of ms, sometimes seconds — and every remote terminal in the project* waits on connect. A node launched in the gap just omits the flag (the designed fail-open* fallback); the next launch, once the answer lands, gets `auto`.+ *+ * A FAILED attempt (no claude found) retries on a bounded backoff — a transient hiccup must not+ * disable `auto` until the next reconnect. EVERY attempt pushes its answer immediately (the+ * fail-open `false` first, a later success upgrading it): launch paths that wait on the first+ * answer (`ensureActivePermissionMode`) must never be held hostage by the retry tail. A definite+ * version — old or new — stops the retries: a CLI doesn't change under a live connection.*/private async probeClaudeAutoPermissionMode(projectId: string, entry: Conn): Promise<void> {- // One remote `claude --version` feeds BOTH version gates (permission-mode auto >= 2.1.71 and- // fullscreen tui >= 2.1.89) — no second probe.- const version = await this.remoteClaudeVersion(entry.conn, entry.controlPath)- const supported = supportsAutoPermissionMode(version)- // Disconnected / reconnected (new Conn) while we probed → the answer belongs to a dead- // connection; drop it rather than write it onto the new one.- if (this.conns.get(projectId) !== entry) return- entry.claudeAutoPermissionMode = supported- this.r.onStatus({ projectId, status: 'connected', claudeAutoPermissionMode: supported })- // Ensure Claude's fullscreen TUI on the host's ~/.claude/settings.json (write-if-absent), so a- // remote Claude session behaves natively in the host's tmux. Gated on the same probed version;- // fail-open inside RemoteHooks. Needs the resolved $HOME for an absolute path.- if (entry.remoteHome && supportsFullscreenTui(version)) {- await this.remoteHooks.ensureFullscreenTui(entry.conn, entry.controlPath, entry.remoteHome)+ const delays = this.r.probeRetryDelaysMs ?? PROBE_RETRY_DELAYS_MS+ for (let attempt = 0; ; attempt++) {+ // One remote `claude --version` feeds BOTH version gates (permission-mode auto >= 2.1.71 and+ // fullscreen tui >= 2.1.89) — no second probe.+ const version = await this.remoteClaudeVersion(entry.conn, entry.controlPath)+ // Disconnected / reconnected (new Conn) while we probed → the answer belongs to a dead+ // connection; drop it rather than write it onto the new one.+ if (this.conns.get(projectId) !== entry) return+ const supported = supportsAutoPermissionMode(version)+ entry.claudeAutoPermissionMode = supported+ entry.remoteClaudeVersion = version+ this.r.onStatus({+ projectId,+ status: 'connected',+ claudeAutoPermissionMode: supported,+ remoteClaudeVersion: version+ })+ if (version !== null) {+ // Ensure Claude's fullscreen TUI on the host's ~/.claude/settings.json (write-if-absent),+ // so a remote Claude session behaves natively in the host's tmux. Gated on the same probed+ // version; fail-open inside RemoteHooks. Needs the resolved $HOME for an absolute path.+ if (entry.remoteHome && supportsFullscreenTui(version)) {+ await this.remoteHooks.ensureFullscreenTui(entry.conn, entry.controlPath, entry.remoteHome)+ }+ return+ }+ if (attempt >= delays.length) return+ await new Promise((r) => setTimeout(r, delays[attempt]))+ if (this.conns.get(projectId) !== entry) return}}diff --git a/src/renderer/canvas/Canvas.tsx b/src/renderer/canvas/Canvas.tsxindex c710bf062..79f3b06dd 100644--- a/src/renderer/canvas/Canvas.tsx+++ b/src/renderer/canvas/Canvas.tsx@@ -201,6 +201,7 @@ import {reparentNode,resolveNewNodeAccount,accountsForProject,+ sshAccountsHint,ungroupNodes,type CanvasNode} from '../state/workspace'@@ -3551,11 +3552,15 @@ export function Canvas() {: undefinedconst withDefaultMark = (label: string, id?: string): string =>id === defaultAccountId ? `${label} ✓` : label+ // SSH project with no accounts on its host: keep the submenu, with a disabled row saying+ // where this host's accounts come from — local accounts are correctly invisible here, and+ // a bare flat entry read as "multi-account is broken on SSH".+ const accountsHint = sshAccountsHint(project, accounts)return [...BUILTIN_AGENT_IDS.filter((aid) => !disabled.includes(aid)).map((aid): MenuItem => {// Claude gets an account picker submenu when ≥1 account exists; System = project// default (resolved). Other agents stay flat (accounts are Claude-only).- if (aid === 'claude' && accounts.length > 0) {+ if (aid === 'claude' && (accounts.length > 0 || accountsHint)) {return {type: 'submenu',label: `New ${AGENT_CONFIG[aid].label}`,@@ -3572,7 +3577,17 @@ export function Canvas() {icon: <AgentIcon agentId="claude" />,onClick: () => addAgentNode('claude', at, groupId, a.id)})- )+ ),+ ...(accountsHint+ ? [+ {+ label: 'No accounts on this host yet',+ onClick: () => {},+ disabled: true,+ hint: accountsHint+ } satisfies MenuItem+ ]+ : [])]}}@@ -4856,7 +4871,9 @@ export function Canvas() {// on a later `connected` event — record it so this project's next Claude launch can use// `--permission-mode auto`. Absent = nothing new to record (keep omitting the flag).if (e.claudeAutoPermissionMode !== undefined) {- useSshConn.getState().setClaudeAutoPermissionMode(e.projectId, e.claudeAutoPermissionMode)+ useSshConn+ .getState()+ .setClaudeAutoPermissionMode(e.projectId, e.claudeAutoPermissionMode, e.remoteClaudeVersion)}// 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 indiff --git a/src/renderer/components/Dock.tsx b/src/renderer/components/Dock.tsxindex 15129e5a7..2dc9af6f1 100644--- a/src/renderer/components/Dock.tsx+++ b/src/renderer/components/Dock.tsx@@ -3,7 +3,7 @@ import { AGENT_CONFIG, BUILTIN_AGENT_IDS, type AgentId } from '@shared/agents/coimport { AgentIcon } from '../lib/agentIcons'import { useSettings } from '../state/settings'import { useProjects } from '../state/projects'-import { accountsForProject } from '../state/workspace'+import { accountsForProject, sshAccountsHint } from '../state/workspace'interface DockProps {dirty: boolean@@ -92,8 +92,21 @@ export function Dock({<span>{AGENT_CONFIG[aid].label}</span></button>)+ if (aid !== 'claude') return [base]+ // SSH project with no accounts on its host: a disabled row saying where this+ // host's accounts come from (local accounts are correctly invisible here).+ const acctHint = sshAccountsHint(activeProject, localAccounts)+ if (acctHint) {+ return [+ base,+ <button key={`${aid}-acct-hint`} disabled title={acctHint}>+ <AgentIcon agentId={aid} size={18} />+ <span>No accounts on this host yet</span>+ </button>+ ]+ }// Claude picks up one flat entry per logged-in local account (dock can't nest).- if (aid !== 'claude' || localAccounts.length === 0) return [base]+ if (localAccounts.length === 0) return [base]return [base,...localAccounts.map((a) => (diff --git a/src/renderer/components/TabBar.tsx b/src/renderer/components/TabBar.tsxindex b20b74918..50b261912 100644--- a/src/renderer/components/TabBar.tsx+++ b/src/renderer/components/TabBar.tsx@@ -3,7 +3,9 @@ import { createPortal } from 'react-dom'import { useProjects } from '../state/projects'import { useAgentStatus } from '../state/agentStatus'import { useSettings } from '../state/settings'-import { accountsForProject, systemAccountDisplay } from '../state/workspace'+import { accountsForProject, sshAccountsHint, systemAccountDisplay } from '../state/workspace'+import { useSshConn } from '../state/sshConn'+import { sshAutoModeHint } from '../state/permissionMode'import { useSystemAccount } from '../state/systemAccount'import { sessionCount, sessionForProject, useProjectSession } from '../session/session'import { tabClickAction } from '../session/relay-tab'@@ -104,6 +106,25 @@ export function TabBar({// Accounts eligible as the caret-menu project's default: local accounts for a local project, this// host's accounts for an SSH project (pending logins always excluded).const menuAccounts = accountsForProject(claudeAccounts, menuProject)+ // SSH project with no accounts on its host: say where accounts for this host come from instead+ // of presenting a bare System-only list (which read as "multi-account is broken on SSH").+ const menuAccountsHint = sshAccountsHint(menuProject, menuAccounts)+ // Live remote-probe view for the Auto rows below: on an SSH project `auto` only applies once the+ // REMOTE claude CLI is confirmed >= 2.1.71, and without a hint that silent fail-open degrade is+ // indistinguishable from a broken dropdown. Subscribed (not getState) so the ⚠︎ clears the+ // moment the probe answers while the menu is open.+ const autoPermByProject = useSshConn((s) => s.autoPermByProject)+ const remoteClaudeVersionByProject = useSshConn((s) => s.remoteClaudeVersionByProject)+ const menuAutoHint = menuProject?.ssh+ ? sshAutoModeHint(+ autoPermByProject[menuProject.id] === undefined+ ? 'unknown'+ : autoPermByProject[menuProject.id]+ ? 'yes'+ : 'no',+ remoteClaudeVersionByProject[menuProject.id]+ )+ : nullconst closeMenu = () => {setMenuId(null)@@ -326,6 +347,12 @@ export function TabBar({{a.label}</button>))}+ {menuAccountsHint && (+ <button disabled title={menuAccountsHint}>+ <span className="tab-menu__check" />+ No accounts on this host yet+ </button>+ )}</div>)}</>@@ -340,6 +367,9 @@ export function TabBar({{modeOpen && (<div className="tab-menu__sub"><button+ // On an SSH project the global Auto only applies once the REMOTE CLI is+ // confirmed — surface why it may currently do nothing (see menuAutoHint).+ title={globalMode === 'auto' ? (menuAutoHint ?? undefined) : undefined}onClick={() => {onSetDefaultPermissionMode(menuProject.id, undefined)closeMenu()@@ -349,17 +379,23 @@ export function TabBar({{menuProject.defaultPermissionMode ? '' : '✓'}</span>Use global ({PERMISSION_MODE_LABELS[globalMode]})+ {globalMode === 'auto' && menuAutoHint ? ' ⚠︎' : ''}</button>{ALL_PERMISSION_MODES.map((m) => (<buttonkey={m}// A project override is written to <cwd>/.nodeterm/project.json, which is// git-shared and mirrored to SSH servers — spell out for "Bypass all" that- // the choice travels to everyone who clones the repo.+ // the choice travels to everyone who clones the repo. The Auto row instead+ // explains when it will NOT apply on this SSH project's host (remote CLI too+ // old / not found / not probed yet) — still selectable: the setting is kept+ // and applies the moment the host's CLI qualifies.title={m === 'bypassPermissions'? 'Skips every permission prompt. This override is saved in the project file (.nodeterm/project.json), so if you commit it, everyone who clones the repo runs Claude without permission checks too.'- : undefined+ : m === 'auto'+ ? (menuAutoHint ?? undefined)+ : undefined}onClick={() => {onSetDefaultPermissionMode(menuProject.id, m)@@ -369,7 +405,7 @@ export function TabBar({<span className="tab-menu__check">{menuProject.defaultPermissionMode === m ? '✓' : ''}</span>- {m === 'bypassPermissions'+ {m === 'bypassPermissions' || (m === 'auto' && menuAutoHint)? `${PERMISSION_MODE_LABELS[m]} ⚠︎`: PERMISSION_MODE_LABELS[m]}</button>diff --git a/src/renderer/state/permissionMode.test.ts b/src/renderer/state/permissionMode.test.tsindex fbf58cc51..1394fcddf 100644--- a/src/renderer/state/permissionMode.test.ts+++ b/src/renderer/state/permissionMode.test.ts@@ -8,7 +8,9 @@ import {activePermissionMode,ensureActivePermissionMode,ensureClaudeCliCaps,- resetClaudeCliCapsForTests+ resetClaudeCliCapsForTests,+ sshAutoModeHint,+ SSH_AUTO_PROBE_WAIT_MS} from './permissionMode'/** Stand in for the preload/bridge `claude.cliCaps()` probe. */@@ -26,7 +28,7 @@ const SSH_SERVER = { id: 's1', label: 'box', host: 'box', user: 'me' } as unknowbeforeEach(() => {useProjects.getState().hydrate({ version: 2, activeProjectId: '', projects: [] })useSettings.setState({ settings: { ...DEFAULT_SETTINGS }, hydrated: false })- useSshConn.setState({ byProject: {}, autoPermByProject: {} })+ useSshConn.setState({ byProject: {}, autoPermByProject: {}, remoteClaudeVersionByProject: {} })resetClaudeCliCapsForTests()mockCliCaps(MODERN)})@@ -205,3 +207,92 @@ describe('ensureActivePermissionMode', () => {}})})++// A cold-restore relaunch on an SSH project fires on mount, seconds before the REMOTE probe's+// login shell answers. Without a bounded wait, every relaunch after a server reboot silently+// dropped `auto` — the exact "the setting does nothing on SSH" report this exists to fix.+describe('ensureActivePermissionMode — SSH projects wait for the remote probe', () => {+ it('waits for the remote answer, so a relaunch racing the probe still gets auto', async () => {+ mockCliCaps(OLD) // the LOCAL CLI is irrelevant for a remote launch+ const p = activeProject('remote', { server: SSH_SERVER, remoteCwd: '/srv/app' })++ const pending = ensureActivePermissionMode()+ // The probe answer lands ASYNCHRONOUSLY, after the relaunch already started waiting — the+ // exact cold-restore race (mount beats the remote login-shell probe by seconds).+ setTimeout(+ () => useSshConn.getState().setClaudeAutoPermissionMode(p.id, true, '2.1.90 (Claude Code)'),+ 25+ )++ await expect(pending).resolves.toBe('auto')+ })++ it('resolves without waiting when the probe already answered', async () => {+ vi.useFakeTimers()+ try {+ mockCliCaps(MODERN)+ const p = activeProject('remote', { server: SSH_SERVER, remoteCwd: '/srv/app' })+ useSshConn.getState().setClaudeAutoPermissionMode(p.id, false, null)++ const pending = ensureActivePermissionMode()+ await vi.advanceTimersByTimeAsync(0) // no timer must be needed++ await expect(pending).resolves.toBe('manual') // probed 'no' ⇒ bare command+ } finally {+ vi.useRealTimers()+ }+ })++ it('times out into the bare command when no probe answer ever arrives', async () => {+ vi.useFakeTimers()+ try {+ mockCliCaps(MODERN)+ activeProject('remote', { server: SSH_SERVER, remoteCwd: '/srv/app' })++ const pending = ensureActivePermissionMode()+ await vi.advanceTimersByTimeAsync(SSH_AUTO_PROBE_WAIT_MS)++ await expect(pending).resolves.toBe('manual')+ } finally {+ vi.useRealTimers()+ }+ })++ it('does not wait at all when the resolved mode is not auto', async () => {+ vi.useFakeTimers()+ try {+ mockCliCaps(MODERN)+ const p = activeProject('remote', { server: SSH_SERVER, remoteCwd: '/srv/app' })+ useProjects.getState().setProjectDefaultPermissionMode(p.id, 'plan')++ const pending = ensureActivePermissionMode()+ await vi.advanceTimersByTimeAsync(0)++ await expect(pending).resolves.toBe('plan')+ } finally {+ vi.useRealTimers()+ }+ })+})++// The tab menu's Auto rows surface WHY Auto may not apply on an SSH project — the silent+// degradation was indistinguishable from "the dropdown is broken".+describe('sshAutoModeHint', () => {+ it('no hint once the remote CLI is confirmed to support auto', () => {+ expect(sshAutoModeHint('yes', '2.1.90 (Claude Code)')).toBeNull()+ })++ it('names the too-old remote version and the required minimum', () => {+ const hint = sshAutoModeHint('no', '2.0.30 (Claude Code)')+ expect(hint).toContain('2.0.30')+ expect(hint).toContain('2.1.71')+ })++ it('says claude was not found when the probe failed', () => {+ expect(sshAutoModeHint('no', null)).toMatch(/not found/i)+ })++ it('reads as unverified while the probe has not answered', () => {+ expect(sshAutoModeHint('unknown', undefined)).toMatch(/not verified/i)+ })+})diff --git a/src/renderer/state/permissionMode.ts b/src/renderer/state/permissionMode.tsindex 40a52f723..467a565d4 100644--- a/src/renderer/state/permissionMode.ts+++ b/src/renderer/state/permissionMode.ts@@ -1,8 +1,13 @@-import { gatePermissionMode, resolvePermissionMode, type AgentPermissionMode } from '@shared/agents/config'+import {+ AUTO_PERMISSION_MODE_MIN_VERSION,+ gatePermissionMode,+ resolvePermissionMode,+ type AgentPermissionMode+} from '@shared/agents/config'import { UNKNOWN_CLAUDE_CLI_CAPS, type ClaudeCliCaps, type Project } from '@shared/types'import { useProjects } from './projects'import { useSettings } from './settings'-import { useSshConn } from './sshConn'+import { useSshConn, type SshAutoPermAnswer } from './sshConn'/*** Local Claude CLI capabilities, probed once per app run through `claude.cliCaps()` (main/server →@@ -82,13 +87,68 @@ export function activePermissionMode(): AgentPermissionMode {return gatePermissionMode(resolvePermissionMode(project, settings), autoSupportedFor(project))}+/** How long a launch on an SSH project may wait for the REMOTE probe's first answer. The probe+ * fires right after connect and pushes every attempt's answer immediately, so this usually+ * resolves in the first couple of seconds; the cap keeps a dead probe from stalling a relaunch. */+export const SSH_AUTO_PROBE_WAIT_MS = 10_000++/** Resolve once the project's remote probe has ANY answer (yes/no), or after `ms`. Fail-open:+ * a timeout just means the caller gates on 'unknown' — bare command, never a blocked launch. */+function waitForSshAutoAnswer(projectId: string, ms: number): Promise<void> {+ if (useSshConn.getState().autoPermAnswer(projectId) !== 'unknown') return Promise.resolve()+ return new Promise((resolve) => {+ let settled = false+ const finish = (): void => {+ if (settled) return+ settled = true+ clearTimeout(timer)+ unsub()+ resolve()+ }+ const unsub = useSshConn.subscribe((s) => {+ if (s.autoPermByProject[projectId] !== undefined) finish()+ })+ const timer = setTimeout(finish, ms)+ })+}+/*** `activePermissionMode()` for callers that can run BEFORE the boot-time probe has answered — the* cold-restore agent relaunch fires on node mount. Awaiting the (memoized, warmed in the shell)* probe there means a rebooted machine still gets `auto`, instead of silently falling back to the* bare command for one session.+ *+ * On an SSH project the gate consults the REMOTE probe, which races the same mount (it fires+ * after connect, through a slow login shell) — so when the resolved mode is `auto`, this also+ * waits (bounded) for that probe's first answer. Any other mode never waits: the gate only ever+ * touches `auto`.*/export async function ensureActivePermissionMode(): Promise<AgentPermissionMode> {await ensureClaudeCliCaps()+ const { settings } = useSettings.getState()+ const { getProject, activeProjectId } = useProjects.getState()+ const project = getProject(activeProjectId)+ if (project?.ssh && resolvePermissionMode(project, settings) === 'auto') {+ await waitForSshAutoAnswer(project.id, SSH_AUTO_PROBE_WAIT_MS)+ }return activePermissionMode()}++/**+ * Why `auto` may not apply on this SSH project, for the tab menu's Auto rows — null when the+ * remote CLI is confirmed and Auto works as chosen. The silent fail-open degrade is correct for+ * launches but indistinguishable from "the dropdown is broken" without this.+ */+export function sshAutoModeHint(+ answer: SshAutoPermAnswer,+ version: string | null | undefined+): string | null {+ if (answer === 'yes') return null+ if (answer === 'no') {+ const v = version?.match(/\d+\.\d+\.\d+/)?.[0]+ return v+ ? `The server's Claude CLI is ${v} — Auto needs ${AUTO_PERMISSION_MODE_MIN_VERSION} or newer, so sessions start without a mode flag until it is upgraded.`+ : 'Claude CLI was not found on the server, so Auto cannot apply — sessions start without a mode flag.'+ }+ return `Not verified on this server yet — Auto applies once the server's Claude CLI (≥ ${AUTO_PERMISSION_MODE_MIN_VERSION}) is confirmed.`+}diff --git a/src/renderer/state/sshConn.test.ts b/src/renderer/state/sshConn.test.tsindex 50bb312a4..183e2129b 100644--- a/src/renderer/state/sshConn.test.ts+++ b/src/renderer/state/sshConn.test.ts@@ -2,7 +2,7 @@ import { describe, it, expect, beforeEach } from 'vitest'import { useSshConn } from './sshConn'beforeEach(() => {- useSshConn.setState({ byProject: {}, autoPermByProject: {} })+ useSshConn.setState({ byProject: {}, autoPermByProject: {}, remoteClaudeVersionByProject: {} })})// If a project's SSH server gets repointed to a DIFFERENT host whose claude CLI is older, the@@ -55,3 +55,54 @@ describe('useSshConn — auto-permission-mode cache invalidation on disconnect',expect(useSshConn.getState().getControlPath('p1')).toBe('/tmp/cm')})})++// The tab menu's Auto hint needs THREE states, not the boolean gate: 'unknown' (not probed yet /+// disconnected) reads differently from 'no' (probed: old CLI or claude missing). The launch gate+// (`supportsAutoPermissionMode`) stays boolean and conservative.+describe('useSshConn — tri-state probe answer + remote version (tab-menu hint)', () => {+ it('answers unknown before any probe, no/yes after, unknown again after invalidation', () => {+ const s = useSshConn.getState()+ expect(s.autoPermAnswer('p1')).toBe('unknown')++ s.setClaudeAutoPermissionMode('p1', false, '2.0.30 (Claude Code)')+ expect(useSshConn.getState().autoPermAnswer('p1')).toBe('no')++ s.setClaudeAutoPermissionMode('p1', true, '2.1.90 (Claude Code)')+ expect(useSshConn.getState().autoPermAnswer('p1')).toBe('yes')++ s.invalidateAutoPermissionMode('p1')+ expect(useSshConn.getState().autoPermAnswer('p1')).toBe('unknown')+ })++ it('records the probed version, including null for "claude not found"', () => {+ const s = useSshConn.getState()+ expect(s.getRemoteClaudeVersion('p1')).toBeUndefined()++ s.setClaudeAutoPermissionMode('p1', false, null)+ expect(useSshConn.getState().getRemoteClaudeVersion('p1')).toBeNull()++ s.setClaudeAutoPermissionMode('p1', true, '2.1.90 (Claude Code)')+ expect(useSshConn.getState().getRemoteClaudeVersion('p1')).toBe('2.1.90 (Claude Code)')+ })++ it('invalidation drops the cached version along with the answer (repointed host)', () => {+ const s = useSshConn.getState()+ s.setClaudeAutoPermissionMode('p1', false, '2.0.30 (Claude Code)')++ s.invalidateAutoPermissionMode('p1')++ expect(useSshConn.getState().getRemoteClaudeVersion('p1')).toBeUndefined()+ })++ it('setConn carries a reused connection’s probe answer + version', () => {+ const s = useSshConn.getState()+ s.setConn('p1', {+ controlPath: '/tmp/cm',+ claudeAutoPermissionMode: true,+ remoteClaudeVersion: '2.1.90 (Claude Code)'+ })++ expect(useSshConn.getState().autoPermAnswer('p1')).toBe('yes')+ expect(useSshConn.getState().getRemoteClaudeVersion('p1')).toBe('2.1.90 (Claude Code)')+ })+})diff --git a/src/renderer/state/sshConn.ts b/src/renderer/state/sshConn.tsindex f0a9b96de..5bd5f34d1 100644--- a/src/renderer/state/sshConn.ts+++ b/src/renderer/state/sshConn.ts@@ -19,8 +19,16 @@ export interface SshConnInfo {* is usually absent here and arrives later on a `connected` status event. Absent/false ⇒ this* project's Claude nodes launch with the bare command (no `auto` flag). */claudeAutoPermissionMode?: boolean+ /** The probed remote `claude --version` output (`null` = probe ran, claude not found). Feeds+ * the tab menu's Auto hint; only present on a reused (already probed) connection. */+ remoteClaudeVersion?: string | null}+/** What the remote probe has said so far — the tab menu's Auto hint reads differently for "not+ * probed yet" vs "probed and unsupported". The LAUNCH gate stays `supportsAutoPermissionMode`+ * (boolean, conservative: unknown = no flag). */+export type SshAutoPermAnswer = 'yes' | 'no' | 'unknown'+/*** Transient map of SSH project id → its live connection info (ControlMaster `controlPath` +* optional remote `hookEndpointPath`) returned by `sshProject.connect`. Not persisted: it's@@ -34,9 +42,13 @@ interface SshConnState {* because the remote probe runs after connect and can land before OR after the connect promise* writes the entry — a separate map makes the two orders equivalent. */autoPermByProject: Record<string, boolean>+ /** project id → the probed remote `claude --version` output (`null` = claude not found). Kept+ * beside `autoPermByProject` (same lifecycle) so the tab-menu hint can name the version. */+ remoteClaudeVersionByProject: Record<string, string | null>setConn(projectId: string, info: SshConnInfo): void- /** Record the remote CLI probe's answer (pushed on a `connected` status event once it lands). */- setClaudeAutoPermissionMode(projectId: string, supported: boolean): void+ /** Record the remote CLI probe's answer (pushed on a `connected` status event once it lands).+ * `version` rides the same event; undefined leaves the cached version untouched. */+ setClaudeAutoPermissionMode(projectId: string, supported: boolean, version?: string | null): voidgetControlPath(projectId: string): string | undefinedgetHookEndpointPath(projectId: string): string | undefinedgetTmuxConfPath(projectId: string): string | undefined@@ -44,6 +56,11 @@ 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+ /** Tri-state view of the probe for UI hints: 'unknown' until an answer lands (or after+ * invalidation), then 'yes'/'no'. The launch gate above stays boolean. */+ autoPermAnswer(projectId: string): SshAutoPermAnswer+ /** The probed remote version (`null` = probed, claude not found; undefined = never probed). */+ getRemoteClaudeVersion(projectId: string): string | null | undefined/** 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`@@ -56,6 +73,7 @@ interface SshConnState {export const useSshConn = create<SshConnState>((set, get) => ({byProject: {},autoPermByProject: {},+ remoteClaudeVersionByProject: {},setConn(projectId, info) {set((s) => ({byProject: { ...s.byProject, [projectId]: info },@@ -63,11 +81,21 @@ export const useSshConn = create<SshConnState>((set, get) => ({autoPermByProject:info.claudeAutoPermissionMode === undefined? s.autoPermByProject- : { ...s.autoPermByProject, [projectId]: info.claudeAutoPermissionMode }+ : { ...s.autoPermByProject, [projectId]: info.claudeAutoPermissionMode },+ remoteClaudeVersionByProject:+ info.remoteClaudeVersion === undefined+ ? s.remoteClaudeVersionByProject+ : { ...s.remoteClaudeVersionByProject, [projectId]: info.remoteClaudeVersion }}))},- setClaudeAutoPermissionMode(projectId, supported) {- set((s) => ({ autoPermByProject: { ...s.autoPermByProject, [projectId]: supported } }))+ setClaudeAutoPermissionMode(projectId, supported, version) {+ set((s) => ({+ autoPermByProject: { ...s.autoPermByProject, [projectId]: supported },+ remoteClaudeVersionByProject:+ version === undefined+ ? s.remoteClaudeVersionByProject+ : { ...s.remoteClaudeVersionByProject, [projectId]: version }+ }))},getControlPath(projectId) {return get().byProject[projectId]?.controlPath@@ -84,12 +112,23 @@ export const useSshConn = create<SshConnState>((set, get) => ({supportsAutoPermissionMode(projectId) {return get().autoPermByProject[projectId] === true},+ autoPermAnswer(projectId) {+ const v = get().autoPermByProject[projectId]+ return v === undefined ? 'unknown' : v ? 'yes' : 'no'+ },+ getRemoteClaudeVersion(projectId) {+ return get().remoteClaudeVersionByProject[projectId]+ },invalidateAutoPermissionMode(projectId) {set((s) => {- if (!(projectId in s.autoPermByProject)) return s+ if (!(projectId in s.autoPermByProject) && !(projectId in s.remoteClaudeVersionByProject)) {+ return s+ }const next = { ...s.autoPermByProject }delete next[projectId]- return { autoPermByProject: next }+ const nextVersion = { ...s.remoteClaudeVersionByProject }+ delete nextVersion[projectId]+ return { autoPermByProject: next, remoteClaudeVersionByProject: nextVersion }})},clear(projectId) {@@ -98,7 +137,9 @@ export const useSshConn = create<SshConnState>((set, get) => ({delete next[projectId]const nextAuto = { ...s.autoPermByProject }delete nextAuto[projectId]- return { byProject: next, autoPermByProject: nextAuto }+ const nextVersion = { ...s.remoteClaudeVersionByProject }+ delete nextVersion[projectId]+ return { byProject: next, autoPermByProject: nextAuto, remoteClaudeVersionByProject: nextVersion }})}}))diff --git a/src/renderer/state/workspace.account.test.ts b/src/renderer/state/workspace.account.test.tsindex f4044743c..35c5f5e2f 100644--- a/src/renderer/state/workspace.account.test.ts+++ b/src/renderer/state/workspace.account.test.ts@@ -1,5 +1,11 @@import { describe, it, expect } from 'vitest'-import { accountChipLabel, isAccountLoginNode, systemAccountDisplay } from './workspace'+import {+ accountChipLabel,+ accountsForProject,+ isAccountLoginNode,+ sshAccountsHint,+ systemAccountDisplay+} from './workspace'import type { ClaudeAccount } from '@shared/types'const acct = (over: Partial<ClaudeAccount>): ClaudeAccount => ({@@ -81,3 +87,29 @@ describe('isAccountLoginNode', () => {expect(isAccountLoginNode({})).toBe(false)})})++// An SSH project's account pickers list ONLY accounts created on that host — local accounts are+// (correctly) invisible there, which read as "multi-account is broken on SSH" without a hint row+// explaining where accounts for this host come from.+describe('sshAccountsHint', () => {+ const sshProject = { ssh: { server: { host: 'box', user: 'me' } } }++ it('hints on an SSH project whose host has no eligible accounts', () => {+ const localOnly = [acct({ id: 'a1' })] // no `host` → local → filtered out for SSH+ const eligible = accountsForProject(localOnly, sshProject)+ expect(eligible).toEqual([])+ expect(sshAccountsHint(sshProject, eligible)).toMatch(/Settings → Accounts/)+ })++ it('is null once the host has a matching account', () => {+ const hosted = [acct({ id: 'a2', host: 'me@box' })]+ const eligible = accountsForProject(hosted, sshProject)+ expect(eligible).toHaveLength(1)+ expect(sshAccountsHint(sshProject, eligible)).toBeNull()+ })++ it('is null for local projects (empty list there just means no managed accounts)', () => {+ expect(sshAccountsHint(undefined, [])).toBeNull()+ expect(sshAccountsHint({}, [])).toBeNull()+ })+})diff --git a/src/renderer/state/workspace.ts b/src/renderer/state/workspace.tsindex 853c4a82a..b2d91ea3f 100644--- a/src/renderer/state/workspace.ts+++ b/src/renderer/state/workspace.ts@@ -251,6 +251,22 @@ export function accountsForProject(return accounts.filter((a) => !a.pending && (hostKey ? a.host === hostKey : !a.host))}+/**+ * Hint row for an SSH project's account pickers when the host has no eligible accounts —+ * local accounts are (correctly) filtered out there, which reads as "multi-account is broken+ * on SSH" unless the menu says where this host's accounts come from. Null for local projects+ * (an empty list there just means no managed accounts) and once a matching account exists.+ * Takes the ALREADY-FILTERED list (`accountsForProject`), which every picker computes anyway.+ */+export function sshAccountsHint(+ project: { ssh?: unknown } | undefined,+ eligibleAccounts: ClaudeAccount[]+): string | null {+ return project?.ssh && eligibleAccounts.length === 0+ ? 'No accounts on this host yet — add one in Settings → Accounts while this project is connected.'+ : null+}+/** Account for a NEW Claude node: explicit pick, else the project default, else system. */export function resolveNewNodeAccount(explicit: string | undefined,diff --git a/src/renderer/styles.css b/src/renderer/styles.cssindex 9e016461e..bc7a5ad6c 100644--- a/src/renderer/styles.css+++ b/src/renderer/styles.css@@ -268,7 +268,7 @@ body,cursor: pointer;}-.tab-menu button:hover {+.tab-menu button:hover:not(:disabled) {background: var(--panel-header);}@@ -437,10 +437,16 @@ body,cursor: pointer;}-.dock-menu button:hover {+.dock-menu button:hover:not(:disabled) {background: var(--panel-header);}+/* Inert hint rows (e.g. "No accounts on this host yet" in an SSH project). */+.dock-menu button:disabled {+ color: var(--muted);+ cursor: not-allowed;+}+.dock-menu svg {color: var(--muted);flex-shrink: 0;diff --git a/src/shared/types.ts b/src/shared/types.tsindex 77bf1a5e7..9066ee851 100644--- a/src/shared/types.ts+++ b/src/shared/types.ts@@ -536,6 +536,10 @@ export interface SshProjectStatusEvent {status: SshProjectStatuserror?: stringclaudeAutoPermissionMode?: boolean+ /** The remote `claude --version` output the probe read, riding the same `connected` event as+ * `claudeAutoPermissionMode`. `null` = the probe ran but found no claude (distinguishable from+ * "old CLI" in the tab-menu hint); absent = nothing new. */+ remoteClaudeVersion?: string | null}export interface SshProjectApi {@@ -551,6 +555,8 @@ export interface SshProjectApi {remoteHome?: string/** Whether the REMOTE host's claude CLI accepts `--permission-mode auto` (probed on connect). */claudeAutoPermissionMode?: boolean+ /** The probed remote `claude --version` output (`null` = probe failed; only on reused conns). */+ remoteClaudeVersion?: string | null}>/** Tear down the master (remote tmux is unaffected). */disconnect(projectId: string): Promise<void>