diff options
| author | Paul Buetow <paul@buetow.org> | 2026-03-06 19:35:08 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-03-06 19:35:08 +0200 |
| commit | 013e46d7856a604d4890a880b8bbfb4b8c58202b (patch) | |
| tree | f8b100ccd04a30b212f0fe728c91736087c60fc1 /internal/tui/dashboard | |
| parent | 0b2d40cf7ff9b26bfd020488b537bdfdd6f852ae (diff) | |
feat(tui): add flamegraph click lineage undo and scope quit key
Diffstat (limited to 'internal/tui/dashboard')
| -rw-r--r-- | internal/tui/dashboard/model.go | 25 | ||||
| -rw-r--r-- | internal/tui/dashboard/model_test.go | 23 |
2 files changed, 47 insertions, 1 deletions
diff --git a/internal/tui/dashboard/model.go b/internal/tui/dashboard/model.go index aae98b1..fb509b0 100644 --- a/internal/tui/dashboard/model.go +++ b/internal/tui/dashboard/model.go @@ -214,7 +214,7 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { return m, nil } if m.activeTab == TabFlame { - next, cmd := m.flamegraphModel.Update(msg) + next, cmd := m.flamegraphModel.Update(translateFlamegraphMsg(msg)) m.flamegraphModel = next.(flamegraphtui.Model) return m, cmd } @@ -835,3 +835,26 @@ func flameViewport(width, height int, showHelp bool) (int, int) { } return width, height } + +func translateFlamegraphMsg(msg tea.Msg) tea.Msg { + switch mouse := msg.(type) { + case tea.MouseClickMsg: + m := mouse.Mouse() + m.Y -= dashboardTabBarRows + return tea.MouseClickMsg(m) + case tea.MouseReleaseMsg: + m := mouse.Mouse() + m.Y -= dashboardTabBarRows + return tea.MouseReleaseMsg(m) + case tea.MouseMotionMsg: + m := mouse.Mouse() + m.Y -= dashboardTabBarRows + return tea.MouseMotionMsg(m) + case tea.MouseWheelMsg: + m := mouse.Mouse() + m.Y -= dashboardTabBarRows + return tea.MouseWheelMsg(m) + default: + return msg + } +} diff --git a/internal/tui/dashboard/model_test.go b/internal/tui/dashboard/model_test.go index fafcad3..2e1ca17 100644 --- a/internal/tui/dashboard/model_test.go +++ b/internal/tui/dashboard/model_test.go @@ -810,3 +810,26 @@ func TestHelpToggleWithH(t *testing.T) { t.Fatalf("expected help hint after pressing h again") } } + +func TestTranslateFlamegraphMouseMsgOffsetsTabBarRow(t *testing.T) { + translated := translateFlamegraphMsg(tea.MouseClickMsg{ + X: 17, + Y: 9, + Button: tea.MouseLeft, + }) + click, ok := translated.(tea.MouseClickMsg) + if !ok { + t.Fatalf("expected translated message to stay mouse click, got %T", translated) + } + if click.X != 17 || click.Y != 8 { + t.Fatalf("expected click coordinates (17,8), got (%d,%d)", click.X, click.Y) + } +} + +func TestTranslateFlamegraphMsgLeavesNonMouseUnchanged(t *testing.T) { + msg := messages.StatsTickMsg{} + translated := translateFlamegraphMsg(msg) + if _, ok := translated.(messages.StatsTickMsg); !ok { + t.Fatalf("expected non-mouse message to remain unchanged, got %T", translated) + } +} |
