Skip to content

Conversation

@mrubens
Copy link
Collaborator

@mrubens mrubens commented Aug 17, 2025

In the words of Opus:

Now I understand the issue. The terminal logic has a mismatch between what the prompt tells the model and what the implementation actually does:

The Problem:

The prompt tells the model that when no cwd is specified, commands will execute in the project root directory (args.cwd)
But the implementation sets requiredCwd to false when no custom cwd is provided, which allows reusing ANY non-busy terminal regardless of its current directory
This means a command could execute in a completely different directory than expected


Important

Fixes terminal reuse logic by removing requiredCwd parameter, ensuring commands execute in the specified directory.

  • Behavior:
    • Fixes terminal reuse logic by removing requiredCwd parameter in TerminalRegistry.getOrCreateTerminal().
    • Ensures commands execute in the specified directory, aligning with prompt expectations.
  • Tests:
    • Updates executeCommand.spec.ts to reflect changes in terminal reuse logic.
    • Removes requiredCwd parameter from test cases in executeCommand.spec.ts.
  • Misc:
    • Removes logic for reusing any non-busy terminal in TerminalRegistry.ts.

This description was created by Ellipsis for 72f8c1a. You can customize this summary. It will automatically update as commits are pushed.

@mrubens mrubens requested review from cte and jr as code owners August 17, 2025 06:01
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. bug Something isn't working labels Aug 17, 2025
Copy link
Contributor

@roomote roomote bot left a comment

Choose a reason for hiding this comment

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

Thank you for this fix! The changes correctly address the terminal reuse logic issue. The removal of the requiredCwd parameter ensures commands will only execute in terminals with matching directories, preventing the mismatch between expected and actual execution directories.

Review Findings:

✅ What works well:

  • The fix correctly removes the problematic "reuse any non-busy terminal" logic
  • Test updates properly reflect the API changes
  • The core issue of commands executing in unexpected directories is resolved

📝 Suggestions for improvement:

  1. Documentation update in TerminalRegistry.ts: The JSDoc comment for getOrCreateTerminal has been updated to remove the requiredCwd parameter reference, which is good. Consider adding a note about the terminal reuse behavior for extra clarity.

  2. Consider adding explanatory comment: Where the "Third priority" logic was removed (around line 194 in TerminalRegistry.ts), it might be helpful to add a comment explaining why we no longer reuse any non-busy terminal. This would help future maintainers understand the design decision.

  3. Test coverage: The test updates correctly reflect the API change. Consider adding a specific test case that validates terminals with different working directories won't be reused, even when not busy, to ensure the bug doesn't resurface.

Overall, this is a solid fix that addresses the core issue effectively. The changes are minimal and focused, which reduces the risk of introducing new issues.

@mrubens mrubens merged commit 185365a into main Aug 17, 2025
19 checks passed
@mrubens mrubens deleted the fix_terminal_reuse_bug branch August 17, 2025 06:11
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Aug 17, 2025
@github-project-automation github-project-automation bot moved this from Triage to Done in Roo Code Roadmap Aug 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working size:M This PR changes 30-99 lines, ignoring generated files.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants