Skip to content

perf(desktop): reduce terminal memory footprint#1471

Closed
saddlepaddle wants to merge 1 commit into
mainfrom
fly-alerts
Closed

perf(desktop): reduce terminal memory footprint#1471
saddlepaddle wants to merge 1 commit into
mainfrom
fly-alerts

Conversation

@saddlepaddle
Copy link
Copy Markdown
Collaborator

@saddlepaddle saddlepaddle commented Feb 13, 2026

Summary

  • Reduce default terminal scrollback from 10,000 to 5,000 lines, saving ~1.6MB per terminal session (both renderer xterm and daemon headless emulator)
  • Extract scrollback default to shared constant DEFAULT_TERMINAL_SCROLLBACK for future configurability
  • Clear emulator scrollback buffer before dispose for immediate memory release instead of relying on GC

Test plan

  • Typecheck passes
  • All 735 tests pass
  • Lint clean
  • Verify terminal scrollback still works (scroll up through history)
  • Verify terminal dispose doesn't cause errors on tab close

Summary by CodeRabbit

  • Changes
    • Default terminal scrollback reduced to 5,000 lines (now driven by a shared constant).
    • Improved terminal disposal to proactively clear buffers and free memory.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 13, 2026

📝 Walkthrough

Walkthrough

The pull request centralizes previously hard-coded terminal scrollback values into a new exported constant DEFAULT_TERMINAL_SCROLLBACK = 5000, updates usages across main and renderer code to reference the constant, and adds a proactive clear during headless terminal disposal. No public APIs or exported signatures were changed.

Changes

Cohort / File(s) Summary
Shared Constants
apps/desktop/src/shared/constants.ts
Add exported DEFAULT_TERMINAL_SCROLLBACK = 5000.
Main process terminal code
apps/desktop/src/main/lib/terminal-host/headless-emulator.ts, apps/desktop/src/main/lib/terminal/session.ts, apps/desktop/src/main/terminal-host/session.ts
Replace magic 10000 scrollback defaults with DEFAULT_TERMINAL_SCROLLBACK; add clearing of headless terminal before dispose; update snapshot serialization and constructor options.
Renderer terminal config
apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/Terminal/config.ts
Change TERMINAL_OPTIONS.scrollback from 10000 to DEFAULT_TERMINAL_SCROLLBACK.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

Poem

🐇 I nibbled the magic number down to five K,
I hopped through code paths to tuck it away.
A shared little constant, tidy and neat,
No more scattered numbers on every seat.
Hooray for clean defaults — let memory sleep sweet!

🚥 Pre-merge checks | ✅ 3 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and accurately summarizes the main change: reducing terminal memory footprint through configuration adjustments.
Description check ✅ Passed The description provides a clear summary of changes, test results, and pending manual tests, but is missing the formally structured template sections.
Merge Conflict Detection ✅ Passed ✅ No merge conflicts detected when merging into main

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fly-alerts

No actionable comments were generated in the recent review. 🎉


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Reduce default scrollback from 10,000 to 5,000 lines across renderer,
daemon, and headless emulator (~1.6MB saved per terminal session).
Extract to shared constant for future configurability. Also clear
emulator buffer before dispose for immediate memory release.
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.

2 participants