feat(viewer): connect batch signed-URL callers, probe image encodings & add public doc helper (#283, #282, #036) - #2075
Conversation
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in:47 minutes Limit details: You’ve used all 1 included review currently available under your plan. You completed 100 included PR reviews in the past 7 days; at that activity level, included reviews refill at 1 review per hour. Your organization has reached its usage spending cap. Adjust your spending cap in the billing tab. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (18)
Comment |
CI triageCI failed on this PR. Automated classification of the 2 failed job(s):
Compared with main CI run #11840 (cancelled). Classification is evidence routing, not permission to ignore a failure. Exact quarantined Playwright identities remain governed by the flake ledger. |
There was a problem hiding this comment.
Pull request overview
This PR reduces N+1 signed-URL fetches for document images by introducing a client-side batch prefetch + cache population path, adds a public-document visibility predicate intended to inform signing behavior, and adds a read-only corpus probe script to detect whether PDF.js image decoders are needed.
Changes:
- Add batch signed-URL fetching (
/api/images/signed-urls) with client-side chunking + cache population and integrate prefetching into the document viewer + document search results. - Add
isPublicDocument/isPublicDocumentRowhelper and associated tests/exports for defining the public vs private boundary. - Add
probe-corpus-image-encodingsscript + tests and regenerate generated doc indices / review record.
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/use-batch-signed-urls.dom.test.tsx | JSDOM test asserting one batch request populates the signed URL cache for multiple images. |
| tests/batch-signed-urls.test.ts | Unit tests for chunking, cache population, and 401 handling in the batch client helper. |
| tests/documents-is-public.test.ts | Unit tests for the new public document predicate behavior. |
| tests/probe-corpus-image-encodings.test.ts | Tests for the probe script’s self-test and report shape. |
| src/lib/batch-signed-urls.ts | Core batch fetch/chunk/merge + cache population utilities. |
| src/components/clinical-dashboard/use-batch-signed-urls.ts | React hook that batches and prefetches signed URLs into the shared LRU cache. |
| src/components/document-viewer/source-panels.tsx | Document viewer image list now prefetches visible image signed URLs via the batch hook. |
| src/components/clinical-dashboard/document-search-results.tsx | Search results now prefetch cover image signed URLs for visible results via the batch hook. |
| src/app/api/documents/signed-urls/route.ts | Alias route re-exporting the images batch-signed-urls handler. |
| src/lib/documents/is-public-document.ts | New helper defining a public-vs-private predicate for document rows/metadata. |
| src/lib/documents/index.ts | Exports the new helper/types from the documents lib entrypoint. |
| scripts/probe-corpus-image-encodings.mjs | Read-only scanner for PDF image encoding/font references to guide decoder asset decisions. |
| docs/site-map.md | Regenerated sitemap entries including the new route. |
| docs/scripts-index.md | Regenerated scripts inventory counts. |
| docs/codebase-index.md | Index update referencing the new documents/ helper. |
| docs/branch-review-records/*.record.md | Appended branch review record. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
BigSimmo
commented
Aug 18, 2026
@copilot Fix the code for all comments in this review thread. When a review comment includes a suggested change, apply the suggestion exactly. Do not make changes beyond what is described in the linked review thread. |
… into batch signed-URL route - use-batch-signed-urls.ts: use registerAuthRequest/isAuthEpochCurrent (from useAuthSession) to guard populateBatchSignedUrlsInCache against stale post-sign-out responses; release auth request in a finally block - batch-signed-urls.ts: normalize options.headers via new Headers() before setting content-type, so Headers instances and tuple arrays are handled correctly - api/images/signed-urls/route.ts: import isPublicDocument and use it to split valid images into public corpus (use getPublicUrl, no signing overhead) vs private (createSignedUrls); also selects owner_id from documents so isPublicDocument can detect null owner" Co-authored-by: BigSimmo <87357024+BigSimmo@users.noreply.github.com>
Head branch was pushed to by a user without write access
Done in
|
Content-identical dependency-array line-wrap. Fixes the Static PR checks / format:changed CI failure. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015qDHwBNZYyRLdJHqSkiYTg
BigSimmo
commented
Aug 18, 2026
CI status update:
Generated by Claude Code |
…window mock useBatchSignedImageUrls (wired into the document rail by this PR) now reads registerAuthRequest/isAuthEpochCurrent off useAuthSession(). The test's local mock predates that and only returned authorizationHeader/ markSessionExpired/session, so every mount threw "registerAuthRequest is not a function". Stub both, matching the pattern already used in image-lightbox-url-mode.dom.test.tsx. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Uh oh!
There was an error while loading. Please reload this page.
Summary
Addresses Workstream 7 (#283, #282, #36):
src/app/api/documents/signed-urls/route.tsre-exportingruntimeandPOSTfromsrc/app/api/images/signed-urls/route.ts.src/lib/batch-signed-urls.tssupporting chunking in batches of <= 100 IDs and populating client LRU signed URL cache.useBatchSignedImageUrlsinsrc/components/clinical-dashboard/use-batch-signed-urls.tswith session tracking and 401 retry handling.DocumentImageListinsrc/components/document-viewer/source-panels.tsxandDocumentSearchResultsinsrc/components/clinical-dashboard/document-search-results.tsx, eliminating N+1 single image signed-URL fetch waterfalls while preserving individual single-image endpoint fallbacks for lightboxes and retries.scripts/probe-corpus-image-encodings.mjsto scan document metadata fixtures and PDF streams for image filter encodings (JBIG2,JPX,DCT,Flate,CCITTFax,LZW) and standard-14 fonts.--self-testand--jsonmodes.src/lib/documents/is-public-document.tsandsrc/lib/documents/index.tsexportingisPublicDocumentandisPublicDocumentRow.public_corpus,is_public,visibility: "public", andsource_kind: "registry_record".src/lib/documentstodocs/codebase-index.md.docs/branch-review-records/7d870a0e009afb1f94df3f20108573b8df7967431be9e6825bfb162d37506944.record.md.Verification
tests/batch-signed-urls.test.ts(7/7 passed)tests/use-batch-signed-urls.dom.test.tsx(1/1 passed)tests/probe-corpus-image-encodings.test.ts(3/3 passed)tests/documents-is-public.test.ts(6/6 passed)tests/document-detail-performance.test.ts(9/9 passed)tests/signed-url-cache.test.ts(6/6 passed)tests/auth-signed-url-cache.dom.test.tsx(6/6 passed)node scripts/probe-corpus-image-encodings.mjs --self-testpassed.npm run typecheck:internalpassed with 0 errors.npm run lint:internalpassed with 0 errors and 0 warnings.npm run docs:check-inventory&npm run docs:check-indexpassed.npm run formatpassed clean.Risk and Rollout
Clinical Governance Preflight
Clinical KB Database(sjrfecxgysukkwxsowpy)