Repository navigation
feat(context-center): in-app file preview for documents (md, txt, pdf, images) - #33734
Conversation
Implement pure utility function to resolve renderer by file extension or MIME type. Supports markdown, text, PDF, and raster images; SVG treated as unsupported per security requirement. Co-Authored-By: Claude Haiku 4.5 <[email protected]>
Test the markdown renderer against real react-markdown (default sanitization only, no rehype-raw/dangerouslySetInnerHTML) to assert <script> content is neutralized and javascript: links are dropped. Extends the Jest transformIgnorePatterns exception list to cover the ESM-only unified/remark/rehype dependency chain react-markdown pulls in, and polyfills Blob#text on jsdom's Blob (missing in jsdom 20) via FileReader so renderers that read Blob content can be tested.
Co-Authored-By: Claude Sonnet 5 <[email protected]>
Co-Authored-By: Claude Sonnet 5 <[email protected]>
Co-Authored-By: Claude Sonnet 5 <[email protected]>
Co-Authored-By: Claude Sonnet 5 <[email protected]>
… dead key Co-Authored-By: Claude Sonnet 5 <[email protected]>
❌ PR checklist incompleteThis PR cannot be merged until the following are addressed on its linked issue:
The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically. Maintainers can bypass this check by adding the |
🔄 Playwright impact map auto-refreshedThis PR touched specs or UI source that changed the source→spec routing map. I regenerated What is this file? It is the auto-generated half of Playwright's PR planner. It routes "if source X changes, run specs Y" by walking spec imports and cross-referencing What if I want to regenerate locally instead? Run this before pushing your next change to skip the bot commit: python3 .github/scripts/generate_playwright_impact_map.py
git add .github/playwright/impact-map.generated.json
git commit --amend --no-edit # or a separate commit |
…o context-center-file-preview
| Typography, | ||
| } from '@openmetadata/ui-core-components'; | ||
| import { Check, ChevronRight } from '@untitledui/icons'; | ||
| import { Check, ChevronRight, Eye } from '@untitledui/icons'; |
There was a problem hiding this comment.
The new Eye icon is imported directly from @untitledui/icons. The repository directive requires application icons and assets to go through the design-system layer using @openmetadata/ui-core-components/icons; this requirement must be satisfied before merging.
Context Used: CLAUDE.md (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
| "file-preview-pdf-page-limit": "Showing the first {{count}} pages. Download the file to view all pages.", | ||
| "file-size-exceeded": "حجم الملف يتجاوز الحد الأقصى المسموح به للـ {{size}}", | ||
| "file-size-limit-exceeded": "تتجاوز بعض الملفات الحد الأقصى للحجم 5 ميجابايت ولم يتم تحميلها.", | ||
| "file-too-large-to-preview": "This file is too large to preview. Download it to view.", |
There was a problem hiding this comment.
Locale placeholders remain English
These new Arabic locale entries are copied English placeholders rather than translations. The same three entries remain untranslated across the other changed non-English bundles, including de-de.json and es-es.json. The repository directive requires replacing synchronized placeholders with real translations in every non-English locale before merging.
Context Used: CLAUDE.md (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
…caps, pdf error handling, download fallback, types rename
✅ Playwright Results — workflow succeededValidated commit ✅ 4551 passed · ❌ 0 failed · 🟡 7 flaky · ⏭️ 1 skipped · 🧰 0 lifecycle flaky PerformanceBlocking targets: ✅ met · Optimization targets: 🟡 in progress Shard-job maxima below are not the full workflow wall time; the linked run includes build, fixture, planning, and reporting. 🕒 Full workflow signal wall (to summary) 59m 21s ⏱️ Max setup 4m 36s · max shard execution 21m 44s · max shard-job elapsed before upload 25m 16s · reporting 20s 🌐 224.54 requests/attempt · 2.23 app boots/UI scenario · 29.91% common-shard skew Optimization targets still in progress:
🟡 7 flaky test(s) (passed on retry)
How to debug locally# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip # view trace |
…pe-gated preview button - add a reusable useFilePreviewContent hook (fetch + size guard) shared by the modal and a new detail-panel miniature preview that expands to the full modal - support svg via the image renderer (<img> src is script-inert) - gate the row preview button on renderer-supported types only - preview no longer blocks on processingStatus (extraction status is independent of whether the uploaded bytes are viewable) - dialog title shows the (truncated) filename - FilePreviewer creates/revokes its object URL in one effect (StrictMode-safe) - compact renderer mode (PDF first page, image fit-to-box)
… panel miniature - render the row preview button as an invisible placeholder for renderer-unsupported files so the status badge and action icons stay column-aligned across rows - remove the detail-panel miniature preview (preview stays on the row eye button + full modal); revert DocumentPreviewPanel to metadata-only
…d in e2e - reorder DocumentsView imports to satisfy organize-imports (ui-checkstyle src lint) - route the /download endpoint in the preview e2e: the CI Playwright stack has no object storage configured (ASSET_UPLOADER unset), so the real endpoint 404s (resolveAsset -> null). Serving the fixture bytes from the test keeps the fetch -> renderer -> DOM pipeline exercised on real bytes, storage-independent, and drops the now-unneeded processing-wait
…real download The per-PR fast lane has no object storage, so the preview /download 404s there. The nightly/AUT deployment has real storage, so run the preview suite there against the real upload/download/render pipeline (no route mock).
🔄 Playwright impact map auto-refreshedThis PR touched specs or UI source that changed the source→spec routing map. I regenerated What is this file? It is the auto-generated half of Playwright's PR planner. It routes "if source X changes, run specs Y" by walking spec imports and cross-referencing What if I want to regenerate locally instead? Run this before pushing your next change to skip the bot commit: python3 .github/scripts/generate_playwright_impact_map.py
git add .github/playwright/impact-map.generated.json
git commit --amend --no-edit # or a separate commit |
Add an Eye SVG to ui-core-components and regenerate the icon set, then import it from @openmetadata/ui-core-components/icons in DocumentsView instead of @untitledui/icons — icons must go through the design-system layer per CLAUDE.md.
…o context-center-file-preview
Code Review ✅ Approved 4 closed / 4 findings🟡 Medium risk · Adds Context Center previews with authenticated downloads and untrusted-file rendering. Adds in-app file preview for Context Center documents (Markdown, text, PDF, images) with authenticated download, size guards, safe rendering, and comprehensive test coverage. Resolved abort signal handling, text preview buffering, modal stability, and eager-download issues. ✅ 4 closed✅ Performance: Abort signal never passed to download request
✅ Performance: Text preview dumps up to 25MB into a single <pre>
✅ Bug: Unstable onClose forces preview modal to re-download
✅ Performance: Detail panel eagerly downloads full file for thumbnail
OptionsDisplay: compact → Counting what did not apply, without listing it. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
|
🚦 Removed from the merge queue —
|
🚦 Removed from the merge queue —
|



Fixes https://github.com/open-metadata/openmetadata-collate/issues/4554
Description
Adds an in-app file preview for Context Center documents. Each document row gets an eye button (next to Download) that opens a modal rendering the file content. Supported in this PR: Markdown, plain text / CSV, PDF, and raster images. The renderer is a generic, reusable
components/common/FilePreviewer/that dispatches on the backendFileTypeenum, so new formats (docx, xlsx) plug in later without a parallel type map.How it works
preview-btnon each row → opensFilePreviewModal.FilePreviewModalfetches bytes from the same-origin authenticateddownloadDriveFile(id), applies a 25 MB size guard and a processing-status guard (Failed/Unsupported → download-only), aborts in-flight fetches on close, and toasts on error.FilePreviewerselects a renderer from a registry keyed on the backendFileType(generated/entity/data/contextFile.ts); extension/MIME are used only to (a) exclude SVG insideImageand (b) pick Markdown vs plain text insideText, plus a fallback that mirrors the backendContextFileUploadSupport.detectFileTypeclassifier. Markdown and PDF renderers are lazy-loaded.Security (file preview of untrusted uploads)
react-markdowndefault sanitization — norehype-raw, nodangerouslySetInnerHTML;javascript:/data:links neutralized.pdfjs-distwithisEvalSupported: false, scripting/annotation JS off, canvas-only render (closes the CVE-2024-4367 class). PDF page render is bounded (max 50 pages) so a small-byte many-page PDF can't OOM the tab.Type of change
Tests
react-markdown(script +javascript:link stripped), image/unsupported renderers, PDF renderer assertsisEvalSupported: falseand the page cap,FilePreviewerobject-URL revoke-on-unmount,FilePreviewModalsize/status guards + single-fetch-across-rerender + fetch-error toast. Mocks only thedownloadDriveFileboundary.ContextCenterFilePreview.spec.tscovers md/txt/pdf/image rendering in the modal, the unsupported download fallback, and modal close/focus-restore. Live run against the Docker stack is deferred to CI.Notes for reviewers
[email protected].yarn i18n-synced; non-English locales carry English placeholders pending translation (per repo i18n norm; CI checks sync only).main; a rebase may be needed before merge.🤖 Generated with Claude Code
The implementation appears safe to merge, with the non-blocking caveat that its end-to-end preview suite is not currently executed by CI.
Findings
Summary
Adds reusable in-app previews for Context Center documents, including text/Markdown, PDF, and image rendering, guarded downloads, cancellation, modal integration, and design-system icon support.
Diagram
%%{init: {'theme': 'neutral'}}%% flowchart LR A[Document row preview button] --> B[FilePreviewModal] B --> C[useFilePreviewContent] C --> D[Authenticated drive download] D --> E{Blob within 25 MB?} E -- No --> F[Download fallback] E -- Yes --> G[FilePreviewer] G --> H{Resolved renderer} H --> I[Markdown] H --> J[Plain text] H --> K[PDF canvas] H --> L[Image]Reviews (7) · Last reviewed commit: "Merge remote-tracking branch 'origin/con..."