Skip to content

Commit abc037b

Browse files
committed
fix(tui): resolve layout scrambling and search bugs
1 parent 1946d2d commit abc037b

File tree

2 files changed

+22
-8
lines changed

2 files changed

+22
-8
lines changed

internal/tui/model.go

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,11 +156,10 @@ func (m *Model) applyFilter() {
156156
if m.searchQuery != "" {
157157
query := strings.ToLower(m.searchQuery)
158158
name := strings.ToLower(r.Name)
159-
path := strings.ToLower(r.Path)
160159
branch := strings.ToLower(r.Status.Branch)
161160

161+
// Only search Name and Branch to avoid matching parent paths
162162
if !strings.Contains(name, query) &&
163-
!strings.Contains(path, query) &&
164163
!strings.Contains(branch, query) {
165164
continue
166165
}
@@ -276,3 +275,19 @@ func formatNumber(n int) string {
276275
}
277276
return fmt.Sprintf("%d", n)
278277
}
278+
279+
// resizeTable calculates and sets the correct table height based on UI state
280+
func (m *Model) resizeTable() {
281+
usedHeight := 12 // Header + Stats + Legend + Help + Padding
282+
if m.state == StateSearching {
283+
usedHeight += 3 // Search input
284+
} else if m.searchQuery != "" {
285+
usedHeight += 1 // Search badge
286+
}
287+
288+
h := m.height - usedHeight
289+
if h < 1 {
290+
h = 1
291+
}
292+
m.table.SetHeight(h)
293+
}

internal/tui/update.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,7 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
1616
case tea.WindowSizeMsg:
1717
m.width = msg.Width
1818
m.height = msg.Height
19-
// Adjust table height based on window size
20-
tableHeight := m.height - 12
21-
if tableHeight < 5 {
22-
tableHeight = 5
23-
}
24-
m.table.SetHeight(tableHeight)
19+
m.resizeTable()
2520

2621
case scanCompleteMsg:
2722
m.repos = msg.repos
@@ -67,6 +62,7 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
6762
// Enter search mode
6863
if m.state == StateReady {
6964
m.state = StateSearching
65+
m.resizeTable()
7066
m.textInput.Focus()
7167
m.textInput.SetValue(m.searchQuery)
7268
return m, textinput.Blink
@@ -142,6 +138,7 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
142138
if m.state == StateReady {
143139
m.searchQuery = ""
144140
m.filterMode = FilterAll
141+
m.resizeTable()
145142
m.updateTable()
146143
m.statusMsg = "Filters cleared"
147144
return m, nil
@@ -167,13 +164,15 @@ func (m Model) handleSearchMode(msg tea.KeyMsg) (tea.Model, tea.Cmd) {
167164
case "esc":
168165
// Cancel search, keep previous query
169166
m.state = StateReady
167+
m.resizeTable()
170168
m.textInput.Blur()
171169
return m, nil
172170

173171
case "enter":
174172
// Apply search
175173
m.searchQuery = m.textInput.Value()
176174
m.state = StateReady
175+
m.resizeTable()
177176
m.textInput.Blur()
178177
m.updateTable()
179178
if m.searchQuery != "" {

0 commit comments

Comments
 (0)