Skip to content

Commit 897b6bb

Browse files
committed
fix(pdf-server): remove page-loading overlay
The overlay had multiple issues: - Hardcoded white background broke dark mode - Could get stuck visible, breaking sizing/layout - Added little value since previous page stays visible during render and the 150ms delay meant most renders completed before it showed
1 parent b4ea8c5 commit 897b6bb

2 files changed

Lines changed: 0 additions & 77 deletions

File tree

examples/pdf-server/src/mcp-app.css

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -261,46 +261,6 @@ body {
261261
--min-font-size-inv: calc(1 / var(--min-font-size, 1));
262262
}
263263

264-
/* Page Loading Overlay - shown while page data is being fetched */
265-
.page-loading-overlay {
266-
position: absolute;
267-
top: 0;
268-
left: 0;
269-
right: 0;
270-
bottom: 0;
271-
display: flex;
272-
align-items: center;
273-
justify-content: center;
274-
background: rgba(255, 255, 255, 0.9);
275-
border-radius: 4px;
276-
z-index: 10;
277-
}
278-
279-
.page-loading-content {
280-
display: flex;
281-
flex-direction: column;
282-
align-items: center;
283-
gap: 0.75rem;
284-
padding: 1.5rem 2rem;
285-
background: var(--bg000);
286-
border: 1px solid var(--bg200);
287-
border-radius: 8px;
288-
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
289-
}
290-
291-
.page-loading-spinner {
292-
width: 32px;
293-
height: 32px;
294-
border: 3px solid var(--bg200);
295-
border-top-color: var(--text100);
296-
border-radius: 50%;
297-
animation: spin 0.8s linear infinite;
298-
}
299-
300-
.page-loading-text {
301-
font-size: 0.85rem;
302-
color: var(--text100);
303-
}
304264

305265
.text-layer :is(span, br) {
306266
color: transparent;

examples/pdf-server/src/mcp-app.ts

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -624,9 +624,6 @@ async function renderPage() {
624624
isRendering = true;
625625
pendingPage = null;
626626

627-
// Show loading overlay while page data is being fetched
628-
showPageLoadingOverlay();
629-
630627
try {
631628
const pageToRender = currentPage;
632629
const page = await pdfDocument.getPage(pageToRender);
@@ -719,7 +716,6 @@ async function renderPage() {
719716
log.error("Error rendering page:", err);
720717
showError(`Failed to render page ${currentPage}`);
721718
} finally {
722-
hidePageLoadingOverlay();
723719
preloadPaused = false;
724720
isRendering = false;
725721

@@ -1013,39 +1009,6 @@ type RangeResult = { bytes: Uint8Array; totalBytes: number };
10131009
const rangeCache = new Map<string, RangeResult>();
10141010
const inflightRequests = new Map<string, Promise<RangeResult>>();
10151011

1016-
// Page loading overlay state — shown after a delay so cached pages never flash it
1017-
let pageLoadingOverlay: HTMLElement | null = null;
1018-
let pageLoadingTimer: ReturnType<typeof setTimeout> | null = null;
1019-
const PAGE_LOADING_DELAY_MS = 150;
1020-
1021-
function showPageLoadingOverlay() {
1022-
if (pageLoadingOverlay || pageLoadingTimer) return; // Already showing or scheduled
1023-
1024-
pageLoadingTimer = setTimeout(() => {
1025-
pageLoadingTimer = null;
1026-
const overlay = document.createElement("div");
1027-
overlay.className = "page-loading-overlay";
1028-
overlay.innerHTML = `
1029-
<div class="page-loading-content">
1030-
<div class="page-loading-spinner"></div>
1031-
<span class="page-loading-text">Loading page...</span>
1032-
</div>
1033-
`;
1034-
canvasContainerEl.appendChild(overlay);
1035-
pageLoadingOverlay = overlay;
1036-
}, PAGE_LOADING_DELAY_MS);
1037-
}
1038-
1039-
function hidePageLoadingOverlay() {
1040-
if (pageLoadingTimer) {
1041-
clearTimeout(pageLoadingTimer);
1042-
pageLoadingTimer = null;
1043-
}
1044-
if (pageLoadingOverlay) {
1045-
pageLoadingOverlay.remove();
1046-
pageLoadingOverlay = null;
1047-
}
1048-
}
10491012

10501013
// Max bytes per server request (must match server's MAX_CHUNK_BYTES)
10511014
const MAX_CHUNK_BYTES = 512 * 1024;

0 commit comments

Comments
 (0)