diff options
| author | Paul Buetow <paul@buetow.org> | 2026-05-14 08:27:02 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-05-14 08:27:02 +0300 |
| commit | 2bd75e2218cbc1544a8e4da374805a9853aeb385 (patch) | |
| tree | 46ab201f74322f8a7f307e046db92da3f538aee4 /internal/tui/dashboard/tabregistry.go | |
| parent | 17beb6ba6a739f7323288aeae673dd43f7ee50e5 (diff) | |
use configurable fastRefreshEvery for InitCmd on flame and stream tabs
Change tabDescriptor.InitCmd from func() tea.Cmd to func(*Model) tea.Cmd
so the initial tick for the flame and stream tabs uses the model's
fastRefreshEvery interval rather than hardcoded 200 ms constants.
Both call sites in Init() and postKeyTransitionCmd() now pass the model
pointer. The now-unused streamTickCmdFn/flameTickCmdFn package-level
adapters are removed; the TabFlame and TabStream registry entries use
inline closures that delegate to m.flameTickCmd()/m.streamTickCmd().
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'internal/tui/dashboard/tabregistry.go')
| -rw-r--r-- | internal/tui/dashboard/tabregistry.go | 25 |
1 files changed, 15 insertions, 10 deletions
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 }, }, } |
