Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion apps/desktop-ui/src/app/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Suspense } from "react";
import { cookies } from "next/headers";
import { SidebarProvider } from "@/components/ui/sidebar";
import { AppContent } from "./app-content";
Expand All @@ -14,7 +15,12 @@ export default async function Layout({ children }: { children: React.ReactNode }

return (
<SidebarProvider defaultOpen={defaultOpen}>
<AppContent>{children}</AppContent>
{/* Suspense boundary so tool pages that read useSearchParams() (base64,
jwt-decoder, hash-generator, url-encode, json-formatter, qr-code) pass
the static export prerender instead of erroring on a CSR bailout. */}
<AppContent>
<Suspense fallback={null}>{children}</Suspense>
</AppContent>
</SidebarProvider>
);
}
9 changes: 6 additions & 3 deletions apps/desktop-ui/src/store/pinned-tools-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,16 @@ export const usePinnedToolsStore = create<PinnedToolsStore>()(

/** Returns true once the persisted state has finished rehydrating from storage. */
export function usePinnedToolsHydrated(): boolean {
const [hydrated, setHydrated] = useState(() => usePinnedToolsStore.persist.hasHydrated())
// `.persist` is absent during the static-export prerender (no storage on the
// server), so guard every access — "hydrated" is simply false there, and the
// real value resolves on the client where the persist API exists.
const [hydrated, setHydrated] = useState(() => usePinnedToolsStore.persist?.hasHydrated?.() ?? false)
useEffect(() => {
if (usePinnedToolsStore.persist.hasHydrated()) {
if (usePinnedToolsStore.persist?.hasHydrated?.()) {
setHydrated(true)
return
}
const unsub = usePinnedToolsStore.persist.onFinishHydration(() => setHydrated(true))
const unsub = usePinnedToolsStore.persist?.onFinishHydration?.(() => setHydrated(true))
return unsub
}, [])
return hydrated
Expand Down