fix(vscode): set TZ for gh child processes on Windows - #12922
fix(vscode): set TZ for gh child processes on Windows#12922santhiprakash wants to merge 1 commit into
Conversation
When gh is spawned on Windows without TZ, it calls tzutil.exe to resolve the local time zone. With Windows Terminal as the default terminal, that spawns a visible console window that flashes over fullscreen games. Inject TZ (from process.env.TZ or Intl.DateTimeFormat) into the child environment for every gh invocation on Windows. This covers PRStatusPoller, WorktreeManager, and any future gh callers that go through shell-env. Fixes Kilo-Org#12912
|
|
||
| function fakeGhBin(): { dir: string; cleanup: () => void } { | ||
| const dir = fs.mkdtempSync(path.join(os.tmpdir(), "gh-tz-")) | ||
| fs.symlinkSync(process.execPath, path.join(dir, "gh")) |
There was a problem hiding this comment.
SUGGESTION: fs.symlinkSync may fail for Windows contributors running these tests locally
Creating a file symlink on Windows requires Developer Mode or an elevated process (SeCreateSymbolicLinkPrivilege). A contributor on Windows without either will hit EPERM: operation not permitted, symlink here and the whole TZ suite fails before reaching its assertions. CI only runs these tests on Linux, so it won't catch that.
Consider a small fallback, e.g. try { fs.symlinkSync(...) } catch { fs.copyFileSync(process.execPath, path.join(dir, "gh")) }, or skip the suite when symlink creation isn't permitted. The git symlink in the "non-gh commands" test below has the same exposure.
Reply with @kilocode-bot fix it to have Kilo Code address this issue.
Code Review SummaryStatus: 1 Issue Found | Recommendation: Address before merge Overview
Issue Details (click to expand)SUGGESTION
The fix itself is sound: Fix these issues in Kilo Cloud Files Reviewed (3 files)
Reviewed by kimi-k3 · Input: 80.8K · Output: 16.7K · Cached: 756.7K Review guidance: REVIEW.md from base branch |
|
Thanks for your contribution! This has been superseded by #12936, so I’m closing this PR. I really appreciate your time and effort. Hope to see more from you! |
Issue
Fixes #12912
Context
When
ghis spawned on Windows withoutTZin its environment, it callstzutil.exeto resolve the local time zone. When Windows Terminal is the default terminal, thattzutilchild creates a visible console window that flashes for ~300–500 ms and steals focus from fullscreen games.The
PRStatusPoller(and other Agent Manager code) already spawnsghthroughexecWithShellEnvinpackages/kilo-vscode/src/agent-manager/shell-env.ts, so this is the single choke-point where we can stop the console flash for everyghcall.Implementation
withTzEnvhelper inshell-env.tsthat:process.platform === "win32";gh(by base name, stripping.exe);process.env.TZif set, otherwise falls back toIntl.DateTimeFormat().resolvedOptions().timeZoneand caches the result;TZalready present in the caller-suppliedenv.execWithShellEnvnow wraps every invocation withwithTzEnvbefore callingexec(), soPRStatusPoller,WorktreeManager, and any futureghcallers all getTZautomatically.util/process.tsalready forceswindowsHide: trueon every child process, but the visible window comes from thetzutilgrandchild spawned bygh, so hiding theghwindow alone is not enough. PassingTZpreventsghfrom spawningtzutilin the first place.packages/kilo-vscode/tests/unit/shell-env.test.tscovering: TZ injection, fallback inference, non-gh commands, non-Windows platforms, and explicitTZpreservation..changesetfor the user-facing bug fix.Screenshots / Video
N/A — the visible console window is a transient Windows Terminal focus-steal that cannot be captured in a static screenshot, and the fix is verified by the unit tests.
How to Test
Manual/local verification
bun test tests/unit/shell-env.test.ts→ 15 pass (TZ-specific cases pass)bun run test:unit→ 3732 pass, 0 failbun run lint→ passbun run typecheck→ passbun run format:check→ passbun run knip→ passbun run script/check-md-table-padding.ts→ passReviewer test steps
ghcalls fromPRStatusPollerno longer flash a console window.Blocked checks and substitute verification
The local
git pushpre-push hook runs the fullbun turbo typecheckpipeline. The JetBrains typecheck attempted to download Gradle and failed with a network timeout (java.net.SocketTimeoutException: Connect timed outwhile fetchinggradle-9.4.1-bin.zip). This is unrelated to thekilo-vscodechanges. Substitute verification:bun turbo typecheck --filter='!@kilocode/kilo-jetbrains'completed successfully (28 tasks, all type checks passed).bun run typecheckinpackages/kilo-vscode/completed successfully.Checklist