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(agents): make codex's "ask each time" actually ask
enesf3a1eeb035eb
diff --git a/src/renderer/components/TabBar.tsx b/src/renderer/components/TabBar.tsxindex f3b55c015..8205e41e9 100644--- a/src/renderer/components/TabBar.tsx+++ b/src/renderer/components/TabBar.tsx@@ -17,7 +17,7 @@ import {PERMISSION_MODE_LABELS,type AgentPermissionMode} from '@shared/agents/config'-import { permissionModeAgentsLabel } from '@shared/agents/approval-mode'+import { bypassSandboxCaveat, permissionModeAgentsLabel } from '@shared/agents/approval-mode'interface TabBarProps {onSwitch: (id: string) => void@@ -477,11 +477,14 @@ export function TabBar({// and applies the moment the host's CLI qualifies.title={m === 'bypassPermissions'- ? // The agent list is derived from the mapping (approval-mode.ts): it names- // exactly the agents "Bypass all" actually reaches, so it cannot warn- // about an agent the mode never applies to — or fall silent about one it- // newly does.- `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 their ${permissionModeAgentsLabel({ mode: 'bypassPermissions' })} sessions without permission checks too.`+ ? // Both the agent list and the sandbox caveat are derived from the mapping+ // (approval-mode.ts): the list names exactly the agents "Bypass all"+ // actually reaches, so it cannot warn about an agent the mode never applies+ // to — or fall silent about one it newly does. The caveat is owed because+ // for codex the mode skips APPROVALS only: `--ask-for-approval never` does+ // not touch `--sandbox`, which we deliberately leave alone, so "no+ // permission checks" must not be read as "no sandbox either".+ `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 their ${permissionModeAgentsLabel({ mode: 'bypassPermissions' })} sessions without permission checks too. ${bypassSandboxCaveat()}`.trim(): m === 'auto'? (menuAutoHint ?? undefined): undefineddiff --git a/src/renderer/components/settings/sections/AgentsSection.tsx b/src/renderer/components/settings/sections/AgentsSection.tsxindex fad8cc07e..b07285fd3 100644--- a/src/renderer/components/settings/sections/AgentsSection.tsx+++ b/src/renderer/components/settings/sections/AgentsSection.tsx@@ -16,7 +16,11 @@ import {type AgentId,type AgentPermissionMode} from '@shared/agents/config'-import { permissionModeAgentsLabel, unsupportedModesNote } from '@shared/agents/approval-mode'+import {+ permissionModeAgentIds,+ permissionModeAgentsLabel,+ unsupportedModesNote+} from '@shared/agents/approval-mode'import { AgentIcon } from '../../../lib/agentIcons'import { hintLabel } from '@shared/platform-utils'import { SegmentedPill } from '@renderer/ui/SegmentedPill'@@ -78,6 +82,10 @@ function permissionModeDescription(): string {.join(' ')}+// The agents claude's version gate does NOT apply to — every other capable agent. Module level: the+// capable list cannot change while the app runs.+const otherModeAgents = permissionModeAgentIds({ exclude: ['claude'] })+export function AgentsSection({ isActive }: { isActive: boolean }): React.JSX.Element {const settings = useSettings((s) => s.settings)const update = useSettings((s) => s.update)@@ -104,7 +112,17 @@ export function AgentsSection({ isActive }: { isActive: boolean }): React.JSX.El// evidence of an old CLI, and guessing would be its own kind of wrong.const autoNote =settings.claudePermissionMode === 'auto' && cliCaps?.version && !cliCaps.autoPermissionMode- ? `Your Claude CLI (${cliCaps.version.split(/\s+/)[0]}) doesn't support Auto — Claude sessions start in "${PERMISSION_MODE_LABELS.manual}". Requires Claude Code ${AUTO_PERMISSION_MODE_MIN_VERSION} or newer. ${permissionModeAgentsLabel({ exclude: ['claude'] })} are unaffected.`+ ? [+ `Your Claude CLI (${cliCaps.version.split(/\s+/)[0]}) doesn't support Auto — Claude sessions start in "${PERMISSION_MODE_LABELS.manual}". Requires Claude Code ${AUTO_PERMISSION_MODE_MIN_VERSION} or newer.`,+ // The bystanders are derived, AND so is the verb agreeing with them: a hardcoded "are"+ // degrades to "Grok are unaffected." if the capable list ever narrows to two, and the+ // sentence has to disappear entirely if claude is ever the only capable agent.+ otherModeAgents.length+ ? `${permissionModeAgentsLabel({ exclude: ['claude'] })} ${otherModeAgents.length === 1 ? 'is' : 'are'} unaffected.`+ : ''+ ]+ .filter(Boolean)+ .join(' '): undefinedreturn (diff --git a/src/shared/agents/approval-mode.test.ts b/src/shared/agents/approval-mode.test.tsindex 52031d3c9..17e963dfc 100644--- a/src/shared/agents/approval-mode.test.ts+++ b/src/shared/agents/approval-mode.test.ts@@ -1,11 +1,17 @@import { describe, expect, it } from 'vitest'import {approvalFlags,+ bypassSandboxCaveat,modeSupported,+ permissionModeAgentIds,permissionModeAgentsLabel,unsupportedModesNote} from './approval-mode'-import { ALL_PERMISSION_MODES, type AgentPermissionMode } from './config'+import {+ ALL_PERMISSION_MODES,+ PERMISSION_MODE_LABELS,+ type AgentPermissionMode+} from './config'/*** Measured flag vocabularies:@@ -49,11 +55,35 @@ describe('approvalFlags — gemini', () => {describe('approvalFlags — codex REFUSES what it cannot express', () => {it('maps only the three modes that have a real counterpart', () => {- expect(approvalFlags('codex', 'manual')).toEqual([])expect(approvalFlags('codex', 'auto')).toEqual(['--ask-for-approval', 'on-request'])expect(approvalFlags('codex', 'bypassPermissions')).toEqual(['--ask-for-approval', 'never'])})+ /**+ * codex is the only agent where `manual` emits a flag, and it MUST. Measured on 0.146.0:+ * `codex doctor` reports `approval policy OnRequest` with no `approval` key in+ * ~/.codex/config.toml, so codex's built-in default is "the model decides when to ask" — not "ask+ * each time". Unflagged, `manual` and `auto` would be the SAME runtime policy: two dropdown+ * entries collapsed onto one behaviour, under a label promising something else. `untrusted` is the+ * documented equivalent ("only run trusted commands without asking; escalate anything else").+ */+ it('emits `untrusted` for manual, because codex’s own default is not "ask each time"', () => {+ expect(approvalFlags('codex', 'manual')).toEqual(['--ask-for-approval', 'untrusted'])+ // ...and it is therefore a DIFFERENT policy from auto, which is the whole point.+ expect(approvalFlags('codex', 'manual')).not.toEqual(approvalFlags('codex', 'auto'))+ // codex has an equivalent, so the derived copy must NOT claim otherwise.+ expect(modeSupported('codex', 'manual')).toBe(true)+ expect(unsupportedModesNote()).not.toContain(PERMISSION_MODE_LABELS.manual)+ })++ it('leaves every other agent’s manual unflagged — their own default already prompts', () => {+ // gemini's `default` is documented as "prompt for approval", so no flag keeps the promise there.+ for (const id of ['claude', 'grok', 'gemini']) {+ expect(approvalFlags(id, 'manual'), id).toEqual([])+ expect(modeSupported(id, 'manual'), id).toBe(true)+ }+ })+it('emits NO flag for a mode codex has no equivalent of', () => {// Silently substituting a nearest match would tell the user "Plan" while codex ran in// on-request. No flag = codex's own default, which is the honest degrade.@@ -102,11 +132,34 @@ describe('UI copy derived from the mapping', () => {expect(label).not.toContain('opencode')})+ it('agrees grammatically with the list it names, however long that list is', () => {+ // A hardcoded plural reads as "Grok are unaffected." the day the capable list narrows, which is+ // the same drift the label helper exists to prevent, one level down. The ids are exported so the+ // caller can agree with them; this pins that they describe the SAME set the label does.+ const ids = permissionModeAgentIds({ exclude: ['claude'] })+ expect(ids).toEqual(['grok', 'gemini', 'codex'])+ const label = permissionModeAgentsLabel({ exclude: ['claude'] })+ for (const id of ids) expect(label.toLowerCase()).toContain(id === 'codex' ? 'codex' : id)+ expect(label).not.toContain('Claude')+ })++ it('warns that Bypass all keeps codex’s sandbox, which is a separate axis', () => {+ // `--ask-for-approval never` does not touch `--sandbox`, so "no permission checks" must not be+ // read as "no sandbox either". Only codex has that second axis among the capable agents.+ const caveat = bypassSandboxCaveat()+ expect(caveat).toContain('Codex')+ expect(caveat).toContain('sandbox')+ expect(caveat).not.toContain('Gemini')+ expect(caveat).not.toContain('Claude')+ })+it('admits codex’s two gaps, and names no agent that has none', () => {const note = unsupportedModesNote()expect(note).toContain('Plan')expect(note).toContain('Accept edits')expect(note).toContain('Codex')+ // Number agreement: "Codex sessions start in Codex's own default", never "in its own default".+ expect(note).toContain("Codex's own default")// gemini expresses all five, so it must never appear in a sentence about missing modes.expect(note).not.toContain('Gemini')expect(note).not.toContain('Claude Code')diff --git a/src/shared/agents/approval-mode.ts b/src/shared/agents/approval-mode.tsindex 90d92d538..7cd27c350 100644--- a/src/shared/agents/approval-mode.ts+++ b/src/shared/agents/approval-mode.ts@@ -34,11 +34,22 @@ const GEMINI_MODES: Partial<Record<AgentPermissionMode, string>> = {}const CODEX_MODES: Partial<Record<AgentPermissionMode, string>> = {+ // codex is the FIRST agent where `manual` emits a flag, and it has to. For every other agent+ // `manual` = no flag = a default that already prompts (gemini's own `default` is documented as+ // "prompt for approval"), which is exactly what the label "Ask each time" promises. codex's+ // built-in default is NOT that: measured on 0.146.0, `codex doctor` reports `approval policy+ // OnRequest` with no `approval` key in ~/.codex/config.toml — the model decides when to ask. So+ // leaving `manual` unflagged would deliver `on-request` under an "ask each time" label, and+ // collapse two dropdown entries onto one behaviour — the same dishonesty this module exists to+ // remove, just expressed as an unflagged claim instead of a substituted flag. `untrusted` is the+ // real equivalent: "only run trusted commands without asking; escalate anything not in the trusted+ // set". No codex launch has ever carried this flag (codex joined the list in the same change), so+ // there is no historical command line to keep byte-identical here.+ manual: 'untrusted',auto: 'on-request',bypassPermissions: 'never'// No `plan` and no edit-specific mode exist in codex 0.146.0, so `plan` and `acceptEdits` are- // absent ON PURPOSE — see modeSupported. `untrusted` is deliberately unused: it is stricter than- // codex's own default, and none of our five modes asks for that.+ // absent ON PURPOSE — see modeSupported.}const tableFor = (agentId: AgentId): Partial<Record<AgentPermissionMode, string>> | null =>@@ -51,7 +62,12 @@ const flagFor = (agentId: AgentId): string =>* agent uses its own default — surfaced in the UI so the user is not misled. */export function modeSupported(agentId: AgentId, mode: AgentPermissionMode): boolean {if (!isPermissionMode(mode)) return false- if (mode === 'manual') return hasPermissionMode(agentId) // "ask each time" = the agent's own default+ // `manual` — "ask each time" — is reachable on every capable agent, but for two different reasons,+ // which is why the table is not its authority: claude/grok/gemini get there by emitting NO flag+ // (their own default already prompts), and codex gets there through `untrusted`, because its+ // default does not. Either way the promise holds; an agent whose CLI could offer neither would+ // need this early return revisited.+ if (mode === 'manual') return hasPermissionMode(agentId)const table = tableFor(agentId)if (table) return mode in tablereturn hasPermissionMode(agentId)@@ -114,15 +130,27 @@ const joinAnd = (parts: string[]): string =>* must not name an agent the mode never reaches); `exclude` drops one the sentence is already about* (claude's version-gate note, whose subject is claude).*/-export function permissionModeAgentsLabel(opts?: {+export function permissionModeAgentsLabel(opts?: PermissionModeAgentFilter): string {+ return joinAnd(permissionModeAgentIds(opts).map(agentLabel))+}++interface PermissionModeAgentFilter {mode?: AgentPermissionModeexclude?: readonly AgentId[]-}): string {- const ids = PERMISSION_MODE_CAPABLE.filter(+}++/**+ * The ids `permissionModeAgentsLabel` will name, under the same filter.+ *+ * Exported so a caller can AGREE with the label grammatically — one agent takes "is", several take+ * "are" — instead of hardcoding a plural that reads as "Grok are unaffected" the day the capable list+ * narrows. Same drift `permissionModeAgentsLabel` exists to prevent, one level down.+ */+export function permissionModeAgentIds(opts?: PermissionModeAgentFilter): AgentId[] {+ return PERMISSION_MODE_CAPABLE.filter((id) =>!opts?.exclude?.includes(id) && (opts?.mode === undefined || modeSupported(id, opts.mode)))- return joinAnd(ids.map(agentLabel))}/**@@ -139,7 +167,26 @@ export function unsupportedModesNote(): string {.map(({ label, gaps }) => {const modes = joinAnd(gaps.map((m) => PERMISSION_MODE_LABELS[m]))const verb = gaps.length > 1 ? 'have' : 'has'- return `${modes} ${verb} no ${label} equivalent, so ${label} sessions start in its own default.`+ return `${modes} ${verb} no ${label} equivalent, so ${label} sessions start in ${label}'s own default.`}).join(' ')}++/**+ * Agents where `bypassPermissions` bypasses APPROVALS only, because their sandbox is a separate axis+ * this module deliberately does not touch — codex's `--sandbox`, where `--ask-for-approval never`+ * still sandboxes. Kept beside the mapping that causes it rather than in the component, so the+ * warning copy cannot drift from which agents it is true of.+ */+const SANDBOX_RETAINED: readonly AgentId[] = ['codex']++/** The clause a "Bypass all" warning owes, so "no permission checks" is not read as "no sandbox+ * either". Empty string when it applies to nobody. */+export function bypassSandboxCaveat(): string {+ const ids = permissionModeAgentIds({ mode: 'bypassPermissions' }).filter((id) =>+ SANDBOX_RETAINED.includes(id)+ )+ if (!ids.length) return ''+ const label = joinAnd(ids.map(agentLabel))+ return `${label} still ${ids.length > 1 ? 'run' : 'runs'} in its own sandbox — only the approval prompts are skipped.`+}