Skip to content

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.

feat(claude): ensure fullscreen TUI in settings.json (write-if-absent, version-gated)

enes4b6a42b4c001
diff --git a/src/core/agents/hooks/claude-tui.test.ts b/src/core/agents/hooks/claude-tui.test.ts
new file mode 100644
index 000000000..deaa47d3e
--- /dev/null
+++ b/src/core/agents/hooks/claude-tui.test.ts
@@ -0,0 +1,75 @@
+import { describe, expect, it } from 'vitest'
+import { mkdtempSync, readFileSync, writeFileSync, existsSync } from 'fs'
+import { tmpdir } from 'os'
+import path from 'path'
+import { ensureFullscreenTui, ensureFullscreenTuiInFile, TUI_FULLSCREEN } from './claude-tui'
+
+describe('ensureFullscreenTui (pure)', () => {
+ it('writes tui=fullscreen when the key is absent', () => {
+ const { config, changed } = ensureFullscreenTui({})
+ expect(changed).toBe(true)
+ expect(config.tui).toBe(TUI_FULLSCREEN)
+ })
+
+ it('preserves every other key when it writes', () => {
+ const { config } = ensureFullscreenTui({ hooks: { Stop: [] }, model: 'x' })
+ expect(config).toEqual({ hooks: { Stop: [] }, model: 'x', tui: TUI_FULLSCREEN })
+ })
+
+ it('never overwrites an existing tui value (write-if-absent) — any value', () => {
+ for (const value of ['default', 'fullscreen', 'garbage', 42, null]) {
+ const input = { tui: value, other: 1 }
+ const { config, changed } = ensureFullscreenTui(input as never)
+ expect(changed).toBe(false)
+ expect(config).toBe(input) // returned untouched (same reference)
+ }
+ })
+
+ it("treats an explicit tui:undefined as present (the key exists → don't touch)", () => {
+ const { changed } = ensureFullscreenTui({ tui: undefined })
+ expect(changed).toBe(false)
+ })
+})
+
+describe('ensureFullscreenTuiInFile (fail-open file wrapper)', () => {
+ const dir = mkdtempSync(path.join(tmpdir(), 'nt-tui-'))
+
+ it('creates the key in a missing file (parents made, valid JSON written)', () => {
+ const p = path.join(dir, 'nested', 'settings.json')
+ expect(ensureFullscreenTuiInFile(p)).toBe(true)
+ expect(JSON.parse(readFileSync(p, 'utf8'))).toEqual({ tui: TUI_FULLSCREEN })
+ })
+
+ it('leaves a file that already has a tui value untouched, byte-for-byte', () => {
+ const p = path.join(dir, 'has-tui.json')
+ const original = JSON.stringify({ tui: 'default', hooks: { Stop: [] } }, null, 2)
+ writeFileSync(p, original, 'utf8')
+ expect(ensureFullscreenTuiInFile(p)).toBe(false)
+ expect(readFileSync(p, 'utf8')).toBe(original)
+ })
+
+ it('merges into an existing file without a tui key, preserving its contents', () => {
+ const p = path.join(dir, 'no-tui.json')
+ writeFileSync(p, JSON.stringify({ hooks: { Stop: [{ x: 1 }] } }), 'utf8')
+ expect(ensureFullscreenTuiInFile(p)).toBe(true)
+ expect(JSON.parse(readFileSync(p, 'utf8'))).toEqual({
+ hooks: { Stop: [{ x: 1 }] },
+ tui: TUI_FULLSCREEN
+ })
+ })
+
+ it('tolerates a corrupt file (parses to {} then writes the key, like install-helper)', () => {
+ const p = path.join(dir, 'corrupt.json')
+ writeFileSync(p, '{ not json', 'utf8')
+ expect(ensureFullscreenTuiInFile(p)).toBe(true)
+ expect(JSON.parse(readFileSync(p, 'utf8'))).toEqual({ tui: TUI_FULLSCREEN })
+ })
+
+ it('an empty file is treated as {} and gets the key', () => {
+ const p = path.join(dir, 'empty.json')
+ writeFileSync(p, '', 'utf8')
+ expect(ensureFullscreenTuiInFile(p)).toBe(true)
+ expect(existsSync(p)).toBe(true)
+ expect(JSON.parse(readFileSync(p, 'utf8'))).toEqual({ tui: TUI_FULLSCREEN })
+ })
+})
diff --git a/src/core/agents/hooks/claude-tui.ts b/src/core/agents/hooks/claude-tui.ts
new file mode 100644
index 000000000..3eb988272
--- /dev/null
+++ b/src/core/agents/hooks/claude-tui.ts
@@ -0,0 +1,56 @@
+// Ensure Claude Code's fullscreen rendering (`"tui": "fullscreen"` in settings.json). That setting
+// is what makes a Claude session take the alternate screen + mouse, so it behaves natively inside
+// nodeterm's tmux instead of dropping drags into tmux's copy-mode (yellow selection + counter).
+//
+// Two hard guardrails, both enforced here:
+// - WRITE-IF-ABSENT: if the `tui` key already exists with ANY value, leave it untouched — a user
+// who ran `/tui default` has spoken, and `/tui` always has the last word (no nodeterm toggle).
+// - VERSION-GATED at the CALL SITE: only run this when the CLI is known to be >= 2.1.89
+// (FULLSCREEN_TUI_MIN_VERSION). This pure helper does not know the version; callers gate it.
+//
+// Merge semantics mirror install-helper.ts: pure transform on a parsed object (`ensureFullscreenTui`)
+// plus a thin fail-open file wrapper (`ensureFullscreenTuiInFile`) that tolerates a missing/empty/
+// corrupt settings.json the same way (defaults to `{}`), and only writes when something changed.
+import path from 'path'
+import { readFileSync, writeFileSync, mkdirSync } from 'fs'
+
+/** The settings.json value that turns on Claude's fullscreen rendering. */
+export const TUI_FULLSCREEN = 'fullscreen'
+
+/** A subset of Claude's settings.json — we only reason about the `tui` key; everything else rides. */
+export type TuiSettings = { tui?: unknown; [k: string]: unknown }
+
+/**
+ * Pure: ensure `"tui": "fullscreen"` ONLY when the `tui` key is absent. When it already exists
+ * (any value — `"default"`, `"fullscreen"`, or garbage), the object is returned untouched and
+ * `changed` is false so the caller skips the write. Every other key is preserved.
+ */
+export function ensureFullscreenTui(config: TuiSettings): { config: TuiSettings; changed: boolean } {
+ if ('tui' in config) return { config, changed: false }
+ return { config: { ...config, tui: TUI_FULLSCREEN }, changed: true }
+}
+
+/**
+ * Fail-open file wrapper for the local surfaces (system `~/.claude` + managed account dirs). Reads
+ * `configPath` (a missing/empty/corrupt file → `{}`, matching install-helper), applies
+ * `ensureFullscreenTui`, and writes back ONLY if the key was added. Returns whether it wrote.
+ * A read or write error is swallowed + warned, never thrown.
+ */
+export function ensureFullscreenTuiInFile(configPath: string): boolean {
+ let config: TuiSettings = {}
+ try {
+ config = JSON.parse(readFileSync(configPath, 'utf8')) as TuiSettings
+ } catch {
+ config = {}
+ }
+ const { config: next, changed } = ensureFullscreenTui(config)
+ if (!changed) return false
+ try {
+ mkdirSync(path.dirname(configPath), { recursive: true })
+ writeFileSync(configPath, JSON.stringify(next, null, 2), 'utf8')
+ return true
+ } catch (e) {
+ console.warn('[claude-tui] fullscreen tui write failed', e)
+ return false
+ }
+}
diff --git a/src/core/agents/hooks/claude.ts b/src/core/agents/hooks/claude.ts
index 0f87f97a9..60e9ee2bf 100644
--- a/src/core/agents/hooks/claude.ts
+++ b/src/core/agents/hooks/claude.ts
@@ -3,6 +3,8 @@
import { homedir } from 'os'
import path from 'path'
import { installHooksInto, removeHooksFrom } from './install-helper'
+import { ensureFullscreenTuiInFile } from './claude-tui'
+import { claudeCliCaps } from '../../claude-cli'
const CLAUDE_EVENTS = [
'SessionStart',
@@ -44,6 +46,23 @@ export function installClaudeHooksInto(configDir: string): void {
})
}
+/**
+ * Ensure `"tui": "fullscreen"` in the SYSTEM `~/.claude/settings.json` — write-if-absent, and only
+ * when the local CLI is >= 2.1.89 (see FULLSCREEN_TUI_MIN_VERSION / claudeCliCaps.fullscreenTui).
+ * Best-effort: the probe is memoized + never rejects, the write fails open. Call it AFTER the hook
+ * install so the merge lands on a settings.json that already has the managed hooks.
+ */
+export async function ensureClaudeFullscreenTui(): Promise<void> {
+ if (!(await claudeCliCaps()).fullscreenTui) return
+ ensureFullscreenTuiInFile(configPath())
+}
+
+/** Same guardrails, for a managed account's config dir (`<dir>/settings.json`). */
+export async function ensureClaudeFullscreenTuiInto(configDir: string): Promise<void> {
+ if (!(await claudeCliCaps()).fullscreenTui) return
+ ensureFullscreenTuiInFile(path.join(configDir, 'settings.json'))
+}
+
export function removeClaudeHooks(): void {
removeHooksFrom({
configPath: configPath(),
diff --git a/src/core/agents/hooks/index.ts b/src/core/agents/hooks/index.ts
index 68c8ae03e..0f5f69bf3 100644
--- a/src/core/agents/hooks/index.ts
+++ b/src/core/agents/hooks/index.ts
@@ -1,7 +1,7 @@
// Installer registry: drives install/remove of the managed hook script across every
// built-in agent. Each call is wrapped in try/catch with a per-agent console.warn so one
// agent failing never blocks the others (fail open).
-import { installClaudeHooks, removeClaudeHooks } from './claude'
+import { installClaudeHooks, ensureClaudeFullscreenTui, removeClaudeHooks } from './claude'
import { installCodexHooks, removeCodexHooks } from './codex'
import { installGeminiHooks, removeGeminiHooks } from './gemini'
@@ -27,6 +27,11 @@ export function installManagedAgentHooks(): void {
console.warn(`[agent-hooks] ${agent} install failed`, e)
}
}
+ // Ensure Claude's fullscreen TUI in the system `~/.claude/settings.json` (write-if-absent,
+ // version-gated) right after its hooks land. Fire-and-forget (it awaits the memoized CLI probe)
+ // and fail-open, so it never blocks boot — and runs on BOTH desktop and Server Edition, which
+ // both call this at launch. Managed account dirs are ensured by their own install call sites.
+ void ensureClaudeFullscreenTui()
}
export function removeManagedAgentHooks(): void {
diff --git a/src/core/claude-cli.test.ts b/src/core/claude-cli.test.ts
index 4188abc8c..1a13b91da 100644
--- a/src/core/claude-cli.test.ts
+++ b/src/core/claude-cli.test.ts
@@ -5,17 +5,27 @@ describe('claudeCliCapsFrom', () => {
it('reads a real `claude --version` line', () => {
expect(claudeCliCapsFrom('2.1.207 (Claude Code)\n')).toEqual({
version: '2.1.207 (Claude Code)',
- autoPermissionMode: true
+ autoPermissionMode: true,
+ fullscreenTui: true
})
})
it('marks an older CLI as not knowing `auto` (it would exit 1 on the flag value)', () => {
expect(claudeCliCapsFrom('2.1.50 (Claude Code)')).toEqual({
version: '2.1.50 (Claude Code)',
- autoPermissionMode: false
+ autoPermissionMode: false,
+ fullscreenTui: false
})
})
+ it('gates fullscreen tui on >= 2.1.89 (older CLI knows the flag but not the setting)', () => {
+ // A CLI new enough for `--permission-mode auto` (>= 2.1.71) can still be too old for the
+ // `tui` setting (>= 2.1.89) — the two capabilities are independent version gates.
+ expect(claudeCliCapsFrom('2.1.88 (Claude Code)').fullscreenTui).toBe(false)
+ expect(claudeCliCapsFrom('2.1.89 (Claude Code)').fullscreenTui).toBe(true)
+ expect(claudeCliCapsFrom('2.1.88 (Claude Code)').autoPermissionMode).toBe(true)
+ })
+
it('collapses no output to the fail-open caps (no version → no auto → bare command)', () => {
expect(claudeCliCapsFrom(null)).toEqual(UNKNOWN_CLAUDE_CLI_CAPS)
expect(claudeCliCapsFrom(undefined)).toEqual(UNKNOWN_CLAUDE_CLI_CAPS)
diff --git a/src/core/claude-cli.ts b/src/core/claude-cli.ts
index e775894de..3f02609b4 100644
--- a/src/core/claude-cli.ts
+++ b/src/core/claude-cli.ts
@@ -7,7 +7,7 @@
// The remote (SSH) CLI is probed separately on its own host — see SshProjectManager.
import { execFile } from 'child_process'
import { promisify } from 'util'
-import { supportsAutoPermissionMode } from '../shared/agents/config'
+import { supportsAutoPermissionMode, supportsFullscreenTui } from '../shared/agents/config'
import { IPC } from '../shared/ipc'
import { UNKNOWN_CLAUDE_CLI_CAPS, type ClaudeCliCaps } from '../shared/types'
import { findInLoginPath } from './pty-manager'
@@ -21,7 +21,11 @@ export { UNKNOWN_CLAUDE_CLI_CAPS, type ClaudeCliCaps }
/** Pure: `claude --version` output → caps. The impure probe below is just plumbing around it. */
export function claudeCliCapsFrom(versionOutput: string | null | undefined): ClaudeCliCaps {
const version = versionOutput?.trim() || null
- return { version, autoPermissionMode: supportsAutoPermissionMode(version) }
+ return {
+ version,
+ autoPermissionMode: supportsAutoPermissionMode(version),
+ fullscreenTui: supportsFullscreenTui(version)
+ }
}
let cached: Promise<ClaudeCliCaps> | null = null
diff --git a/src/main/claude-accounts.ts b/src/main/claude-accounts.ts
index d40af5044..ace85319d 100644
--- a/src/main/claude-accounts.ts
+++ b/src/main/claude-accounts.ts
@@ -10,7 +10,7 @@ import { ipcMain } from 'electron'
import { IPC } from '../shared/ipc'
import { isSupportedClaudeVersion, parseLoginCapture } from '../core/claude-accounts-core'
import { claudeConfigDirFor } from '../core/claude-config-dir'
-import { installClaudeHooksInto } from '../core/agents/hooks/claude'
+import { installClaudeHooksInto, ensureClaudeFullscreenTuiInto } from '../core/agents/hooks/claude'
import { installCanvasSkillInto } from './canvas-control'
import { findInLoginPath } from '../core/pty-manager'
import type { SshProjectManager } from './remote-ssh/ssh-project'
@@ -76,6 +76,9 @@ export function initClaudeAccounts(getSshManager?: () => SshProjectManager | und
// the canvas (Claude resolves skills relative to CLAUDE_CONFIG_DIR, not ~/.claude).
installClaudeHooksInto(configDir)
installCanvasSkillInto(configDir)
+ // Ensure fullscreen TUI in the new account dir (write-if-absent, version-gated). Best-effort,
+ // off the response path — the memoized probe + write both fail open.
+ void ensureClaudeFullscreenTuiInto(configDir)
const versionSupported = await checkClaudeVersion()
return { id, configDir, versionSupported }
})
diff --git a/src/main/index.ts b/src/main/index.ts
index fb4206c09..e885d9960 100644
--- a/src/main/index.ts
+++ b/src/main/index.ts
@@ -53,7 +53,7 @@ import { initClaudeAccounts } from './claude-accounts'
import { claudeCliCaps, registerClaudeCliIpc } from '../core/claude-cli'
import { claudeConfigDirFor } from '../core/claude-config-dir'
import { isSafeLocalTranscriptPath, isSafeRemoteTranscriptPath } from '../core/claude-accounts-core'
-import { installClaudeHooksInto } from '../core/agents/hooks/claude'
+import { installClaudeHooksInto, ensureClaudeFullscreenTuiInto } from '../core/agents/hooks/claude'
import { createPairingService } from './pairing-service'
import {
initRemoteHost,
@@ -760,6 +760,10 @@ app.whenReady().then(async () => {
try {
installClaudeHooksInto(claudeConfigDirFor(acct.id))
installCanvasSkillInto(claudeConfigDirFor(acct.id))
+ // Ensure fullscreen TUI in this account dir (write-if-absent, version-gated). Off the
+ // critical path: it awaits the memoized CLI probe, then writes fail-open. (The system
+ // ~/.claude is handled by installManagedAgentHooks above, which covers Server Edition too.)
+ void ensureClaudeFullscreenTuiInto(claudeConfigDirFor(acct.id))
} catch (e) {
console.warn(`[agent-hooks] account ${acct.id} hook install failed`, e)
}
diff --git a/src/main/remote-ssh/remote-hooks.test.ts b/src/main/remote-ssh/remote-hooks.test.ts
index 3c9336499..a31e165a9 100644
--- a/src/main/remote-ssh/remote-hooks.test.ts
+++ b/src/main/remote-ssh/remote-hooks.test.ts
@@ -45,6 +45,55 @@ describe('RemoteHooks.setup', () => {
})
})
+describe('RemoteHooks.ensureFullscreenTui', () => {
+ // Paths are posixQuote'd (single-quoted) in the remote commands; a read is `cat '<path>' …`
+ // and a write is `… cat > '<path>'`, so we distinguish them by the presence of `cat >`.
+ const isWriteTo = (args: string[], p: string) => args.join(' ').includes(`cat > `) && args.join(' ').includes(p)
+ const isReadOf = (args: string[], p: string) =>
+ !args.join(' ').includes('cat > ') && args.join(' ').includes(`cat `) && args.join(' ').includes(p)
+
+ it('writes tui=fullscreen into the host settings when absent (preserving other keys)', async () => {
+ const target = '/home/u/.claude/settings.json'
+ const calls: { args: string[]; stdin?: string }[] = []
+ const run = vi.fn(async (args: string[], stdin?: string) => {
+ calls.push({ args, stdin })
+ if (isReadOf(args, target)) return { code: 0, stdout: JSON.stringify({ hooks: { Stop: [] } }) }
+ return { code: 0, stdout: '' }
+ })
+ const rh = new RemoteHooks({ run })
+ await rh.ensureFullscreenTui(conn, '/s.sock', '/home/u')
+ const write = calls.find((c) => isWriteTo(c.args, target))
+ expect(write).toBeTruthy()
+ expect(JSON.parse(write!.stdin!)).toEqual({ hooks: { Stop: [] }, tui: 'fullscreen' })
+ })
+
+ it('never overwrites an existing tui value (write-if-absent) — no write issued', async () => {
+ const target = '/home/u/.claude/settings.json'
+ const calls: { args: string[]; stdin?: string }[] = []
+ const run = vi.fn(async (args: string[]) => {
+ calls.push({ args })
+ if (isReadOf(args, target)) return { code: 0, stdout: JSON.stringify({ tui: 'default' }) }
+ return { code: 0, stdout: '' }
+ })
+ const rh = new RemoteHooks({ run })
+ await rh.ensureFullscreenTui(conn, '/s.sock', '/home/u')
+ expect(calls.some((c) => isWriteTo(c.args, target))).toBe(false)
+ })
+
+ it('writes into the absolute account-dir settings path', async () => {
+ const target = '/home/u/.nodeterm/claude-accounts/acc-1/settings.json'
+ const calls: { args: string[]; stdin?: string }[] = []
+ const run = vi.fn(async (args: string[], stdin?: string) => {
+ calls.push({ args, stdin })
+ return { code: 0, stdout: '{}' } // any read → empty settings
+ })
+ const rh = new RemoteHooks({ run })
+ await rh.ensureFullscreenTuiInAccountDir(conn, '/s.sock', '/home/u', 'acc-1')
+ expect(calls.some((c) => isWriteTo(c.args, target))).toBe(true)
+ expect(calls.some((c) => (c.stdin ?? '').includes('"tui": "fullscreen"'))).toBe(true)
+ })
+})
+
describe('RemoteHooks.teardown', () => {
it('cancels the reverse forward', async () => {
const { rh, run } = mk()
diff --git a/src/main/remote-ssh/remote-hooks.ts b/src/main/remote-ssh/remote-hooks.ts
index 9e5efa424..278b08139 100644
--- a/src/main/remote-ssh/remote-hooks.ts
+++ b/src/main/remote-ssh/remote-hooks.ts
@@ -7,6 +7,7 @@
import { childArgs, hookForwardArgs, hookForwardCancelArgs, remoteEndpointFileContents } from '../../core/remote-ssh/control-master'
import { buildManagedScript } from '../../core/agents/hooks/managed-script'
import { mergeManagedHook, type HookSettings } from '../../core/agents/hooks/install-helper'
+import { ensureFullscreenTui, type TuiSettings } from '../../core/agents/hooks/claude-tui'
import { posixQuote, type SshConnection } from '../../shared/ssh'
export interface RemoteRunner {
@@ -135,6 +136,52 @@ export class RemoteHooks {
}
}
+ /**
+ * Ensure `"tui": "fullscreen"` in the REMOTE host's `~/.claude/settings.json` — write-if-absent,
+ * so a remote Claude session takes the alternate screen + mouse and behaves natively in the
+ * host's tmux. The CALLER gates this on the host CLI being >= 2.1.89 (the remote `claude --version`
+ * already cached on the connection — no second probe). `remoteHome` is the resolved remote `$HOME`
+ * so the path is absolute (a literal `~` would not expand). Fail-open.
+ */
+ async ensureFullscreenTui(conn: SshConnection, controlPath: string, remoteHome: string): Promise<void> {
+ await this.ensureFullscreenTuiAt(conn, controlPath, `${remoteHome}/.claude/settings.json`)
+ }
+
+ /** Same guardrails, for a REMOTE managed-account config dir's `settings.json`. */
+ async ensureFullscreenTuiInAccountDir(
+ conn: SshConnection,
+ controlPath: string,
+ remoteHome: string,
+ accountId: string
+ ): Promise<void> {
+ const config = `${remoteHome}/.nodeterm/claude-accounts/${accountId}/settings.json`
+ await this.ensureFullscreenTuiAt(conn, controlPath, config)
+ }
+
+ /** Read-merge-write the fullscreen-tui key at one absolute remote config path, over the master.
+ * Same read-if-present, write-only-if-changed, fail-open mechanics as the hook merge above. */
+ private async ensureFullscreenTuiAt(conn: SshConnection, controlPath: string, config: string): Promise<void> {
+ try {
+ const { stdout: raw } = await this.r.run(
+ childArgs(conn, controlPath, `cat ${posixQuote(config)} 2>/dev/null || echo '{}'`)
+ )
+ let cfg: TuiSettings = {}
+ try {
+ cfg = JSON.parse(raw || '{}') as TuiSettings
+ } catch {
+ cfg = {}
+ }
+ const { config: next, changed } = ensureFullscreenTui(cfg)
+ if (!changed) return // key already present (any value) → never overwrite the user's `/tui`
+ await this.r.run(
+ childArgs(conn, controlPath, `mkdir -p $(dirname ${posixQuote(config)}) && cat > ${posixQuote(config)}`),
+ JSON.stringify(next, null, 2)
+ )
+ } catch {
+ /* fail-open: a failed remote read/write must never break the connect */
+ }
+ }
+
async teardown(projectId: string, conn: SshConnection, controlPath: string): Promise<void> {
const spec = this.specs.get(projectId)
this.specs.delete(projectId)
diff --git a/src/main/remote-ssh/ssh-project.ts b/src/main/remote-ssh/ssh-project.ts
index 607f072ef..97c966bb6 100644
--- a/src/main/remote-ssh/ssh-project.ts
+++ b/src/main/remote-ssh/ssh-project.ts
@@ -6,7 +6,7 @@ import { IPC } from '../../shared/ipc'
import { parseLsDirs, posixQuote, quoteRemotePath, remoteTmuxConf, type SshConnection } from '../../shared/ssh'
import type { SshProjectStatusEvent } from '../../shared/types'
import { remoteAccountConfigDir, isSupportedClaudeVersion } from '../../core/claude-accounts-core'
-import { supportsAutoPermissionMode } from '../../shared/agents/config'
+import { supportsAutoPermissionMode, supportsFullscreenTui } from '../../shared/agents/config'
import {
controlPathFor,
masterArgs,
@@ -380,7 +380,13 @@ export class SshProjectManager {
// Install the managed hook into the account dir's settings.json (needs the absolute $HOME so the
// merged `sh "…"` command has no unexpanded ~). Fail-open when the home never resolved.
if (c.remoteHome) await this.remoteHooks.installIntoAccountDir(c.conn, c.controlPath, c.remoteHome, accountId)
- return { configDir: dir, versionSupported: await this.remoteClaudeVersionOk(c) }
+ // One remote `claude --version` gates both the keychain-scoping answer (>= 2.1, fail-open true)
+ // AND the fullscreen-tui write (>= 2.1.89, write-if-absent) into the account dir.
+ const version = await this.remoteClaudeVersion(c.conn, c.controlPath)
+ if (c.remoteHome && supportsFullscreenTui(version)) {
+ await this.remoteHooks.ensureFullscreenTuiInAccountDir(c.conn, c.controlPath, c.remoteHome, accountId)
+ }
+ return { configDir: dir, versionSupported: version ? isSupportedClaudeVersion(version) : true }
}
/** Read a managed remote account's `.claude.json` (login capture); null when not connected or the
@@ -434,22 +440,21 @@ export class SshProjectManager {
* fallback); the next launch, once the answer lands, gets `auto`.
*/
private async probeClaudeAutoPermissionMode(projectId: string, entry: Conn): Promise<void> {
- const supported = supportsAutoPermissionMode(
- await this.remoteClaudeVersion(entry.conn, entry.controlPath)
- )
+ // 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 })
- }
-
- /** Is the remote claude new enough to scope credentials per config dir? Returns true when it
- * can't be determined so remote account add is never blocked on detection (fail-open). */
- private async remoteClaudeVersionOk(c: Conn): Promise<boolean> {
- const version = await this.remoteClaudeVersion(c.conn, c.controlPath)
- if (!version) return true
- return isSupportedClaudeVersion(version)
+ // 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)
+ }
}
async disconnect(projectId: string): Promise<void> {
diff --git a/src/renderer/state/permissionMode.test.ts b/src/renderer/state/permissionMode.test.ts
index 2228541fe..fbf58cc51 100644
--- a/src/renderer/state/permissionMode.test.ts
+++ b/src/renderer/state/permissionMode.test.ts
@@ -18,8 +18,8 @@ function mockCliCaps(caps: ClaudeCliCaps | Error): ReturnType<typeof vi.fn> {
return fn
}
-const MODERN: ClaudeCliCaps = { version: '2.1.207 (Claude Code)', autoPermissionMode: true }
-const OLD: ClaudeCliCaps = { version: '2.1.50 (Claude Code)', autoPermissionMode: false }
+const MODERN: ClaudeCliCaps = { version: '2.1.207 (Claude Code)', autoPermissionMode: true, fullscreenTui: true }
+const OLD: ClaudeCliCaps = { version: '2.1.50 (Claude Code)', autoPermissionMode: false, fullscreenTui: false }
const SSH_SERVER = { id: 's1', label: 'box', host: 'box', user: 'me' } as unknown as SshConnection
diff --git a/src/shared/agents/auto-mode-gate.test.ts b/src/shared/agents/auto-mode-gate.test.ts
index 65bf444e2..43a1cf3fc 100644
--- a/src/shared/agents/auto-mode-gate.test.ts
+++ b/src/shared/agents/auto-mode-gate.test.ts
@@ -5,7 +5,9 @@
import { describe, it, expect } from 'vitest'
import {
AUTO_PERMISSION_MODE_MIN_VERSION,
+ FULLSCREEN_TUI_MIN_VERSION,
supportsAutoPermissionMode,
+ supportsFullscreenTui,
gatePermissionMode,
withPermissionMode,
ALL_PERMISSION_MODES,
@@ -50,6 +52,32 @@ describe('supportsAutoPermissionMode', () => {
})
})
+describe('supportsFullscreenTui', () => {
+ it('accepts the first version that understands the tui setting and everything above it', () => {
+ expect(FULLSCREEN_TUI_MIN_VERSION).toBe('2.1.89')
+ expect(supportsFullscreenTui('2.1.89')).toBe(true)
+ expect(supportsFullscreenTui('2.1.90')).toBe(true)
+ expect(supportsFullscreenTui('2.2.0')).toBe(true)
+ expect(supportsFullscreenTui('3.0.0')).toBe(true)
+ expect(supportsFullscreenTui('2.1.207 (Claude Code)')).toBe(true)
+ })
+
+ it('rejects versions below the 2.1.89 floor', () => {
+ expect(supportsFullscreenTui('2.1.88')).toBe(false)
+ expect(supportsFullscreenTui('2.1.71')).toBe(false)
+ expect(supportsFullscreenTui('2.0.99')).toBe(false)
+ expect(supportsFullscreenTui('1.9.999')).toBe(false)
+ })
+
+ it('fails open (no write) on anything it cannot read', () => {
+ expect(supportsFullscreenTui('')).toBe(false)
+ expect(supportsFullscreenTui(null)).toBe(false)
+ expect(supportsFullscreenTui(undefined)).toBe(false)
+ expect(supportsFullscreenTui('command not found')).toBe(false)
+ expect(supportsFullscreenTui('2.1')).toBe(false)
+ })
+})
+
describe('gatePermissionMode', () => {
it('degrades auto to manual (= no flag, bare command) when the CLI is too old', () => {
expect(gatePermissionMode('auto', false)).toBe('manual')
diff --git a/src/shared/agents/config.ts b/src/shared/agents/config.ts
index 6a014b7eb..c97c6ad65 100644
--- a/src/shared/agents/config.ts
+++ b/src/shared/agents/config.ts
@@ -141,21 +141,50 @@ export const AUTO_PERMISSION_MODE_MIN_VERSION = '2.1.71'
const MIN_AUTO_VERSION: readonly number[] = AUTO_PERMISSION_MODE_MIN_VERSION.split('.').map(Number)
/**
- * Does this `claude --version` output know `--permission-mode auto`? Pure (the probe that feeds it
- * lives in core/claude-cli.ts). FAILS OPEN to `false` on anything unreadable — an unknown version
- * means we omit the flag and launch the bare command (today's behavior), never a failed launch.
+ * Pure numeric-version gate shared by the Claude CLI capability checks: parse the first
+ * `major.minor.patch` out of a `claude --version` line and answer whether it is >= `min`.
+ * FAILS OPEN to `false` on anything unreadable — an unknown version is treated as "too old", so
+ * every caller degrades to the conservative, pre-feature behavior rather than a failed launch.
*/
-export function supportsAutoPermissionMode(versionOutput: string | null | undefined): boolean {
+function versionAtLeast(versionOutput: string | null | undefined, min: readonly number[]): boolean {
const m = (versionOutput ?? '').match(/(\d+)\.(\d+)\.(\d+)/)
if (!m) return false
const v = [Number(m[1]), Number(m[2]), Number(m[3])]
- for (let i = 0; i < MIN_AUTO_VERSION.length; i++) {
- if (v[i] > MIN_AUTO_VERSION[i]) return true
- if (v[i] < MIN_AUTO_VERSION[i]) return false
+ for (let i = 0; i < min.length; i++) {
+ if (v[i] > min[i]) return true
+ if (v[i] < min[i]) return false
}
return true // exactly the minimum
}
+/**
+ * Does this `claude --version` output know `--permission-mode auto`? Pure (the probe that feeds it
+ * lives in core/claude-cli.ts). FAILS OPEN to `false` on anything unreadable — an unknown version
+ * means we omit the flag and launch the bare command (today's behavior), never a failed launch.
+ */
+export function supportsAutoPermissionMode(versionOutput: string | null | undefined): boolean {
+ return versionAtLeast(versionOutput, MIN_AUTO_VERSION)
+}
+
+/**
+ * First Claude Code version whose `settings.json` understands `"tui": "fullscreen"` (the setting
+ * that makes a session take the alternate screen + mouse, so it behaves natively inside nodeterm's
+ * tmux instead of dropping drags into tmux copy-mode). Earlier CLIs don't know the key; writing it
+ * for them risks an unknown-setting warning, so the setting is only written when the CLI is known
+ * to be at least this version. MEASURED, not guessed.
+ */
+export const FULLSCREEN_TUI_MIN_VERSION = '2.1.89'
+
+const MIN_FULLSCREEN_TUI_VERSION: readonly number[] = FULLSCREEN_TUI_MIN_VERSION.split('.').map(Number)
+
+/**
+ * Does this `claude --version` output understand `"tui": "fullscreen"` in settings.json (>= 2.1.89)?
+ * Pure. FAILS OPEN to `false` — an unknown/older version means nodeterm does NOT write the key.
+ */
+export function supportsFullscreenTui(versionOutput: string | null | undefined): boolean {
+ return versionAtLeast(versionOutput, MIN_FULLSCREEN_TUI_VERSION)
+}
+
/**
* The mode a session can ACTUALLY start in on the CLI that will run it. `auto` degrades to
* `manual` — which emits no flag at all, i.e. the bare `claude` command nodeterm shipped before
diff --git a/src/shared/types.ts b/src/shared/types.ts
index 083227a55..652019340 100644
--- a/src/shared/types.ts
+++ b/src/shared/types.ts
@@ -1000,10 +1000,18 @@ export interface ClaudeCliCaps {
version: string | null
/** `--permission-mode auto` is only accepted by Claude Code >= 2.1.71. */
autoPermissionMode: boolean
+ /** `"tui": "fullscreen"` in settings.json is only understood by Claude Code >= 2.1.89. Gates
+ * whether nodeterm writes that key (write-if-absent) so sessions render fullscreen in tmux. */
+ fullscreenTui: boolean
}
-/** The answer whenever the CLI version can't be determined: no `auto` flag → bare command. */
-export const UNKNOWN_CLAUDE_CLI_CAPS: ClaudeCliCaps = { version: null, autoPermissionMode: false }
+/** The answer whenever the CLI version can't be determined: no `auto` flag → bare command, and no
+ * fullscreen-tui write (an unknown settings key can warn on old CLIs — silence is safer). */
+export const UNKNOWN_CLAUDE_CLI_CAPS: ClaudeCliCaps = {
+ version: null,
+ autoPermissionMode: false,
+ fullscreenTui: false
+}
export interface ClaudeApi {
/** Capabilities of the local Claude CLI (memoized in the shell; safe to call repeatedly).