Skip to content

Conversation

@daniel-lxs
Copy link
Contributor

This change improves the terminal reuse logic to prevent the creation of unnecessary terminals. The previous implementation was too strict and would create new terminals even when idle ones were available.

The new logic introduces a fallback mechanism to reuse idle terminals even if their current working directory has drifted. When a terminal with a drifted CWD is reused, a cd command is prepended to the command being executed to ensure it runs in the correct directory.

This change also includes:

  • Updates to the RooTerminal interface and BaseTerminal class to support the new logic.
  • Comprehensive unit tests to validate the new terminal reuse behavior.

google-labs-jules bot and others added 2 commits October 9, 2025 12:56
This change improves the terminal reuse logic to prevent the creation of unnecessary terminals. The previous implementation was too strict and would create new terminals even when idle ones were available.

The new logic introduces a fallback mechanism to reuse idle terminals even if their current working directory has drifted. When a terminal with a drifted CWD is reused, a `cd` command is prepended to the command being executed to ensure it runs in the correct directory.

This change also includes:
- Updates to the `RooTerminal` interface and `BaseTerminal` class to support the new logic.
- Comprehensive unit tests to validate the new terminal reuse behavior.

if (this.requestedCwd && !arePathsEqual(this.requestedCwd, currentCwd)) {
// Wrap path in quotes to handle spaces
commandToRun = `cd "${this.requestedCwd}" && ${command}`
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The path wrapping in double quotes doesn't escape special shell characters within the path itself. If requestedCwd contains characters like $, backticks (`), ", or \, they could be interpreted by the shell, potentially leading to command injection or unexpected behavior. Consider using single quotes instead (which prevent variable expansion) or properly escaping the path before wrapping it in double quotes.

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