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(launch): verify retained commands and require explicit recovery
reviewef0f872b1ca8
diff --git a/CLAUDE.md b/CLAUDE.mdindex 71f5bd9a8..24a7af2c9 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -569,14 +569,10 @@ Lifecycle, by intent:landed. The predicate is deliberately the narrowest one that closes it — a tmux-backed session isnever protected (the kill costs a redraw), and neither is a plain terminal, a finished agent oran unknown state (nothing is running to lose). **A fifth lever owes the same gate.**- The fifth is the offscreen release of an ARMED node (`--after`, `shouldDeferReleaseForHeldLaunch`,- 2026-09-02): the held launch is delivered by session NAME, so with tmux underneath the release is- harmless and the node stays `sessionReady` (the teardown keeps the flag for an offscreen release- of a tmux-backed session); on the plain-shell fallback the release would destroy the very pane- the launch is typed into, so it is deferred while armed. MEASURED before the fix: a released- QUEUED node held its launch through its dependency going `done`, the badge claimed the terminal- "has not started yet", and only a camera travel (revive) ever fired it — "the chain works when I- look at it" was this.+ The fifth is the offscreen release of an ARMED node (`shouldDeferReleaseForHeldLaunch`):+ held launches now require the attached transport for echo verification, on every backend.+ Keep that transport until delivery or recovery; a blind paste by session name loses the+ shell-init repair and canonical-line protections.- **Node unmount (project switch)** → the RENDERER **parks** the terminal (`TerminalNode.tsx``parkedTerminals`): the xterm instance + its attached PTY stay alive with the `.xterm` elementdetached from the DOM, so a remount within `TERM_PARK_MS` (5 min) re-adopts them — instant, and@@ -2575,14 +2571,17 @@ command-bearing opens; this does not add a human-confirm dialog or change mobile(#827/#811). Even a visible node with no deps has not mounted its PTY when the open reply issent. `queueControlLaunch` moves the command out of `initialCommand`; the PTY-ready gate belowmakes this safe. The open reply says `queued`, and project serialization retains the brief.- (4) Delivery is **exactly-once via `launchInFlight`** (an id stays in the set forever once- `sendText` resolved true — clearing `pendingLaunch` is a state update that can lag a re-render),- and a **refused** `sendText` retries (`launchRetryDelay`'s backoff) instead of vanishing.- (5) `pendingLaunch` **is persisted** (unlike `initialCommand`), but agent state is not — so after- a restart nothing will ever report `done` and the node carries a manual ▶ **run-now** escape in- its QUEUED badge (which disarms only on a delivery that LANDED — dropping it unconditionally- threw the command away in exactly the state the button exists to rescue). (6) Canvas subscribes- to `armedDepSig`, NOT `useAgentStatus(s => s.byId)` —+ (4) Desktop automatic and manual launch delivery share `terminal/launch-command.ts`, which+ uses `deliverCommand`: echo verification, bounded Ctrl-U repair, platform kill-line and overlong+ line refusal. The PTY-lifetime writer coalesces concurrent requests and remembers submission+ across parked views. A warm attach never automatically replays a retained launch: its clearing+ autosave may have been lost after Enter. Explicit Run now rechecks the foreground shell and+ clears any incomplete line; a refused/throwing/cancelled launch stays held, `manualOnly`.+ (5) UI `initialCommand` stays until submission; serialization converts unsubmitted UI intent+ into a manual-only `pendingLaunch`, including a project switch during shell settle. Server+ saves `manualOnly` BEFORE sending and only clears the command after acknowledgment. Failed+ independent/dependent launches are never retried by unrelated hooks. Boot remains inert.+ (6) Canvas subscribes to `armedDepSig`, NOT `useAgentStatus(s => s.byId)` —the same discipline as `loopSig`; the full map re-renders the canvas on every hook event.Pure logic + refusal matrix in `renderer/lib/pendingLaunch.ts` (unit-tested);the dep→node edge is a **rope** (`ctrl-<dep>-<node>`, persisted in `project.ropes` like the@@ -2613,15 +2612,15 @@ command-bearing opens; this does not add a human-confirm dialog or change mobilean ADOPTED park (already typeable, and its create continuation ran on a previous mount) and, fora fresh spawn, at the SAME `whenShellSettled` moment `writeWhenShellReady` delivers an`initialCommand` — both write a CLI command line, and a line delivered across zsh's rc-file tty- flush comes out mangled. A **park keeps it** (a parked tmux session is still addressable by name);- only a real teardown clears it. The loop then WAITS instead of burning attempts, and the backoff- (`launchRetryDelay`, ~12 s over five attempts) covers only the residual race after readiness.+ flush comes out mangled. A **park keeps the writer and transport**; a real teardown removes+ the writer. The loop WAITS instead of burning attempts before readiness. Once attempted,+ only the verified writer's bounded echo repair runs; further recovery is explicit.Because a wait with no end is the failure mode this replaces, both give-up states are **visible**in the transient `state/launchDelivery.ts` and rendered by the QUEUED badge's amber ⚠ + tooltip(`launchTooltip`, pure): `stalled` = gate open, no terminal yet, **still held** (raised by a`LAUNCH_STALL_MS` timer with a fire-time re-ask; the launch still fires whenever the session- finally comes up — an SSH host reconnecting takes this path) and `failed` = the session came up- and refused every attempt, so nothing will retry it. Neither is ever inferred from silence, and+ finally comes up) and `failed` = submission is unconfirmed, so automatic retry is stopped.+ A persisted `manualOnly` record carries that warning after reload too. Neither is ever inferred from silence, andthe tooltip names no cause it did not measure (the node's own overlay owns the diagnosis).The open verbs' replies carry the same fact for callers OUTSIDE the app: `result.queued` +`result.queuedIds` on `open-terminal`/`open-claude`/`open-agent`, always true for thediff --git a/CONTRIBUTING.md b/CONTRIBUTING.mdindex 8f7aceaf6..4e1248e68 100644--- a/CONTRIBUTING.md+++ b/CONTRIBUTING.md@@ -657,6 +657,11 @@ coordinate nodeterm, not external editors, so do not claim a filesystem-wide com**Creating an agent node is not proof it started.** Control opens retain their launch commanduntil delivery is acknowledged, and report `queued` while it is held. A successful terminal sendproves delivery only; never describe it as a healthy/running agent without agent evidence.+Desktop launches (automatic and Run now) use the echo-verified command writer, not `sendText`.+Keep unsubmitted UI intent durable through shell settle/unmount. Warm attachments never auto-replay+retained launch intent; Run now checks the shell and only confirmed submission clears it. Server+marks attempts manual-only on disk before input, so failed delivery cannot retry on unrelated hooks.+Held Desktop launches retain their attached transport, including when offscreen with tmux.## Testingdiff --git a/src/renderer/canvas/Canvas.tsx b/src/renderer/canvas/Canvas.tsxindex b0e40af68..66ad4a76e 100644--- a/src/renderer/canvas/Canvas.tsx+++ b/src/renderer/canvas/Canvas.tsx@@ -1,3 +1,4 @@+import { launchCommand } from '../terminal/launch-command'import { useCallback, useEffect, useMemo, useRef, useState } from 'react'import { useShallow } from 'zustand/react/shallow'import { playSfx, primeSfx } from '@renderer/lib/sfx'@@ -462,7 +463,6 @@ import {import { buildBackgroundLinkMaps, buildContextLinkNote, buildLinkMap, buildNotePushMessage, classifyLink, hiddenLinkIds, linkIdsCoveredByRopes, pairKey, planBridges, type LinkEndpoint } from '../lib/noteLink'import {launchesToFire,- launchRetryDelay,queueControlLaunch,LAUNCH_STALL_MS,type ArmedNode@@ -1941,8 +1941,8 @@ export function Canvas() {launchInFlight.current.add(f.id)const attempt = (launchAttempts.current.get(f.id) ?? 0) + 1launchAttempts.current.set(f.id, attempt)- void api.pty.sendText(f.id, f.command).catch(() => false).then((ok) => {- if (ok) {+ void launchCommand(f.id, f.command).then((outcome) => {+ if (outcome === 'submitted') {setNodes((ns) =>ns.map((n) => (n.id === f.id ? { ...n, data: { ...n.data, pendingLaunch: undefined } } : n)))@@ -1950,19 +1950,12 @@ export function Canvas() {markDirty()return}- // Refused although the session reported ready — a narrow residual race now, not the- // whole cold-start window. Let it back out of flight and re-run after the backoff; a- // launch that silently vanishes is worse than a late one.- launchInFlight.current.delete(f.id)- const delay = launchRetryDelay(attempt)- if (delay !== null) {- setTimeout(() => setLaunchNudge((v) => v + 1), delay)- return- }- // Out of attempts against a session that IS up. Nothing else will retry this, so it is- // reported where the person looking at the node can see it — the QUEUED badge turns into- // a warning pointing at the manual ▶. The log line stays for a bug report; it is no- // longer the only place the failure exists.+ // The verified writer already exhausted its bounded echo repair. A failed launch+ // needs an explicit retry; unrelated hooks and remounts must never inject it later.+ setNodes((ns) => ns.map((n) => n.id === f.id && n.data.pendingLaunch+ ? { ...n, data: { ...n.data, pendingLaunch: { ...n.data.pendingLaunch, manualOnly: true } } }+ : n))+ markDirty()useLaunchDelivery.getState().markFailed(f.id, attempt)console.warn('[pending-launch] gave up delivering held launch for', f.id)})diff --git a/src/renderer/canvas/pending-launch-delivery.source.test.ts b/src/renderer/canvas/pending-launch-delivery.source.test.tsindex d4ad3ff1c..e2fd88c6a 100644--- a/src/renderer/canvas/pending-launch-delivery.source.test.ts+++ b/src/renderer/canvas/pending-launch-delivery.source.test.ts@@ -49,11 +49,6 @@ describe('armed-launch delivery (source pins)', () => {expect(src).toMatch(/subscribeSessionReady\(\(nodeId\) => \{[\s\S]{0,400}?n\.data\.pendingLaunch/)})- it('retries a refused delivery on the shared backoff and gives up only when it is exhausted', () => {- const body = launchEffect()- expect(body).toContain('launchRetryDelay(attempt)')- expect(body).toMatch(/delay !== null[\s\S]{0,200}?setTimeout/)- })it('a give-up is REPORTED, not only logged — the console.warn is no longer the whole story', () => {const body = launchEffect()@@ -74,18 +69,6 @@ describe('armed-launch delivery (source pins)', () => {expect(body).toMatch(/setTimeout\(\(\) => \{[\s\S]{0,600}?!isSessionReady\(f\.id\)[\s\S]{0,300}?markStalled/)})- it('keeps the exactly-once and dep-satisfaction invariants the feature already had', () => {- const body = launchEffect()- // Exactly-once: an id enters the in-flight set before the send and only LEAVES it on a- // refusal (a successful delivery is irreversible and must never be re-attempted).- expect(body).toContain('launchInFlight.current.add(f.id)')- expect(body).toMatch(/if \(ok\)[\s\S]{0,400}?pendingLaunch: undefined/)- expect(body).toMatch(/launchInFlight\.current\.delete\(f\.id\)/)- // Satisfaction is still `launchesToFire`'s call — the ready gate is an ADDITIONAL condition,- // never a replacement for the dependency matrix.- expect(body).toContain('launchesToFire(')- expect(body).toContain('setupDoneForGroup')- })it('stops reporting on a node that is no longer armed — no stale warning on a running session', () => {const body = launchEffect()diff --git a/src/renderer/lib/controlRouting.ts b/src/renderer/lib/controlRouting.tsindex 94b3d65c4..a0d2ad25a 100644--- a/src/renderer/lib/controlRouting.ts+++ b/src/renderer/lib/controlRouting.ts@@ -176,7 +176,7 @@ export function storedNodeListing() {return nodes.map((n) => {const status = statuses[n.id]- const launchState = controlLaunchState(!!n.pendingLaunch, deliveries[n.id], status) ??+ const launchState = controlLaunchState(!!n.pendingLaunch, deliveries[n.id] ?? ((n.pendingLaunch as { manualOnly?: boolean } | undefined)?.manualOnly ? { kind: 'failed', attempts: 1, at: 0 } : undefined), status) ??(n.agentId && !status?.state ? 'unconfirmed' as const : undefined)return {id: n.id, kind: n.kind ?? 'terminal', title: n.title ?? '',diff --git a/src/renderer/lib/pendingLaunch.test.ts b/src/renderer/lib/pendingLaunch.test.tsindex 9104e8505..d89283a22 100644--- a/src/renderer/lib/pendingLaunch.test.ts+++ b/src/renderer/lib/pendingLaunch.test.ts@@ -3,10 +3,8 @@ import {launchesToFire,queueControlLaunch,controlLaunchState,- launchRetryDelay,launchTooltip,unmetDeps,- LAUNCH_DELIVERY_ATTEMPTS,LAUNCH_STALL_MS,type ArmedNode,type StatusById@@ -176,26 +174,6 @@ describe('unmetDeps', () => {* dependency.*/describe('launch delivery policy (#569 item 1)', () => {- it('the schedule backs off and is bounded — exhaustion is reachable, so "gave up" can be told', () => {- const delays: number[] = []- for (let attempt = 1; ; attempt++) {- const d = launchRetryDelay(attempt)- if (d === null) break- delays.push(d)- expect(attempt).toBeLessThan(20) // guard: a schedule that never ends is the bug, not a fix- }- expect(delays.length).toBe(LAUNCH_DELIVERY_ATTEMPTS)- // Strictly increasing: a flat schedule is what made the old budget a fixed 2 s wall.- for (let i = 1; i < delays.length; i++) expect(delays[i]).toBeGreaterThan(delays[i - 1])- // And the whole window is comfortably wider than the old one, measured from READINESS.- expect(delays.reduce((a, b) => a + b, 0)).toBeGreaterThan(10_000)- })-- it('an attempt past the end has no delay — nothing silently retries forever', () => {- expect(launchRetryDelay(LAUNCH_DELIVERY_ATTEMPTS)).not.toBeNull()- expect(launchRetryDelay(LAUNCH_DELIVERY_ATTEMPTS + 1)).toBeNull()- })-it('the stall warning waits longer than a cold project switch could plausibly take', () => {expect(LAUNCH_STALL_MS).toBeGreaterThanOrEqual(30_000)})@@ -221,17 +199,17 @@ describe('launchTooltip — the QUEUED badge never goes silent (#569 item 1)', (expect(t.toLowerCase()).not.toMatch(/ssh|host is down|crash/)})- it('a failed launch reports the attempt count and that nothing will retry it', () => {+ it('a failed launch reports uncertainty and requires explicit recovery', () => {const t = launchTooltip({ kind: 'failed', attempts: 5, at: 1 }, 'Builder', cmd)- expect(t).toContain('5 attempts')- expect(t).toContain('nothing will retry it')+ expect(t).toContain('unconfirmed')+ expect(t).toContain('automatic retry is stopped')expect(t).toContain('▶')expect(t).toContain(cmd)})- it('singularises one attempt (the manual ▶ reports exactly one refusal)', () => {+ it('a manual refusal instructs the user to inspect the terminal', () => {expect(launchTooltip({ kind: 'failed', attempts: 1, at: 1 }, 'Builder', cmd)).toContain(- '1 attempt was refused'+ 'Inspect the terminal')})@@ -293,3 +271,17 @@ it('an exhausted delivery stays held on rerender; a stalled terminal may still bexpect(node.data.pendingLaunch?.command).toBe('echo new')expect(launchesToFire([node], {}, live, undefined, { new: { kind: 'stalled', since: 1 } })).toEqual([{ id: 'new', command: 'echo new' }])})++ it('a durable manual-only launch stays held after a reload and unrelated successful hooks', () => {+ const node = armed('new', [])+ node.data.pendingLaunch!.manualOnly = true+ const restored = JSON.parse(JSON.stringify(node))+ expect(launchesToFire([restored], { other: { state: 'done' } }, new Set(['new', 'other']))).toEqual([])+ expect(restored.data.pendingLaunch.command).toBe('echo new')+})++it('manual recovery does not promise that retrying an errored dependency will automatically release it', () => {+ const tooltip = launchTooltip({ kind: 'failed', attempts: 1, at: 0 }, 'upstream', 'claude brief', 'upstream')+ expect(tooltip).toContain('automatic retry is stopped')+ expect(tooltip).not.toContain('successful turn releases')+})diff --git a/src/renderer/lib/pendingLaunch.ts b/src/renderer/lib/pendingLaunch.tsindex 351119a9a..5e4cbf2ed 100644--- a/src/renderer/lib/pendingLaunch.ts+++ b/src/renderer/lib/pendingLaunch.ts@@ -124,7 +124,7 @@ export function launchesToFire(const out: LaunchToFire[] = []for (const n of nodes) {const p = n.data.pendingLaunch- if (!p || !p.command || p.executor === 'server') continue+ if (!p || !p.command || p.manualOnly || p.executor === 'server') continueif (deliveries?.[n.id]?.kind === 'failed') continueif (p.awaitSetupGroup && !(setupDone?.(p.awaitSetupGroup) ?? true)) continueif (p.after.every((d) => depSatisfied(d, status, live))) out.push({ id: n.id, command: p.command })@@ -143,33 +143,6 @@ export function unmetDeps(return p.after.filter((d) => !depSatisfied(d, status, live))}-/**- * The backoff between delivery attempts, in milliseconds, indexed by the number of attempts- * ALREADY made. `null` = the schedule is exhausted; the launch has failed for good.- *- * This replaces a flat 5 × 400 ms budget (2 s from the moment the canvas mounted the node) that- * measured the wrong thing entirely: it started when the CANVAS decided the node was ready to- * launch, and spent itself while the terminal was still being spawned. A cold project switch —- * load the canvas, mount the node, spawn tmux, settle the shell — routinely costs more than two- * seconds, so the launch was abandoned before the session it was meant for existed. That is- * issue #569 item 1: a node that says QUEUED forever with no way to tell it apart from one that- * is simply waiting on a dependency.- *- * The fix is mostly NOT here: delivery is now gated on the node reporting its session ready- * (`isSessionReady`), so the schedule below only has to cover the residual race between "the- * shell settled" and "tmux will accept a paste for this session". It is nevertheless generous- * and bounded — roughly 12 s across five attempts — because the alternative to a bound is a- * retry loop nobody can see the end of.- */-const LAUNCH_RETRY_SCHEDULE_MS = [400, 800, 1600, 3200, 6400] as const--export function launchRetryDelay(attemptsMade: number): number | null {- return LAUNCH_RETRY_SCHEDULE_MS[attemptsMade - 1] ?? null-}--/** Total attempts a refused delivery gets before it is reported as failed. */-export const LAUNCH_DELIVERY_ATTEMPTS = LAUNCH_RETRY_SCHEDULE_MS.length-/*** How long an armed node whose gate is OPEN may sit with no terminal to deliver into before the* badge says so. It is a WARNING, not a deadline: the launch is still held and still fires the@@ -205,6 +178,11 @@ export function launchTooltip(erroredOn?: string): string {const runs = `Runs:\n${command}`+ if (delivery?.kind === 'failed')+ return (+ 'Launch delivery is unconfirmed; automatic retry is stopped.\n' ++ `Inspect the terminal, then press \u25b6 to retry at a shell prompt.\n${runs}`+ )// Issue #521: an errored upstream is idle, so without this the tooltip would say "waiting for X// to finish" about a station that finished twenty minutes ago. Named first, because it is the// one case where waiting will not end on its own.@@ -214,12 +192,6 @@ export function launchTooltip('what it did not produce.\n' +`Retry or nudge it — a successful turn releases this — or press ▶ to run it now.\n${runs}`)- if (delivery?.kind === 'failed')- return (- `This session did not accept its launch — ${delivery.attempts} ` +- `attempt${delivery.attempts === 1 ? ' was' : 's were'} refused, and nothing will retry it.\n` +- `Press \u25b6 to run it now.\n${runs}`- )if (delivery?.kind === 'stalled')return ('Ready to run, but this terminal has not started yet — the launch is still held and ' +diff --git a/src/renderer/nodes/TerminalNode.tsx b/src/renderer/nodes/TerminalNode.tsxindex 2158070be..8389a6cf6 100644--- a/src/renderer/nodes/TerminalNode.tsx+++ b/src/renderer/nodes/TerminalNode.tsx@@ -1,3 +1,5 @@+import { isLaunchShell } from '@shared/agents/pane'+import { createLaunchWriter, launchCommand, registerLaunchWriter } from '../terminal/launch-command'import { Suspense, lazy, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react'import { NODE_MIN_SIZES } from '../lib/nodeSizing'import {@@ -1826,7 +1828,9 @@ export function TerminalNode({// ordinary case (still waiting on a dependency); the two states it can carry are the ones that// used to be invisible — see the store. Selected by id so an unarmed node never re-renders on// another node's delivery.- const launchDelivery = useLaunchDelivery((s) => s.byId[id])+ const observedLaunchDelivery = useLaunchDelivery((s) => s.byId[id])+ const launchDelivery = observedLaunchDelivery ?? (pendingLaunch?.manualOnly+ ? { kind: 'failed' as const, attempts: 1, at: 0 } : undefined)const pendingWaitingOn = [...(pendingLaunch?.after ?? []).map((depId) => ((getNode(depId) as CanvasNode | undefined)?.data.title as string) || depId@@ -3429,6 +3433,15 @@ export function TerminalNode({unsub()})}+ const launchWriter = createLaunchWriter({+ fresh: fresh && !freshUnverified,+ io: { write: (d) => transport.write(sid, d), onData: (cb) => transport.onData(sid, cb) },+ // A fresh shell is known at spawn; subsequent/manual deliveries must recheck the pane.+ shellReady: async (manual) =>+ (!manual && fresh && !sessionPersistent) || isLaunchShell(await queryPaneWithin(() => api.pty.paneCommand(id), RESTART_EXIT_TIMEOUT_MS)),+ killLine: getTerminalKillLine(),+ cleanup: (cancel) => cleanups.push(cancel)+ })const writeWhenShellReady = (cmd: string): void => {whenShellSettled(() => {cleanups.push(@@ -3457,7 +3470,10 @@ export function TerminalNode({// comes out mangled. Published unconditionally (not only for an armed node): whether this// node is armed is Canvas's question, it can change after the spawn resolves, and the// subscribers filter by id anyway.- whenShellSettled(() => setSessionReady(id, true))+ whenShellSettled(() => {+ cleanups.push(registerLaunchWriter(id, launchWriter))+ setSessionReady(id, true)+ })// Paused (see agentStatus.paused) is the ONE exception to the "a cold start always resumes"// rule below: it exists precisely to survive a cold restart, so it must NOT be dropped, and// the auto-resume branch must be skipped — only an explicit Resume (which reuses the same@@ -3528,8 +3544,26 @@ export function TerminalNode({// Run a one-shot command on first open (e.g. "gh auth login" or the agent CLI), then// forget it.if (data.initialCommand) {- writeWhenShellReady(data.initialCommand)- updateNodeData(id, { initialCommand: undefined })+ const command = data.initialCommand+ // Publish durable intent before the asynchronous settle/echo work. The automatic+ // Canvas loop leaves this manual-only record to this writer; an interrupted mount+ // retains it for recovery instead of starting a second writer.+ updateNodeData(id, { pendingLaunch: { after: [], command, manualOnly: true } })+ whenShellSettled(() => {+ void launchWriter(command, false).then((outcome) => {+ if (outcome === 'submitted') {+ updateNodeData(id, { initialCommand: undefined, pendingLaunch: undefined })+ } else {+ // Keep the exact brief and expose Run now, including an interrupted settle.+ updateNodeData(id, {+ initialCommand: undefined,+ pendingLaunch: { after: [], command, manualOnly: true }+ })+ useLaunchDelivery.getState().markFailed(id, 1)+ if (outcome === 'line-too-long') setCo(termKey, { launchTooLongBytes: lineBytes(command) })+ }+ })+ })} else if (coldStart && canColdRestore) {// Cold restart of an agent node: the live agent is gone, so re-launch it. Resume the// prior conversation by its session id when we have one; otherwise start the agent@@ -5513,17 +5547,17 @@ export function TerminalNode({{launchDelivery ? '⚠ ' : ''}QUEUED<buttonclassName="term-node__queued-run"- title="Run now without waiting"+ title={pendingLaunch.manualOnly ? "Retry launch at a shell prompt" : "Run now without waiting"}onClick={(e) => {e.stopPropagation()// Disarm only on a delivery that actually landed. Dropping `pendingLaunch`// unconditionally threw the command away whenever the session was not up yet —// and "not up yet" is precisely the state a user reaches for this button in, so// the one escape hatch could destroy the thing it exists to rescue.- void api.pty.sendText(id, pendingLaunch.command).then((ok) => {- if (ok) {+ void launchCommand(id, pendingLaunch.command, true).then((outcome) => {+ if (outcome === 'submitted') {useLaunchDelivery.getState().clear(id)- updateNodeData(id, { pendingLaunch: undefined })+ updateNodeData(id, { initialCommand: undefined, pendingLaunch: undefined })} else {useLaunchDelivery.getState().markFailed(id, 1)}diff --git a/src/renderer/state/workspace.cold-open.test.ts b/src/renderer/state/workspace.cold-open.test.tsindex 95ff60792..30e79f521 100644--- a/src/renderer/state/workspace.cold-open.test.ts+++ b/src/renderer/state/workspace.cold-open.test.ts@@ -76,3 +76,14 @@ describe('cold-open pin (b): an empty `after` is vacuously ready', () => {expect(ready).toEqual([])})})++it('retains an unsubmitted UI command across a project switch without automatically replaying it', () => {+ const live = nodeStatesToFlow([armedState])[0]+ live.data.pendingLaunch = undefined+ live.data.initialCommand = 'claude "complete original brief"'+ const restored = nodeStatesToFlow(flowToNodeStates([live]))[0]+ expect(restored.data.pendingLaunch).toEqual({+ after: [], command: 'claude "complete original brief"', manualOnly: true+ })+ expect(launchesToFire([restored], {}, new Set([restored.id]))).toEqual([])+})diff --git a/src/renderer/state/workspace.ts b/src/renderer/state/workspace.tsindex d5feae820..ca6cec5e5 100644--- a/src/renderer/state/workspace.ts+++ b/src/renderer/state/workspace.ts@@ -2033,7 +2033,11 @@ export function flowToNodeStates(nodes: CanvasNode[]): CanvasNodeState[] {agentModel: n.data.agentModel,accountId: n.data.accountId,agentSessionId: n.data.agentSessionId,- pendingLaunch: n.data.pendingLaunch,+ // A not-yet-submitted UI command is durable too. Recover it explicitly on reload:+ // the old PTY may have accepted it before the clearing save landed.+ pendingLaunch: n.data.pendingLaunch ?? (n.data.initialCommand+ ? { after: [], command: n.data.initialCommand, manualOnly: true }+ : undefined),ssh: n.data.ssh,sshRemoteTmux: n.data.sshRemoteTmux,sshFs: n.data.sshFs,diff --git a/src/renderer/terminal/launch-command.test.ts b/src/renderer/terminal/launch-command.test.tsnew file mode 100644index 000000000..2e96c3ed3--- /dev/null+++ b/src/renderer/terminal/launch-command.test.ts@@ -0,0 +1,125 @@+import { afterEach, describe, expect, it, vi } from 'vitest'+import { createLaunchWriter, launchCommand, registerLaunchWriter } from './launch-command'+import { KILL_LINE, WINDOWS_KILL_LINE, VERIFY_TIMEOUT_MS, DELIVERY_ATTEMPTS } from './command-delivery'++function fixture(fresh = true, killLine = KILL_LINE) {+ const cleanups: Array<() => void> = []+ let output: ((text: string) => void) | undefined+ const write = vi.fn()+ const shellReady = vi.fn(async () => true)+ const writer = createLaunchWriter({ fresh, io: {+ write, onData: (cb) => { output = cb; return () => { output = undefined } }+ }, shellReady, killLine, cleanup: (cancel) => cleanups.push(cancel) })+ return { writer, write, shellReady, echo: (text: string) => output?.(text),+ dispose: () => cleanups.forEach((fn) => fn()) }+}+afterEach(() => vi.useRealTimers())+describe('durable launch delivery', () => {+ it('acknowledges only after echoed command and Enter; stale UI and concurrent clicks never paste twice', async () => {+ const f = fixture()+ const command = 'claude complete-brief'+ const first = f.writer(command, false)+ expect(f.writer(command, true)).toBe(first)+ await Promise.resolve()+ expect(f.write.mock.calls).toEqual([[command]])+ f.echo(command)+ expect(await first).toBe('submitted')+ expect(await f.writer(command, true)).toBe('submitted')+ expect(f.write.mock.calls).toEqual([[command], ['\r']])+ })+ it('repairs a swallowed head using Ctrl-U before submitting', async () => {+ vi.useFakeTimers()+ const f = fixture()+ const command = 'claude complete-brief'+ const result = f.writer(command, false)+ await Promise.resolve()+ f.echo('complete-brief')+ await vi.advanceTimersByTimeAsync(VERIFY_TIMEOUT_MS)+ expect(f.write.mock.calls).toEqual([[command], [KILL_LINE], [command]])+ f.echo(command)+ expect(await result).toBe('submitted')+ })+ it('retains overlong unverified launches and refuses automatic reattempts, but permits an explicit retry', async () => {+ vi.useFakeTimers()+ const f = fixture()+ const command = 'x'.repeat(2000)+ const result = f.writer(command, false)+ await vi.advanceTimersByTimeAsync(VERIFY_TIMEOUT_MS * DELIVERY_ATTEMPTS)+ expect(await result).toBe('line-too-long')+ expect(f.write).not.toHaveBeenCalledWith('\r')+ const calls = f.write.mock.calls.length+ expect(await f.writer(command, false)).toBe('cancelled')+ expect(f.write).toHaveBeenCalledTimes(calls)+ const retry = f.writer(command, true)+ await Promise.resolve()+ f.echo(command)+ expect(await retry).toBe('submitted')+ })+ it('does not replay a durable command on warm resume even if its successful clear was never saved', async () => {+ const f = fixture(false)+ expect(await f.writer('codex brief', false)).toBe('cancelled')+ expect(f.write).not.toHaveBeenCalled()+ f.shellReady.mockResolvedValue(false) // running agent/editor: manual retry also refuses+ expect(await f.writer('codex brief', true)).toBe('cancelled')+ expect(f.write).not.toHaveBeenCalled()+ f.shellReady.mockResolvedValue(true)+ const retry = f.writer('codex brief', true)+ await Promise.resolve()+ f.echo('codex brief')+ expect(await retry).toBe('submitted')+ })+ it('manual Windows recovery clears a partial line with Escape and submits Enter separately after echo', async () => {+ const f = fixture(false, WINDOWS_KILL_LINE)+ const result = f.writer('codex brief', true)+ await Promise.resolve()+ expect(f.write.mock.calls).toEqual([[WINDOWS_KILL_LINE], ['codex brief']])+ f.echo('codex brief')+ expect(await result).toBe('submitted')+ expect(f.write.mock.calls).toEqual([[WINDOWS_KILL_LINE], ['codex brief'], ['\r']])+ expect(f.write).not.toHaveBeenCalledWith(KILL_LINE)+ })+ it('cancels teardown during shell probing without losing the command or writing late', async () => {+ const f = fixture()+ let ready!: (value: boolean) => void+ f.shellReady.mockImplementation(() => new Promise((resolve) => { ready = resolve }))+ const result = f.writer('codex brief', false)+ f.dispose()+ ready(true)+ expect(await result).toBe('cancelled')+ expect(f.write).not.toHaveBeenCalled()+ })+ it('cancels teardown during echo verification without Enter or an orphan retry timer', async () => {+ vi.useFakeTimers()+ const f = fixture()+ const result = f.writer('codex brief', false)+ await Promise.resolve()+ f.dispose()+ expect(await result).toBe('cancelled')+ await vi.runAllTimersAsync()+ expect(f.write.mock.calls).toEqual([['codex brief']])+ })+ it.each(['probe', 'command', 'enter'])('reports a rejected %s as unconfirmed and allows manual recovery', async (failure) => {+ const f = fixture()+ if (failure === 'probe') f.shellReady.mockRejectedValueOnce(new Error('offline'))+ else f.write.mockImplementation((text) => {+ if (failure === 'command' || text === '\r') throw new Error('offline')+ })+ const result = f.writer('claude brief', false)+ await Promise.resolve()+ f.echo('claude brief')+ expect(await result).toBe('cancelled')+ f.write.mockReset()+ const retry = f.writer('claude brief', true)+ await Promise.resolve()+ f.echo('claude brief')+ expect(await retry).toBe('submitted')+ })+ it('an unmounted writer cannot be reached, and an old cleanup cannot remove its replacement', async () => {+ const first = registerLaunchWriter('node', async () => 'cancelled')+ const second = registerLaunchWriter('node', async () => 'submitted')+ first()+ expect(await launchCommand('node', 'cmd')).toBe('submitted')+ second()+ expect(await launchCommand('node', 'cmd', true)).toBe('cancelled')+ })+})diff --git a/src/renderer/terminal/launch-command.ts b/src/renderer/terminal/launch-command.tsnew file mode 100644index 000000000..157f25202--- /dev/null+++ b/src/renderer/terminal/launch-command.ts@@ -0,0 +1,49 @@+import { deliverCommand, type DeliveryIo, type DeliveryOutcome } from './command-delivery'++// A writer belongs to the PTY lifetime (including a parked view), not a Canvas render.+// Warm attachments never replay durable launch intent: a previous submission may have landed+// just before its clearing autosave. The retained command is available for explicit recovery.+type Writer = (command: string, manual: boolean) => Promise<DeliveryOutcome>+const writers = new Map<string, Writer>()+export function registerLaunchWriter(id: string, writer: Writer): () => void {+ writers.set(id, writer)+ return () => { if (writers.get(id) === writer) writers.delete(id) }+}+export function launchCommand(id: string, command: string, manual = false): Promise<DeliveryOutcome> {+ return writers.get(id)?.(command, manual) ?? Promise.resolve('cancelled')+}++export function createLaunchWriter(opts: {+ fresh: boolean+ io: DeliveryIo+ shellReady(manual: boolean): Promise<boolean>+ killLine: string+ cleanup(cancel: () => void): void+}): Writer {+ let attempted = false+ let submitted = false+ let inFlight: Promise<DeliveryOutcome> | undefined+ let disposed = false+ opts.cleanup(() => { disposed = true })+ return (command, manual) => {+ if (submitted) return Promise.resolve('submitted') // stale UI/save; never paste twice+ if (inFlight) return inFlight+ if (disposed || (!manual && (!opts.fresh || attempted))) return Promise.resolve('cancelled')+ attempted = true+ inFlight = (async () => {+ if (!(await opts.shellReady(manual)) || disposed) return 'cancelled' as const+ return new Promise<DeliveryOutcome>((resolve) => {+ try {+ // A cancelled delivery may have left an unsubmitted prefix in the shell editor.+ // Explicit recovery starts a new line rather than appending another CLI command.+ if (manual) opts.io.write(opts.killLine)+ opts.cleanup(deliverCommand(opts.io, command, resolve, { killLine: opts.killLine }))+ } catch { resolve('cancelled') }+ })+ })().then((outcome) => {+ submitted = outcome === 'submitted'+ return outcome+ }).catch(() => 'cancelled' as const).finally(() => { inFlight = undefined })+ return inFlight+ }+}diff --git a/src/renderer/terminal/offscreen-policy.test.ts b/src/renderer/terminal/offscreen-policy.test.tsindex f4a3aa71f..fcdeebe71 100644--- a/src/renderer/terminal/offscreen-policy.test.ts+++ b/src/renderer/terminal/offscreen-policy.test.ts@@ -226,8 +226,8 @@ describe('shouldDeferReleaseForHeldLaunch — the fifth kill lever: an armed nodexpect(shouldDeferReleaseForHeldLaunch({ tmuxBacked: false, armed: true })).toBe(true)})- it('never defers a TMUX-BACKED armed node — its session stays typeable by name through a release', () => {- expect(shouldDeferReleaseForHeldLaunch({ tmuxBacked: true, armed: true })).toBe(false)+ it('retains a TMUX-BACKED armed node for echo verification', () => {+ expect(shouldDeferReleaseForHeldLaunch({ tmuxBacked: true, armed: true })).toBe(true)})it('never defers a node that is not armed, on either backend', () => {diff --git a/src/renderer/terminal/offscreen-policy.ts b/src/renderer/terminal/offscreen-policy.tsindex 276666bbd..a65b9240f 100644--- a/src/renderer/terminal/offscreen-policy.ts+++ b/src/renderer/terminal/offscreen-policy.ts@@ -107,19 +107,10 @@ export function shouldDeferReleaseForLiveWork(i: LiveWorkInput): boolean {return wouldKillLiveWork(i)}-/**- * THE FIFTH LEVER (CLAUDE.md: "a fifth lever owes the same gate"): an ARMED node — one holding a- * `pendingLaunch` for the canvas-control `--after` edge — has work a kill would strand, even though- * nothing is running in it yet. The launch is delivered by session NAME (`sendText` → tmux- * paste-buffer), so with tmux underneath a release is harmless: the client detaches, the session- * stays typeable, and the launch still lands. On the plain-shell fallback the pty IS the shell, so- * the same release destroys the pane the launch was going to be typed into, and nothing revives a- * released node except the camera coming back — the launch is held until someone happens to look.- * Same shape as `shouldDeferReleaseForLiveWork`, and uncapped for the same reason: what this waits- * for (the launch firing, or the user disarming it) always ends the hold.- */+/** A held launch needs the attached transport for echo verification, including with tmux.+ * Keep the view until submission/recovery rather than reverting to a blind paste by session name. */export function shouldDeferReleaseForHeldLaunch(i: { tmuxBacked: boolean; armed: boolean }): boolean {- return !i.tmuxBacked && i.armed+ return i.armed}/**diff --git a/src/server/headless-node-factory.test.ts b/src/server/headless-node-factory.test.tsindex d29a91509..b0dd36d1c 100644--- a/src/server/headless-node-factory.test.ts+++ b/src/server/headless-node-factory.test.ts@@ -41,6 +41,8 @@ class FakePty implements HeadlessPty {return { sessionId: `pty-${options.persistKey}`, fresh: true, persistent: true }}+ async paneCommand(): Promise<string | null> { return 'bash' }+async sessionExists(persistKey: string): Promise<boolean> {return this.live.has(persistKey)}@@ -1038,7 +1040,48 @@ describe('HeadlessNodeFactory', () => {})})- it('reports a partial batch and recovers only the retained launch', async () => {+ it.each(['vim', null])('refuses initial input when the pane is %s and never retries on hooks', async (pane) => {+ vi.spyOn(pty, 'paneCommand').mockResolvedValue(pane)+ const reply = await factory.openAgent('term-source', { agent: 'claude', prompt: 'brief' }, true)+ expect(reply.ok).toBe(false)+ expect(pty.sends).toEqual([])+ await factory.refreshArmed({ nodeId: 'term-upstream', state: 'done' })+ expect(pty.sends).toEqual([])+ })++ it('saves manual recovery intent before sending, including a successful send whose clearing save fails', async () => {+ const save = vi.spyOn(store, 'save')+ vi.spyOn(pty, 'sendText').mockImplementationOnce(async (id) => {+ const durable = await store.load({ sideline: false })+ expect(durable.projects[0].nodes.find((n) => n.id === id)?.pendingLaunch)+ .toMatchObject({ command: "claude 'brief'", manualOnly: true })+ save.mockRejectedValueOnce(new Error('disk unavailable after delivery'))+ pty.sends.push({ nodeId: id, text: 'brief' })+ return true+ })+ await expect(factory.openAgent('term-source', { agent: 'claude', prompt: 'brief' }, true))+ .rejects.toThrow('disk unavailable')+ await factory.refreshArmed({ nodeId: 'term-upstream', state: 'done' })+ expect(pty.sends).toHaveLength(1)+ })++ it('a failed dependent launch is retained durably and not replayed after unrelated hooks', async () => {+ states['term-upstream'] = 'working'+ const reply = await factory.openAgent('term-source', {+ agent: 'claude', prompt: 'brief', after: 'term-upstream'+ }, true)+ const id = (reply.result as { id: string }).id+ const send = vi.spyOn(pty, 'sendText').mockResolvedValue(false)+ await factory.refreshArmed({ nodeId: 'term-upstream', state: 'done' })+ await factory.refreshArmed({ nodeId: 'term-source', state: 'done' })+ await factory.refreshArmed()+ expect(send).toHaveBeenCalledTimes(1)+ const durable = await store.load({ sideline: false })+ expect(durable.projects[0].nodes.find((n) => n.id === id)?.pendingLaunch)+ .toMatchObject({ command: "claude 'brief'", manualOnly: true })+ })++ it('reports a partial batch and never retries the retained launch on unrelated hooks', async () => {vi.spyOn(pty, 'sendText').mockResolvedValueOnce(true).mockResolvedValueOnce(false)const reply = await factory.openAgent('term-source', { agent: 'codex', prompt: 'work', count: '2' }, true)const [delivered, failed] = (reply.result as { ids: string[] }).ids@@ -1049,7 +1092,8 @@ describe('HeadlessNodeFactory', () => {pty.sends.length = 0await factory.refreshArmed()await factory.refreshArmed()- expect(pty.sends.map((send) => send.nodeId)).toEqual([failed])+ expect(pty.sends).toEqual([])+ expect(workspace.projects[0].nodes.find((node) => node.id === failed)?.pendingLaunch?.manualOnly).toBe(true)})it('persists --after without launching, then flushes exactly once on the idle state', async () => {diff --git a/src/server/headless-node-factory.ts b/src/server/headless-node-factory.tsindex bec60bb74..b0261ac03 100644--- a/src/server/headless-node-factory.ts+++ b/src/server/headless-node-factory.ts@@ -1,3 +1,4 @@+import { isLaunchShell } from '../shared/agents/pane'import { randomBytes, randomUUID } from 'node:crypto'import path from 'node:path'@@ -51,6 +52,7 @@ export interface ServerControlReply {export interface HeadlessPty {createHeadless(options: PtyCreateOptions): Promise<PtyCreateResult>/** Probe only. Boot reconciliation must never turn absence into a fresh session. */+ paneCommand(persistKey: string): Promise<string | null>sessionExists(persistKey: string): Promise<boolean>sendText(nodeId: string, text: string, opts?: { enter?: boolean }): Promise<boolean>destroySession(@@ -95,8 +97,6 @@ export interface HeadlessNodeFactoryDeps {publishNode?: (projectId: string, node: CanvasNodeState) => voidpublishRemoval?: (projectId: string, nodeId: string) => voidpublishProject?: (project: Project) => void- schedule?: (cb: () => void, ms: number) => ReturnType<typeof setTimeout>- clearSchedule?: (timer: ReturnType<typeof setTimeout>) => void/** Injectable only so tests can seed creator facts; production uses a fresh process-local ledger. */ownership?: HeadlessNodeOwnership}@@ -138,8 +138,6 @@ const H_GAP = 80const V_GAP = 36const GROUP_PAD = 28const GROUP_HEADER = 34-const AFTER_RETRY_MS = 500-const AFTER_RETRY_LIMIT = 5const SERVER_AGENTS: ReadonlySet<string> = new Set(['claude', 'codex', 'gemini'])function token(): string {@@ -513,8 +511,6 @@ export class HeadlessNodeFactory {* project path, so a surviving agent session is never stranded after that restart.*/private projectGrants = new Map<string, Set<string>>()- private retryCount = new Map<string, number>()- private retryTimers = new Map<string, ReturnType<typeof setTimeout>>()private stopped = falseconstructor(private readonly deps: HeadlessNodeFactoryDeps) {@@ -834,10 +830,6 @@ export class HeadlessNodeFactory {this.ownership.forget(id)this.attached.delete(id)this.awaitingFirstWorking.delete(id)- this.retryCount.delete(id)- const timer = this.retryTimers.get(id)- if (timer) (this.deps.clearSchedule ?? clearTimeout)(timer)- this.retryTimers.delete(id)}return {ok: true,@@ -1184,6 +1176,7 @@ export class HeadlessNodeFactory {after,command,executor: 'server' as const,+ ...(!mustWait ? { manualOnly: true } : {}),...(awaitWorking.length ? { awaitWorking: [...awaitWorking] } : {})}: undefined@@ -1245,7 +1238,8 @@ export class HeadlessNodeFactory {if (verb === 'open-agent' && result.fresh) this.awaitingFirstWorking.add(node.id)const command = commands.get(node.id)if (command) {- if (await this.deps.ptyManager.sendText(node.id, command)) node.pendingLaunch = undefined+ if (isLaunchShell(await this.deps.ptyManager.paneCommand(node.id)) &&+ await this.deps.ptyManager.sendText(node.id, command)) node.pendingLaunch = undefinedelse failed.push(node.id)}} catch {@@ -1255,6 +1249,9 @@ export class HeadlessNodeFactory {// Creation and delivery are separate transactions. A refused/throwing send retains the// exact command for the user's Run now action; boot still cannot adopt persisted nodes.+ for (const node of created) {+ if (failed.includes(node.id) && node.pendingLaunch) node.pendingLaunch.manualOnly = true+ }await this.deps.workspaceStore.save(workspace)this.publish(target, created)const ids = created.map((node) => node.id)@@ -1377,7 +1374,7 @@ export class HeadlessNodeFactory {for (const project of workspace.projects) {for (const node of project.nodes) {const pending = node.pendingLaunch- if (!pending || pending.executor !== 'server' || !pending.command) continue+ if (!pending || pending.executor !== 'server' || !pending.command || pending.manualOnly) continue// A persisted arm surviving a restart is data, not creator proof. Only a node freshly// spawned for this caller during the current run may receive automatic input.if (!this.ownership.ownerOf(node.id)) continue@@ -1413,15 +1410,14 @@ export class HeadlessNodeFactory {const live = this.attached.has(node.id) ||await this.deps.ptyManager.sessionExists(node.id).catch(() => false)if (!live) continue- if (!(await this.deps.ptyManager.sendText(node.id, pending.command).catch(() => false))) {- this.scheduleRetry(node.id)- continue- }+ // Persist the attempt BEFORE input. A failed/uncertain send (or a crash before its+ // acknowledgement save) must never be replayed by an unrelated hook.+ pending.manualOnly = true+ await this.deps.workspaceStore.save(workspace)+ markChanged()+ if (!isLaunchShell(await this.deps.ptyManager.paneCommand(node.id).catch(() => null))) continue+ if (!(await this.deps.ptyManager.sendText(node.id, pending.command).catch(() => false))) continuenode.pendingLaunch = undefined- this.retryCount.delete(node.id)- const timer = this.retryTimers.get(node.id)- if (timer) (this.deps.clearSchedule ?? clearTimeout)(timer)- this.retryTimers.delete(node.id)markChanged()}}@@ -1437,23 +1433,8 @@ export class HeadlessNodeFactory {})}- private scheduleRetry(nodeId: string): void {- if (this.stopped || this.retryTimers.has(nodeId)) return- const count = (this.retryCount.get(nodeId) ?? 0) + 1- this.retryCount.set(nodeId, count)- if (count > AFTER_RETRY_LIMIT) return- const schedule = this.deps.schedule ?? ((cb: () => void, ms: number) => setTimeout(cb, ms))- const timer = schedule(() => {- this.retryTimers.delete(nodeId)- void this.refreshArmed()- }, AFTER_RETRY_MS)- this.retryTimers.set(nodeId, timer)- }-stop(): void {this.stopped = true- for (const timer of this.retryTimers.values()) (this.deps.clearSchedule ?? clearTimeout)(timer)- this.retryTimers.clear()this.ownership.clear()this.projectGrants.clear()}diff --git a/src/shared/agents/launch-shell.test.ts b/src/shared/agents/launch-shell.test.tsnew file mode 100644index 000000000..091526a59--- /dev/null+++ b/src/shared/agents/launch-shell.test.ts@@ -0,0 +1,8 @@+import { expect, it } from 'vitest'+import { isLaunchShell } from './pane'+it.each(['bash', '-zsh', '/bin/fish', 'pwsh.exe', 'PowerShell.EXE', 'C:\\Windows\\System32\\cmd.exe'])('recognizes the launch shell %s', (name) => {+ expect(isLaunchShell(name)).toBe(true)+})+it.each([null, '', 'vim', 'node', 'claude', 'codex', 'sh -c vim'])('refuses non-shell/unknown %s', (name) => {+ expect(isLaunchShell(name)).toBe(false)+})diff --git a/src/shared/agents/pane.ts b/src/shared/agents/pane.tsindex c068693ad..2dcbeb00a 100644--- a/src/shared/agents/pane.ts+++ b/src/shared/agents/pane.ts@@ -21,3 +21,10 @@ export function isShellCommand(cmd: string | null | undefined): boolean {const base = cmd.replace(/^-/, '').split('/').pop() ?? ''return SHELLS.has(base)}++/** Launch/retry gate, including native Windows shells. Unknown foregrounds are never writable. */+export function isLaunchShell(cmd: string | null | undefined): boolean {+ if (isShellCommand(cmd)) return true+ const base = cmd?.split(/[\\/]/).pop()?.toLowerCase().replace(/\.exe$/, '')+ return base === 'pwsh' || base === 'powershell' || base === 'cmd'+}diff --git a/src/shared/types.ts b/src/shared/types.tsindex 0c0ebc7c4..8734ffc94 100644--- a/src/shared/types.ts+++ b/src/shared/types.ts@@ -337,6 +337,8 @@ export type NodeKind = 'terminal' | 'sticky' | 'group' | 'editor' | 'diff' | 'vi* a stalled station must never be a dead end.*/export interface PendingLaunch {+ /** An attempted/uncertain delivery requires explicit Run now; never replay on hooks. */+ manualOnly?: boolean/*** Node ids to wait for. Only nodes running a hook-reporting agent may appear here — a plain* terminal never reports `done`, so waiting on one would stall forever (refused at creation).