summaryrefslogtreecommitdiff
path: root/internal/tui/tui.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-02-25 08:55:58 +0200
committerPaul Buetow <paul@buetow.org>2026-02-25 08:55:58 +0200
commit22f1589e62aeafed805b8dd07d4610b7662f205e (patch)
tree1661bd680ccd0d969359c3f3cf3cbd3d8ec4a5a3 /internal/tui/tui.go
parentd423225771a10ebae87d22c69fe88e5b65a3d378 (diff)
Polish stream filter UX and expand TUI viewport
Diffstat (limited to 'internal/tui/tui.go')
-rw-r--r--internal/tui/tui.go26
1 files changed, 17 insertions, 9 deletions
diff --git a/internal/tui/tui.go b/internal/tui/tui.go
index 84d8cab..7e77a81 100644
--- a/internal/tui/tui.go
+++ b/internal/tui/tui.go
@@ -174,7 +174,7 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
if !m.exporter.Visible() && m.showHelp {
return m, nil
}
- if flags.Get().TUIExportEnable && m.screen == ScreenDashboard && !m.attaching && m.lastErr == nil && key.Matches(msg, m.keys.Export) && !m.exporter.Visible() {
+ if flags.Get().TUIExportEnable && m.screen == ScreenDashboard && !m.attaching && m.lastErr == nil && key.Matches(msg, m.keys.Export) && !m.exporter.Visible() && !m.dashboard.BlocksGlobalShortcuts() {
m.exporter = m.exporter.Open()
return m, nil
}
@@ -192,6 +192,7 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
return m.handlePidSelected(msg)
case TracingStartedMsg:
m.attaching = false
+ m.dashboard.SetStreamSource(getEventStreamSource())
return m, m.dashboard.Init()
case TracingErrorMsg:
m.attaching = false
@@ -289,32 +290,32 @@ func (m Model) View() string {
if m.attaching {
line := fmt.Sprintf("%s Attaching tracepoints...", m.spin.View())
- return ScreenStyle.Render(PanelStyle.Render(line))
+ return placeToViewport(m.width, m.height, ScreenStyle.Render(PanelStyle.Render(line)))
}
if m.lastErr != nil {
- return ScreenStyle.Render(ErrorStyle.Render(m.lastErr.Error()))
+ return placeToViewport(m.width, m.height, ScreenStyle.Render(ErrorStyle.Render(m.lastErr.Error())))
}
switch m.screen {
case ScreenPIDPicker:
base := m.pidPicker.View()
if m.exporter.Visible() {
- return m.exporter.View(m.width, m.height) + "\n" + base
+ return placeToViewport(m.width, m.height, m.exporter.View(m.width, m.height)+"\n"+base)
}
if m.showHelp {
- return renderHelpOverlay(m.width, m.height, [][]key.Binding{m.keys.PickerShortHelp()}) + "\n" + base
+ return placeToViewport(m.width, m.height, renderHelpOverlay(m.width, m.height, [][]key.Binding{m.keys.PickerShortHelp()})+"\n"+base)
}
- return base
+ return placeToViewport(m.width, m.height, base)
case ScreenDashboard:
base := m.dashboard.View()
if m.exporter.Visible() {
- return m.exporter.View(m.width, m.height) + "\n" + base
+ return placeToViewport(m.width, m.height, m.exporter.View(m.width, m.height)+"\n"+base)
}
if m.showHelp {
- return renderHelpOverlay(m.width, m.height, m.keys.DashboardFullHelp()) + "\n" + base
+ return placeToViewport(m.width, m.height, renderHelpOverlay(m.width, m.height, m.keys.DashboardFullHelp())+"\n"+base)
}
- return base
+ return placeToViewport(m.width, m.height, base)
default:
return ""
}
@@ -471,3 +472,10 @@ func renderHelpOverlay(width, height int, groups [][]key.Binding) string {
return lipgloss.Place(width, height, lipgloss.Center, lipgloss.Center, box)
}
+
+func placeToViewport(width, height int, content string) string {
+ if width <= 0 || height <= 0 {
+ return content
+ }
+ return lipgloss.Place(width, height, lipgloss.Left, lipgloss.Top, content)
+}