Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(web): PDFs in the desktop file panel can be saved again #38749

Mergedjuliusmarmingemerged 1 commit intomain fromrefs/pull/38749/headmerged by juliusmarminge View on GitHub

juliusmarmingecommented

No changes this round. The brief listed nothing to change, so I watched PR #38749 instead. All 38 checks passed on 52500a6, including the 8 required ones. CodeRabbit's review produced no actionable comments. Macroscope's checks were skipped and it left no comments or reviews. The fix is unchanged: the workspace PDF preview passes a 'Save file' action into the in-app PDF.js viewer's toolbar (PdfViewer via BrowserDocumentFrame). The desktop app shows that viewer for PDFs, and its toolbar had lost the download button Chromium's own viewer provided. The button re-mints the asset URL, fetches the file and saves it under its own name through a blob URL. Browsers that use their native PDF viewer and attachment PDFs are unchanged.

Fixes pingdotgg/t3code#38686

Reproduction on main

Commit 081afe08dc (origin/main). Ran the desktop app on Linux under Xvfb (T3CODE_DEV_SEED=0 T3CODE_DESKTOP_REMOTE_DEBUGGING_PORT=9338 headless-desktop vp run dev:desktop), fresh database, driven with Playwright over CDP. Clicked Start, then Add project > Local folder and added a small git repo holding report.pdf (one page, made with ImageMagick) and notes.docx (a minimal OOXML file). Opened report.pdf with the file picker (Ctrl+P): it opened in the in-app PDF.js viewer, and its only actions were Previous page, Next page, Zoom out, Zoom in, Fit width and Find in PDF. There was no 'Save file'. Opened notes.docx the same way: the header showed a 'Save file' download icon. Captures: PDF https://gh-file-drop-api-prod-mi5fy3sowv63ufte.pinglabs.workers.dev/f/df7d91cc15555a03/07-pdf.png , DOCX https://gh-file-drop-api-prod-mi5fy3sowv63ufte.pinglabs.workers.dev/f/c2a0373eb3d131f9/08-docx.png . Not run on Windows: the cause only checks for the desktop app (isElectron), not the OS, so Windows desktop takes the same path.

Evidence

Reproduced in the real Linux Electron desktop app under Xvfb, with fresh databases, identical synthetic files, light theme, and a 1440×900 viewport. Add the sample repository through Add project > Local folder, then use Ctrl+P to open report.pdf and notes.docx. PDF lacks Save file on base and gains it on head; DOCX retains it on both.

BeforeAfter
f1d64aa0b652500a6615
Before: PDF toolbar has no Save file actionAfter: PDF toolbar shows Save file
Before: DOCX shows Save fileAfter: DOCX still shows Save file

Shared reproduction driver · Synthetic sample files

Not shown:

  • Windows was not run; this comparison reproduced the desktop-only PDF toolbar behavior on Linux, matching triage.
  • Native save-dialog completion and the final disk write were not exercised; this proof verifies the missing action is restored.

Tests

This round: none run locally, because nothing changed. On 52500a6, CI passed all 38 checks, including Build and Typecheck, Test, Test Web 1 and 2, and Test Server 1–5 and 8. From the previous round: vp run check:changed passed, and a manual check in the dev server showed the Save file button in the PDF.js toolbar and that it downloads report.pdf correctly.

Not in this change

  • The blob-download code now appears three times (AttachmentFilePreview, WorkspaceLargeTextPreview, WorkspacePdfSaveAction); it could be pulled into one shared helper.
  • Open PR #33827 proposes a panel-level 'Save file' for every preview type; that is a broader redesign and is not part of this fix.

Who did the work

  • Written by Claude Opus 5.5, in Claude Code
  • Reviewed by GPT-6.1 Sol, in Codex, and by Claude Opus 5.5, each on its own
  • Proof captured by GPT-6.1 Sol and checked by Claude Opus 5.5

