summaryrefslogtreecommitdiff
path: root/internal/tui/tui.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-03-06 23:14:09 +0200
committerPaul Buetow <paul@buetow.org>2026-03-06 23:14:09 +0200
commit106fcb3fe959966dec19d1242ff87df644a43fad (patch)
tree5152e1d4dadbf991040d0db069c8d76db889364d /internal/tui/tui.go
parent013e46d7856a604d4890a880b8bbfb4b8c58202b (diff)
fix(tui): restore bubble modes and stabilize flame zoom lineage
Diffstat (limited to 'internal/tui/tui.go')
-rw-r--r--internal/tui/tui.go50
1 files changed, 48 insertions, 2 deletions
diff --git a/internal/tui/tui.go b/internal/tui/tui.go
index deb6150..c375057 100644
--- a/internal/tui/tui.go
+++ b/internal/tui/tui.go
@@ -230,6 +230,7 @@ type Model struct {
pidFilter int
tidFilter int
+ pickerReturn *pickerReturnState
exportEnabled bool
isDark bool
focused bool
@@ -247,6 +248,11 @@ type Model struct {
suppressPressUntil time.Time
}
+type pickerReturnState struct {
+ pidFilter int
+ tidFilter int
+}
+
// NewModel creates the top-level TUI model.
func NewModel(initialPID int, startTrace TraceStarter) Model {
return NewModelWithConfig(flags.Get(), initialPID, startTrace)
@@ -429,6 +435,12 @@ func (m Model) canQuitFromMainDashboard(msg tea.KeyPressMsg) bool {
!m.dashboard.BlocksGlobalShortcuts(msg)
}
+func (m Model) shouldCancelPickerToDashboard(msg tea.KeyPressMsg) bool {
+ return m.screen == ScreenPIDPicker &&
+ m.pickerReturn != nil &&
+ (isEscKey(msg) || key.Matches(msg, m.keys.Quit))
+}
+
func (m Model) shouldRouteQuitToEsc(msg tea.KeyPressMsg) bool {
if m.helpOverlayVisible {
return false
@@ -444,6 +456,10 @@ func (m Model) handleGlobalKeyPress(msg tea.KeyPressMsg) (tea.Model, tea.Cmd, bo
}
return m, nil, true
}
+ if m.shouldCancelPickerToDashboard(msg) {
+ next, cmd := m.cancelPickerToDashboard()
+ return next, cmd, true
+ }
if key.Matches(msg, m.keys.Quit) {
if m.canQuitFromMainDashboard(msg) {
m.quitting = true
@@ -638,6 +654,7 @@ func (m Model) handlePidSelected(msg PidSelectedMsg) (tea.Model, tea.Cmd) {
m.stopTrace()
m.pidFilter = pid
m.tidFilter = -1
+ m.pickerReturn = nil
m.dashboard.SetPidFilter(pid)
m.screen = ScreenDashboard
m.attaching = true
@@ -654,6 +671,7 @@ func (m Model) handleTidSelected(msg TidSelectedMsg) (tea.Model, tea.Cmd) {
m.stopTrace()
m.pidFilter = pid
m.tidFilter = tid
+ m.pickerReturn = nil
m.dashboard.SetPidFilter(pid)
m.screen = ScreenDashboard
m.attaching = true
@@ -662,6 +680,10 @@ func (m Model) handleTidSelected(msg TidSelectedMsg) (tea.Model, tea.Cmd) {
}
func (m Model) reselectPID() (tea.Model, tea.Cmd) {
+ m.pickerReturn = &pickerReturnState{
+ pidFilter: m.pidFilter,
+ tidFilter: m.tidFilter,
+ }
m.stopTrace()
m.screen = ScreenPIDPicker
m.attaching = false
@@ -683,6 +705,10 @@ func (m Model) reselectPID() (tea.Model, tea.Cmd) {
func (m Model) reselectTID() (tea.Model, tea.Cmd) {
pid := m.pidFilter
+ m.pickerReturn = &pickerReturnState{
+ pidFilter: m.pidFilter,
+ tidFilter: m.tidFilter,
+ }
m.stopTrace()
m.screen = ScreenPIDPicker
m.attaching = false
@@ -708,6 +734,22 @@ func selectedPIDFilter(pid int) int {
return pid
}
+func (m Model) cancelPickerToDashboard() (tea.Model, tea.Cmd) {
+ if m.pickerReturn == nil {
+ return m, nil
+ }
+ returnState := *m.pickerReturn
+ m.pickerReturn = nil
+ m.stopTrace()
+ m.pidFilter = returnState.pidFilter
+ m.tidFilter = returnState.tidFilter
+ m.dashboard.SetPidFilter(m.pidFilter)
+ m.screen = ScreenDashboard
+ m.attaching = true
+ m.lastErr = nil
+ return m, tea.Batch(m.spin.Tick, m.beginTraceCmd())
+}
+
func (m *Model) beginTraceCmd() tea.Cmd {
ctx, cancel := context.WithCancel(context.Background())
m.traceStop = cancel
@@ -810,8 +852,12 @@ func isHelpOverlayOpenKey(msg tea.KeyPressMsg) bool {
return msg.String() == "H"
}
+func isEscKey(msg tea.KeyPressMsg) bool {
+ return msg.Code == tea.KeyEsc || msg.String() == "esc"
+}
+
func isHelpOverlayCloseKey(msg tea.KeyPressMsg) bool {
- return msg.Code == tea.KeyEsc || msg.String() == "esc" || msg.String() == "?"
+ return isEscKey(msg) || msg.String() == "?"
}
func isHelpOverlayQuitKey(msg tea.KeyPressMsg) bool {
@@ -930,7 +976,7 @@ func (m Model) helpSections() []helpSection {
{
title: "PID/TID Picker",
lines: []string{
- "enter select r refresh esc back",
+ "enter select r refresh esc/q back",
},
},
}