Skip to content

feat: configurable terminal pool size with cleanup on task release#12156

Draft
roomote-v0[bot] wants to merge 1 commit intomainfrom
feature/configurable-terminal-pool-size
Draft

feat: configurable terminal pool size with cleanup on task release#12156
roomote-v0[bot] wants to merge 1 commit intomainfrom
feature/configurable-terminal-pool-size

Conversation

@roomote-v0
Copy link
Copy Markdown
Contributor

@roomote-v0 roomote-v0 bot commented Apr 20, 2026

Related GitHub Issue

Closes: #12153

Description

This PR attempts to address Issue #12153 by implementing two key terminal management improvements:

  1. Configurable terminal pool size -- A new maxTerminalPoolSize setting (range 1-20, default 5) that caps how many terminals Roo Code keeps open simultaneously. When the limit is reached, the oldest idle terminal is disposed before creating a new one.

  2. Terminal cleanup on task release -- When a task ends, releaseTerminalsForTask() now disposes idle terminals that are not busy and have no pending output, rather than just clearing their taskId. Busy terminals are left intact.

These mechanisms apply regardless of whether the VSCode integrated terminal or the inline (execa) terminal is used, as requested by the issue commenter.

Files changed:

  • packages/types/src/global-settings.ts -- Added maxTerminalPoolSize to the settings schema with validation (int, 1-20)
  • packages/types/src/vscode-extension-host.ts -- Added to the settings key union type
  • src/integrations/terminal/TerminalRegistry.ts -- Pool size getter/setter, enforcePoolSizeLimit(), disposeTerminal(), updated releaseTerminalsForTask()
  • src/core/webview/ClineProvider.ts -- Wire the setting through state initialization and getState
  • src/core/webview/webviewMessageHandler.ts -- Handle setting updates from the UI
  • webview-ui/src/components/settings/TerminalSettings.tsx -- Slider UI for pool size (1-20)
  • webview-ui/src/components/settings/SettingsView.tsx -- Pass new prop
  • webview-ui/src/context/ExtensionStateContext.tsx -- State and setter for the new setting
  • webview-ui/src/i18n/locales/en/settings.json -- English translation for the setting

Test Procedure

  • Added 6 new unit tests in TerminalRegistry.spec.ts covering:
    • Default pool size value
    • Setting pool size within bounds
    • Clamping to min (1) and max (20)
    • Disposing oldest idle terminal when pool is at capacity
    • Disposing idle terminals on task release
    • Not disposing busy terminals on task release
    • Not disposing terminals belonging to other tasks
  • All 12 tests pass (cd src && npx vitest run integrations/terminal/__tests__/TerminalRegistry.spec.ts)
  • Full lint and type-check pass across all packages

Pre-Submission Checklist

  • Issue Linked: This PR is linked to an approved GitHub Issue (see above).
  • Scope: Changes are focused on terminal pool management.
  • Self-Review: Done.
  • Testing: 6 new tests added covering pool enforcement and task release cleanup.
  • Documentation Impact: The setting is self-documenting via the UI slider and i18n description.
  • Contribution Guidelines: Reviewed.

Documentation Updates

The new setting is exposed in the Terminal Settings UI with a description. No external documentation changes needed.

Feedback and guidance are welcome.

Interactively review PR in Roo Code Cloud

- Add maxTerminalPoolSize setting (1-20, default 5) to global settings schema
- Enforce pool size limit in TerminalRegistry.createTerminal() by disposing
  oldest idle terminals when at capacity
- Update releaseTerminalsForTask() to dispose idle terminals when a task ends
- Wire setting through ClineProvider, webviewMessageHandler, and ExtensionStateContext
- Add slider UI in Terminal Settings (Basic section)
- Add English i18n translation for the new setting
- Add tests for pool size enforcement and task release cleanup

Addresses #12153
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.

[BUG] Terminal Management

1 participant