Skip to content

Refactor status command to use JSON protocol#191

Open
nsams wants to merge 2 commits into
mainfrom
claude/dazzling-dijkstra-byx4zc
Open

Refactor status command to use JSON protocol#191
nsams wants to merge 2 commits into
mainfrom
claude/dazzling-dijkstra-byx4zc

Conversation

@nsams

@nsams nsams commented Jun 16, 2026

Copy link
Copy Markdown
Member

mainly in preparation for #177, but imho generally a better idea to use a json protocol and render the table client side.

Description

The status command previously rendered tables directly in the daemon process and streamed the formatted output to the client. This approach mixed presentation logic with daemon logic and made it difficult to handle the status command differently from other commands.

This change separates concerns by:

  1. Moving table rendering logic from the daemon to the client command
  2. Having the daemon send structured JSON data instead of formatted text
  3. Extracting script status data collection into a reusable getScriptEntries() function
  4. Exporting a new ScriptStatusEntry interface for type safety

Additionally, the connect() function's default data handler is extracted into a new pipeToStdout() function, which is now explicitly called by commands that need it (logs, restart, shutdown, start, stop). This allows the status command to handle data differently without affecting other commands.

Benefits:

  • Cleaner separation between daemon and client concerns
  • Status command can now parse and render data on the client side
  • Easier to extend or modify status output formatting without touching daemon code
  • Other commands continue to work as before with explicit pipeToStdout() calls

https://claude.ai/code/session_01Atpc7SdHY1FwGiMUyjXAMB

Extracted from PR #177. The status daemon-command previously rendered a
cli-table3 table (with ANSI colors via log-update) directly into the
socket. Move that rendering to the CLI client: the daemon now emits a
newline-delimited JSON array of ScriptStatusEntry objects (or a JSON
error object), and the client parses each line and renders the table
locally, using log-update for the --interval refresh case.

Because connect() no longer auto-pipes socket data to stdout (the status
client needs to consume the data itself), pipeToStdout() is extracted as
an explicit helper that the start/stop/restart/logs/shutdown commands
call.
@nsams nsams requested a review from Fabian-Fynn June 16, 2026 18:30
@nsams nsams self-assigned this Jun 16, 2026
@nsams nsams marked this pull request as ready for review June 16, 2026 18:34
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.

2 participants