From 7ecab519ed1c05f2c02c72da70f6f2c72c5d1d5c Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Thu, 2 Apr 2026 03:05:15 -0500 Subject: [PATCH] Fix VersionCheck crash: move VersionCheck and Toaster inside BrowserRouter VersionCheck uses which requires React Router context. It was rendered in App.tsx outside BrowserRouter, causing a null destructuring error at runtime. Moved VersionCheck and Toaster into AppRouter.tsx inside BrowserRouter. Also added null check and truncation for changelog excerpt items to prevent undefined access and overly long toast descriptions. --- src/App.tsx | 5 +---- src/AppRouter.tsx | 4 ++++ src/components/VersionCheck.tsx | 7 +++++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index fab7a7dc..8bfaff91 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -8,7 +8,6 @@ import { Suspense, useEffect } from 'react'; import LightningFS from '@isomorphic-git/lightning-fs'; import NostrProvider from '@/components/NostrProvider'; import { NostrSync } from '@/components/NostrSync'; -import { Toaster } from "@/components/ui/toaster"; import { TooltipProvider } from "@/components/ui/tooltip"; import { NostrLoginProvider } from '@nostrify/react/login'; import { AppProvider } from '@/components/AppProvider'; @@ -30,7 +29,7 @@ import { OfflineIndicator } from '@/components/OfflineIndicator'; import { PWAUpdatePrompt } from '@/components/PWAUpdatePrompt'; import { ErrorBoundary } from '@/components/ErrorBoundary'; import { LockdownModeDetector } from '@/components/LockdownModeDetector'; -import { VersionCheck } from '@/components/VersionCheck'; + import AppRouter from './AppRouter'; @@ -149,11 +148,9 @@ export function App() { - - diff --git a/src/AppRouter.tsx b/src/AppRouter.tsx index 01f1d710..5b263dbf 100644 --- a/src/AppRouter.tsx +++ b/src/AppRouter.tsx @@ -1,7 +1,9 @@ import { BrowserRouter, Route, Routes } from "react-router-dom"; +import { Toaster } from "./components/ui/toaster"; import { ScrollToTop } from "./components/ScrollToTop"; import { SessionMonitor } from "./components/SessionMonitor"; import { URLFragmentHandler } from "./components/URLFragmentHandler"; +import { VersionCheck } from "./components/VersionCheck"; import Index from "./pages/Index"; import Clone from "./pages/Clone"; @@ -28,6 +30,8 @@ import { ChangelogPage } from "./pages/ChangelogPage"; export function AppRouter() { return ( + + diff --git a/src/components/VersionCheck.tsx b/src/components/VersionCheck.tsx index d4a300c9..58ddb47c 100644 --- a/src/components/VersionCheck.tsx +++ b/src/components/VersionCheck.tsx @@ -19,8 +19,11 @@ async function fetchChangelogExcerpt(version: string): Promise e.version === version) ?? entries[0]; if (!entry) return undefined; - // Return the first item from the first section. - return entry.sections[0]?.items[0]; + // Return a truncated first item from the first section. + const item = entry.sections[0]?.items[0]; + if (!item) return undefined; + if (item.length <= 60) return item; + return item.slice(0, 60).trimEnd() + '…'; } catch { return undefined; }