From 1d72e80ed340564c6c2d37366e20896aa00341e2 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Fri, 6 Mar 2026 16:38:41 +0200 Subject: refactor: use interfaces for TUI runtime binding sources (task 382) --- internal/tui/flamegraph/model.go | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'internal/tui/flamegraph') 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() -- cgit v1.2.3