Skip to content

fix settings tui cutoff#409

Merged
SuperCoolPencil merged 4 commits intomainfrom
fix-settings-tui-cutoff
Apr 23, 2026
Merged

fix settings tui cutoff#409
SuperCoolPencil merged 4 commits intomainfrom
fix-settings-tui-cutoff

Conversation

@SuperCoolPencil
Copy link
Copy Markdown
Member

@SuperCoolPencil SuperCoolPencil commented Apr 23, 2026

  • refactor: introduce utility for text wrapping and replace manual truncation in TUI components
  • refactor: centralize string truncation logic into utils package and remove redundant local implementations

Greptile Summary

This PR centralizes text truncation and wrapping into internal/utils/text.go and replaces ad-hoc, byte-based truncation logic across several TUI components with the new runewidth-aware WrapText and Truncate helpers. The core utility implementation is correct — hard-wrap byte-slicing, empty-line preservation, and multi-byte/CJK handling all look sound — and the test suite covers the important edge cases.

Confidence Score: 5/5

Safe to merge; all remaining findings are cosmetic P2 suggestions.

The new utility functions are correct and well-tested. All truncation and wrapping call sites have been updated consistently. The one open comment (URL continuation-line indentation) is a visual imperfection, not a correctness issue.

internal/tui/components/add_download_modal.go — minor visual alignment issue with wrapped URL continuation lines.

Important Files Changed

Filename Overview
internal/utils/text.go New utility file centralizing WrapText, Truncate, and truncateMiddle — logic is correct, runewidth-aware, and handles multi-byte/CJK characters properly.
internal/utils/text_test.go Good coverage of happy-path and edge cases including width=1, hard-wrap mid-sentence, emoji/CJK, and truncateMiddle edge cases (limit 1/2/3).
internal/tui/components/add_download_modal.go Uses WrapText for URL display, but continuation lines after wrapping will not be indented to align with the "URL: " prefix.
internal/tui/components/confirmation_modal.go Refactored to renderBody(width) pattern; RenderWithBtopBox now correctly wraps to innerWidth; getDetailStyle() extracted to avoid duplication.
internal/tui/view.go renderFocusedDetails now uses WrapText+lipgloss.Top for multi-line values; local truncateString/truncateMiddle helpers removed; pre-truncation of Detail/URL removed in favour of component-level wrapping.
internal/tui/view_settings.go Settings list truncation now uses utils.Truncate; settings detail description now uses WrapText; formatSettingValue uses utils.Truncate properly.

Comments Outside Diff (1)

  1. internal/tui/helpers.go, line 42-44 (link)

    P2 Stale comment after wrapping strategy change

    The comment says "Lines wider than the viewport will be clipped during rendering," but the code now uses utils.WrapText so lines are wrapped, not clipped. The comment should be updated to reflect the new approach.

    Prompt To Fix With AI
    This is a comment left during a code review.
    Path: internal/tui/helpers.go
    Line: 42-44
    
    Comment:
    **Stale comment after wrapping strategy change**
    
    The comment says "Lines wider than the viewport will be clipped during rendering," but the code now uses `utils.WrapText` so lines are wrapped, not clipped. The comment should be updated to reflect the new approach.
    
    
    
    How can I resolve this? If you propose a fix, please make it concise.
Prompt To Fix All With AI
This is a comment left during a code review.
Path: internal/tui/components/add_download_modal.go
Line: 39-43

Comment:
**Wrapped URL continuation lines lack "URL: " indentation**

`WrapText` is called with `innerWidth-5` to reserve space for the `"URL: "` prefix, but that prefix is only prepended to the first line. Continuation lines start at column 0 with no indentation, so a wrapped URL renders like:

```
URL: https://very-long-url-
that-wraps-here
```

Consider rendering each wrapped line separately with the appropriate indentation on the first line and spaces on the rest, or omit the label from the wrap width calculation and let a style with `Width`/`MaxWidth` handle clipping.

How can I resolve this? If you propose a fix, please make it concise.

Reviews (2): Last reviewed commit: "refactor: consolidate text wrapping logi..." | Re-trigger Greptile

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 23, 2026

Binary Size Analysis

⚠️ Size Increased

Version Human Readable Raw Bytes
Main 19.19 MB 20119844
PR 19.21 MB 20144420
Difference 24.00 KB 24576

Comment thread internal/utils/text.go Outdated
Comment thread internal/tui/components/confirmation_modal.go Outdated
Comment thread internal/utils/text.go
Comment thread internal/utils/text_test.go
@SuperCoolPencil SuperCoolPencil merged commit 29fc556 into main Apr 23, 2026
16 checks passed
@SuperCoolPencil SuperCoolPencil deleted the fix-settings-tui-cutoff branch April 23, 2026 18: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