From 09d011fd832bdfdc232ef97f46f483cece00ab52 Mon Sep 17 00:00:00 2001 From: why <1577027554@qq.com> Date: Sat, 22 Aug 2026 15:54:07 +0800 Subject: [PATCH] fix(agents): hide async hook console window on Windows Add windowsHide to asynchronous shell hook processes so detached sh.exe processes do not flash a console window on Windows. Fixes #494 --- .../codemie-code-hooks/__tests__/shell-hooks-source.test.ts | 6 ++++++ src/agents/plugins/codemie-code-hooks/shell-hooks-source.ts | 1 + 2 files changed, 7 insertions(+) diff --git a/src/agents/plugins/codemie-code-hooks/__tests__/shell-hooks-source.test.ts b/src/agents/plugins/codemie-code-hooks/__tests__/shell-hooks-source.test.ts index 31b34a81a..c468cf926 100644 --- a/src/agents/plugins/codemie-code-hooks/__tests__/shell-hooks-source.test.ts +++ b/src/agents/plugins/codemie-code-hooks/__tests__/shell-hooks-source.test.ts @@ -90,6 +90,12 @@ beforeEach(() => { }); describe('SHELL_HOOKS_PLUGIN_SOURCE', () => { + it('hides the console window for asynchronous hook commands', () => { + expect(SHELL_HOOKS_PLUGIN_SOURCE).toMatch( + /spawn\("sh",\s*\["-c", command\],[\s\S]*?windowsHide:\s*true/, + ); + }); + it('exports an async factory returning flat dotted-key handlers', async () => { const hooks = await loadHooks(['UserPromptSubmit']); diff --git a/src/agents/plugins/codemie-code-hooks/shell-hooks-source.ts b/src/agents/plugins/codemie-code-hooks/shell-hooks-source.ts index 995d95c8e..9854c8c03 100644 --- a/src/agents/plugins/codemie-code-hooks/shell-hooks-source.ts +++ b/src/agents/plugins/codemie-code-hooks/shell-hooks-source.ts @@ -235,6 +235,7 @@ function execCommandAsync( env: { ...process.env, ...env }, stdio: ["pipe", "ignore", "ignore"], detached: true, + windowsHide: true, }); // A ChildProcess or stdin 'error' with no listener is an UNHANDLED error // event, which throws inside the host OpenCode process. Stop is configured