From 72807afbb4b664a9a4c5235d72ee08404961f740 Mon Sep 17 00:00:00 2001 From: Kiet Ho Date: Sat, 7 Feb 2026 08:27:17 -0800 Subject: [PATCH] fix(desktop): simplify chat re-render fix by removing unnecessary refs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace the ref-based workaround for tRPC mutation stability with a simple eslint-disable. Mutations are stable transports that don't need to be reactive dependencies — an eslint suppression is clearer and avoids 4 lines of boilerplate. --- .../TabView/ChatPane/ChatInterface/ChatInterface.tsx | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/TabView/ChatPane/ChatInterface/ChatInterface.tsx b/apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/TabView/ChatPane/ChatInterface/ChatInterface.tsx index 0cd3af92538..33e3db8b516 100644 --- a/apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/TabView/ChatPane/ChatInterface/ChatInterface.tsx +++ b/apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/TabView/ChatPane/ChatInterface/ChatInterface.tsx @@ -85,19 +85,15 @@ export function ChatInterface({ sessionId, cwd }: ChatInterfaceProps) { }); const stopSession = electronTrpc.aiChat.stopSession.useMutation(); - const startSessionRef = useRef(startSession); - startSessionRef.current = startSession; - const stopSessionRef = useRef(stopSession); - stopSessionRef.current = stopSession; - useEffect(() => { if (!sessionId || !cwd) return; hasConnected.current = false; setSessionReady(false); - startSessionRef.current.mutate({ sessionId, cwd }); + startSession.mutate({ sessionId, cwd }); return () => { - stopSessionRef.current.mutate({ sessionId }); + stopSession.mutate({ sessionId }); }; + // eslint-disable-next-line react-hooks/exhaustive-deps -- mutations are stable transports, not reactive deps }, [sessionId, cwd]); // Connect once both session is ready and config has loaded