feat: add forceMaxWidth config override#501
Merged
Merged
Conversation
jarrodwatts
requested changes
Apr 29, 2026
jarrodwatts
left a comment
Owner
There was a problem hiding this comment.
Thanks for the focused report and implementation. I am holding this for changes before it can merge.
Required fixes:
- Remove all committed dist/ artifacts. This repo keeps PR review on source/tests/docs; CI builds dist after merge.
- Restore the existing showSessionName default coverage that was replaced in tests/config.test.js. Add forceMaxWidth tests as new coverage.
- Restore or preserve stderr-width fallback coverage in tests/render-width.test.js.
- Add coverage for forceMaxWidth with null/invalid maxWidth so the opt-in cannot accidentally erase detected width behavior.
This overlaps the active width-detection PRs (#510/#511), so keeping the diff source-only and narrowly tested matters here.
Contributor
Author
|
Updated.
Full test suite passes. |
Allow users to explicitly apply maxWidth even when terminal width detection returns a smaller value, which helps in subprocess-driven statusline environments on Linux. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Restore the replaced config and width-fallback coverage, add guardrails for invalid forceMaxWidth inputs, and drop generated dist changes from the PR so review stays source-focused. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
5cb9788 to
721cfba
Compare
jarrodwatts
approved these changes
May 6, 2026
jarrodwatts
left a comment
Owner
There was a problem hiding this comment.
Security, regression, and maintainability review passed after dist artifacts were removed and width fallback coverage was restored. The new forceMaxWidth option is opt-in and keeps default width behavior unchanged. Local validation: npm test passed with 518 passing, 1 skipped.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add an explicit
forceMaxWidthconfig option so users can tell claude-hud to usemaxWidtheven when a terminal width is detected.This fixes a real issue I hit on Linux when running claude-hud inside the Claude Code statusline environment: the HUD process saw a much smaller width than the actual visible terminal width, so long lines were unnecessarily truncated with
....With this change:
maxWidthstill works as a fallback by defaultforceMaxWidth: truewhen width detection is inaccurateProblem
On my Linux setup, Claude Code itself was displayed in a wide terminal, but the claude-hud subprocess only detected a narrow width. As a result, fields like:
were truncated even though there was enough visible horizontal space.
This was a width detection mismatch between the HUD subprocess and the actual terminal UI.
Solution
Introduce:
{ "maxWidth": 300, "forceMaxWidth": true }When
forceMaxWidthis enabled, claude-hud uses the configuredmaxWidthinstead of the detected terminal width.Why this approach
Test plan
forceMaxWidthis not setmaxWidthoverrides detected width whenforceMaxWidth: trueforceMaxWidth: trueforceMaxWidthvalues fall back tofalsenpm testExample
{ "lineLayout": "expanded", "maxWidth": 300, "forceMaxWidth": true }This resolved the truncation issue for me on Linux in Claude Code's statusline environment.
🤖 Generated with Claude Code