Skip to content

Commit 7dc7c55

Browse files
[CAP-9371] show loading spinner in content pane only, keeping header and footer visible (#315)
Previously, the loading spinner took over the entire screen (including header and footer), which created a jarring effect when navigating between models. Now, the loading spinner only uses the content pane, allowing the header and footer to remain in place during loading. This also allows the breadcrumbs (the header) to update and display immediately so users know what they're waiting for. GitOrigin-RevId: 23ce64fe1dabff6b612a6e0118333927613029bc
1 parent 3c9fbcb commit 7dc7c55

1 file changed

Lines changed: 21 additions & 7 deletions

File tree

pkg/tui/stack.go

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -244,19 +244,33 @@ func (m *StackModel) StackSizeMsg() StackSizeMsg {
244244
}
245245

246246
func (m *StackModel) View() string {
247+
if len(m.stack) == 0 {
248+
if m.loadingSpinner != nil {
249+
loadingTmpl := "%s Loading..."
250+
if m.loadingMsg != "" {
251+
loadingTmpl = m.loadingMsg
252+
}
253+
return lipgloss.Place(m.width, m.height, lipgloss.Center, lipgloss.Center, fmt.Sprintf(loadingTmpl, m.loadingSpinner.View()))
254+
}
255+
return ""
256+
}
257+
258+
header := m.header()
259+
footer := m.footer()
260+
261+
var content string
247262
if m.loadingSpinner != nil {
248263
loadingTmpl := "%s Loading..."
249264
if m.loadingMsg != "" {
250265
loadingTmpl = m.loadingMsg
251266
}
252-
return lipgloss.Place(m.width, m.height, lipgloss.Center, lipgloss.Center, fmt.Sprintf(loadingTmpl, m.loadingSpinner.View()))
253-
}
254-
255-
if len(m.stack) == 0 {
256-
return ""
267+
contentHeight := m.height - lipgloss.Height(header) - lipgloss.Height(footer)
268+
content = lipgloss.Place(m.width, contentHeight, lipgloss.Center, lipgloss.Center, fmt.Sprintf(loadingTmpl, m.loadingSpinner.View()))
269+
} else {
270+
content = m.stack[len(m.stack)-1].Model.View()
257271
}
258272

259-
return lipgloss.JoinVertical(lipgloss.Left, m.header(), m.stack[len(m.stack)-1].Model.View(), m.footer())
273+
return lipgloss.JoinVertical(lipgloss.Left, header, content, footer)
260274
}
261275

262276
func (m *StackModel) header() string {
@@ -293,7 +307,7 @@ func (m *StackModel) footer() string {
293307
commands = append(commands, prevCommand)
294308
}
295309

296-
if m.stack[len(m.stack)-1].Cmd != "" {
310+
if len(m.stack) > 0 && m.stack[len(m.stack)-1].Cmd != "" {
297311
commands = append(commands, saveToClipboard)
298312
}
299313

0 commit comments

Comments
 (0)