Refine desktop viewer boundary and stabilize desktop tests#39
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8989f27159
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| title: string; | ||
| overlayBytes?: Uint8Array | null; | ||
| onPageCount?: (n: number) => void; | ||
| rendererFactory?: () => ViewerRenderer; |
There was a problem hiding this comment.
Make renderer factory mandatory or supply a default
rendererFactory is declared optional, but when it is omitted and bytes is non-null the component now renders "Viewer renderer unavailable." instead of displaying the PDF, which is a runtime regression from the previous behavior and easy to trigger in any caller that forgets the new prop. Because the prop is optional, TypeScript will not catch those call sites; either require the prop in Props or provide an internal fallback renderer.
Useful? React with 👍 / 👎.
Motivation
Description
createViewerRendererinapps/desktop/src/lib/viewerRenderer.tsso only infrastructure constructsPdfjsRendererAdapter.PdfViewerto accept an injectablerendererFactory?: () => ViewerRendererand stop directly importing@gitplant/viewer-pdfjs, preserving theRenderScene/layer model and keeping the current single-base-layer proof path.Appto passcreateViewerRendererintoPdfViewerso the app remains desktop-ready while UI code uses onlyviewer-coreabstractions.PdfViewertests to assert bothApp.tsxandPdfViewer.tsxdo not contain directpdfjs-dist/@gitplant/viewer-pdfjsimports, switch test setup to@testing-library/jest-dom/vitest, move tovitest/configwithglobals, and updateapps/desktop/tsconfig.jsonto reduce lib/type noise (skipLibCheck,lib, and test excludes).Testing
npm testand all desktop tests passed (4tests acrossPdfViewer.test.tsxandApp.test.tsx), result: success.npm run typecheckand TypeScript checks passed in the adjusted desktoptsconfig.json, result: success.npm run build:web -w @gitplant/desktopto validate bundling of the PDF worker, result: success.cargo testfor Rust-side tests but the run was blocked by network access tocrates.io(HTTP 403) in this environment; Rust tests were not completed due to that network constraint.Codex Task