diff options
| author | Paul Buetow <paul@buetow.org> | 2026-03-06 16:38:41 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-03-06 16:38:41 +0200 |
| commit | 1d72e80ed340564c6c2d37366e20896aa00341e2 (patch) | |
| tree | f59ece0abc4b8d7de77a8f8214e0c7392a6bf700 /internal/tui/flamegraph | |
| parent | 91c0d807274defe2bc62db773f2ac0695dbb91c5 (diff) | |
refactor: use interfaces for TUI runtime binding sources (task 382)
Diffstat (limited to 'internal/tui/flamegraph')
| -rw-r--r-- | internal/tui/flamegraph/model.go | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/internal/tui/flamegraph/model.go b/internal/tui/flamegraph/model.go index c4973fb..cc208ae 100644 --- a/internal/tui/flamegraph/model.go +++ b/internal/tui/flamegraph/model.go @@ -9,7 +9,6 @@ import ( "strings" "time" - coreflamegraph "ior/internal/flamegraph" common "ior/internal/tui/common" "charm.land/bubbles/v2/key" @@ -28,6 +27,17 @@ type animTickMsg struct{} const animFrameDuration = 33 * time.Millisecond +// LiveTrieSource is the minimal trie contract needed by the flamegraph TUI model. +type LiveTrieSource interface { + Fields() []string + CountField() string + Reconfigure([]string) error + SetCountField(string) error + Reset() + Version() uint64 + SnapshotJSON() ([]byte, uint64) +} + type zoomState struct { path string previousSelectedIdx int @@ -61,7 +71,7 @@ func defaultFlameKeyMap() flameKeyMap { // Model is the Bubble Tea model for the TUI flamegraph tab. type Model struct { - liveTrie *coreflamegraph.LiveTrie + liveTrie LiveTrieSource lastVersion uint64 snapshot *snapshotNode globalTotal uint64 @@ -113,7 +123,7 @@ type tuiFrame struct { } // NewModel constructs a flamegraph tab model with default state. -func NewModel(liveTrie *coreflamegraph.LiveTrie) Model { +func NewModel(liveTrie LiveTrieSource) Model { searchInput := textinput.New() searchInput.Prompt = "/" searchInput.CharLimit = 0 @@ -316,7 +326,7 @@ func (m Model) View() tea.View { } // SetLiveTrie updates the data source used by the flamegraph model. -func (m *Model) SetLiveTrie(liveTrie *coreflamegraph.LiveTrie) { +func (m *Model) SetLiveTrie(liveTrie LiveTrieSource) { m.liveTrie = liveTrie m.syncFieldPresetToTrie() m.syncCountFieldToTrie() |
