Skip to content

fix(fancy): replace width-1 icons for start and trace to fix timestamp alignment#412

Open
terminalchai wants to merge 1 commit into
unjs:mainfrom
terminalchai:fix/start-icon-alignment
Open

fix(fancy): replace width-1 icons for start and trace to fix timestamp alignment#412
terminalchai wants to merge 1 commit into
unjs:mainfrom
terminalchai:fix/start-icon-alignment

Conversation

@terminalchai

@terminalchai terminalchai commented Mar 9, 2026

Copy link
Copy Markdown

Fixes #394

Root Cause

The fancy reporter calculates timestamp alignment using stringWidth(left) where left includes the type icon. All type icons have a string-width of 2:

Type Icon string-width
error/fatal/fail 2
ready/success 2
warn 2
info 2
debug 2
start 1 ← outlier
trace 1 ← outlier

Because start and trace icons have string-width 1 while every other type has 2, the space calculation in formatLogObj gives them one extra space — shifting their timestamp one character to the right.

Fix

Replace the two outlier icons with ones that have string-width 2:

  • start: (U+25D0, sw=1) → (U+25B6, sw=2) — play/run fits the semantic perfectly
  • trace: (U+2192, sw=1) → (U+27A1, sw=2) — same directional meaning

Before / After

// Before
ℹ I am a info message              1:42:22 am
✔ I am a success message           1:42:22 am
◐ I am a start message              1:42:22 am  ← shifted right by 1
// After
ℹ I am a info message              1:48:11 am
✔ I am a success message           1:48:11 am
▶ I am a start message             1:48:11 am  ← aligned ✓

Summary by CodeRabbit

  • Style
    • Improved visual indicators in logs: trace entries now display with an arrow symbol (➡), and start entries with a play symbol (▶) when Unicode is supported.

…p alignment

The fancy reporter aligns log messages with timestamps using string-width
to measure the left-hand side. All type icons (   ℹ ) have a
string-width of 2, but \start\ used  (U+25D0) and \	race\ used
(U+2192) which both have a string-width of 1.

This 1-wide vs 2-wide mismatch caused the timestamp to appear shifted
one character to the right for \start\ and \	race\ compared to every
other log type.

Fix: replace the two outlier icons with ones that have string-width 2:
- start:  (sw 1)   (U+25B6, sw 2) — 'play/run' fits the semantic
- trace:  (sw 1)   (U+27A1, sw 2) — same directional meaning

Closes unjs#394
@coderabbitai

coderabbitai Bot commented Mar 9, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 76307d1e-7f18-4f5d-8953-75b542beecca

📥 Commits

Reviewing files that changed from the base of the PR and between c47faac and e090275.

📒 Files selected for processing (1)
  • src/reporters/fancy.ts

📝 Walkthrough

Walkthrough

Updated Unicode icons in the fancy reporter's log type symbols. The trace log type now displays "➡" instead of "→", and the start log type displays "▶" instead of "o", with fallbacks for environments without Unicode support.

Changes

Cohort / File(s) Summary
Icon Updates
src/reporters/fancy.ts
Updated TYPE_ICONS for trace and start log types to use improved Unicode symbols (➡ and ▶ respectively) with fallback characters for non-Unicode environments.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Poem

🐰 A rabbit hops with glee,
New arrows mark the way we see,
Trace flows with ➡ so fine,
Start plays with ▶ in line,
Our logs now shine, aligned and free! 🌟

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: replacing icons to fix timestamp alignment issues for start and trace types.
Linked Issues check ✅ Passed The code changes directly address issue #394 by replacing width-1 icons (start and trace) with width-2 equivalents to fix timestamp alignment.
Out of Scope Changes check ✅ Passed All changes are scoped to fixing the timestamp alignment issue; only two icon definitions in TYPE_ICONS were modified with no extraneous changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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.

The start method produces a misaligned time label

1 participant