Skip to content

feat: cap markdown render width on wide terminals + add --width flag#119

Merged
steipete merged 2 commits intosteipete:mainfrom
howardpen9:fix/width-flag
Mar 7, 2026
Merged

feat: cap markdown render width on wide terminals + add --width flag#119
steipete merged 2 commits intosteipete:mainfrom
howardpen9:fix/width-flag

Conversation

@howardpen9
Copy link
Contributor

Summary

Fixes #101 — wide terminals make summaries tough to read because lines stretch across the full terminal width.

  • Cap default render width at 120 columns: markdownRenderWidth() now applies Math.min(w - 1, 120), so text stays readable even on very wide terminals. This is the default behavior with no flags needed.
  • Add --width <columns> CLI flag: Users can explicitly override the render width if they prefer a different value (e.g., --width 80 for narrow output, or --width 200 to use the full width).
  • The --width flag works by injecting the value into env.COLUMNS, which flows through the existing terminalWidth()markdownRenderWidth() pipeline — all 7 call sites automatically get the override with zero changes needed.

Implementation

File Change
src/run/terminal.ts markdownRenderWidth() caps at DEFAULT_MAX_RENDER_WIDTH (120)
src/run/help.ts New --width <columns> CLI option
src/run/runner.ts Parse --width, validate ≥ 20, inject into env.COLUMNS
tests/terminal.test.ts 3 new test cases for wide terminal capping

Test plan

  • vitest run tests/terminal.test.ts — all 7 tests pass (3 new)
  • tsc -p tsconfig.build.json --noEmit — clean
  • Manual: summarize "https://example.com" on a wide terminal → verify lines cap at ~120 chars
  • Manual: summarize "https://example.com" --width 80 → verify narrower output
  • Manual: summarize "https://example.com" --width 200 → verify wider output (up to 200)

🤖 Generated with Claude Code

howardpen9 and others added 2 commits March 7, 2026 15:23
On wide terminals (>120 columns), the rendered summary becomes hard to
read because lines stretch across the full width. Cap the default
markdown render width at 120 columns for better readability.

Add a --width <columns> CLI flag to let users explicitly override the
terminal width used for markdown rendering.

Fixes steipete#101

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@steipete steipete merged commit 000b8f9 into steipete:main Mar 7, 2026
1 check passed
@steipete
Copy link
Owner

steipete commented Mar 7, 2026

Landed via temp rebase onto main.

  • Gate: pnpm -s build && pnpm -s lint && pnpm -s test
  • Land commit: fb4e334
  • Merge commit: 000b8f9

Thanks @howardpen9!

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.

Wide terminals make summary tough to read

2 participants