Skip to content

[Bug]: Built-in browser preview shows stale local HTML after the file changes; Refresh doesn't help, only reopening does #43912

Done

Description

@yishisanren

Before submitting

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

Area

apps/server

Steps to reproduce

  1. In a thread, open a local workspace HTML file (for example report.html, which may reference sibling .css/.js/images) in the built-in browser preview.
  2. Change the file on disk (edit it yourself, or have the agent rewrite it).
  3. Look at the preview tab, then press the preview's Refresh button (or ⌘R).
  4. Close the preview tab and open the same file again.

Expected behavior

After the file changes, the preview shows the current version. At the latest, Refresh shows the new content. Ideally the preview reloads by itself when the opened file (or a file it loaded) changes on disk, the way a dev server's live reload works.

Actual behavior

  • The preview does not update by itself when the file changes.
  • Refresh / ⌘R keeps showing the old content.
  • Only closing the tab and opening the file again shows the new version.

From reading the 0.1.13-nightly bundle, this looks like the cause:

  • Workspace files are served through the signed /api/assets/* route, and assetResponseHeaders() (and the bytes branch of layerAssetRoute) set Cache-Control: private, max-age=3600.
  • The preview's Refresh and its refresh shortcut call webContents.reload(), not reloadIgnoringCache(), so the cached copies of the page's resources are used for up to an hour.
  • Opening the file again issues a new signed URL (new token), which the browser treats as a new resource, so that path is the only one that shows the current file.
  • I found no file watcher that reloads a preview tab when its entry file or the files it requested (entryFileName is already tracked in the asset claims) change.

Related: #15739 (stale content in the Files panel). That one covered text and image tabs. This one is about HTML in the browser preview.

Impact

Major degradation or frequent failure

Iterating on agent-generated HTML (reports, charts, mockups) is a core loop. Every edit needs the tab closed and reopened. Refresh looks like it worked but still shows the old version, so it's easy to review a stale page by mistake.

Version or commit

T3 Code (Nightly) 0.1.13-nightly.20261126.5305

Environment

macOS 27.3, desktop app, local environment

Logs or stack traces

N/A

Workaround

Close the preview tab and open the file again. Or serve the folder from a local dev server with live reload and open the localhost URL in the preview.

Suggested fix

  • Serve workspace-file / workspace-file-exact assets with Cache-Control: no-cache (or no-store), or add an ETag/Last-Modified based on the file's mtime and size, so a normal reload revalidates.
  • Optionally make the preview Refresh use reloadIgnoringCache() for workspace-file pages.
  • Optionally watch the entry file and its tracked dependencies, and auto-reload the tab when they change.
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