Run by the t3code factory in T3 Code.

    1. tanstack-source added labelsbug

    2. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    3. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      Explain Change →

      No actionable comments were generated in the recent review.

      Walkthrough

      The PDF viewer accepts optional toolbar actions through BrowserDocumentFrame. The workspace PDF preview adds a save action that refreshes the asset URL, fetches the file, and downloads it through a blob URL.

      Changes: PDF Preview Save

      Layer / File(s)Summary
      Pass toolbar actions to the PDF viewer
      apps/web/src/components/files/PdfViewer.tsx, apps/web/src/components/files/BrowserDocumentFrame.tsx
      PdfViewer renders optional toolbar content. BrowserDocumentFrame passes the actions through the PDF.js viewer path; the native PDF iframe path remains unchanged.
      Add the workspace PDF save action
      apps/web/src/components/files/FilePreviewPanel.tsx
      The workspace preview supplies a save action. It refreshes the asset URL, fetches the file, downloads it using a blob URL, and reports failures through an error toast.

      Estimated code review effort: 2 (Simple) | ~10 minutes

      Change: Bug fix · Severity of issue fixed: Low

      Sequence Diagram(s)

      sequenceDiagram
        participant PdfViewer
        participant WorkspacePdfSaveAction
        participant AssetURL
        participant FetchAPI
        participant Browser
        PdfViewer->>WorkspacePdfSaveAction: Displays supplied toolbar action
        WorkspacePdfSaveAction->>AssetURL: Refreshes asset URL
        WorkspacePdfSaveAction->>FetchAPI: Fetches file
        FetchAPI-->>WorkspacePdfSaveAction: Returns response blob
        WorkspacePdfSaveAction->>Browser: Downloads blob URL with filename

      Suggested reviewers: edemaine, maria-rcks, macroscopeapp

      Merge Risk: Minimal · up to 52500

      This adds a Save file button to the in-app PDF preview toolbar. It downloads the file and shows an error toast on failure. No merge-blocking risk was found.

      Pre-merge checks: Passed 3 · Inconclusive 1

      Failed Failed checks: 1 inconclusive
      Check nameStatusExplanationResolution
      Description checkInconclusiveThe description is detailed and technically specific about the problem, the fix, and the evidence, but it does not follow the repository template. It has no 'Problem', 'Change', 'Scope', or 'Verificat…Reorganize the description under the template headings: Problem, Change, Scope, Verification, and the agent attribution line. Move the 'No changes this round' and CI status notes out of the body, since they do not describe the change. Keep …
      Passed Passed checks: 3 passed

      Check nameStatusExplanation
      Title checkPassedThe title names the fix (saving workspace PDFs from the desktop file panel) and the scope (web). It matches the main change: a save action added to the PDF.js toolbar for workspace PDFs. It follows th…
      Linked Issues checkPassed[#38686] Requirement: the PDF side-panel preview must offer a working Download/Save action, as the DOCX preview does. Evidence: (1) The diff of apps/web/src/components/files/BrowserDocumentFrame.tsx a…
      Out of Scope Changes checkPassedAll changes support the linked issue #38686. BrowserDocumentFrame.tsx threads an optional actions node from pdfActions through PdfDocument and PdfDocumentRevision to PdfViewer, limited to the PDF.…
      Full details: Title check

      Explanation

      The title names the fix (saving workspace PDFs from the desktop file panel) and the scope (web). It matches the main change: a save action added to the PDF.js toolbar for workspace PDFs. It follows the conventional commit format from the template. It is specific enough for a teammate scanning history.

      Full details: Linked Issues check

      Explanation

      [#38686] Requirement: the PDF side-panel preview must offer a working Download/Save action, as the DOCX preview does. Evidence: (1) The diff of apps/web/src/components/files/BrowserDocumentFrame.tsx at the reviewed head adds a pdfActions prop. It passes that prop as actions to PdfViewer only on the PDF.js branch (props.pdf), so the native-viewer branch is unchanged. (2) The PR summary states that PdfViewer renders actions at the end of its toolbar and that WorkspaceBrowserPreview supplies WorkspacePdfSaveAction. This save action re-mints the asset URL, fetches the file, downloads it through a blob URL with the basename, and shows 'Could not save file' on failure. (3) The author reports a manual check on a browser with navigator.pdfViewerEnabled=false. The toolbar showed 'Save file', and the click downloaded report.pdf (584 bytes, starting with %PDF-1.4). Limits: the diff for apps/web/src/components/files/FilePreviewPanel.tsx could not be read because its changed blobs were missing from the checkout. The WorkspaceBrowserPreview wiring is therefore supported by the PR summary and the author's manual run, not by a direct code read. The Electron app and Windows were not run. The issue's Windows case uses the same isElectron PDF.js path that the author reproduced on Linux.

      Full details: Out of Scope Changes check

      Explanation

      All changes support the linked issue #38686. BrowserDocumentFrame.tsx threads an optional actions node from pdfActions through PdfDocument and PdfDocumentRevision to PdfViewer, limited to the PDF.js branch. PdfViewer.tsx adds an optional actions prop rendered in its toolbar. FilePreviewPanel.tsx (per the PR summary) adds WorkspacePdfSaveAction and passes it only from WorkspaceBrowserPreview. Attachment PDFs do not pass actions, so they get no duplicate button. The PR reuses existing strings, so it adds no i18n keys. Tests and supporting changes reported in the PR description relate to this same save action. No unrelated change was identified. The FilePreviewPanel.tsx diff could not be read, so this verdict relies on the PR summary for that file.

      Full details: Description check

      Explanation

      The description is detailed and technically specific about the problem, the fix, and the evidence, but it does not follow the repository template. It has no 'Problem', 'Change', 'Scope', or 'Verification' headings. It also leads with status updates on CI and review bots rather than the change itself. It does link the issue (#38686) and reports a Linux reproduction with before/after captures. Required content is mostly present, but the structure differs from the template.

      Resolution

      Reorganize the description under the template headings: Problem, Change, Scope, Verification, and the agent attribution line. Move the 'No changes this round' and CI status notes out of the body, since they do not describe the change. Keep the Linux reproduction and before/after screenshots under Verification. In Scope, state that the change restores an existing action for a bug (#38686), not a feature. The description also states that Windows was not tested, so keep that note under Verification.

      Finishing Touches

      Generate unit tests (beta)

      • Commit to this branch
      • Create a new PR
      • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
      Recent review info

      Run configuration

      Commits

      Reviewing files that changed from the base of the PR and between 75cae42febdbedc2bd39430a1d6f017e38f6bfe0 and 52500a6615b1f91b400b57d1f10ec634b9f13370.

      Files selected for processing: 3

      • apps/web/src/components/files/BrowserDocumentFrame.tsx
      • apps/web/src/components/files/FilePreviewPanel.tsx
      • apps/web/src/components/files/PdfViewer.tsx

      Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review.

    4. juliusmarminge merged thise48d6f3

    5. juliusmarminge closed this

Sign in to join this conversation.