Skip to content

CLI: Truncate cwd in welcome header on narrow terminals - #3134

Merged
youknowriad merged 1 commit into
trunkfrom
claude/eloquent-ride-bd2a9e
Apr 18, 2026
Merged

CLI: Truncate cwd in welcome header on narrow terminals#3134
youknowriad merged 1 commit into
trunkfrom
claude/eloquent-ride-bd2a9e

Conversation

@youknowriad

Copy link
Copy Markdown
Contributor

Related issues

  • Related to: small-terminal layout glitch in the AI chat CLI welcome screen.

How AI was used in this PR

The fix was implemented with Claude Code. The diff is small and self-contained — please verify the truncation thresholds and behavior in your own narrow terminal.

Proposed Changes

  • Measure the terminal width when rendering the welcome header in apps/cli/ai/ui.ts.
  • If the model · provider · cwd line doesn't fit next to the WordPress logo, truncate the cwd with a leading ellipsis (e.g. …orktrees/eloquent-ride-bd2a9e) so the meaningful suffix stays visible.
  • If even a short ellipsised path doesn't fit, drop the cwd entirely and show only model · provider.
  • The logo's max width is now derived from the strings rather than hardcoded, so it stays correct if the logo is ever changed.

Before this change, on a narrow terminal the cwd wrapped onto subsequent lines and visually broke the logo layout (see screenshot in the issue / discussion).

Testing Instructions

  1. npm run cli:build
  2. Resize your terminal to ~60–70 columns wide.
  3. Run node apps/cli/dist/cli/main.mjs (or whichever entrypoint launches the AI chat UI) from a directory with a long absolute path (e.g. a worktree under ~/Workspace/.../worktrees/long-name-xxxxx).
  4. Confirm the WordPress logo renders cleanly on the left and the cwd is shown with a leading ellipsis on the right.
  5. Resize the terminal wider — the full path should reappear once it fits.
  6. Resize very narrow — the path should drop entirely, leaving only model · provider.

Pre-merge Checklist

  • Have you checked for TypeScript, React or other console errors?
Avoid wrapping the welcome line and breaking the WordPress logo layout
when the terminal is too narrow. The cwd is shortened with a leading
ellipsis (preserving the meaningful suffix) and dropped entirely if
even that doesn't fit.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@youknowriad
youknowriad requested a review from mtias April 18, 2026 11:16
@youknowriad youknowriad self-assigned this Apr 18, 2026
@wpmobilebot

Copy link
Copy Markdown
Collaborator

📊 Performance Test Results

Comparing b41bded vs trunk

app-size

Metric trunk b41bded Diff Change
App Size (Mac) 1439.57 MB 1439.57 MB +0.00 MB ⚪ 0.0%

site-editor

Metric trunk b41bded Diff Change
load 1883 ms 1829 ms 54 ms 🟢 -2.9%

site-startup

Metric trunk b41bded Diff Change
siteCreation 8138 ms 9126 ms +988 ms 🔴 12.1%
siteStartup 4952 ms 4948 ms 4 ms ⚪ 0.0%

Results are median values from multiple test runs.

Legend: 🟢 Improvement (faster) | 🔴 Regression (slower) | ⚪ No change (<50ms diff)

@youknowriad
youknowriad merged commit 0bf74cc into trunk Apr 18, 2026
10 checks passed
@youknowriad
youknowriad deleted the claude/eloquent-ride-bd2a9e branch April 18, 2026 11:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants