Skip to content

feat(cli): give every preview lifecycle op one JSON document - #3309

Draft
miguel-heygen wants to merge 1 commit into
cli-preview-session-ownershipfrom
cli-preview-json-lifecycle
Draft

feat(cli): give every preview lifecycle op one JSON document#3309
miguel-heygen wants to merge 1 commit into
cli-preview-session-ownershipfrom
cli-preview-json-lifecycle

Conversation

@miguel-heygen

Copy link
Copy Markdown
Collaborator

--status, --stop, --list and --kill-all emit a schema-versioned envelope with an ok discriminant under --json, from one writer and one failure-payload builder. Human output is unchanged; the JSON path is additive.

{"schemaVersion":1,"operation":"status","ok":true,"result":{"state":"running","mode":"background","port":3002,"pid":1234,...}}
{"schemaVersion":1,"operation":"stop","ok":false,"error":{"code":"preview-stop-failed","message":"..."}}

Why the failure paths are the point

An agent that gets a bare error line on stderr and an empty stdout cannot tell a crash from a "not running". Every failure is a document too — including a missing project, which under --json resolves through the throwing resolver rather than the human-shaped nudge.

Verifying

Start a background preview, then run each of --status, --list, --stop with --json and pipe stdout through a JSON parser: one document each, with the matching operation and state.

Stack

Based on u4b-preview-session-ownership. Retarget to main before merging.

@miguel-heygen
miguel-heygen force-pushed the cli-preview-session-ownership branch from d982ef5 to f68c19a Compare August 18, 2026 05:24
`--status`, `--stop`, `--list` and `--kill-all` emit a schema-versioned
envelope with an `ok` discriminant under `--json`, from one writer and one
failure-payload builder. Human output is unchanged; the JSON path is additive.

The value is in the failure paths. An agent that gets a bare error line on
stderr and an empty stdout cannot tell a crash from a "not running", so every
failure is a document too — including a missing project, which under `--json`
resolves through the throwing resolver rather than the human-shaped nudge.
@miguel-heygen
miguel-heygen force-pushed the cli-preview-json-lifecycle branch from 3a42f81 to eea3af8 Compare August 18, 2026 05:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant