Uh oh!
There was an error while loading. Please reload this page.
fix(server): fall back to a UTF-8 locale in terminal spawn env - #4827
fix(server): fall back to a UTF-8 locale in terminal spawn env#4827Kaidstor wants to merge 2 commits into
Conversation
GUI apps launched from the macOS Dock/Finder inherit no LANG/LC_* from launchd, so the integrated terminal's PTY shell starts in the single-byte C locale and zsh's line editor renders multibyte input (any non-ASCII text) as raw bytes like `<0080>`. Default LANG to en_US.UTF-8 on macOS and C.UTF-8 on Linux when neither LANG nor LC_ALL is present; explicitly configured locales and runtime env overrides stay untouched.
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
ApprovabilityVerdict: Approved 83d4050 Straightforward bug fix that adds a UTF-8 locale fallback for terminal spawning when no locale is configured. The change is defensive, respects existing user settings, and includes test coverage for both the fallback and preservation behaviors. You can customize Macroscope's approvability policy. Learn more. |
Kaidstor
commented
Aug 8, 2026
? |
t3dotgg
commented
Aug 27, 2026
Note 🤖 GPT-5.6 Sol responding on behalf of Theo We're closing this PR as we clean up the T3 Code backlog. Thank you for taking the time to put this together. Closing the server-wide LANG fallback. The desktop macOS launch problem now has a narrower fix that respects existing locale settings and supplies LC_CTYPE only when needed. This patch changes every non-Windows terminal spawn. A remaining standalone-server or Linux failure needs its own current reproduction. Related work: #6236. If you believe we closed this in error, please reopen the PR and leave a comment explaining what we missed. If GitHub does not let you reopen it, leave a comment here and we'll take another look. |
What Changed
The terminal manager now falls back to a UTF-8 locale when spawning a PTY whose environment defines neither
LANGnorLC_ALL:en_US.UTF-8on macOS,C.UTF-8on Linux (the only one guaranteed to exist), nothing on Windows. An explicitly configured locale — even a non-UTF-8 one — and per-session runtime env overrides are left untouched. Two tests cover the fallback and the "explicit locale wins" case.Why
GUI apps launched from the macOS Dock/Finder get no
LANG/LC_*from launchd (Terminal.app and iTerm inject their own; the integrated terminal inherits the server process env instead). The PTY shell therefore starts in the single-byte C locale, and zsh's line editor mangles any multibyte input — typing non-ASCII text (e.g. Cyrillic) renders as raw bytes instead of characters:Repro on macOS: launch the packaged app from the Dock, open the integrated terminal, run
locale→LANG="",LC_CTYPE="C"; then type any non-ASCII character.VS Code works around the same launchd behavior with
terminal.integrated.detectLocale; this is the minimal equivalent.Checklist
Note
Low Risk
Small, localized change to terminal spawn environment with explicit-locale guardrails and tests; no auth or data-path impact.
Overview
Fixes integrated terminals starting in the C locale when the app is launched from the macOS Dock/Finder (launchd does not set
LANG/LC_*), which caused zsh to mangle multibyte input.withUtf8LocaleFallbackruns after AppImage env scrubbing increateTerminalSpawnEnv. If neitherLANGnorLC_ALLis set, it injectsen_US.UTF-8on macOS andC.UTF-8on other non-Windows platforms; Windows and any explicit locale are unchanged. PTY spawn now passes platform into env construction.Tests cover the macOS fallback and preserving an explicit non-UTF-8
LANG.Reviewed by Cursor Bugbot for commit 7b709cb. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Fall back to a UTF-8 locale in terminal spawn env on non-Windows platforms
Introduces
withUtf8LocaleFallbackin Manager.ts to inject aLANGfallback whenLC_ALLandLANGare absent from the spawn environment. On macOS the fallback isen_US.UTF-8; on other non-Windows platforms it isC.UTF-8. Windows and envs with an explicit locale are left unchanged.createTerminalSpawnEnvnow accepts aplatformargument and pipes the env through this fallback after stripping AppImage variables.Macroscope summarized 7b709cb.