Skip to content

fix: add Windows UTF-8 encoding env vars for terminals with fixed tests#11873

Draft
roomote-v0[bot] wants to merge 1 commit intomainfrom
fix/windows-terminal-utf8-encoding-tests
Draft

fix: add Windows UTF-8 encoding env vars for terminals with fixed tests#11873
roomote-v0[bot] wants to merge 1 commit intomainfrom
fix/windows-terminal-utf8-encoding-tests

Conversation

@roomote-v0
Copy link
Contributor

@roomote-v0 roomote-v0 bot commented Mar 6, 2026

Related GitHub Issue

Closes: #10709

Description

This PR attempts to address Issue #10709 where terminal output exhibits character corruption on Windows systems using non-UTF-8 encodings like GBK (code page 936). This is a follow-up to PR #10796 which had the right approach but failed Windows CI tests.

Changes:

  1. Terminal.ts (getEnv()): On Windows (process.platform === "win32"), adds PYTHONIOENCODING=utf-8, PYTHONUTF8=1, and RUBYOPT=-EUTF-8 environment variables.

  2. ExecaTerminalProcess.ts: Adds the same UTF-8 encoding environment variables to the execa subprocess env (these are set unconditionally since they are harmless on non-Windows).

  3. TerminalRegistry.spec.ts (key fix): The previous PR failed because these tests used exact env object matching. On Windows CI, the new env vars were present but not expected. Fixed by defining a WIN32_UTF8_ENV helper that conditionally spreads the Windows-specific vars into the expected env objects.

  4. ExecaTerminalProcess.spec.ts: Added tests for the new UTF-8 env vars and override behavior.

  5. Terminal.getEnv.spec.ts (new): Dedicated tests for Terminal.getEnv() covering platform-conditional behavior.

Feedback and guidance are welcome.

Test Procedure

Run the affected tests:

cd src && npx vitest run integrations/terminal/__tests__/ExecaTerminalProcess.spec.ts integrations/terminal/__tests__/Terminal.getEnv.spec.ts integrations/terminal/__tests__/TerminalRegistry.spec.ts

All 26 tests pass. The TerminalRegistry.spec.ts tests now correctly handle both Windows and non-Windows platforms.

Pre-Submission Checklist

  • Issue Linked: This PR is linked to an approved GitHub Issue (see "Related GitHub Issue" above).
  • Scope: My changes are focused on the linked issue (one major feature/fix per PR).
  • Self-Review: I have performed a thorough self-review of my code.
  • Testing: New and/or updated tests have been added to cover my changes.
  • Documentation Impact: I have considered if my changes require documentation updates.
  • Contribution Guidelines: I have read and agree to the Contributor Guidelines.

Documentation Updates

  • No documentation updates are required.

Additional Notes

This supersedes PR #10796 with the same feature implementation plus fixed tests that account for platform-conditional env vars.

Interactively review PR in Roo Code Cloud

Adds Windows-specific UTF-8 environment variables (PYTHONIOENCODING,
PYTHONUTF8, RUBYOPT) to both VSCode terminals and Execa terminals to
prevent character corruption when the system uses non-UTF-8 encodings
like GBK (code page 936).

Fixes the test failures from PR #10796 by updating TerminalRegistry
tests to conditionally include the Windows-specific env vars based on
the platform.

Closes #10709
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] In the inline terminal, the output of any command exhibits character corruption.

1 participant