Skip to content

feat(system): per-session RAM breakdown in Settings → System (v0.142.0)#242

Merged
vikasprogrammer merged 1 commit into
mainfrom
feat/session-ram-breakdown
Jul 13, 2026
Merged

feat(system): per-session RAM breakdown in Settings → System (v0.142.0)#242
vikasprogrammer merged 1 commit into
mainfrom
feat/session-ram-breakdown

Conversation

@vikasprogrammer

Copy link
Copy Markdown
Owner

What

Follow-up to #240. The Host resources panel now shows how much RAM each agent session is using — not just the host total.

For every live session it sums the resident memory of that session's process tree (the tmux pane's shell → claude/node → its MCP subprocesses), lists them heaviest-first, and shows a fleet total (e.g. "4.6 GB · 8 live"). So you can see how much of the box the running agents are holding, and which session is the hog.

How

  • New SessionBackend.sessionRss() — one tmux list-panes -a -F '#{session_name} #{pane_pid}' maps each live pane to its root PID; one ps -Ao pid=,ppid=,rss= snapshot is walked into a child map and summed over each pane's subtree. Portable across macOS (BSD) and Linux (GNU) ps; RSS is KiB on both.
  • TerminalManager.sessionMemory() joins that map against the running term_sessions rows (bytes out).
  • Surfaced on the existing owner/admin-gated GET /api/system as a sessions field; rendered in HostResourcesPanel.
  • LauncherSessionBackend (Linux uid-isolation, off by default) returns null — uid-private sockets the app can't inspect → UI shows "not measurable here."

Caveat: RSS is approximate — shared library pages are counted once per process, so the per-tree sum slightly over-reports. Labeled as such in the UI.

Testing

  • typecheck ✅ · web build ✅ · server build ✅
  • Validated against the live instapods box (8 running sessions): per-session ~504–735 MB, total 4.58 GB — realistic for 8 Claude Code process trees. The tmux list-panes + ps subtree-sum algorithm was run against the live tmux socket to confirm the numbers before shipping.

🤖 Generated with Claude Code

Show how much resident memory each live agent session holds — its process
tree (shell → claude/node → MCP subprocesses) — with a fleet total, sorted
heaviest-first, in the Host resources panel.

New SessionBackend.sessionRss(): one `tmux list-panes -a` maps each live pane
to its root PID; one `ps -Ao pid,ppid,rss` snapshot is walked to sum RSS over
each pane's subtree (portable BSD/Linux). TerminalManager.sessionMemory() joins
that against the running rows; GET /api/system surfaces it. LauncherSessionBackend
returns null (uid-private sockets) → UI shows "not measurable here". RSS is
approximate (shared pages counted per process).

Validated against 8 live sessions on the instapods box: ~500-735 MB each, 4.6 GB total.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@vikasprogrammer vikasprogrammer force-pushed the feat/session-ram-breakdown branch from 9d26144 to cb436a6 Compare July 13, 2026 09:15
@vikasprogrammer vikasprogrammer merged commit 665fafc into main Jul 13, 2026
1 check passed
@vikasprogrammer vikasprogrammer deleted the feat/session-ram-breakdown branch July 13, 2026 09:15
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