[PR #13222] fix: resolve ACP hanging indefinitely in thinking state on Windows #14567

Closed
opened 2026-02-16 18:19:21 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/13222

State: closed
Merged: Yes


Problem

When using OpenCode through ACP (e.g. JetBrains AI Assistant), the agent gets stuck on "Thinking..." forever on Windows.

Root cause

Bun's $ shell template tag makes child processes inherit the parent's stdin. In ACP mode, stdin is a pipe carrying protocol data (ndjson between the IDE and OpenCode). On Windows, when git inherits this pipe, the child process deadlocks and never finishes. This blocks Snapshot.track(), which blocks the stream processor, so no response ever shows up.

This doesn't happen in terminal mode because stdin is a normal TTY there, not a protocol pipe.

Fix

Added a git() utility (src/util/git.ts) that checks Flag.OPENCODE_CLIENT:

  • Default (terminal): Uses Bun's lightweight $ shell as before — no behavior change
  • ACP mode: Uses Bun.spawn with stdin: "ignore" so git doesn't inherit the protocol pipe

Updated snapshot/index.ts to use this utility for all git commands. No changes to the processor or ACP agent — snapshots stay fully blocking as intended.

Changes

  • packages/opencode/src/util/git.ts (new): git command wrapper that detaches stdin in ACP mode
  • packages/opencode/src/snapshot/index.ts (modified): uses the git utility instead of $ shell directly

Tested

On Windows 11 with JetBrains AI Assistant ACP. Before: stuck on "Thinking..." forever. After: responses show up immediately.

Fixes https://github.com/anomalyco/opencode/issues/7632
Fixes https://github.com/anomalyco/opencode/issues/7587
Fixes https://github.com/anomalyco/opencode/issues/3730
Fixes https://github.com/anomalyco/opencode/issues/12133
Fixes https://github.com/anomalyco/opencode/issues/7587
Fixes https://github.com/anomalyco/opencode/issues/13024

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/13222 **State:** closed **Merged:** Yes --- ## Problem When using OpenCode through ACP (e.g. JetBrains AI Assistant), the agent gets stuck on "Thinking..." forever on Windows. ## Root cause Bun's `$` shell template tag makes child processes inherit the parent's stdin. In ACP mode, stdin is a pipe carrying protocol data (ndjson between the IDE and OpenCode). On Windows, when git inherits this pipe, the child process deadlocks and never finishes. This blocks `Snapshot.track()`, which blocks the stream processor, so no response ever shows up. This doesn't happen in terminal mode because stdin is a normal TTY there, not a protocol pipe. ## Fix Added a `git()` utility (`src/util/git.ts`) that checks `Flag.OPENCODE_CLIENT`: - **Default (terminal):** Uses Bun's lightweight `$` shell as before — no behavior change - **ACP mode:** Uses `Bun.spawn` with `stdin: "ignore"` so git doesn't inherit the protocol pipe Updated `snapshot/index.ts` to use this utility for all git commands. No changes to the processor or ACP agent — snapshots stay fully blocking as intended. ## Changes - **`packages/opencode/src/util/git.ts`** (new): git command wrapper that detaches stdin in ACP mode - **`packages/opencode/src/snapshot/index.ts`** (modified): uses the git utility instead of `$` shell directly ## Tested On Windows 11 with JetBrains AI Assistant ACP. Before: stuck on "Thinking..." forever. After: responses show up immediately. Fixes https://github.com/anomalyco/opencode/issues/7632 Fixes https://github.com/anomalyco/opencode/issues/7587 Fixes https://github.com/anomalyco/opencode/issues/3730 Fixes https://github.com/anomalyco/opencode/issues/12133 Fixes https://github.com/anomalyco/opencode/issues/7587 Fixes https://github.com/anomalyco/opencode/issues/13024
yindo added the pull-request label 2026-02-16 18:19:21 -05:00
yindo closed this issue 2026-02-16 18:19:21 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#14567