Skip to content

[Bug]: "Open file in preview browser" shows an old version of a file that changed #38465

Closed

Description

@imryanthedev

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/web

Steps to reproduce

  1. Connect a client to a T3 Code server and open a workspace PDF in the Files panel.
  2. Click Open file in preview browser. The PDF opens in a Browser tab.
  3. Within about 30 minutes, overwrite the PDF at the same path, for example by rebuilding it.
  4. Check the Files panel: it shows the new PDF.
  5. Close the Browser tab and click Open file in preview browser again.

Expected behavior

The Browser tab shows the current file, matching the Files panel.

Actual behavior

The Browser tab shows the previous version of the PDF, while the Files panel beside it shows the new one.

The button:

Open file in preview browser button

Browser tab after reopening, still on the old subtitle (personal details redacted):

Browser tab showing the old PDF

Files panel at the same moment, on the new subtitle (personal details redacted):

Files panel showing the current PDF

Cause

Two caches line up:

  1. The button reuses its signed URL. FilePreviewPanel creates its runner without refresh: true, so executeAtomQuery returns the value cached by assets.createUrl, which stays fresh for 30 minutes.
  2. The client caches that URL. Asset responses send Cache-Control: private, max-age=3600, and the PDF is embedded by the client, so the same URL is served from its HTTP cache without reaching the server.

The Files panel escapes this because it mints a new URL per workspace revision, under a different resource key (media-file for PDFs, against workspace-file for the button). That re-mint does not refresh the button's entry.

The other two openFileInPreview callers, ChatMarkdown and DesktopWebLinkCoordinator, already pass refresh: true. Only this button does not.

Proposed fix

--- a/apps/web/src/components/files/FilePreviewPanel.tsx
+++ b/apps/web/src/components/files/FilePreviewPanel.tsx
@@
   const createAssetUrl = useAtomQueryRunner(assetEnvironment.createUrl, {
     reportFailure: false,
+    refresh: true,
   });

Each click then mints a new signed URL, so the browser cannot match the old entry. A regression test could assert that two clicks on the button request two mints.

This does not change reloading a tab that is already open: it keeps the same URL, so it can still get cached bytes until max-age runs out. That would need a server change for mutable workspace files, such as no-cache, and seems better handled separately.

What I checked

  • A URL minted before the overwrite, fetched directly from the server afterwards, returned the new bytes with cache-control: private, max-age=3600. The server is correct, so the stale bytes come from the client side.
  • Running executeAtomQuery against a counting atom returned the cached value with refresh: false and a new value with refresh: true.
  • The missing option and the cache header are present in the versions listed below.

I have not run the proposed patch in the app.

Impact

Minor bug or occasional failure

Version or commit

Seen on 0.1.11-nightly.20261117.4851. The same code is in 0.1.11-nightly.20261118.4864 and main @ a93e61a.

Environment

T3 Code server on Linux, used remotely from a macOS client.

Workaround

Open the file from a link in chat, which mints a new URL, or wait about 30 minutes before reopening it from the Files panel.

Related

Same family, different code path: #15676 and #15739 (both closed). #36202 and #36205 cover expired URLs in the Browser panel, not stale content.

Activity

  1. imryanthedev commented on Nov 18, 2026

    @imryanthedev
    ContributorAuthor

    Hey I see we both opened our PR at the same time. And that we more or less have the same code.
    I would appreciate it if you could please consider mine instead?

    Appreciate you guys fixing this bug and working on this project in all cases.

  2. imryanthedev commented on Nov 18, 2026

    @imryanthedev
    ContributorAuthor

    Well that was quick. Thanks for dealing with the bug 🫡

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions