Repository navigation
output: restrained colour on a terminal, plain bytes everywhere else - #33
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #26
Why
A little colour makes the table and the stop and doctor reports scannable. Scripts, pipes and agents must see exactly the bytes they see today.
What
internal/inspect/colour.goColorandColorErrswitches, one per stream.Markcolours a line's leading ✓ (green), ⚠ (yellow) or ✗ (red).·info stays plain.colourTabledims uptime, and dims the whole row of another user's listener.Wiring:
WriteTable, the stop/kill/free result lines instopAll(✓ to stdout; ✗ and skipped to stderr), thewait --goneline, and doctor findings.escapesWork(f)decides each stream for itself. Colour is off for:NO_COLOR;TERM=dumb;WT_SESSIONorTERM_PROGRAM, the same gate as table links.Table links now share this check, so they also turn off under
TERM=dumb.Untouched:
--json, the pickers (TableRows) and the header carry no colour.Docs: commands.mdx says when colour is on and off.
Not added: a
--color=always|neverflag. output: restrained colour, respecting NO_COLOR #26 asks for automatic detection only; a flag can follow if wanted.Evidence
TestPlainTableUnchangedcompares against fixed table text, and the same test passes against main;TestColourOnlyAddsEscapes: the coloured table with links on and an invalid-UTF-8 process name, stripped of SGR and OSC 8 codes, is byte-identical to the plain one.TestColourTable: only uptime is dimmed, the other-user row is dimmed whole, the header is plain;TestMark: each glyph, and each stream separately.TestColourrunsports doctoron a real PTY. It's coloured on a terminal, has no SGR withNO_COLOR=1, and no escape bytes through a pipe.portsandports doctorunderscript; the output is as described.webbuilds.internal/inspect/output.go. A fresh-context review gave SHIP WITH NITS; the second commit fixes them:·is no longer dimmed;NO_COLORdocs wording is corrected;Rollback
Revert the squash commit. No output format changes, and machine output is untouched.
Generated by Claude Code