Skip to content

feat(cli): show RAM usage in sidebar - #7371

Closed
alex-alecu wants to merge 3 commits into
mainfrom
feat/sidebar-ram-display
Closed

feat(cli): show RAM usage in sidebar#7371
alex-alecu wants to merge 3 commits into
mainfrom
feat/sidebar-ram-display

Conversation

@alex-alecu

Copy link
Copy Markdown
Contributor

Why

When the CLI process uses a lot of memory, users have no way to know about it or what to do. They only find out when their system slows down or the process gets killed.

What changed

The TUI sidebar now shows a "Memory" section when the process uses more than 2 GB of RAM. It displays total memory in a warning color alongside what's currently active — connected MCP servers, plugins, and messages in the session — so users can understand what's contributing. It also suggests running /compact or /new to free memory. The server exposes a lightweight memory endpoint, and the TUI polls it every 10 seconds with negligible overhead since it runs in-process.

How to test

  1. Start the CLI with bun run dev and open a session
  2. The Memory section should not appear (RSS is below 2 GB in normal use)
  3. To verify it works, temporarily lower the threshold in sidebar.tsx from 2 * 1024 * 1024 * 1024 to something small like 1
  4. Confirm the sidebar shows "Memory" with the current GB value, active counts, and the /compact or /new tip
  5. Restore the original threshold

Add a lightweight /memory route to the server that returns
process.memoryUsage.rss() (Bun's fast-path). Regenerate the SDK
so sdk.client.memory.status() is available as a typed method.
Add memory field to the sync store, fetch it during bootstrap,
and poll every 10 seconds. Uses in-process fetch so overhead is
negligible. Cleans up the interval via onCleanup.
Conditionally render a Memory section between Context and MCP
showing total RAM, active MCP server count, plugin count, message
count, and an actionable tip (/compact or /new). Reuses existing
connectedMcpCount and messages memos.
@kilo-code-bot

kilo-code-bot Bot commented Mar 20, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (6 files)
  • packages/opencode/src/cli/cmd/tui/context/sync.tsx
  • packages/opencode/src/cli/cmd/tui/routes/session/sidebar.tsx
  • packages/opencode/src/server/server.ts
  • packages/sdk/js/src/v2/gen/sdk.gen.ts
  • packages/sdk/js/src/v2/gen/types.gen.ts
  • packages/sdk/openapi.json

Reviewed by gpt-5.4-20260305 · 1,388,107 tokens

@alex-alecu
alex-alecu marked this pull request as draft March 25, 2026 13:01
@alex-alecu

Copy link
Copy Markdown
Contributor Author

Fixed here #7617

@alex-alecu alex-alecu closed this Mar 26, 2026
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