diff options
| author | Paul Buetow <paul@buetow.org> | 2026-03-06 08:02:58 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-03-06 08:02:58 +0200 |
| commit | c6ec3b3ee34c9e77daa7159e8c164e413c2101b5 (patch) | |
| tree | 0b7bba3228caddbdc24614c1734560a64dcd7770 /internal/tui/flamegraph/model.go | |
| parent | 1955effb0daa5269d1b4069f3fb5175dbc29793f (diff) | |
Improve flamegraph selection, filter, and zoom feedback
Diffstat (limited to 'internal/tui/flamegraph/model.go')
| -rw-r--r-- | internal/tui/flamegraph/model.go | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/internal/tui/flamegraph/model.go b/internal/tui/flamegraph/model.go index bbf4af3..4453452 100644 --- a/internal/tui/flamegraph/model.go +++ b/internal/tui/flamegraph/model.go @@ -353,12 +353,18 @@ func (m *Model) rebuildFrames(animate bool) { func (m *Model) zoomIn() { if len(m.frames) == 0 || m.snapshot == nil { + m.statusMessage = "Zoom unavailable: no frame selected" return } m.clampSelection() selectedPath := m.frames[m.selectedIdx].Path + if selectedPath == m.currentRootPath() { + m.statusMessage = "Zoom unchanged: selected frame is current view root" + return + } target := findNodeByPath(m.snapshot, selectedPath) if target == nil { + m.statusMessage = "Zoom failed: selected node is unavailable" return } m.zoomStack = append(m.zoomStack, zoomState{ @@ -369,10 +375,12 @@ func (m *Model) zoomIn() { m.zoomPath = selectedPath m.selectedIdx = 0 m.rebuildFrames(true) + m.statusMessage = "Zoom: " + compactFramePath(selectedPath) } func (m *Model) zoomUndo() { if len(m.zoomStack) == 0 || m.snapshot == nil { + m.statusMessage = "Zoom undo unavailable" return } last := m.zoomStack[len(m.zoomStack)-1] @@ -385,16 +393,23 @@ func (m *Model) zoomUndo() { } m.selectedIdx = last.previousSelectedIdx m.rebuildFrames(true) + if m.zoomPath == "" { + m.statusMessage = "Zoom: root" + return + } + m.statusMessage = "Zoom: " + compactFramePath(m.zoomPath) } func (m *Model) zoomReset() { if m.zoomRoot == nil && len(m.zoomStack) == 0 { + m.statusMessage = "Zoom already at root" return } m.zoomRoot = nil m.zoomPath = "" m.zoomStack = nil m.rebuildFrames(false) + m.statusMessage = "Zoom reset to root" } func (m *Model) moveVertical(delta int) { @@ -492,3 +507,13 @@ func abs(v int) int { func animTickCmd() tea.Cmd { return tea.Tick(animFrameDuration, func(time.Time) tea.Msg { return animTickMsg{} }) } + +func (m Model) currentRootPath() string { + if m.zoomPath != "" { + return m.zoomPath + } + if len(m.frames) == 0 { + return "" + } + return m.frames[0].Path +} |
