Skip to content

Improve display of processing documents - #1456

Open
dnass wants to merge 6 commits into
edit-modefrom
modified-document-processing
Open

dnass wants to merge 6 commits into
edit-modefrom
modified-document-processing

Conversation

@dnass

@dnass dnass commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

Reprocessing a modified document on the server happens in several steps:

  1. The document status changes to processing
  2. The original PDF is overwritten with the modified version
  3. The page images are deleted and regenerated
  4. The document's page_spec and updated_at timestamps are updated, and status changes to success

This PR ensures that the user sees the correct layout for the modified document at every step.

After modifications are saved, the new layout is added to a store keyed to the document ID. The layout store is persisted to local storage using saveStore. When a stored layout is present for a document, it overrides the page spec to become the source of truth for page ordering and dimensions.

In order to determine when the PDF has been overwritten, ViewerState tracks the file's Last-Modified header. If the current PDF's timestamp doesn't match the stored layout timestamp, it means the user has reloaded the viewer after the PDF was rewritten but before processing was complete (i.e. after step 2). In this case, the PDF viewer doesn't apply reordering or rotations from the stored layout because the page is being rendered from the new file. (This prevents the modifications from being applied twice.)

After the page images have been deleted but not yet regenerated (step 3), thumbnails in grid layout fail to load. Those image elements now watch for loading errors and show a loading spinner in place of missing images. Image URLs also use the document's updated_at timestamp as a cache-busting param to ensure the fresh versions are loaded after reprocessing is complete.

After the document is finished reprocessing, the stored layout is deleted and the document is rendered normally.

@dnass
dnass added this pull request to stack #1453 November 10, 2026 22:38
@github-actions

Copy link
Copy Markdown

Preview deployed: https://preview-1456.staging.documentcloud.org

@dnass dnass changed the title Modified document processing Improve display of processing documents Nov 10, 2026
@dnass
dnass force-pushed the modified-document-processing branch 2 times, most recently from 87a87a0 to 9a400cf Compare November 10, 2026 22:56
@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 55.31% 4577 / 8274
🔵 Statements 53.96% 5402 / 10010
🔵 Functions 50.13% 1804 / 3598
🔵 Branches 51.82% 2334 / 4504
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
src/lib/api/documents.ts 86.66% 83.78% 94.44% 87.67% 108-118, 183-184, 193, 211-215, 224, 533, 556-558, 752
src/lib/components/toolbars/EditToolbar.svelte 80.2% 62.5% 81.25% 83.33% 141-156, 190, 194, 221, 220, 233
src/lib/components/viewer/Grid.svelte 96.77% 60% 93.75% 95.12% 78-79
src/lib/components/viewer/PDFPage.svelte 79.27% 47.36% 85.71% 80% 182, 220, 221, 224, 260, 265-313
src/lib/components/viewer/ViewerContext.svelte 100% 100% 100% 100%
src/lib/state/pendingLayout.ts 84.21% 75% 62.5% 84.61% 22-23
src/lib/state/search.svelte.ts 89.81% 81.13% 92.85% 92.92% 181-190, 203, 204, 205
src/lib/state/viewer.svelte.ts 97.97% 95.65% 96.49% 98.78% 33-36, 74
src/lib/utils/page.svelte.ts 100% 100% 100% 100%
src/lib/utils/pdfModified.ts 100% 100% 100% 100%
Generated in workflow #1476 for commit 61c93d2 by the Vitest Coverage Report Action

@dnass
dnass marked this pull request as ready for review November 11, 2026 16:46
@dnass
dnass force-pushed the modified-document-processing branch from 9a400cf to 87edbc9 Compare November 12, 2026 17:51
@dnass
dnass force-pushed the modified-document-processing branch from 87edbc9 to 61c93d2 Compare November 13, 2026 00:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant