Skip to content

fix: keep chalk's colour output in nested and multi-line text - #353

Merged
finalerock44 merged 1 commit into
devfrom
fix/styling-chalk-parity
Nov 23, 2026
Merged

finalerock44 merged 1 commit into
devfrom
fix/styling-chalk-parity

Conversation

@finalerock44

Copy link
Copy Markdown
Contributor

util.styleText's output differs across the runtimes the CLI ships on. bun 1.3, which compiles the standalone binaries, and Node before 22.20 drop the outer colour after a nested span, so in dcd live the text after a highlighted command lost its dim. No runtime closes and re-opens colour around line breaks, as chalk did, and an empty string came back as a pair of escape codes.

style() now builds the escape codes from util.inspect.colors, the table styleText reads, and applies chalk's rules itself: an inner span that ends the colour re-opens it, each line break is closed and re-opened, and an empty string stays empty. Output is now byte-identical to the chalk-based CLI on every supported runtime.

What & why

Type of change

  • fix — bug fix
  • feat — new feature
  • perf — performance improvement
  • refactor — code change that's neither a fix nor a feature
  • docs — documentation only
  • chore / ci / build / test — tooling, no user-facing change
  • Breaking change (title has ! or PR notes a BREAKING CHANGE:)

Checklist

  • PR title follows the Conventional Commits format (see comment above)
  • pnpm lint passes
  • pnpm typecheck passes
  • pnpm build passes
  • I have not bumped the version or edited CHANGELOG.md (the release workflow handles this)
  • I have signed the CLA (the bot will prompt on first contribution)
  • Docs / README.md / STYLE_GUIDE.md updated if behaviour or output changed

How to test

util.styleText's output differs across the runtimes the CLI ships on.
bun 1.3, which compiles the standalone binaries, and Node before 22.20
drop the outer colour after a nested span, so in `dcd live` the text
after a highlighted command lost its dim. No runtime closes and
re-opens colour around line breaks, as chalk did, and an empty string
came back as a pair of escape codes.

style() now builds the escape codes from util.inspect.colors, the table
styleText reads, and applies chalk's rules itself: an inner span that
ends the colour re-opens it, each line break is closed and re-opened,
and an empty string stays empty. Output is now byte-identical to the
chalk-based CLI on every supported runtime.
@finalerock44 finalerock44 self-assigned this Nov 23, 2026
@claude

claude Bot commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

🤖 Generated with Claude Code

@finalerock44
finalerock44 merged commit bb273f0 into dev Nov 23, 2026
9 checks passed
@finalerock44
finalerock44 deleted the fix/styling-chalk-parity branch November 23, 2026 17:07
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