fix(ui-tui): prevent React effect cleanup from killing python TUI gateway subprocess

The useEffect at useMainApp.ts:546-565 calls gw.kill() in its cleanup function. React calls cleanup on every re-render when the dependency array ([gw, sys]) shifts — which happens whenever sys changes identity (any system message). This sends SIGTERM to the Python TUI gateway subprocess, silently killing the backend mid-session.

The kill path was already handled by entry.tsx's setupGracefulExit for real app exits (SIGINT, uncaught exception). The die() function also calls gw.kill() for explicit user exit. Removing the cleanup kill leaves all exit paths covered while preventing accidental mid-session kills on ordinary React re-renders.
This commit is contained in:
Nexus 2026-04-28 20:20:16 +01:00 committed by Teknium
parent 1a03e3b1c6
commit 660ce7c54b

View file

@ -606,10 +606,10 @@ export function useMainApp(gw: GatewayClient) {
gw.on('exit', exitHandler)
gw.drain()
// entry.tsx's setupGracefulExit handles process cleanup on real exit.
return () => {
gw.off('event', handler)
gw.off('exit', exitHandler)
gw.kill()
}
}, [gw, sys])