From 4c4e63888a505bb96cbc4a35ca2eb7be56d656a1 Mon Sep 17 00:00:00 2001 From: wenshao Date: Mon, 6 Apr 2026 14:21:28 +0800 Subject: [PATCH] fix: kill child process when statusLine config is removed When statusLineCommand becomes undefined (user removes the setting), kill any in-flight child process, bump generation counter, and clear the debounce timer so stale callbacks cannot resurrect the output. Co-Authored-By: Claude Opus 4.6 (1M context) --- packages/cli/src/ui/hooks/useStatusLine.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/cli/src/ui/hooks/useStatusLine.ts b/packages/cli/src/ui/hooks/useStatusLine.ts index 24cac528e..be1d78b6b 100644 --- a/packages/cli/src/ui/hooks/useStatusLine.ts +++ b/packages/cli/src/ui/hooks/useStatusLine.ts @@ -204,6 +204,14 @@ export function useStatusLine(): { // Trigger update when meaningful state changes useEffect(() => { if (!statusLineCommand) { + // Command removed — kill any in-flight process and discard callbacks. + activeChildRef.current?.kill(); + activeChildRef.current = undefined; + generationRef.current++; + if (debounceTimerRef.current !== undefined) { + clearTimeout(debounceTimerRef.current); + debounceTimerRef.current = undefined; + } setOutput(null); return; } @@ -233,9 +241,8 @@ export function useStatusLine(): { if (!hasMountedRef.current) return; if (statusLineCommand) { doUpdate(); - } else { - setOutput(null); } + // Cleanup when command is removed is handled by the state-change effect. // eslint-disable-next-line react-hooks/exhaustive-deps }, [statusLineCommand]);