Skip to content

feat(tui): per-session cpu/mem readout + caffeinate flag in sidebar#57

Open
mmoscosa wants to merge 7 commits into
rtalexk:mainfrom
mmoscosa:pr/session-resource-stats
Open

feat(tui): per-session cpu/mem readout + caffeinate flag in sidebar#57
mmoscosa wants to merge 7 commits into
rtalexk:mainfrom
mmoscosa:pr/session-resource-stats

Conversation

@mmoscosa

@mmoscosa mmoscosa commented Jun 22, 2026

Copy link
Copy Markdown

What

Adds per-session resource visibility to the sidebar, gated behind a single config flag sidebar.show_session_stats (default on):

  1. Current cpu/mem inline on every row — a compact <cpu>% <mem> readout (e.g. 5% 1.0G) in the right-hand slot (taking the last-seen-age slot when a stat is available). now = the live sum of every process across every pane in that tmux session.

  2. Rolling peak under the focused row — the selected row expands with two lines: cpu <now>% now · <peak>% peak and mem <now> now · <peak> peak. peak = the rolling max over the last 60 proc-poll samples (~2 min).

  3. Coffee glyph (Nerd-Font nf-fa-coffee, U+F0F4) beside any session running caffeinate. Scope is correct by construction — only pane process-trees are walked, so an agent-spawned caffeinate (e.g. an editor/agent keep-awake) flags the session but a standalone one started outside tmux does not.

How

  • New isolated internal/tui/session_stats.go: computeSessionTotals (reuses the existing aggStats + proc.BuildTree + tmux.GroupBySessions primitives) and SessionStatsModel (rolling-peak ring, pruned when a session disappears). The zero value is usable — no constructor wiring.
  • Fed from handleProcDataMsg right next to the existing SetProcLabels call; pushed into the sidebar via SetSessionStats.
  • Rendering reuses the existing per-node-height viewport machinery: the inline readout is a normal right-side indicator; nodeHeight becomes cursor-aware (+2 rows for the focused peak lines); the coffee glyph is a themed indicator (IconCaffeine).
  • Summed CPU can exceed 100% on multi-core — shown verbatim (matches Activity Monitor).

Tests

go test ./... green. Unit coverage for aggregation, caffeinate detection (positive + negative scope), rolling-peak decay/hold/prune, the config default, the coffee indicator, the inline per-row readout, the focused-row peak lines, and the cursor-aware nodeHeight.

Notes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant