From 280eade6eae6bc236952913610fcdb6115dee595 Mon Sep 17 00:00:00 2001 From: Garry Tan Date: Mon, 25 May 2026 19:43:47 -0700 Subject: [PATCH] chore(design): emit SERVE_STARTED back-compat alias; drop dead import MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit design/src/cli.ts publishToDaemon now emits `SERVE_STARTED: port=N html=` as a third stderr line alongside DAEMON_STARTED/DAEMON_ATTACHED + BOARD_URL. Any out-of-tree script that grepped the legacy line still gets the port — they'd still fail at the reload step (the endpoint moved to /boards// api/reload) but they no longer fail at the port-detection step. Combined with the resolver updates one commit back, this is belt-and-suspenders compat. Fixed the stale docstring at cli.ts:316 that claimed back-compat without actually emitting the alias. The maintainability specialist flagged it. Dropped a dead `DaemonState` import from daemon-client.ts. Same review pass. Co-Authored-By: Claude Opus 4.7 (1M context) --- design/src/cli.ts | 18 ++++++++++++++---- design/src/daemon-client.ts | 1 - 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/design/src/cli.ts b/design/src/cli.ts index 247e308cf..a55d92555 100644 --- a/design/src/cli.ts +++ b/design/src/cli.ts @@ -323,11 +323,17 @@ async function main(): Promise { * publish the board, open the browser to its URL, then exit. The daemon * survives. * - * Backward-compatible stderr lines for any external script that scraped the - * old `SERVE_STARTED` output: - * - "DAEMON_ATTACHED port=N" or "DAEMON_STARTED port=N" (one or the other) + * Stderr lines (in order): + * - "DAEMON_STARTED port=N version=V" (or "DAEMON_ATTACHED port=N ..." + * if a daemon was already running) * - "BOARD_PUBLISHED: http://127.0.0.1:N/boards//" - * - "BOARD_URL: " (alias for grep-friendliness) + * - "BOARD_URL: " (alias for grep-friendliness) + * - "SERVE_STARTED: port=N html=" (legacy back-compat alias for + * any external script that scraped the pre-daemon output — note the + * daemon hosts boards under /boards//, not /, so scripts that + * ALSO POSTed /api/reload at the parsed port need to switch to + * BOARD_URL + ./api/reload to work end-to-end. Emitting the legacy + * line keeps port-only consumers from breaking outright.) */ async function publishToDaemon(opts: { html: string; title?: string }): Promise { if (!opts.html) { @@ -345,6 +351,10 @@ async function publishToDaemon(opts: { html: string; title?: string }): Promise< }); console.error(`BOARD_PUBLISHED: ${result.url}`); console.error(`BOARD_URL: ${result.url}`); + // Legacy alias so anything still grepping `SERVE_STARTED: port=` gets the + // port. The full back-compat story requires the caller to ALSO learn the + // per-board path; see publishToDaemon docstring above. + console.error(`SERVE_STARTED: port=${ensured.port} html=${opts.html}`); console.log(JSON.stringify({ id: result.id, url: result.url, sourceDir: result.sourceDir }, null, 2)); openBrowser(result.url); // Short-lived publisher process exits; daemon keeps serving. diff --git a/design/src/daemon-client.ts b/design/src/daemon-client.ts index 427e81282..fefb8ad09 100644 --- a/design/src/daemon-client.ts +++ b/design/src/daemon-client.ts @@ -33,7 +33,6 @@ import { setTimeout as delay } from "timers/promises"; import { acquireLock, CMDLINE_MARKER, - DaemonState, healthCheck, isProcessAlive, readStateFile,