The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.
TypeScript 3d-modelingagent-frameworkagent-harnessai-agentscadclaude-codecodexcoding-agentsdeveloper-toolsesp32game-developmentmcp-servermulti-agentopen-hardwareopencodeopenharnesspcbroboticsterminaltmux
fix(cli): unplugging the dial killed the daemon
0xdiego258f29c3344dff
diff --git a/cli/src/cable/cableSession.ts b/cli/src/cable/cableSession.tsindex cc1307e67..885ebbd41 100644--- a/cli/src/cable/cableSession.ts+++ b/cli/src/cable/cableSession.ts@@ -482,8 +482,13 @@ export class CableSession {// Turn state is UNSOLICITED: the daemon reports every turn in every agent, including ones started at the// keyboard. A dial that only saw answers to its own sends would sit idle through most of what the// machine actually does.- async turnStarted(agentId: string): Promise<void> {- await this.send({ t: 'turn.started', agentId })+ /**+ * `text` is the status line the tile draws — "Working…", the tool that is running, what it is waiting on.+ * It travels because without it the dial gets a card with a state and nothing to render: the tile knows+ * a turn is live and shows the user nothing that says so.+ */+ async turnStarted(agentId: string, text = ''): Promise<void> {+ await this.send({ t: 'turn.started', agentId, text })}async turnDone(agentId: string): Promise<void> {await this.send({ t: 'turn.done', agentId })diff --git a/cli/src/cable/serial.ts b/cli/src/cable/serial.tsindex b9cc01d87..2de514398 100644--- a/cli/src/cable/serial.ts+++ b/cli/src/cable/serial.ts@@ -5,7 +5,7 @@// a per-platform release matrix into a distribution that is currently a download. A tty is a file, `stty`// puts it in raw mode, and that is the whole of what this needs.import { exec } from 'node:child_process'-import { existsSync, readFileSync, readdirSync } from 'node:fs'+import { constants, existsSync, readFileSync, readdirSync } from 'node:fs'import { open, type FileHandle } from 'node:fs/promises'import { promisify } from 'node:util'@@ -132,10 +132,24 @@ export class SerialLink {// Raw mode is not optional. Left in the default line discipline the tty maps CR to NL, strips the// eighth bit on some paths and echoes what we write back at us — and a mangled frame is// indistinguishable from a bad cable at the far end.+ //+ // `clocal` belongs with it: it tells the line discipline to ignore modem control lines, so losing+ // carrier — which is what unplugging a USB serial device looks like — does not hang the port up+ // underneath us.const flag = process.platform === 'darwin' ? '-f' : '-F'- await execFile(`stty ${flag} ${JSON.stringify(path)} raw -echo -echoe -echok -echoctl -echoke`)-- const handle = await open(path, 'r+')+ await execFile(`stty ${flag} ${JSON.stringify(path)} raw clocal -echo -echoe -echok -echoctl -echoke`)++ // O_NOCTTY IS LOAD-BEARING, AND ITS ABSENCE KILLED THE DAEMON.+ //+ // The daemon is spawned detached, which makes it a session leader. A session leader that opens a tty+ // without this flag ACQUIRES it as its controlling terminal — and when the USB device is unplugged the+ // kernel sends SIGHUP to that terminal's process group. Default disposition for SIGHUP is terminate,+ // so pulling the cable killed the process outright: no exception, no stack, nothing for the+ // unhandledRejection guard to catch, and a log that simply stops mid-second.+ //+ // Measured 2026-08-24: the daemon died at the exact second the cable came out, every time, and the+ // dial then greeted an empty room until it timed out and showed no agents.+ const handle = await open(path, constants.O_RDWR | constants.O_NOCTTY)const link = new SerialLink(path, handle, onData, onClosed)void link.readLoop()return linkdiff --git a/cli/src/cli.ts b/cli/src/cli.tsindex e6f728bb1..f79d285cc 100644--- a/cli/src/cli.ts+++ b/cli/src/cli.ts@@ -2716,8 +2716,14 @@ async function runForeground(session: AuthSession): Promise<void> {// again at each call site: a new event kind reaches the dial the day it reaches the socket.backend.onOutboundCommander = (frame) => {const event = cableEventFor(frame as { type?: string; agentId?: string; payload?: { kind?: string; text?: string; recap?: string } })+ // Logged at the fork, not at the send: this is the one place that can answer "did the daemon even+ // decide to tell the dial", which is a different question from "did the wire carry it" and was the+ // question nobody could answer when the tile stayed idle through a whole turn.+ if (env.LOG_FRAMES && frame?.type === 'commander_event') {+ console.log(`[cable] tee ${(frame as { payload?: { kind?: string } }).payload?.kind ?? '?'} → ${event ? 'sent' : 'ignored'}`)+ }if (!event) return- if (event.kind === 'processing') void cable.turnStarted(event.agentId)+ if (event.kind === 'processing') void cable.turnStarted(event.agentId, event.text)else if (event.kind === 'done') void cable.turnDone(event.agentId)else if (event.kind === 'summary') void cable.summary(event.agentId, event.recap || event.text, event.text)else void cable.turnError(event.agentId, event.text)