Skip to content

Align and style red's CLI output - #391

Merged
fcoury merged 6 commits into
mainfrom
fix/plugin-table-alignment
Oct 15, 2026
Merged

fcoury merged 6 commits into
mainfrom
fix/plugin-table-alignment

Conversation

@fcoury

@fcoury fcoury commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Gives red's non-editor commands consistent, readable terminal output, built on a new shared src/cli_style.rs module (table rendering, color helpers, closed-pipe-safe output).

  • red plugin catalog / red plugin list: aligned columns with a header row instead of tab-separated output that drifted on long ids. Bold names, cyan Official, green/red compatibility, dimmed host target.
  • red --check-config: colored error/warning, bold setting path, dimmed location and fallback; green ✓ for config ok.
  • red --agent-check: dimmed labels, green ready / red not ready.
  • red --runtime-files: aligned columns; files from your config dir or $RED_RUNTIME are highlighted and the embedded majority is dimmed, so overrides stand out.
  • red --self-check: plugin status colored by state.
  • Success messages (plugin install/update/enable/disable/remove, language trust/untrust/check-indent, --eject): green ✓ and bold subject.
  • Errors: bold red Error: when stderr is a terminal.
  • red plugin enable|disable <missing> now says the plugin is not installed instead of "failed to read install record".
  • Pipes: red plugin catalog | head exits with status 141 (SIGPIPE convention) instead of panicking.
  • Allowed the linker_messages lint to silence Apple ld's __eh_frame section too large note, which only affects unwind performance.

Plain output compatibility

Color is emitted only when the stream is a terminal and NO_COLOR is unset. Styling only wraps existing words in ANSI codes and never changes the text, because release CI and the updater match --self-check output verbatim (final line red self-check ok, unhealthy plugins detected via ^plugin .+: (pending|disabled|...)$). The plugin tables and --runtime-files did change layout from tab/fixed-gap separated to aligned columns, so scripts using cut -f on them would need awk.

Testing

  • cargo test -p red --lib: 2577 passed; cargo test -p red --bin red, --test self_check, --test agent_check pass
  • cargo clippy --all-targets -p red and cargo fmt --check clean
  • Replayed the release workflow's self-check assertions against piped NO_COLOR=1 output
  • For each changed command, captured output under a pseudo-terminal, stripped ANSI codes, and confirmed it is byte-identical to the piped output (aside from ✓ marks)
  • Exercised --check-config diagnostics and a user-overridden runtime plugin with a scratch XDG_CONFIG_HOME

Replace tab-separated rows, which drifted whenever a plugin id crossed
an 8-column tab stop, with a shared print_plugin_table helper that sizes
each column to its widest cell and adds an uppercase header row.
Extract onboarding's paint/color_enabled helpers into a cli_style module
and use them to style plugin catalog/list output: dim header, bold name,
cyan Official tier, green/red compatibility, dim host target with yellow
for unavailable. Widths are measured on plain text before painting, and
color is emitted only on a TTY without NO_COLOR, so piped output stays
plain and aligned.
Plugin table output now goes through a locked stdout handle that maps a
broken pipe (e.g. `red plugin catalog | head`) to exit status 141, the
conventional SIGPIPE status, instead of panicking. Allow the
linker_messages lint for the red package: Apple's ld reports the debug
binary's __eh_frame exceeding the 16MB compact unwind limit, which only
affects panic-unwind speed and cannot be avoided at this binary size.
Move the table renderer and the broken-pipe-safe writer into cli_style
and apply the same conventions across red's non-editor output:

- --check-config: colored severity, bold setting path, dimmed location
  and fallback; a green check on success
- --agent-check: dimmed labels, green/red readiness verdict
- --runtime-files: aligned columns, user and $RED_RUNTIME files
  highlighted, embedded files dimmed
- --self-check: status colored per plugin state
- plugin, language and --eject success messages get a green check and
  bold subject; Error: prefix is bold red when stderr is a terminal
- plugin enable/disable on a missing plugin reports it is not installed
  instead of failing to read its install record

Plain output keeps its exact text: release CI and the updater grep
--self-check lines, so color is only ever added around existing words
and only on a terminal without NO_COLOR.
@fcoury fcoury changed the title Align and style plugin CLI tables Align and style red's CLI output Oct 15, 2026
shared_session_lock_blocks_replacement assumed the update lock is free
immediately after the shared owner is dropped. flock locks belong to the
open file description, which a child forked by a concurrently running
test inherits until it execs, so the lock can stay held briefly. This
made the test fail intermittently on CI (including on main). A local
stress run reproduced it: re-locking right after release failed up to
14 of 3000 times while other threads spawned processes, and 0 of 9000
without them. Retry for up to five seconds instead.
@fcoury

fcoury commented Oct 15, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-15T03:55:45.329523Z 43a98f8 Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 43a98f8183

ℹ️ 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".

Comment thread src/cli_style.rs Resolved
A CJK or emoji cell occupies more terminal columns than it has chars,
so char counting let the aligned plugin and runtime-file columns drift.
Delegate cell measurement to unicode_utils::display_width.
@fcoury
fcoury merged commit 1783e93 into main Oct 15, 2026
20 checks passed
@fcoury
fcoury deleted the fix/plugin-table-alignment branch October 15, 2026 04:49
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