From 9964a7fd1a10907c579db4e3aea7b2eda8d383c2 Mon Sep 17 00:00:00 2001 From: David Kaya Date: Tue, 24 Mar 2026 00:23:30 +0100 Subject: [PATCH] fix: move useCallback before early return to fix hooks ordering The jumpToMessage useCallback was placed after a conditional return, violating React's Rules of Hooks and crashing the app on render. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- src/renderer/App.tsx | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/renderer/App.tsx b/src/renderer/App.tsx index 223ba73..326e52e 100644 --- a/src/renderer/App.tsx +++ b/src/renderer/App.tsx @@ -173,6 +173,15 @@ export default function App() { [workspace?.projects], ); + const jumpToMessage = useCallback((messageId: string) => { + const element = document.querySelector(`[data-message-id="${CSS.escape(messageId)}"]`); + if (element) { + element.scrollIntoView({ behavior: 'smooth', block: 'center' }); + element.classList.add('ring-1', 'ring-indigo-500/40', 'rounded-lg'); + setTimeout(() => element.classList.remove('ring-1', 'ring-indigo-500/40', 'rounded-lg'), 1500); + } + }, []); + // Loading state if (!workspace) { return ( @@ -192,15 +201,6 @@ export default function App() { } }; - const jumpToMessage = useCallback((messageId: string) => { - const element = document.querySelector(`[data-message-id="${CSS.escape(messageId)}"]`); - if (element) { - element.scrollIntoView({ behavior: 'smooth', block: 'center' }); - element.classList.add('ring-1', 'ring-indigo-500/40', 'rounded-lg'); - setTimeout(() => element.classList.remove('ring-1', 'ring-indigo-500/40', 'rounded-lg'), 1500); - } - }, []); - // Determine main content let content: React.ReactNode; let detailPanel: React.ReactNode | undefined;