diff --git a/frontend/src/components/viewer/LocalEmbedPDF.tsx b/frontend/src/components/viewer/LocalEmbedPDF.tsx
index f9a8e3fc9..a496e0798 100644
--- a/frontend/src/components/viewer/LocalEmbedPDF.tsx
+++ b/frontend/src/components/viewer/LocalEmbedPDF.tsx
@@ -20,6 +20,8 @@ import { RotatePluginPackage, Rotate } from '@embedpdf/plugin-rotate/react';
import { Rotation } from '@embedpdf/models';
import { CustomSearchLayer } from './CustomSearchLayer';
import { ZoomAPIBridge } from './ZoomAPIBridge';
+import ToolLoadingFallback from '../tools/ToolLoadingFallback';
+import { Center, Stack, Text } from '@mantine/core';
import { ScrollAPIBridge } from './ScrollAPIBridge';
import { SelectionAPIBridge } from './SelectionAPIBridge';
import { PanAPIBridge } from './PanAPIBridge';
@@ -121,55 +123,31 @@ export function LocalEmbedPDF({ file, url }: LocalEmbedPDFProps) {
// Early return if no file or URL provided
if (!file && !url) {
return (
-
+
+
+ 📄
+
+ No PDF provided
+
+
+
);
}
if (isLoading || !engine || !pdfUrl) {
- return (
-
-
-
⏳
-
Loading PDF Engine...
-
-
- );
+ return ;
}
if (error) {
return (
-
-
-
❌
-
Error loading PDF engine: {error.message}
-
-
+
+
+ ❌
+
+ Error loading PDF engine: {error.message}
+
+
+
);
}
diff --git a/frontend/src/components/viewer/ThumbnailSidebar.tsx b/frontend/src/components/viewer/ThumbnailSidebar.tsx
index 8a9b42bda..c6da278ad 100644
--- a/frontend/src/components/viewer/ThumbnailSidebar.tsx
+++ b/frontend/src/components/viewer/ThumbnailSidebar.tsx
@@ -15,6 +15,13 @@ export function ThumbnailSidebar({ visible, onToggle: _onToggle }: ThumbnailSide
const scrollState = getScrollState();
const thumbnailAPI = getThumbnailAPI();
+ // Clear thumbnails when sidebar closes
+ useEffect(() => {
+ if (!visible) {
+ setThumbnails({});
+ }
+ }, [visible]);
+
// Generate thumbnails when sidebar becomes visible
useEffect(() => {
if (!visible || scrollState.totalPages === 0) return;
@@ -45,7 +52,6 @@ export function ThumbnailSidebar({ visible, onToggle: _onToggle }: ThumbnailSide
} catch (error) {
console.error('Failed to generate thumbnail for page', pageIndex + 1, error);
- // Set a placeholder or error state
setThumbnails(prev => ({
...prev,
[pageIndex]: 'error'
@@ -55,16 +61,7 @@ export function ThumbnailSidebar({ visible, onToggle: _onToggle }: ThumbnailSide
};
generateThumbnails();
-
- // Cleanup blob URLs when component unmounts
- return () => {
- Object.values(thumbnails).forEach(url => {
- if (url.startsWith('blob:')) {
- URL.revokeObjectURL(url);
- }
- });
- };
- }, [visible, scrollState.totalPages, thumbnailAPI]);
+ }, [visible, scrollState.totalPages, thumbnailAPI, thumbnails]);
const handlePageClick = (pageIndex: number) => {
const pageNumber = pageIndex + 1; // Convert to 1-based