Skip to content

Conversation

@KJ7LNW
Copy link
Contributor

@KJ7LNW KJ7LNW commented Mar 12, 2025

Description

This PR fixes two critical issues with PowerShell command execution in Windows environments:

  1. Command output buffering: PowerShell can emit the ]633;D marker before the actual command output is received by VSCE, causing missing or incomplete output. Added a small sleep delay to ensure output is captured.
  2. Duplicate command issue: PowerShell currently has a bug where identical subsequent commands are not executed. Added a command counter to make each command unique.

The fix detects PowerShell environments by checking both the Windows platform and the VSCode terminal default profile configuration.

Test Procedure

Tested on Windows with PowerShell by:

  1. Running identical commands in sequence to verify the counter prevents the duplicate command issue
  2. Running commands that produce output to verify the sleep delay ensures all output is captured
  3. Verified behavior on both explicit PowerShell profile and null profile configurations

Type of Change

  • 🐛 Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 📚 Documentation update

Pre-flight Checklist

  • Changes are limited to a single feature, bugfix or chore (split larger changes into separate PRs)
  • Tests are passing (npm test) and code is formatted and linted (npm run format && npm run lint)
  • I have created a changeset using npm run changeset (required for user-facing changes)
  • I have reviewed contributor guidelines

Screenshots

I know this looks insane, but believe me, this is the only way to make it successful in the current state of upstream VSCE shell integration!

image

image

Additional Notes

The sleep delay (150ms) was chosen as the minimum value that reliably ensures output capture while maintaining responsiveness.

For some reason the command is always included in the output, but that is better than not having any output at all.


Important

Fixes PowerShell command execution issues in Windows by adding a command counter and sleep delay for output capture.

  • Behavior:
    • Fixes PowerShell command output buffering by adding a 150ms sleep delay in TerminalProcess.ts to ensure output capture.
    • Resolves duplicate command issue by adding cmdCounter in Terminal.ts and using it in TerminalProcess.ts to make each command unique.
    • Detects PowerShell environments by checking Windows platform and VSCode terminal default profile configuration.
  • Code Changes:
    • Adds cmdCounter to Terminal class in Terminal.ts.
    • Modifies run() in TerminalProcess.ts to append cmdCounter and sleep delay to PowerShell commands.
  • Testing:
    • Verified on Windows with PowerShell for duplicate command prevention and output capture.

This description was created by Ellipsis for a25f1d9. It will automatically update as commits are pushed.

PowerShell requires special handling for command output due to two issues:
- A sleep delay is required to prevent the ]633;D marker from losing the
  original output
- A counter is needed to work around a bug where identical commands are not executed

Changes:
- Add cmdCounter to Terminal class for unique command tracking
- Add PowerShell detection via platform and default shell profile
- Add sleep delay to ensure output is captured before command completion

Signed-off-by: Eric Wheeler <[email protected]>
@changeset-bot
Copy link

changeset-bot bot commented Mar 12, 2025

⚠️ No Changeset found

Latest commit: 50b7326

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@dosubot dosubot bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Mar 12, 2025
Mock VSCode workspace configuration to handle PowerShell detection in terminal tests. This prevents TypeError when accessing getConfiguration() in TerminalProcess.run()

Signed-off-by: Eric Wheeler <[email protected]>
@dosubot dosubot bot added the bug Something isn't working label Mar 12, 2025
@cte
Copy link
Collaborator

cte commented Mar 12, 2025

Ah interesting; thanks for digging in!

Add VSCode workspace configuration mock to TerminalProcess.test.ts to handle PowerShell detection in terminal tests, matching the fix in TerminalProcessExec.test.ts

Signed-off-by: Eric Wheeler <[email protected]>
@KJ7LNW
Copy link
Contributor Author

KJ7LNW commented Mar 12, 2025

This link has this powershell work around rolled in if anybody wants to test in Windows; this is my site, so trust it if you trust me:

Then run code --install-extension roo-cline-3.8.4.vsix and restart your extensions (or close/reopen).

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Mar 12, 2025
@cte cte merged commit 4ce2664 into RooCodeInc:main Mar 12, 2025
11 checks passed
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Mar 12, 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 lgtm This PR has been approved by a maintainer size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants