Skip to content

fix(fs): suppress visible console windows for git.exe children on Windows - #80

Open
DaisyHunter wants to merge 1 commit into
aoci-spec:mainfrom
DaisyHunter:fix/windows-git-child-console
Open

DaisyHunter wants to merge 1 commit into
aoci-spec:mainfrom
DaisyHunter:fix/windows-git-child-console

Conversation

@DaisyHunter

Copy link
Copy Markdown

Fixes #79 — root cause, the measurement method, and the full evidence table are documented there.

Problem

On Windows, every git probe aoci performs spawns a visible console window that steals focus when aoci itself runs console-less (MCP stdio spawned by a host). During agent sessions this happens constantly — see #79 for the user impact and the MainWindowHandle sampling method.

Change

  • internal/fs/git_command.go — the hardened git constructor now calls hideChildConsole(command); all hardening arguments and GIT_OPTIONAL_LOCKS=0 are untouched.
  • internal/fs/git_command_windows.go (new) — sets SysProcAttr{HideWindow: true, CreationFlags: CREATE_NO_WINDOW}.
  • internal/fs/git_command_other.go (new) — no-op stub for non-Windows platforms.
  • internal/fs/git_command_windows_test.go (new) — pins the window-suppression invariant so a refactor cannot silently drop it (platform-suffixed test file, following atomic_create_windows_test.go).

Stdio handle inheritance is not affected by CREATE_NO_WINDOW, so host pipes and interactive terminal output behave exactly as before.

Change evidence (per CONTRIBUTING)

  • Problem and intended boundary: only console allocation for git.exe children on Windows; no change to what git is invoked with, or to env, argv, stdio, or the hardening pipeline.
  • Public contracts and compatibility: no MCP tool, protocol, JSON, or data-format identity change; MCP stdout purity unchanged (blackbox conformance asserts it).
  • Tests run and results (Windows 11, Go 1.26.8): gofmt -l clean; go vet ./... clean; staticcheck 2026.2.1 zero findings; go test ./internal/fs -count=1 green including the new invariant test; go test ./... -count=1 green except 17 pre-existing internal/cli failures reproduced identically on unpatched rc14 (attributed in a [bug] Windows11环境下频繁终端弹窗,干扰鼠标与键盘操作 #79 comment — test-fixture path injection baseline.json.bak\blocker is a no-op on Windows); blackbox mcp_conformance.py 44/46 (the 2 misses are the suite's own aoci-code-relative search expectations run against a third-party repo) and mcp_scenarios.py 57 PASS / 2 CHARACTERIZED / 0 FAIL (T1 no-pty, P2 NTFS trailing-space directory — both platform characterizations, not failures).
  • Operating-system impact: behavior change is Windows-only; cross-compile verified for linux/amd64, darwin/arm64, windows/amd64.
  • Persistence, migration, recovery: none — no persisted artifact, format, or schema is touched.

…dows

UntrustedRepositoryGitCommand is the single channel for every git fact
aoci reads about a repository. When aoci itself runs console-less (MCP
stdio spawned by a host), Windows allocates a new visible console for
each git.exe child, so every refresh flashes a terminal window and
steals focus (issue aoci-spec#79).

hideChildConsole pins CREATE_NO_WINDOW + HideWindow on Windows and is a
no-op on other platforms. Stdio handle inheritance is untouched, so
host pipes and interactive terminal output behave exactly as before.

Evidence: console-less 'aoci check' sampled 1310 git.exe children with
zero windowed handles; on the patched binary gofmt/vet/staticcheck are
clean, the fs package tests (including a new invariant test) pass, and
linux/darwin/windows builds verify the platform stub. Blackbox suites
on Windows: conformance 44/46 (the 2 misses are the suite's own
aoci-code-relative expectations run against a third-party repo) and
scenarios 57 PASS / 2 CHARACTERIZED / 0 FAIL.

Fixes aoci-spec#79
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] Windows11环境下频繁终端弹窗,干扰鼠标与键盘操作

1 participant