summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-03-05 22:21:43 +0200
committerPaul Buetow <paul@buetow.org>2026-03-05 22:21:43 +0200
commitb92fd0618d81b7a7cc53059e601b86a76d7ed2a2 (patch)
treefcfb6cdadae74f3ccab4a981f24263a2708223ba
parent501f514b1a357d695def12e262131d9f49a6c480 (diff)
task 352: wire LiveTrie into TUI runtime bindings
-rw-r--r--internal/tui/tui.go15
-rw-r--r--internal/tui/tui_test.go15
2 files changed, 30 insertions, 0 deletions
diff --git a/internal/tui/tui.go b/internal/tui/tui.go
index f4e45a1..cc627da 100644
--- a/internal/tui/tui.go
+++ b/internal/tui/tui.go
@@ -6,6 +6,7 @@ import (
"errors"
"fmt"
"ior/internal/flags"
+ coreflamegraph "ior/internal/flamegraph"
"ior/internal/probemanager"
"ior/internal/statsengine"
common "ior/internal/tui/common"
@@ -58,6 +59,7 @@ type ProbeManager interface {
type TraceRuntimeBindings interface {
SetDashboardSnapshotSource(source SnapshotSource)
SetEventStreamSource(source *eventstream.RingBuffer)
+ SetLiveTrie(liveTrie *coreflamegraph.LiveTrie)
SetProbeManager(manager ProbeManager)
}
@@ -68,6 +70,7 @@ type runtimeBindings struct {
snapshotSource SnapshotSource
streamSource *eventstream.RingBuffer
+ liveTrieSource *coreflamegraph.LiveTrie
probeManager ProbeManager
}
@@ -87,6 +90,12 @@ func (r *runtimeBindings) SetEventStreamSource(source *eventstream.RingBuffer) {
r.mu.Unlock()
}
+func (r *runtimeBindings) SetLiveTrie(liveTrie *coreflamegraph.LiveTrie) {
+ r.mu.Lock()
+ r.liveTrieSource = liveTrie
+ r.mu.Unlock()
+}
+
func (r *runtimeBindings) SetProbeManager(manager ProbeManager) {
r.mu.Lock()
r.probeManager = manager
@@ -105,6 +114,12 @@ func (r *runtimeBindings) eventStreamSource() *eventstream.RingBuffer {
return r.streamSource
}
+func (r *runtimeBindings) liveTrie() *coreflamegraph.LiveTrie {
+ r.mu.RLock()
+ defer r.mu.RUnlock()
+ return r.liveTrieSource
+}
+
func (r *runtimeBindings) currentProbeManager() ProbeManager {
r.mu.RLock()
defer r.mu.RUnlock()
diff --git a/internal/tui/tui_test.go b/internal/tui/tui_test.go
index 610461d..c801b24 100644
--- a/internal/tui/tui_test.go
+++ b/internal/tui/tui_test.go
@@ -3,6 +3,7 @@ package tui
import (
"context"
"errors"
+ coreflamegraph "ior/internal/flamegraph"
"ior/internal/probemanager"
"ior/internal/statsengine"
dashboardui "ior/internal/tui/dashboard"
@@ -220,6 +221,20 @@ func TestDashboardRefreshPicksLateBoundSource(t *testing.T) {
}
}
+func TestRuntimeBindingsStoreAndExposeLiveTrie(t *testing.T) {
+ runtime := newRuntimeBindings()
+ trie := coreflamegraph.NewLiveTrie([]string{"comm", "path"}, "count")
+ runtime.SetLiveTrie(trie)
+ if got := runtime.liveTrie(); got != trie {
+ t.Fatalf("expected live trie to be stored and returned")
+ }
+
+ runtime.SetLiveTrie(nil)
+ if got := runtime.liveTrie(); got != nil {
+ t.Fatalf("expected live trie to clear on nil assignment")
+ }
+}
+
func TestProbeToggledMsgResetsDashboardStatsSource(t *testing.T) {
src := &fakeResettableDashboardSource{snap: &statsengine.Snapshot{TotalSyscalls: 99}}