summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--internal/tui/dashboard/model.go22
-rw-r--r--internal/tui/dashboard/tabregistry.go25
2 files changed, 21 insertions, 26 deletions
diff --git a/internal/tui/dashboard/model.go b/internal/tui/dashboard/model.go
index 2104cb6..1c6f66c 100644
--- a/internal/tui/dashboard/model.go
+++ b/internal/tui/dashboard/model.go
@@ -173,7 +173,9 @@ func (m Model) Init() tea.Cmd {
cmds := []tea.Cmd{tickCmd(m.refreshEvery)}
d := lookupTab(m.activeTab)
if d.InitCmd != nil {
- cmds = append(cmds, d.InitCmd())
+ // Pass the model so the closure can read fastRefreshEvery and use
+ // the configured cadence rather than falling back to a constant.
+ cmds = append(cmds, d.InitCmd(&m))
} else if m.bubbleEnabledForTab(m.activeTab) {
cmds = append(cmds, bubbleTickCmdFn())
}
@@ -791,7 +793,9 @@ func (m Model) postKeyTransitionCmd(prevActiveTab Tab, cmd tea.Cmd) tea.Cmd {
if prevActiveTab != m.activeTab {
d := lookupTab(m.activeTab)
if d.InitCmd != nil {
- cmds = append(cmds, d.InitCmd())
+ // Pass the model so the closure reads fastRefreshEvery and honours
+ // the configured cadence from the first tick after a tab switch.
+ cmds = append(cmds, d.InitCmd(&m))
} else if m.bubbleEnabledForTab(m.activeTab) {
cmds = append(cmds, bubbleTickCmdFn())
}
@@ -1530,20 +1534,6 @@ func (m Model) flameTickCmd() tea.Cmd {
return tea.Tick(d, func(time.Time) tea.Msg { return flameTickMsg{} })
}
-// streamTickCmdFn is a package-level adapter used by the tab registry's InitCmd
-// field. It uses the constant cadence and is replaced on subsequent ticks by
-// the model-method version that respects fastRefreshEvery.
-func streamTickCmdFn() tea.Cmd {
- return tea.Tick(streamRefreshMs*time.Millisecond, func(time.Time) tea.Msg { return streamTickMsg{} })
-}
-
-// flameTickCmdFn is a package-level adapter used by the tab registry's InitCmd
-// field. It uses the constant cadence and is replaced on subsequent ticks by
-// the model-method version that respects fastRefreshEvery.
-func flameTickCmdFn() tea.Cmd {
- return tea.Tick(flameRefreshMs*time.Millisecond, func(time.Time) tea.Msg { return flameTickMsg{} })
-}
-
func bubbleTickCmdFn() tea.Cmd {
return tea.Tick(bubbleRefreshMs*time.Millisecond, func(time.Time) tea.Msg { return bubbleTickMsg{} })
}
diff --git a/internal/tui/dashboard/tabregistry.go b/internal/tui/dashboard/tabregistry.go
index 801ecab..76fa216 100644
--- a/internal/tui/dashboard/tabregistry.go
+++ b/internal/tui/dashboard/tabregistry.go
@@ -40,8 +40,9 @@ type tabDescriptor struct {
// InitCmd is an optional extra Bubble Tea command to start alongside the
// global refresh tick when this tab is the active tab on Init. Tabs that
// need their own high-frequency tick (stream, flame) set this; others leave
- // it nil.
- InitCmd func() tea.Cmd
+ // it nil. The model is passed so the closure can use the configured
+ // fastRefreshEvery interval rather than a hardcoded constant.
+ InitCmd func(*Model) tea.Cmd
// Render draws the tab body. Nil means the tab has no registered renderer
// (used for tabs that handle rendering via other paths).
Render tabRenderFn
@@ -64,10 +65,12 @@ var tabDescriptors = map[Tab]tabDescriptor{
ShortName: "Flm",
Position: 10,
AllowedVizModes: []tabVizMode{tabVizModeTable},
- InitCmd: flameTickCmdFn,
- Render: tabRenderFlame,
- HandleScroll: nil,
- ShortcutKey: func(k common.KeyMap) key.Binding { return k.One },
+ // Use the model method so the configured fastRefreshEvery interval
+ // is honoured on the very first tick, not just on subsequent ticks.
+ InitCmd: func(m *Model) tea.Cmd { return m.flameTickCmd() },
+ Render: tabRenderFlame,
+ HandleScroll: nil,
+ ShortcutKey: func(k common.KeyMap) key.Binding { return k.One },
},
TabOverview: {
Name: "Overview",
@@ -119,10 +122,12 @@ var tabDescriptors = map[Tab]tabDescriptor{
ShortName: "Str",
Position: 70,
AllowedVizModes: []tabVizMode{tabVizModeTable},
- InitCmd: streamTickCmdFn,
- Render: tabRenderStream,
- HandleScroll: tabScrollStream,
- ShortcutKey: func(k common.KeyMap) key.Binding { return k.Seven },
+ // Use the model method so the configured fastRefreshEvery interval
+ // is honoured on the very first tick, not just on subsequent ticks.
+ InitCmd: func(m *Model) tea.Cmd { return m.streamTickCmd() },
+ Render: tabRenderStream,
+ HandleScroll: tabScrollStream,
+ ShortcutKey: func(k common.KeyMap) key.Binding { return k.Seven },
},
}