You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Terminal functionality is spawning new VS Code terminals instead of reusing an existing one. This leads to many “Roo Code” terminals accumulating during normal usage.
🔁 Steps to Reproduce
Run a command via the extension (execute_command) from a project directory.
After it finishes, run another command from the same project directory/task.
Observe that a new VS Code terminal is created instead of reusing the previous one.
Variants that also reproduce:
First command changes directory in-terminal (e.g., cd src). A subsequent command requested for the original cwd may fail the reuse check and create a new terminal.
If shell integration falls back and later recovers, provider mismatch (“vscode” vs “execa”) can prevent reuse.
💥 Outcome Summary
Expected a single terminal per task/cwd to be reused. Actual behavior creates additional terminals.
Expected Behavior
If an idle terminal exists for the same task/provider, reuse it even if cwd has drifted.
Optionally change directory in the reused terminal prior to running the next command.
Actual Behavior
New terminals are created frequently, leading to terminal proliferation, even when reuse should be possible.
Code Investigation
Reuse decision path:
Selection logic prefers same taskId and matching cwd, then any idle with matching cwd, else creates new:
CWD drift: If terminal’s current cwd (from shell integration) differs from requested cwd, the equality check fails and a new terminal is created.
Provider mismatch: Switching between “vscode” and “execa” (due to shell integration fallback) partitions terminals by provider, preventing reuse.
Busy flag timing: If a terminal remains marked busy momentarily, reuse is skipped and a new terminal is created.
Proposed Direction
Add a third-priority reuse fallback:
If no cwd-match exists but there is an idle same-provider terminal (prefer same taskId), reuse it and prepend cd "<requestedCwd>" && before the command.
Or relax the task-first branch:
Reuse same-taskId terminal regardless of cwd (send a cd to requested cwd when needed).
Keep current behavior behind a setting:
“Reuse terminal across directories” (default on) to control fallback behavior.
Ensure provider consistency or allow reuse across providers when semantically equivalent.
Add unit tests:
Reuse with cwd drift (shell integration reports different cwd).
Reuse across repeated commands for same task/cwd.
No new VS Code terminal created when an idle candidate exists.
Description
Terminal functionality is spawning new VS Code terminals instead of reusing an existing one. This leads to many “Roo Code” terminals accumulating during normal usage.
🔁 Steps to Reproduce
Variants that also reproduce:
cd src). A subsequent command requested for the original cwd may fail the reuse check and create a new terminal.💥 Outcome Summary
Expected a single terminal per task/cwd to be reused. Actual behavior creates additional terminals.
Expected Behavior
Actual Behavior
Code Investigation
Reuse decision path:
Why reuse can fail:
Proposed Direction
cd "<requestedCwd>" &&before the command.cdto requested cwd when needed).Additional Notes