fix(opencode): preserve OCR output on Windows (#1606)
Some checks failed
CI / cross-compile (amd64, darwin) (push) Has been cancelled
CI / cross-compile (arm64, darwin) (push) Has been cancelled
CI / cross-compile (arm64, linux) (push) Has been cancelled
CI / test (push) Has been cancelled
CI / cross-compile (amd64, windows) (push) Has been cancelled
CI / windows (push) Has been cancelled
CI / cross-compile (arm64, windows) (push) Has been cancelled
CodeQL Advanced / Analyze (actions) (push) Has been cancelled
CodeQL Advanced / Analyze (javascript-typescript) (push) Has been cancelled
plugin-contract / plugin-contract (push) Has been cancelled
CodeQL Advanced / Analyze (go) (push) Has been cancelled

Co-authored-by: Kite <254839944+lizhengfeng101@users.noreply.github.com>
This commit is contained in:
OUAO-FRANK 2026-10-10 16:37:26 +08:00 • committed by GitHub
parent 35fc3e259d
commit 357c3f09a2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 19 additions and 1 deletions

View file

@ -178,7 +178,7 @@ async function runOcr(args: string[], options: RunOptions): Promise<RunResult> {
cwd: options.cwd,
env: process.env,
shell: false,
detached: true,
detached: process.platform !== "win32",
},
)
child.stdin.end()

View file

@ -358,6 +358,24 @@ test("ocr_review reports non-zero exits with OCR output", async () => {
)
})
test("ocr_review preserves output from the Windows command shim", { skip: process.platform !== "win32" }, async () => {
await withFakeOcr(
"console.error('windows shim output'); process.exit(7)",
async (worktree) => {
const { hooks } = await loadPlugin(worktree)
await assert.rejects(
hooks.tool.ocr_review.execute({}, toolContext(worktree)),
(error) => {
assert.equal(error.name, "OcrExecutionError")
assert.equal(error.exitCode, 7)
assert.match(error.message, /windows shim output/)
return true
},
)
},
)
})
test("ocr_review removes its temporary background after a non-zero exit", async () => {
await withFakeOcr(
[