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.

Merge origin/main (#1014, #1019) into feat/orchestrator-failure-notice

review0d0489244ba9
diff --cc src/core/canvas-control-core.ts
index 7534ae53a,6a75e8d8e..8506f3c72
--- a/src/core/canvas-control-core.ts
+++ b/src/core/canvas-control-core.ts
@@@ -23,12 -23,7 +23,13 @@@ import { nodeColorChoices } from '@shar
import { offScreenGuidanceLines } from '@shared/control-off-screen'
import { codexThreadIdentityResolverSh } from './codex-thread-identity-sh'
import { ISSUE_SESSION_COLUMNS, issueLaunchPrompt, parseIssueArg } from '../shared/github-issue-ref'
+import {
+ STATION_NOTICE_COMMON_OPTIONS,
+ STATION_QUESTION_NOTICE_MS,
+ STATION_TRIGGERS
+} from '../shared/station-notice'
+import { STATION_NOTICE_FROM } from '../shared/agents/agent-messaging'
+ import { PR_DEADLINE_DEFAULT_MS, PR_DEADLINE_MAX_MS, PR_WAIT_MAX, afterPrFlagRefusal } from '../shared/pr-wait'
import { ISSUE_BRANCH_SLUG_MAX, issueWorktreeBranch } from '../shared/issue-worktree'
/**
diff --cc src/main/station-notice-wiring.test.ts
index 05bb38156,000000000..097dcb213
mode 100644,000000..100644
--- a/src/main/station-notice-wiring.test.ts
+++ b/src/main/station-notice-wiring.test.ts
@@@ -1,77 -1,0 +1,78 @@@
+// The station-failure notice is only as wired as its SHELLS make it, and no type can say so.
+//
+// The monitor (src/core/agents/station-notice.ts) is fed by `onAgentEvent`, the renderer's DROPPED
+// reports arrive over `registerStationNoticeIpc`, and a recipient can only ever be resolved for a
+// node whose `openedBy` the open verbs STAMPED. Every one of those is a call that is perfectly
+// well-typed to leave out: a shell that forgets to feed the monitor compiles, passes the monitor's
+// own suite (which drives it directly), and ships a feature that never fires. That is the class of
+// hole `hook-verified-parity` guards, with the same remedy — pin the wiring at source level.
+import { describe, expect, it } from 'vitest'
+import { readFileSync } from 'fs'
+import { join } from 'path'
+
+const read = (rel: string): string =>
+ readFileSync(join(__dirname, '..', rel), 'utf8').replace(/\r\n/g, '\n')
+
+/** The body of `const <name> = (…) => { … }` up to its closing line at the declaration's indent. */
+function arrowBody(source: string, decl: string, indent = ' '): string {
+ const start = source.indexOf(decl)
+ expect(start, `${decl} not found — this guard is looking at the wrong file`).toBeGreaterThan(-1)
+ const end = source.indexOf(`\n${indent}}`, start)
+ expect(end).toBeGreaterThan(start)
+ return source.slice(start, end)
+}
+
+describe('both shells feed the station-failure monitor', () => {
+ it('desktop: the hook stream reaches it, and its IPC is registered', () => {
+ const src = read('main/index.ts')
+ expect(arrowBody(src, 'const emitAgentStatus = ')).toContain('stationNotices.onAgentEvent(enriched)')
+ expect(src).toContain('registerStationNoticeIpc(corePlatform, () => stationNotices)')
+ expect(src).toContain('stationNotices.start()')
+ // The recipient comes from MAIN's persisted canvases — never from the renderer.
+ expect(src).toContain('stationRecipient(workspaceStore.persistedCanvases(), id)')
+ // …and the pane leg is the messaging service with every gate, not a raw write.
+ expect(src).toContain('deliverStationNotice(notice, messagingDeps)')
+ // The question row's one fact, and the queued notice's final outcome — both optional-looking
+ // hookups a shell can drop and still compile.
+ expect(src).toContain('pendingQuestionOf: (id) => mirrorEntry(id)?.pendingQuestion?.toolUseId')
+ expect(src).toContain(
+ 'messagingDeps.onQueuedResult = (req, outcome) => stationNotices.onQueuedResult(req, outcome)'
+ )
+ })
+
+ it('Server Edition: the canvas-control runtime feeds it and asks its creator ledger', () => {
+ const cc = read('server/canvas-control.ts')
+ expect(arrowBody(cc, 'onAgentEvent: (event) => {', ' ')).toContain(
+ 'stationNotices.onAgentEvent(event)'
+ )
+ expect(cc).toContain('factory.openerOf(stationNodeId)')
+ expect(cc).toContain('deliverStationNotice(notice, messaging)')
+ expect(cc).toContain('pendingQuestionOf: (nodeId) => mirrorEntry(nodeId)?.pendingQuestion?.toolUseId')
+ expect(cc).toContain(
+ 'messaging.onQueuedResult = (req, outcome) => stationNotices.onQueuedResult(req, outcome)'
+ )
+ const idx = read('server/index.ts')
+ expect(idx).toContain('registerStationNoticeIpc(platform, () => canvasControl?.stationNotices ?? null)')
+ })
+})
+
+describe('every canvas-control open path records the opener beside its rope', () => {
+ const canvas = read('renderer/canvas/Canvas.tsx')
+
+ it('the live `connect` (addAndConnect, verify, spawn-team) stamps as it ropes', () => {
+ const body = arrowBody(canvas, 'const connect = (newId: string) => {', ' ')
+ expect(body).toContain('stampOpenedBy(ns, newId, sourceNodeId)')
+ expect(body).toContain('ropeEdge(`ctrl-${sourceNodeId}-${newId}`')
+ })
+
+ it('the off-canvas and cold-open writes stamp the node they rope', () => {
+ expect(canvas).toContain('node: flowToNodeStates([withOpenedBy(placed, sourceNodeId)])[0]')
- // The cold open stamps the node as it is built, right where `--after` is folded into its hold.
- expect(canvas).toMatch(/const node = withOpenedBy\(\s*held && coldAfterIds\.length[\s\S]{0,300}?sourceNodeId\s*\)/)
++ // The cold open stamps the node as it is built, right where `--after` (and any `--after-pr`
++ // hold, via withPrHold) is folded into its hold.
++ expect(canvas).toMatch(/const node = withOpenedBy\(\s*(?:withPrHold\(\s*)?held && coldAfterIds\.length[\s\S]{0,400}?sourceNodeId\s*\)/)
+ })
+
+ it('the renderer mirrors the list and reports DROPPED on the app api', () => {
+ expect(canvas).toContain('installStationNoticeWiring(window.nodeTerminal)')
+ })
+})
diff --cc src/renderer/canvas/Canvas.tsx
index b1cad2f46,f1051362a..28c8e6c76
--- a/src/renderer/canvas/Canvas.tsx
+++ b/src/renderer/canvas/Canvas.tsx
@@@ -11753,18 -11987,19 +11995,24 @@@ export function Canvas()
// Arm it: the project is not mounted, so nothing would deliver an `initialCommand`
// and serialization drops it. `--after` rides the same held launch — an empty `after`
// is vacuously ready, so a node with no deps fires on that project's first view.
- const armed = armForColdOpen(built)
+ // The brief file rides the held launch, so delivery — whenever this project is next
+ // viewed — checks it is still there before typing.
+ const armed = withLaunchBrief(armForColdOpen(built), openPrompt.promptFile)
const held = armed.data.pendingLaunch as PendingLaunch | undefined
- // `--after-pr` rides the same held launch (withPrHold — the one attach every path uses).
- const node = withPrHold(
- held && coldAfterIds.length
- ? {
- ...armed,
- data: { ...armed.data, pendingLaunch: { ...held, after: coldAfterIds } }
- }
- : armed,
- prHoldPre
+ // The cold twin of `connect`: this node's opener rope is appended below, so the
- // opener's name goes on the node now (lib/stationOpener).
++ // opener's name goes on the node now (lib/stationOpener). `--after-pr` rides the same
++ // held launch (withPrHold — the one attach every path uses).
+ const node = withOpenedBy(
- held && coldAfterIds.length
- ? {
- ...armed,
- data: { ...armed.data, pendingLaunch: { ...held, after: coldAfterIds } }
- }
- : armed,
++ withPrHold(
++ held && coldAfterIds.length
++ ? {
++ ...armed,
++ data: { ...armed.data, pendingLaunch: { ...held, after: coldAfterIds } }
++ }
++ : armed,
++ prHoldPre
++ ),
+ sourceNodeId
)
if (coldGroup.groupId) {
const w = (node.width as number) ?? 600
diff --cc src/renderer/nodes/TerminalNode.tsx
index 7b46c4aba,e5e15e51a..99d2f1862
--- a/src/renderer/nodes/TerminalNode.tsx
+++ b/src/renderer/nodes/TerminalNode.tsx
@@@ -220,7 -220,8 +220,9 @@@ import { codexApprovalCaps } from '../s
import { useAgentStatus, agentStatusForApi, inferInterruptAfterSettle } from '../state/agentStatus'
import { useLaunchDelivery } from '../state/launchDelivery'
import { erroredDeps, launchTooltip } from '../lib/pendingLaunch'
+import { StationFailedChip } from '../components/StationFailedChip'
+ import { prHoldExpired, prHoldSummary } from '../lib/prWait'
+ import { pullBoardFor, useGitHubIssues } from '../state/githubIssues'
import type { AgentState } from '@shared/agents/normalize'
import type { ClientId } from '@shared/presence'
import { PresenceChips } from '../components/PresenceChips'
diff --cc src/renderer/state/workspace.ts
index 0600fd213,145d10639..c3e566d24
--- a/src/renderer/state/workspace.ts
+++ b/src/renderer/state/workspace.ts
@@@ -33,7 -33,7 +33,8 @@@ import { folderTitle } from '../lib/exp
import { sshHostKey } from '@shared/ssh'
import { normalizeNodeIcon } from '@shared/node-icon'
import { normalizeIssueRef, type IssueRef } from '@shared/github-issue-ref'
+import { isSafeNodeId } from '@shared/safe-id'
+ import { normalizePendingLaunch } from '@shared/pending-launch-shape'
import { useSettings } from './settings'
// Re-exported so Canvas (and anything else in the renderer) keeps importing it from here, while the
@@@ -1984,11 -1973,11 +1985,13 @@@ export function nodeStatesToFlow(states
// Same seam rule as the icon: a git-shared file becoming live data. A malformed or hostile
// reference becomes no binding (the node is kept — only the chip and history go).
issueRef: normalizeIssueRef(n.issueRef),
+ // Same seam rule: a hostile value becomes no lineage (the node is kept).
+ openedBy: safeOpenedBy(n.openedBy),
accountId: n.accountId,
agentSessionId: n.agentSessionId,
- pendingLaunch: n.pendingLaunch,
+ // Same seam rule again: the launch loop iterates `after`, and a PR wait decides when a
+ // command is typed into a pane. An unreadable hold becomes one that waits for ▶.
+ pendingLaunch: normalizePendingLaunch(n.pendingLaunch),
ssh: n.ssh,
sshRemoteTmux: n.sshRemoteTmux,
sshFs: n.sshFs,