From 1151e5fcdc44ba770fd8404931f00cb718b31854 Mon Sep 17 00:00:00 2001 From: Amolith Date: Sun, 5 Apr 2026 19:58:16 -0600 Subject: [PATCH] Store window size during file picker loading phase --- internal/ui/screens/filepicker.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/internal/ui/screens/filepicker.go b/internal/ui/screens/filepicker.go index fa2d0dc150b0f4a804923682e422c3288181ba56..d03ad77be29a25b78eb794f62e38e7b43ddd8335 100644 --- a/internal/ui/screens/filepicker.go +++ b/internal/ui/screens/filepicker.go @@ -55,6 +55,9 @@ type FilePicker struct { // Notice phase. notice string + // Layout. + lastSize *tea.WindowSizeMsg + // Result. includes []string selection string @@ -97,6 +100,12 @@ func (fp *FilePicker) Init() tea.Cmd { // Update handles messages across all phases. func (fp *FilePicker) Update(msg tea.Msg) (ui.Screen, tea.Cmd) { + // Always capture the latest window size so it can be applied + // to the picker when it is built after loading completes. + if wsm, ok := msg.(tea.WindowSizeMsg); ok { + fp.lastSize = &wsm + } + switch msg := msg.(type) { case tea.KeyPressMsg: if msg.Code == tea.KeyEscape { @@ -199,12 +208,19 @@ func (fp *FilePicker) updateNotice(msg tea.Msg) (ui.Screen, tea.Cmd) { } // buildPicker constructs the picker model from the loaded nodes. +// If a WindowSizeMsg was received during loading, it is applied +// to the picker immediately so it has correct dimensions. func (fp *FilePicker) buildPicker(nodes []restic.LsNode) { sfs := restic.NewSnapshotFS(nodes) p := picker.New(sfs) p.Cursor = strings.TrimSuffix(theme.Cursor, " ") p.Styles = fp.styles.Picker fp.picker = &p + + if fp.lastSize != nil { + fp.picker.AutoHeight = false + fp.picker.SetHeight(max(1, fp.lastSize.Height)) + } } // resolveSelection reads the picker's selection state and converts