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) <noreply@anthropic.com>
This commit is contained in:
wenshao 2026-04-06 14:21:28 +08:00
parent 1a985bb02e
commit 4c4e63888a

View file

@ -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]);