feat(files): expand file editor to support more formats, add docx/xlsx preview#3971
feat(files): expand file editor to support more formats, add docx/xlsx preview#3971waleedlatif1 merged 11 commits intostagingfrom
Conversation
️✅ There are no secrets present in this pull request anymore.If these secrets were true positive and are still valid, we highly recommend you to revoke them. 🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request. |
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryMedium Risk Overview Adds new previews for Tightens/adjusts validation logic by replacing Reviewed by Cursor Bugbot for commit 6c4b02e. Configure here. |
a8f6b74 to
edc103d
Compare
Greptile SummaryThis PR significantly expands the file editor and viewer by adding ~40 code-related extensions to the text-editable set (js, ts, py, go, rs, sql, xml, toml, dockerfile, etc.) and introduces rich DOCX preview (mammoth.js converting to HTML rendered in a sandboxed iframe) and XLSX preview (SheetJS lazily parsing sheets into a table with per-sheet tabs, capped at 1,000 rows). Shared helpers (
Confidence Score: 4/5Requires one fix before merging: DOCX preview renders near-invisible light-gray text on a transparent background, which is unreadable in light mode One confirmed P1 rendering defect in buildDocxPreviewHtml (transparent background + #e4e4e7 text = invisible in light mode) makes DOCX preview broken for all light-mode users. All other findings are P2 style issues that do not block functionality. All previously flagged P0/P1 concerns from earlier reviews are resolved. apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/file-viewer.tsx — specifically the buildDocxPreviewHtml function's missing explicit background color Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[FileViewer receives file + workspaceId] --> B[resolveFileCategory]
B --> C{Category?}
C -->|text-editable| D[TextEditor\ntextarea + PreviewPanel]
C -->|iframe-previewable| E[IframePreview\nPDF via browser iframe]
C -->|image-previewable| F[ImagePreview\nimg with zoom and pan]
C -->|pptx-previewable| G[PptxPreview\npptxviewjs canvas rendering]
C -->|docx-previewable| H[DocxPreview\nmammoth.js → HTML → iframe]
C -->|xlsx-previewable| I[XlsxPreview\nSheetJS → DataTable]
C -->|unsupported| J[UnsupportedPreview]
H --> H1[useWorkspaceFileBinary]
H1 --> H2[mammoth.convertToHtml arrayBuffer]
H2 --> H3[buildDocxPreviewHtml wraps HTML]
H3 -->|P1: background transparent| H4[iframe srcDoc sandbox empty]
I --> I1[useWorkspaceFileBinary]
I1 --> I2[XLSX.read new Uint8Array data]
I2 --> I3[setSheetNames + workbookRef]
I3 --> I4{activeSheet changes}
I4 --> I5[sheet_to_json header 1\ncap at XLSX_MAX_ROWS 1000]
I5 --> I6[DataTable + sheet tabs]
D --> D1[PreviewPanel]
D1 --> D2{resolvePreviewType}
D2 -->|markdown| D3[MarkdownPreview]
D2 -->|html| D4[HtmlPreview]
D2 -->|csv| D5[CsvPreview → DataTable]
D2 -->|svg| D6[SvgPreview]
subgraph Shared[Shared Helpers]
S1[resolvePreviewError]
S2[PreviewError component]
S3[DOCUMENT_SKELETON]
end
H -.uses.-> Shared
I -.uses.-> Shared
G -.uses.-> Shared
Reviews (4): Last reviewed commit: "lint" | Re-trigger Greptile |
apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/file-viewer.tsx
Show resolved
Hide resolved
apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/file-viewer.tsx
Show resolved
Hide resolved
apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/file-viewer.tsx
Outdated
Show resolved
Hide resolved
… tighten iframe sandbox
|
@cursor review |
|
@greptile |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 13c4919. Configure here.
|
@cursor review |
|
@greptile |
apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/file-viewer.tsx
Outdated
Show resolved
Hide resolved
…perly Reduces XLSX_MAX_ROWS from 10,000 to 1,000 to prevent browser sluggishness on large spreadsheets. Types workbookRef with the proper xlsx.WorkBook interface instead of unknown, removing the unsafe cast. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Move SUPPORTED_CODE_EXTENSIONS to validation-constants.ts so client components no longer transitively import Node's `path` module - Extract shared DataTable component used by both CsvPreview and XlsxPreview, eliminating duplicated table markup Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ction
Replace `import path from 'path'` with a simple `extractExtension` helper
that does `fileName.slice(fileName.lastIndexOf('.') + 1)`. This removes
the only Node module dependency from validation.ts, making it safe to
import from client components without pulling in a Node polyfill.
Deletes the unnecessary validation-constants.ts that was introduced as
a workaround — the constants now live back in validation.ts where they
belong.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
@greptile |
|
@cursor review |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 6c4b02e. Configure here.

Summary
Type of Change
Testing
Tested manually
Checklist