Skip to content

fix(tui): bound live render memory pressure#15800

Closed
helix4u wants to merge 1 commit into
NousResearch:mainfrom
helix4u:fix/tui-live-render-memory
Closed

fix(tui): bound live render memory pressure#15800
helix4u wants to merge 1 commit into
NousResearch:mainfrom
helix4u:fix/tui-live-render-memory

Conversation

@helix4u

@helix4u helix4u commented Apr 25, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Bounds the live-rendered text surfaces in the TUI so active reasoning and assistant streaming do not ask Ink/Yoga to re-layout an ever-growing text blob on every render pulse. The full in-memory turn text is still retained for final completion; only the live display is capped to a tail preview with an omitted-lines/chars marker.

This also makes the TUI memory monitor distinguish V8 heap pressure from RSS/native pressure. Heap pressure still writes a heap snapshot, while RSS/native pressure writes diagnostics only, avoiding repeated multi-GB heap snapshots for native RSS growth cases.

Related Issue

Refs #15141

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✅ Tests (adding or improving test coverage)

Changes Made

  • Added boundedLiveRenderText() and live render caps in ui-tui/src/lib/text.ts / ui-tui/src/config/limits.ts.
  • Applied the cap to live assistant streaming in ui-tui/src/app/turnController.ts and ui-tui/src/components/messageLine.tsx.
  • Applied the cap to expanded thinking render in ui-tui/src/components/thinking.tsx.
  • Stopped rendering an empty Thinking accordion just because the TUI is busy when no reasoning has arrived.
  • Added RSS/native-memory source tracking in ui-tui/src/lib/memoryMonitor.ts.
  • Added diagnostics-only native RSS capture in ui-tui/src/lib/memory.ts and updated the startup notice in ui-tui/src/entry.tsx.
  • Added focused coverage in ui-tui/src/__tests__/text.test.ts and ui-tui/src/lib/memoryMonitor.test.ts.

How to Test

  1. Run cd ui-tui && npm test -- --run src/__tests__/text.test.ts src/lib/memoryMonitor.test.ts src/__tests__/details.test.ts.
  2. Run cd ui-tui && npm test.
  3. Run cd ui-tui && npm run type-check.
  4. Run cd ui-tui && npx eslint src/config/limits.ts src/lib/text.ts src/app/turnController.ts src/components/thinking.tsx src/components/messageLine.tsx src/lib/memory.ts src/lib/memoryMonitor.ts src/entry.tsx src/__tests__/text.test.ts src/lib/memoryMonitor.test.ts.
  5. If applying this PR manually to a local checkout, rebuild the TUI before testing because hermes --tui runs ui-tui/dist/entry.js:
cd ui-tui
npm install   # only needed if dependencies are not already installed
npm run build
cd ..
hermes --tui
  1. Monitor the Node TUI process during active streaming and idle, for example: ps -o pid,rss,vsz,comm -p <node pid>.

Local smoke result from a fresh rebuilt hermes --tui run: Node RSS rose during active work, then stabilized while idle and dropped from about 537 MB to about 399 MB over the idle window. The Python gateway stayed flat around 51 MB.

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(scope):, feat(scope):, etc.)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run pytest tests/ -q and all tests pass
  • I've added tests for my changes (required for bug fixes, strongly encouraged for features)
  • I've tested on my platform: WSL/Linux TUI with Node v24.14.1

Documentation & Housekeeping

  • I've updated relevant documentation (README, docs/, docstrings) — N/A
  • I've updated cli-config.yaml.example if I added/changed config keys — N/A
  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows — N/A
  • I've considered cross-platform impact (Windows, macOS) per the compatibility guide
  • I've updated tool descriptions/schemas if I changed tool behavior — N/A

For New Skills

N/A

Screenshots / Logs

Live idle-monitor sample from the rebuilt bundle:

16:36:08  Node RSS 533.6 MB
16:37:48  Node RSS 533.9 MB
16:39:28  Node RSS 536.8 MB
16:40:01  Node RSS 402.6 MB
16:41:47  Node RSS 398.8 MB

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/tui Terminal UI (ui-tui/ + tui_gateway/) type/perf Performance improvement or optimization labels Apr 25, 2026
@helix4u

helix4u commented Apr 25, 2026

Copy link
Copy Markdown
Contributor Author

@kshitijk4poor

Copy link
Copy Markdown
Collaborator

Closing — these changes are already on current main. The boundedLiveRenderText() function exists in ui-tui/src/lib/text.ts, the LIVE_RENDER_MAX_CHARS/LINES constants exist in ui-tui/src/config/limits.ts, and all call sites (turnController.ts, messageLine.tsx, thinking.tsx) already use the bounded function. Your work was absorbed into main through the subsequent TUI perf passes. Thanks for the original fix, @helix4u!

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

Labels

comp/tui Terminal UI (ui-tui/ + tui_gateway/) P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants