diff options
| author | Paul Buetow <paul@buetow.org> | 2026-02-24 10:35:13 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-02-24 10:35:13 +0200 |
| commit | a403ca152b6268eacf2804c2d857ead16af37ef3 (patch) | |
| tree | 6df1ebaa0e2a68f2dfc6c17b9987ae8fbff3129c /internal/tui/dashboard/model.go | |
| parent | 791c7aa9e573e80e90ba37e07c8791f280e74d9a (diff) | |
tui: address review feedback for dashboard and export
Diffstat (limited to 'internal/tui/dashboard/model.go')
| -rw-r--r-- | internal/tui/dashboard/model.go | 42 |
1 files changed, 36 insertions, 6 deletions
diff --git a/internal/tui/dashboard/model.go b/internal/tui/dashboard/model.go index 9c47f4b..8eb7619 100644 --- a/internal/tui/dashboard/model.go +++ b/internal/tui/dashboard/model.go @@ -75,6 +75,9 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { ) case messages.StatsTickMsg: m.latest = msg.Snap + m.syscallsOffset = clampOffset(m.syscallsOffset, m.maxSyscallsRows()) + m.filesOffset = clampOffset(m.filesOffset, m.maxFilesRows()) + m.processesOffset = clampOffset(m.processesOffset, m.maxProcessesRows()) return m, nil case tea.KeyMsg: return m.handleKey(msg) @@ -86,7 +89,9 @@ func (m Model) handleKey(msg tea.KeyMsg) (tea.Model, tea.Cmd) { if m.activeTab == TabSyscalls { switch msg.String() { case "down", "j": - m.syscallsOffset++ + if m.syscallsOffset < m.maxSyscallsRows()-1 { + m.syscallsOffset++ + } return m, nil case "up", "k": if m.syscallsOffset > 0 { @@ -98,7 +103,9 @@ func (m Model) handleKey(msg tea.KeyMsg) (tea.Model, tea.Cmd) { if m.activeTab == TabProcesses { switch msg.String() { case "down", "j": - m.processesOffset++ + if m.processesOffset < m.maxProcessesRows()-1 { + m.processesOffset++ + } return m, nil case "up", "k": if m.processesOffset > 0 { @@ -110,7 +117,9 @@ func (m Model) handleKey(msg tea.KeyMsg) (tea.Model, tea.Cmd) { if m.activeTab == TabFiles { switch msg.String() { case "down", "j": - m.filesOffset++ + if m.filesOffset < m.maxFilesRows()-1 { + m.filesOffset++ + } return m, nil case "up", "k": if m.filesOffset > 0 { @@ -137,10 +146,34 @@ func (m Model) handleKey(msg tea.KeyMsg) (tea.Model, tea.Cmd) { m.activeTab = TabLatency case key.Matches(msg, m.keys.Six): m.activeTab = TabGaps + case key.Matches(msg, m.keys.Refresh): + snap := m.snapshot() + return m, func() tea.Msg { return messages.StatsTickMsg{Snap: snap} } } return m, nil } +func (m Model) maxSyscallsRows() int { + if m.latest == nil { + return 0 + } + return m.latest.SyscallsCount() +} + +func (m Model) maxFilesRows() int { + if m.latest == nil { + return 0 + } + return m.latest.FilesCount() +} + +func (m Model) maxProcessesRows() int { + if m.latest == nil { + return 0 + } + return m.latest.ProcessesCount() +} + func (m Model) snapshot() *statsengine.Snapshot { if m.engine == nil { return nil @@ -171,9 +204,6 @@ func tickCmd(d time.Duration) tea.Cmd { } func renderActiveTab(tab Tab, snap *statsengine.Snapshot, width, height, syscallsOffset, filesOffset, processesOffset int) string { - _ = width - _ = height - if snap == nil { return common.PanelStyle.Render(tab.String() + ": waiting for stats...") } |
