From 00bb5e1d249af10c53d09e1890f560eff07b3c85 Mon Sep 17 00:00:00 2001 From: Neil <4138956+nwparker@users.noreply.github.com> Date: Sat, 30 May 2026 06:05:30 -0700 Subject: [PATCH] fix: guard sidebar restart state (#3684) --- .../src/components/sidebar/SidebarToolbar.tsx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/renderer/src/components/sidebar/SidebarToolbar.tsx b/src/renderer/src/components/sidebar/SidebarToolbar.tsx index 26673dc4cb1..48658c3269d 100644 --- a/src/renderer/src/components/sidebar/SidebarToolbar.tsx +++ b/src/renderer/src/components/sidebar/SidebarToolbar.tsx @@ -23,6 +23,7 @@ import { DropdownMenuTrigger } from '@/components/ui/dropdown-menu' import { toast } from 'sonner' +import { useMountedRef } from '@/hooks/useMountedRef' import { showOnboardingFromRenderer } from '../onboarding/show-onboarding-event' import { SidebarFeedbackDialog } from './SidebarFeedbackDialog' import { ScrollToCurrentWorkspaceToolbarButton } from './ScrollToCurrentWorkspaceToolbarButton' @@ -44,6 +45,7 @@ const SidebarToolbar = React.memo(function SidebarToolbar() { const [showAdminHelpOptions, setShowAdminHelpOptions] = useState(false) const [isRestartingOrca, setIsRestartingOrca] = useState(false) const lastShowOnboardingAtRef = React.useRef(0) + const mountedRef = useMountedRef() const handleShowOnboarding = (): void => { const now = Date.now() @@ -75,10 +77,12 @@ const SidebarToolbar = React.memo(function SidebarToolbar() { setIsRestartingOrca(true) toast.info('Restarting Orca…') void window.api.app.restart().catch((error) => { - setIsRestartingOrca(false) - toast.error('Couldn’t restart Orca.', { - description: error instanceof Error ? error.message : undefined - }) + if (mountedRef.current) { + setIsRestartingOrca(false) + toast.error('Couldn’t restart Orca.', { + description: error instanceof Error ? error.message : undefined + }) + } }) }