fix(ui): prevent error and modal overflow - #48
Merged
Merged
Conversation
Long errors used to be silently clipped to the modal's single-line slot, hiding the actionable tail (e.g. "No such file or directory (os error 2)" became "No such file"). Modals also assumed a generously sized terminal and broke their layout when shrunk. - Add `wrap_message` (cap at 3 lines, ellipsize) and `truncate_to_width` helpers in `ui/mod.rs`. Errors in add-repo, new-worktree, remove-worktree, and discovered-repos modals now wrap up to 3 lines with a " " continuation indent and grow the modal height to match. - Truncate long branch / repo / path strings in modal titles and the "Worktree:" / unmerged-branch warning lines so they can't eat borders. - Render a "Terminal too small" placeholder below 50x12 instead of letting the sidebar+main+modal layout collapse. - Promote sidebar's private `truncate` to the shared `truncate_to_width`. Co-Authored-By: Claude <noreply@anthropic.com>
# Conflicts: # src/ui/add_repo.rs
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
Long errors were silently clipped to the modal's single-line slot, hiding the actionable tail (e.g.
No such file or directory (os error 2)rendered as justNo such file). Modals also assumed a generously sized terminal and broke their layout when shrunk. This PR introduces shared wrap/truncate helpers and applies them across every modal that surfaces an error or a user-supplied path/branch/repo name.Changes
wrap_message(msg, width, max_lines)inui/mod.rshonors embedded\n(anyhow's{:#}formatting), word-wraps, hard-breaks paths longer than the line, and ellipsizes the last shown line when content gets dropped (cap: 3 lines). Used byadd_repo(both variants),confirm::render_remove_worktree, anddiscovered. Modal heights grow to match wrapped error length so we never push the slot past the border.!prefix.Worktree:line, and the unmerged-branch warning all runtruncate_to_widthagainst the available budget. Long branch names can no longer eat the closing border corner.ui::renderpaints a yellowTerminal too small (need at least 50×12)placeholder instead of letting the sidebar+main+modal layout collapse.truncatetopub fn truncate_to_widthinui/mod.rs; sidebar reuses it.Test plan
cargo test— 153 passed (12 new: wrap helpers + tiny-terminal guard + long-error wrap snapshot for AddRepo).cargo clippy --all-targets -- -D warningsclean.cargo fmt --all -- --checkclean.... No such file or directory (os error 2)wrapped onto two lines, with the modal height growing by one row.🤖 Generated with Claude Code