Skip to content

fix: keep restore TUI within terminal bounds (closes #125)#127

Merged
babarot merged 1 commit into
mainfrom
babarot/fix-restore-tui-small-window
May 30, 2026
Merged

fix: keep restore TUI within terminal bounds (closes #125)#127
babarot merged 1 commit into
mainfrom
babarot/fix-restore-tui-small-window

Conversation

@babarot

@babarot babarot commented May 30, 2026

Copy link
Copy Markdown
Owner

WHAT

Adjust the restore TUI to follow the actual terminal size on WindowSizeMsg. The list height now shrinks to fit, the help row is told the terminal width so bubbles can truncate it, and width-only resize messages no longer collapse the list.

WHY

Reported in #125: in small terminals the gomi --restore view broke. The list items were pushed off the top because the list kept its default 30-row height, and the short-help row overflowed the terminal width and wrapped mid-word.

The WindowSizeMsg handler in internal/ui/update.go only called m.list.SetWidth(msg.Width). The height was never updated and m.help.Width was left at 0, so the help model could not truncate its output.

A naive fix (always derive list height from msg.Height) introduces a regression: the confirm-view cancel paths in updateConfirmView send a synthetic tea.WindowSizeMsg{Width: m.list.Width()} with Height == 0, which would collapse the list to 1 row every time the user dismisses the confirm dialog. The fix therefore guards each dimension independently.

HOW

internal/ui/update.go: in the tea.WindowSizeMsg branch, update width and height only when the corresponding field is positive. The list is sized via SetWidth / SetHeight, reserving 3 rows and 4 columns for the help block that view.go renders below the list with lipgloss.Margin(1, 2). The reserved values are declared as named constants with a comment that points back to the layout in view.go so the magic numbers are traceable.

internal/ui/update_test.go: add regression tests covering the small-terminal scenarios. TestUpdate_WindowSizeMsg_ShrinksListHeight and TestUpdate_WindowSizeMsg_SetsHelpWidth assert the list and help shrink to fit. TestView_FitsSmallTerminal is an end-to-end check that Model.View() does not exceed the requested terminal width and height. TestUpdate_WindowSizeMsg_HeightZero guards against the confirm-cancel synthetic message: after a real resize, a width-only message must not change the list height.

The patch attached to #125 by @u1f992 was used as the starting point; the height-zero guard and accompanying test were added on top to avoid the confirm-cancel regression.

@babarot babarot force-pushed the babarot/fix-restore-tui-small-window branch from 8d2e542 to c8e386b Compare May 30, 2026 15:19
@github-actions

Copy link
Copy Markdown
Contributor

Code Metrics Report

main (4f189da) #127 (a6d1395) +/-
Coverage 71.2% 71.2% 0.0%
Code to Test Ratio 1:1.5 1:1.5 +0.0
Test Execution Time 28s 6s -22s
Details
  |                     | main (4f189da) | #127 (a6d1395) | +/-  |
  |---------------------|----------------|----------------|------|
  | Coverage            |          71.2% |          71.2% | 0.0% |
  |   Files             |             24 |             24 |    0 |
  |   Lines             |           1101 |           1101 |    0 |
  |   Covered           |            784 |            784 |    0 |
+ | Code to Test Ratio  |          1:1.5 |          1:1.5 | +0.0 |
  |   Code              |           2739 |           2739 |    0 |
+ |   Test              |           4216 |           4280 |  +64 |
+ | Test Execution Time |            28s |             6s | -22s |

Reported by octocov

@babarot babarot added the kind/improvement An improvement to existing functionality; not a new feature or bug fix label May 30, 2026
@babarot babarot marked this pull request as ready for review May 30, 2026 16:46
@babarot babarot merged commit 8c75e88 into main May 30, 2026
5 checks passed
@babarot babarot deleted the babarot/fix-restore-tui-small-window branch May 30, 2026 16:46
@github-actions github-actions Bot mentioned this pull request May 30, 2026
tmeijn pushed a commit to tmeijn/dotfiles that referenced this pull request Jun 10, 2026
This MR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [babarot/gomi](https://github.com/babarot/gomi) | patch | `v1.6.3` β†’ `v1.6.4` |

MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot).

**Proposed changes to behavior should be submitted there as MRs.**

---

### Release Notes

<details>
<summary>babarot/gomi (babarot/gomi)</summary>

### [`v1.6.4`](https://github.com/babarot/gomi/blob/HEAD/CHANGELOG.md#v164---2026-06-07)

[Compare Source](babarot/gomi@v1.6.3...v1.6.4)

##### Improvements

- fix: keep restore TUI within terminal bounds (closes [#&#8203;125](babarot/gomi#125)) by [@&#8203;babarot](https://github.com/babarot) in [#&#8203;127](babarot/gomi#127)
- Allow --prune to skip confirmation with -f by [@&#8203;babarot](https://github.com/babarot) in [#&#8203;129](babarot/gomi#129)

##### Refactorings

- Fix concurrency safety: eliminate global SelectionManager and add mutex to legacy Storage by [@&#8203;babarot](https://github.com/babarot) in [#&#8203;118](babarot/gomi#118)
- Refactor: extract Trash interface, move orphan logic, and DRY up XDG storage by [@&#8203;babarot](https://github.com/babarot) in [#&#8203;119](babarot/gomi#119)
- Refactor: decouple config, remove unused fields, and narrow UI dependencies by [@&#8203;babarot](https://github.com/babarot) in [#&#8203;120](babarot/gomi#120)
- Update architecture docs and rename manager variables to match Trash interface by [@&#8203;babarot](https://github.com/babarot) in [#&#8203;121](babarot/gomi#121)
- Fix fundamental design issues: circular references, untestable prompts, and implicit init() by [@&#8203;babarot](https://github.com/babarot) in [#&#8203;122](babarot/gomi#122)
- Reduce syscalls in gomi -b restore path by [@&#8203;babarot](https://github.com/babarot) in [#&#8203;123](babarot/gomi#123)

</details>

---

### Configuration

πŸ“… **Schedule**: (UTC)

- Branch creation
  - At any time (no schedule defined)
- Automerge
  - At any time (no schedule defined)

🚦 **Automerge**: Enabled.

β™» **Rebasing**: Whenever MR is behind base branch, or you tick the rebase/retry checkbox.

πŸ”• **Ignore**: Close this MR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Mend Renovate](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4xOTEuMiIsInVwZGF0ZWRJblZlciI6IjQzLjE5MS4yIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJSZW5vdmF0ZSBCb3QiLCJhdXRvbWF0aW9uOmJvdC1hdXRob3JlZCIsImRlcGVuZGVuY3ktdHlwZTo6cGF0Y2giXX0=-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/improvement An improvement to existing functionality; not a new feature or bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant