36b3af2e3d
PR Check / Code Quality: Format (push) Failing after 1s
PR Check / Code Quality: Lint (darwin) (push) Failing after 0s
PR Check / Code Quality: Lint (freebsd) (push) Failing after 1s
PR Check / Code Quality: Lint (windows) (push) Failing after 1s
PR Check / Code Quality: Lint (linux) (push) Failing after 1s
PR Check / Security: Vulnerability Scan (push) Failing after 0s
Update Documentation / update-docs (push) Failing after 2s
PR Check / Code Quality: Vendor (push) Failing after 1s
PR Check / Code Quality: Coverage (push) Failing after 0s
PR Check / Tests: Unit (macos-latest) (push) Has been cancelled
PR Check / Tests: Unit (ubuntu-24.04) (push) Has been cancelled
PR Check / Tests: Unit (ubuntu-24.04-arm) (push) Has been cancelled
PR Check / Tests: Unit (windows-latest) (push) Has been cancelled
43 lines
1.8 KiB
Go
43 lines
1.8 KiB
Go
package tui
|
|
|
|
import "time"
|
|
|
|
// Timing constants for the interactive TUI.
|
|
const (
|
|
// refreshInterval is the auto-refresh cadence for the process/port/
|
|
// container/lock tabs. 3s mirrors top's default.
|
|
refreshInterval = 3 * time.Second
|
|
|
|
// selectionDebounce delays the detail/tree fetch after the selection
|
|
// moves, so holding a cursor key down doesn't spawn a fetch per row.
|
|
selectionDebounce = 500 * time.Millisecond
|
|
|
|
// doubleClickThreshold is the maximum gap between two clicks for them to
|
|
// count as a double-click.
|
|
doubleClickThreshold = 500 * time.Millisecond
|
|
)
|
|
|
|
// Pane split ratios — the fraction of the available width given to the primary
|
|
// pane. These are shared by the resize math, the mouse hit-testing, and the
|
|
// view renderer; keeping them in one place stops those three from drifting
|
|
// apart (which would make clicks land on the wrong pane).
|
|
const (
|
|
listPaneRatio = 0.7 // process list vs. ancestry tree
|
|
detailPaneRatio = 0.7 // detail view vs. environment view
|
|
portPaneRatio = 0.5 // port list vs. port detail
|
|
)
|
|
|
|
// Adaptive auto-refresh. The background-refresh cadence starts at
|
|
// refreshInterval and adapts to the measured refresh cost: after backoffStreak
|
|
// consecutive refreshes over slowFraction of the interval it grows by
|
|
// refreshStep (up to maxRefreshInterval); after backoffStreak under
|
|
// fastFraction it shrinks by refreshStep (back down to refreshInterval). The
|
|
// band between is stable, so it can't oscillate. All internal — no config.
|
|
const (
|
|
maxRefreshInterval = 30 * time.Second // ceiling
|
|
refreshStep = 3 * time.Second // grow/shrink increment
|
|
backoffStreak = 2 // consecutive samples before adjusting
|
|
slowFraction = 0.6 // refresh over this fraction of interval => slow
|
|
fastFraction = 0.3 // refresh under this fraction => fast
|
|
)
|