feat(cli): readable go-code startup output - #1414
Conversation
Starting go-code printed 13 lines in which the one that mattered was indistinguishable from the twelve that did not. The wrapper's messages, harnessd's boot log, and a fatal error all shared one visual channel, so the actionable line sat buried in the middle with no more emphasis than "delayed callbacks enabled". Severity now carries color: cyan for the wrapper's prefix, yellow for warnings, red for errors. The WARN:/ERROR: words stay in the text, so severity survives a monochrome terminal, a pipe, a captured log, and colorblind readers. Only the 8 standard ANSI colors are used, so terminals apply their own theme. A wrapper-started harnessd now writes to a log file instead of inheriting the terminal. A healthy start reports readiness and the log path in a few lines rather than a boot dump, and no daemon line can scribble into the TUI after handoff. Because capturing output would otherwise trade noise for silence, a failed start prints the log back with the fatal line emphasized and the rest dimmed. Color is detected once at startup rather than inside the style helper: the helper runs in command substitution, where stdout is a pipe, so a lazy `-t 1` check would leave stdout permanently uncolored. Closes #1413 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WJGxhoFhA8JjkwZFcLGdS5
…avior Records the -t 1 inside command substitution gotcha in the engineering log: the check has to run once at startup, because $( ) redirects stdout to a pipe, so a lazy check leaves stdout permanently uncolored. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WJGxhoFhA8JjkwZFcLGdS5
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e00b1359e1
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| @@ -1,5 +1,42 @@ | |||
| # Engineering Log | |||
|
|
|||
| ## 2026-09-08 — Issue #1413 readable go-code startup output | |||
There was a problem hiding this comment.
Record the issue success criteria in the intent log
This adds the implementation record for issue #1413, but the reviewed tree's docs/logs/long-term-thinking-log.md contains no #1413 entry. Consequently future agents have no required command intent, user intent, or success definition against which to evaluate follow-up work; add the issue's criteria there as required.
AGENTS.md reference: AGENTS.md:L19-L23
Useful? React with 👍 / 👎.
| @@ -1,5 +1,42 @@ | |||
| # Engineering Log | |||
|
|
|||
| ## 2026-09-08 — Issue #1413 readable go-code startup output | |||
There was a problem hiding this comment.
Update the logs index for the new entry
Adding issue #1413 as the newest engineering-log entry materially changes that file, but docs/logs/INDEX.md is unchanged and still describes engineering-log.md as current for issue #1264. Update the folder index so repository navigation reflects the newly documented work.
AGENTS.md reference: AGENTS.md:L55-L56
Useful? React with 👍 / 👎.
| HARNESSD_LOG="${tmpdir%/}/harnessd.${$}.log" | ||
| ( umask 077; : > "$HARNESSD_LOG" ) |
There was a problem hiding this comment.
Allocate the daemon log with a unique filename
When a daemon started with go-code --server outlives its short-lived wrapper and that wrapper PID is later reused for another invocation on a different port, this $$-derived path collides with the live daemon's log. The subsequent : > "$HARNESSD_LOG" truncates the inode still held by the first daemon, after which both daemons can write overlapping diagnostics; predictable creation in shared /tmp also permits pre-created-file or symlink hazards on platforms without protected-temp semantics. Allocate the path atomically with a genuinely unique file instead.
Useful? React with 👍 / 👎.
Closes #1413
The problem
Starting
go-codeprinted 13 lines in which the one that mattered was indistinguishable from the twelve that did not:Three voices — the wrapper, the daemon's boot log, a fatal error — sharing one visual channel. The actionable
fatal:line sits in the middle with no more emphasis thandelayed callbacks enabled. On success the same boot dump is pure noise in front of someone who asked for a TUI, and because the daemon inherited stdout, a log line emitted after handoff could render into the interface.What changed
Severity carries color. Cyan prefix for info, yellow for warnings, red for errors. The
WARN:/ERROR:words stay in the text, so severity survives a monochrome terminal, a pipe, a captured log, and colorblind readers. Only the 8 standard ANSI colors are used, so terminals apply their own theme rather than a hardcoded shade that can vanish on a light background.The daemon writes to a log file (
${TMPDIR:-/tmp}/harnessd.<pid>.log,umask 077) instead of inheriting the terminal. A healthy start reports readiness and the log path; no daemon line can reach the TUI after handoff.A failed start prints the log back. Capturing output without surfacing it would trade noise for silence, so
dieshows the last 20 lines underharnessd said:withfatal:/panic:/refusing to startin bold red and the rest dimmed.Result
Success, 13 lines down to 4:
Failure, cause no longer buried:
Verification
TestGoCodeScriptSurfacesHarnessdLogOnStartupFailurewas genuinely red first. Redirection landed before surfacing, and the test caught exactly the trap that creates — the wrapper still claimed "See the harnessd log above" while the log was now in a file:TestGoCodeScriptEmitsNoAnsiWhenNotATty(no tty,NO_COLOR=1,TERM=dumb) is a regression guard, not red-first — it cannot fail before the feature exists, and it is labelled that way in the source rather than presented as TDD.All five wrapper tests green under
-race. Bench smoke 13/13 PASS, proving the sibling scripts and the daemon's own logging are untouched.Rendered output was inspected in a real pty for all four states — success, failure, piped,
NO_COLOR. That inspection is what caught a bug the test suite could not: color detection was originally lazy inside thestylehelper, butstyleruns in command substitution, where$( )redirects stdout to a pipe.[[ -t 1 ]]was therefore always false and stdout was never colored, while stderr colored correctly because$( )leaves fd 2 alone. Detection now happens once at startup. The gotcha is recorded in the engineering log.go-code runs | catyields zero escape sequences.Out of scope
Colorizing
harnessd's own Gologoutput. That stream feeds systemd journals, CI logs,macapp, and the benchmark scripts, and should not be restyled to serve one wrapper's presentation.🤖 Generated with Claude Code
https://claude.ai/code/session_01WJGxhoFhA8JjkwZFcLGdS5