Skip to content

snapshot: console window flashes on Windows when snapshot service spawns git #52433

Closed as not planned

Description

@omysurya

Summary

On Windows, the snapshot service spawns git.exe hundreds of times per minute against its shadow repository, and every one of those spawns briefly flashes a console window on screen. Because the children are spawned without a hide-window flag, Windows allocates a fresh conhost.exe for each invocation and tears it down immediately, which is the millisecond flicker observed while the agent is working.

Environment

  • opencode version: 2.0.21
  • OS: Windows 11 Pro, build 26200 (10.0.26200.9550), x64
  • Terminal: Windows Terminal (WT_SESSION present), TERM=xterm-256color
  • Shell: C:\Windows\system32\cmd.exe (opencode spawns pwsh.exe 7.6.6 for the shell tool)
  • Git: 2.55.0.windows.5 (C:\Program Files\Git\cmd\git.EXE)
  • Install/channel: npm global @opencode/cli, channel latest
  • Active plugins: none configured

Reproduction

  1. On Windows, start opencode in a git repository with snapshots enabled (the default).
  2. Let the agent work. No interaction is required.
  3. A console window flashes in the background repeatedly, roughly every few seconds, while the agent is running.
  4. Confirm the source by counting spawns in the server log:
Select-String -Path "$env:USERPROFILE\.local\share\opencode\log\opencode.log" `
  -Pattern 'message="spawning process" command=".*git\.EXE"' | Measure-Object

Expected Behavior

Helper processes spawned by opencode should not create or steal visible console windows. Short-lived internal Git invocations against opencode's own shadow repository should be invisible to the user.

Actual Behavior

A console window appears and disappears repeatedly, with each flash lasting a few milliseconds. The frequency correlates with agent activity.

Measured on this machine, from opencode.log:

  • 935 total git.exe spawns logged in one session
  • 850 (90.9%) of those targeted the snapshot shadow repository under ~/.local/share/opencode/snapshot/<hash>/<hash>, not the project repository
  • By subcommand, for the shadow repository alone:
Subcommand Count
write-tree 540
ls-files 270
diff-files 270
add 19
init 1

A representative log line (hashes redacted):

message="spawning process" command="C:\\Program Files\\Git\\cmd\\git.EXE"
args="[\"--git-dir\",\"<USERPROFILE>\\.local\\share\\opencode\\snapshot\\<hash>\\<hash>\",
\"--work-tree\",\"<project>\",\"diff-files\"]" role=server

write-tree running at twice the rate of ls-files suggests the snapshot loop commits a tree on every watcher tick rather than only when the worktree actually changed, which is what keeps the flicker going for the whole turn.

No PTY is involved. The log contains zero opencode-pty / foreground_process events, so this is unrelated to the terminal tool. The flashing process is a direct child conhost.exe created per git.exe spawn.

Additional Context

The shipped opencode.exe binary contains no window-hiding flags anywhere in its own process helper. A string scan of the binary returns:

  • CREATE_NO_WINDOW: 0 occurrences
  • SW_HIDE: 0 occurrences
  • STARTF_USESHOWWINDOW: 0 occurrences
  • ShowWindow / hwnd: 0 occurrences
  • windowsHide: 23 occurrences, all inside the bundled Node/Bun compatibility layer (child_process shim, cluster, node:child_process) and none in the spawn path used here

The spawn is emitted by opencode's own @opencode/AppProcess module, which wraps the effect platform Command. The options it forwards do not include a hide-window flag, so on Windows each console subsystem binary (git.exe) allocates a console window that is destroyed when the process exits. That is the entire flicker mechanism.

The existing silent option in the binary is about stdio and doNotPauseOnExceptionsAndMuteConsole, not window visibility, so there is no configuration setting that suppresses this today.

Workaround used here: setting "snapshots": false in opencode.json. After a service restart the snapshot Git spawns drop to zero and the flicker stops, which also confirms the attribution. This costs the undo/revert feature, so the underlying spawn flag is still worth fixing.

Suggested fix: pass windowsHide: true (equivalently CREATE_NO_WINDOW) for child processes that opencode spawns for its own internal use, at minimum in the snapshot and Git helper paths. If a single default is inappropriate for the terminal tool, which is intended to own a visible PTY, scoping the flag to non-PTY spawns would be reasonable.

Note: the write-tree / ls-files / diff-files repetition looks like a separate efficiency issue, and coalescing snapshot ticks would reduce process churn even where the window does not flash.

Activity

  1. github-actions commented on Oct 1, 2026

    @github-actions
    Contributor

    This issue doesn't fully meet our contributing guidelines.

    What needs to be fixed:

    • Use the Bug Report template and include its required Description field; the current body uses custom headings instead of the template.
    • Shorten the unusually long technical write-up into a concise description in your own words. Keep the core symptom, reproduction steps, and essential environment details.

    Please edit this issue to address the above within 72 hours, or it will be automatically closed.


    This issue might be a duplicate of existing issues. Please check:

    If you believe this was flagged incorrectly, please let a maintainer know.

  2. github-actions commented on Oct 4, 2026

    @github-actions
    Contributor

    This issue has been automatically closed because it was not updated to meet our contributing guidelines within the 72-hour window.

    Feel free to open a new issue that follows our issue templates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions