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(grok): put the permission-mode flag BEFORE the argv separator
enes1b4182141960
diff --git a/src/core/agent-status-mirror.ts b/src/core/agent-status-mirror.tsindex bca26f1fa..7329eb78a 100644--- a/src/core/agent-status-mirror.ts+++ b/src/core/agent-status-mirror.ts@@ -70,7 +70,13 @@ export interface MirrorServer {* Additive to MirrorFile v1 — absent on old files, ignored by old readers. */export interface MirrorSettings {claudePermissionMode?: string- /** Can `--permission-mode auto` be emitted for launches on THIS host? */+ /** Can `--permission-mode auto` be emitted for **CLAUDE** launches on THIS host? It answers one+ * question only — is this host's *claude* CLI ≥ AUTO_PERMISSION_MODE_MIN_VERSION — because that+ * is the CLI that exits 1 on the value. It is NOT a per-host verdict on the `auto` mode itself:+ * grok has accepted every mode we emit since 1.0.0, so a reader that generalizes this flag to+ * every agent will silently start grok sessions in `default` on a host with an old claude. Gate+ * on it only for claude (the desktop does exactly that — activePermissionMode in+ * renderer/state/permissionMode.ts). */autoSupported?: boolean/** Managed accounts usable on THIS host; dirs are absolute on that host. */claudeAccounts?: { id: string; dir: string }[]diff --git a/src/renderer/state/permissionMode.test.ts b/src/renderer/state/permissionMode.test.tsindex f38f0ca54..c4abea48f 100644--- a/src/renderer/state/permissionMode.test.ts+++ b/src/renderer/state/permissionMode.test.ts@@ -153,13 +153,25 @@ describe("activePermissionMode — the auto gate is CLAUDE's, not every agent's"expect(activePermissionMode('grok')).toBe('plan')})- it('ensureActivePermissionMode does not wait on any probe for a non-claude agent', async () => {+ it('ensureActivePermissionMode does not wait on EITHER probe for a non-claude agent', async () => {vi.useFakeTimers()try {+ // BOTH halves of "does not wait" have to be enforced, and each needs its own trap:+ // - the LOCAL probe: pointed at the never-resolving stub, so awaiting `ensureClaudeCliCaps()`+ // can only be escaped by its 3s timeout — which the assertion below does not allow. A+ // resolving mock would let a wrongly-placed await pass, because it settles in microtasks+ // that `advanceTimersByTimeAsync(0)` flushes. In the Server Edition this await is a real+ // WS-RPC round trip on every launch, so "it resolves eventually" is not good enough.+ // - the REMOTE probe: an SSH project whose answer never arrives, so awaiting it costs+ // SSH_AUTO_PROBE_WAIT_MS.+ // Neither timer may be needed: `advanceTimersByTimeAsync(0)` runs no timer at all.+ ;(globalThis as { window?: unknown }).window = {+ nodeTerminal: { claude: { cliCaps: () => new Promise<never>(() => {}) } }+ }+ resetClaudeCliCapsForTests()useSettings.setState((s) => ({ settings: { ...s.settings, claudePermissionMode: 'auto' } }))activeProject('remote', { server: SSH_SERVER, remoteCwd: '/srv/app' })- // No SSH remote-claude answer will ever arrive in this test, and no timer may be needed:- // a grok launch must not block on claude's probes at all.+const pending = ensureActivePermissionMode('grok')await vi.advanceTimersByTimeAsync(0)diff --git a/src/renderer/state/workspace.agent-prompt.test.ts b/src/renderer/state/workspace.agent-prompt.test.tsindex ad5fbfa7a..8d92c4d00 100644--- a/src/renderer/state/workspace.agent-prompt.test.ts+++ b/src/renderer/state/workspace.agent-prompt.test.ts@@ -29,3 +29,40 @@ describe('createAgentNode — the argv prompt separator', () => {expect(cmd('claude', 'hello')).not.toContain('--')})})++/**+ * The separator and the permission-mode flag interact, and pinning each one alone does not catch it:+ * `withPermissionMode` appends LAST, and `--` means END OF OPTIONS. Appended last, the flag lands+ * after the separator and is a POSITIONAL — either swallowed into the prompt text (the setting+ * silently does nothing) or rejected by clap as an unexpected argument (the launch dies on a usage+ * message). So the flag must precede the separator, matching grok's `grok [OPTIONS] [PROMPT]+ * [COMMAND]`. Asserted on the COMPOSED command, one layer below `withPermissionMode` itself, which+ * is where the two rules actually meet.+ */+describe('createAgentNode — permission mode meets the argv separator', () => {+ const cmd = (agentId: string, prompt?: string, mode?: 'plan' | 'auto' | 'manual'): string =>+ (createAgentNode(agentId, 0, undefined, undefined, prompt, undefined, undefined, mode).data+ .initialCommand as string) ?? ''++ it('puts the flag BEFORE grok\'s `--`, never after it', () => {+ expect(cmd('grok', 'explain this repo', 'plan')).toBe(+ "grok --permission-mode plan -- 'explain this repo'"+ )+ expect(cmd('grok', 'version', 'auto')).toBe("grok --permission-mode auto -- 'version'")+ })++ it('flags a prompt-less grok launch exactly as before (no dangling separator)', () => {+ expect(cmd('grok', undefined, 'plan')).toBe('grok --permission-mode plan')+ })++ it('emits no separator and no flag in manual mode', () => {+ expect(cmd('grok', 'explain this repo', 'manual')).toBe("grok -- 'explain this repo'")+ expect(cmd('grok', undefined, 'manual')).toBe('grok')+ })++ // The claude side of the same rule, pinned here too so the two conventions are readable together+ // (the canonical claude pin lives in workspace.test.ts).+ it('keeps claude flag-LAST, because its prompt is a plain positional', () => {+ expect(cmd('claude', 'fix the bug', 'auto')).toBe("claude 'fix the bug' --permission-mode auto")+ })+})diff --git a/src/renderer/state/workspace.ts b/src/renderer/state/workspace.tsindex 1f95e5dd6..2c22e58d2 100644--- a/src/renderer/state/workspace.ts+++ b/src/renderer/state/workspace.ts@@ -340,16 +340,31 @@ export function createAgentNode(// version` asks the model about "version"). Absent for everyone else, so their command line is// byte-identical to what it was.const sep = agentConfig(agentId)?.argvPromptSeparator+ const isFlagPrompt = agentConfig(agentId)?.promptInjectionMode === 'flag-prompt'+ // The separator only participates when there is actually a prompt to separate (no dangling `--`),+ // and never for a flag-prompt agent, whose prompt is not a positional at all.+ const usesSep = !!promptArg && !!sep && !isFlagPromptconst withPrompt = promptArg- ? agentConfig(agentId)?.promptInjectionMode === 'flag-prompt'+ ? isFlagPrompt? `${baseCmd} --prompt ${promptArg}`: `${baseCmd} ${sep ? `${sep} ` : ''}${promptArg}`: baseCmd- // Flag goes last: the prompt is claude's positional argv and must stay adjacent to the binary.// No mode passed (e.g. a legacy/test call site) = bare command, exactly as before this setting.- const initialCommand = permissionMode- ? withPermissionMode(withPrompt, agentId, permissionMode)- : withPrompt+ const flagged = (cmd: string): string =>+ permissionMode ? withPermissionMode(cmd, agentId, permissionMode) : cmd+ // WHERE the mode flag goes is decided by the agent's prompt convention, and the two conventions+ // are opposites:+ // - No separator (claude): the prompt is a positional that must stay adjacent to the binary, so+ // the flag goes LAST — `claude 'fix the bug' --permission-mode auto`, byte-identical to what+ // nodeterm has always emitted.+ // - With a separator (grok): `--` means END OF OPTIONS, which is the whole reason it is there+ // (`grok -- version` sends "version" to the model instead of running the subcommand). By that+ // same convention anything AFTER it is a positional, so a flag appended last would either be+ // swallowed into the prompt text or rejected by clap as an unexpected argument — the setting+ // would silently do nothing, or the launch would die on a usage message. It therefore goes+ // BEFORE the separator: `grok --permission-mode plan -- 'explain this repo'`, matching grok's+ // own usage line `grok [OPTIONS] [PROMPT] [COMMAND]`.+ const initialCommand = usesSep ? `${flagged(baseCmd)} ${sep} ${promptArg}` : flagged(withPrompt)const size = terminalNodeSize()return {id: nextId('term'),