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.

fix(agents): 'Restart on subscription' drops the gateway model id — resume on the CLI default

Darren Kattanda6a210e6ee4
diff --git a/src/renderer/nodes/TerminalNode.tsx b/src/renderer/nodes/TerminalNode.tsx
index 176add5fa..3ad72020e 100644
--- a/src/renderer/nodes/TerminalNode.tsx
+++ b/src/renderer/nodes/TerminalNode.tsx
@@ -3642,8 +3642,16 @@ export function TerminalNode({
transport.recycle(id)
// `clearEnv` rides the respawn's `transport.create` (read from data above) to strip env at
// spawn; the cold-restore auto-resume relaunches the same agent against the default provider.
+ // The node's `agentModel` is a GATEWAY model id (the one a model switch stored, or the one a
+ // gateway node was created with): it only resolves through the gateway the strip just removed.
+ // Leaving it set would make the resume line append `--model <gateway-model>`, which the
+ // subscription CLI does not know — so the agent fails to launch against the subscription with
+ // a model name that does not exist there. Drop it: the CLI's own default model is what
+ // "subscription" means, and a later model switch (or plain Restart re-applying the gateway)
+ // sets it again.
updateNodeData(id, (node) => ({
clearEnv: true,
+ agentModel: undefined,
respawnNonce: ((node.data.respawnNonce as number | undefined) ?? 0) + 1
}))
return 'restarted'
diff --git a/src/renderer/terminal/agent-restart.test.ts b/src/renderer/terminal/agent-restart.test.ts
index 952f0c75f..501f52ebd 100644
--- a/src/renderer/terminal/agent-restart.test.ts
+++ b/src/renderer/terminal/agent-restart.test.ts
@@ -6,6 +6,7 @@ import {
__resetAgentRestartForTests,
agentHibernateFns,
agentRestartFn,
+ clearEnvEligibility,
exitSequence,
guardConcurrentRestart,
isShellCommand,
@@ -88,6 +89,33 @@ describe('restartEligibility', () => {
})
})
+describe('clearEnvEligibility', () => {
+ it('permits a busy session — terminateForeground is PID-safe, and gateway overload lands mid-turn', () => {
+ // The shared `restartEligibility` refuses working/blocked because its `/exit` would answer a
+ // permission prompt. clearEnv SIGTERMs the foreground group by PID instead — no slash command is
+ // typed into the pane — so it may interrupt a stuck turn, which is exactly the scenario the
+ // feature exists for.
+ expect(clearEnvEligibility('claude', 'abc')).toEqual({ ok: true })
+ expect(clearEnvEligibility('codex', 'abc')).toEqual({ ok: true })
+ expect(clearEnvEligibility('copilot', 'abc')).toEqual({ ok: true })
+ })
+
+ it('still requires a resumable harness and provider session id', () => {
+ expect(clearEnvEligibility('claude', undefined)).toEqual({
+ ok: false,
+ reason: 'no-session'
+ })
+ expect(clearEnvEligibility('my-custom', 'abc')).toEqual({
+ ok: false,
+ reason: 'not-resumable'
+ })
+ // An agent with no vanillaEnvPattern (gemini) still passes THIS gate — resumability is a
+ // separate fact from "has a strip set." The menu row is hidden upstream on the pattern, so
+ // the gate is only ever reached for claude/codex/copilot. Tested in vanilla-env.test.ts.
+ expect(clearEnvEligibility('gemini', 'abc')).toEqual({ ok: true })
+ })
+})
+
function fakeIo() {
const written: string[] = []
let cb: ((chunk: string) => void) | null = null