Skip to content

fix(vscode): set TZ for gh child processes on Windows - #12922

Closed
santhiprakash wants to merge 1 commit into
Kilo-Org:mainfrom
santhiprakash:fix/vscode-gh-tz-12912
Closed

fix(vscode): set TZ for gh child processes on Windows#12922
santhiprakash wants to merge 1 commit into
Kilo-Org:mainfrom
santhiprakash:fix/vscode-gh-tz-12912

Conversation

@santhiprakash

Copy link
Copy Markdown

Issue

Fixes #12912

Context

When gh is spawned on Windows without TZ in its environment, it calls tzutil.exe to resolve the local time zone. When Windows Terminal is the default terminal, that tzutil child 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 spawns gh through execWithShellEnv in packages/kilo-vscode/src/agent-manager/shell-env.ts, so this is the single choke-point where we can stop the console flash for every gh call.

Implementation

  • Added a withTzEnv helper in shell-env.ts that:
    • only runs on process.platform === "win32";
    • only applies when the spawned command is gh (by base name, stripping .exe);
    • uses process.env.TZ if set, otherwise falls back to Intl.DateTimeFormat().resolvedOptions().timeZone and caches the result;
    • respects an explicit TZ already present in the caller-supplied env.
  • execWithShellEnv now wraps every invocation with withTzEnv before calling exec(), so PRStatusPoller, WorktreeManager, and any future gh callers all get TZ automatically.
  • util/process.ts already forces windowsHide: true on every child process, but the visible window comes from the tzutil grandchild spawned by gh, so hiding the gh window alone is not enough. Passing TZ prevents gh from spawning tzutil in the first place.
  • Added a focused unit test in packages/kilo-vscode/tests/unit/shell-env.test.ts covering: TZ injection, fallback inference, non-gh commands, non-Windows platforms, and explicit TZ preservation.
  • Added a .changeset for 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 fail
  • bun run lint → pass
  • bun run typecheck → pass
  • bun run format:check → pass
  • bun run knip → pass
  • bun run script/check-md-table-padding.ts → pass

Reviewer test steps

  1. On Windows, set Windows Terminal as the default terminal.
  2. Open a workspace where the Agent Manager polls PR status.
  3. Observe that gh calls from PRStatusPoller no longer flash a console window.

Blocked checks and substitute verification

The local git push pre-push hook runs the full bun turbo typecheck pipeline. The JetBrains typecheck attempted to download Gradle and failed with a network timeout (java.net.SocketTimeoutException: Connect timed out while fetching gradle-9.4.1-bin.zip). This is unrelated to the kilo-vscode changes. Substitute verification:

  • bun turbo typecheck --filter='!@kilocode/kilo-jetbrains' completed successfully (28 tasks, all type checks passed).
  • bun run typecheck in packages/kilo-vscode/ completed successfully.

Checklist

  • Issue linked above, or exception explained
  • Tests/verification described
  • Screenshots/video included for visual changes, or marked N/A
  • Changeset considered for user-facing changes
  • I personally reviewed the diff and can explain the changes, including any AI-assisted work.

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"))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

@kilo-code-bot

kilo-code-bot Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: 1 Issue Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 0
SUGGESTION 1
Issue Details (click to expand)

SUGGESTION

File Line Issue
packages/kilo-vscode/tests/unit/shell-env.test.ts 24 fs.symlinkSync may fail with EPERM for Windows contributors without Developer Mode/elevation; consider a copy fallback or skip

The fix itself is sound: withTzEnv is correctly gated to win32 + gh basename, preserves caller-supplied TZ, all gh spawns route through execWithShellEnv (verified choke point), the cached inferredTz introduces no memory leak, tests exercise real child processes, and the changeset is user-facing.

Fix these issues in Kilo Cloud

Files Reviewed (3 files)
  • .changeset/fix-gh-tz-windows-console.md - 0 issues
  • packages/kilo-vscode/src/agent-manager/shell-env.ts - 0 issues
  • packages/kilo-vscode/tests/unit/shell-env.test.ts - 1 issue

Reviewed by kimi-k3 · Input: 80.8K · Output: 16.7K · Cached: 756.7K

Review guidance: REVIEW.md from base branch main

@johnnyeric

Copy link
Copy Markdown
Contributor

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!

@johnnyeric johnnyeric closed this Aug 6, 2026
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.

VS Code extension spawns gh (GitHub CLI) with visible console windows — terminal flashes over fullscreen games

2 participants