From 34935a159e66ee57f52f6fe1ee06fbabc2240a20 Mon Sep 17 00:00:00 2001 From: Ayman Bagabas Date: Thu, 17 Jul 2025 16:00:19 -0400 Subject: [PATCH 1/3] fix(tui): app: show error message when window is too small --- internal/tui/tui.go | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/internal/tui/tui.go b/internal/tui/tui.go index 811c18122687464d216e33f093aba60bbf5221c1..c231867f3c25dac1e888a2803bb82b521a9b0c70 100644 --- a/internal/tui/tui.go +++ b/internal/tui/tui.go @@ -109,6 +109,7 @@ func (a *appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) { } return a, tea.Batch(cmds...) case tea.WindowSizeMsg: + a.wWidth, a.wHeight = msg.Width, msg.Height a.completions.Update(msg) return a, a.handleWindowResize(msg.Width, msg.Height) @@ -269,7 +270,6 @@ func (a *appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) { // handleWindowResize processes window resize events and updates all components. func (a *appModel) handleWindowResize(width, height int) tea.Cmd { var cmds []tea.Cmd - a.wWidth, a.wHeight = width, height if a.showingFullHelp { height -= 5 } else { @@ -400,6 +400,26 @@ func (a *appModel) moveToPage(pageID page.PageID) tea.Cmd { // View renders the complete application interface including pages, dialogs, and overlays. func (a *appModel) View() tea.View { + var view tea.View + t := styles.CurrentTheme() + view.BackgroundColor = t.BgBase + if a.wWidth < 25 || a.wHeight < 15 { + view.Layer = lipgloss.NewCanvas( + lipgloss.NewLayer( + t.S().Base.Width(a.wWidth).Height(a.wHeight). + Align(lipgloss.Center, lipgloss.Center). + Render( + t.S().Base. + Padding(1, 2). + Background(t.BgSubtle). + Foreground(t.White). + Render("Too small!"), + ), + ), + ) + return view + } + page := a.pages[a.currentPage] if withHelp, ok := page.(core.KeyMapHelp); ok { a.status.SetKeyMap(withHelp.Help()) @@ -446,10 +466,7 @@ func (a *appModel) View() tea.View { layers..., ) - var view tea.View - t := styles.CurrentTheme() view.Layer = canvas - view.BackgroundColor = t.BgBase view.Cursor = cursor return view } From 199e315cf44095e466deafb6bb7fb3d37fa238b2 Mon Sep 17 00:00:00 2001 From: Christian Rocha Date: Tue, 22 Jul 2025 12:40:35 -0400 Subject: [PATCH 2/3] chore(tui): small window design adjustments --- internal/tui/tui.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/internal/tui/tui.go b/internal/tui/tui.go index c231867f3c25dac1e888a2803bb82b521a9b0c70..99b4151a4495f5fcf9d2d49c2c962a2a7f975733 100644 --- a/internal/tui/tui.go +++ b/internal/tui/tui.go @@ -410,9 +410,10 @@ func (a *appModel) View() tea.View { Align(lipgloss.Center, lipgloss.Center). Render( t.S().Base. - Padding(1, 2). - Background(t.BgSubtle). + Padding(1, 4). Foreground(t.White). + BorderStyle(lipgloss.RoundedBorder()). + BorderForeground(t.Primary). Render("Too small!"), ), ), From 9ce4fb6094bab32eacc09c93c08921a34aaa2d6d Mon Sep 17 00:00:00 2001 From: Christian Rocha Date: Tue, 22 Jul 2025 14:50:29 -0400 Subject: [PATCH 3/3] chore: be specific about what is too small --- internal/tui/tui.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/tui/tui.go b/internal/tui/tui.go index 99b4151a4495f5fcf9d2d49c2c962a2a7f975733..08f610bb584e679e8716a55aa9ffa379bc68ad56 100644 --- a/internal/tui/tui.go +++ b/internal/tui/tui.go @@ -414,7 +414,7 @@ func (a *appModel) View() tea.View { Foreground(t.White). BorderStyle(lipgloss.RoundedBorder()). BorderForeground(t.Primary). - Render("Too small!"), + Render("Window too small!"), ), ), )