Skip to content

[Bug]: Files panel keeps showing old file contents after the file changes on the server #15739

Description

@nekohasekai

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

Use a project with a text file (docs/release-notes.md), an image (assets/hero.png) and a README.md that embeds the image (![Hero banner](assets/hero.png)).

A. File changed outside the thread

  1. Open a thread, then open docs/release-notes.md in the Files panel. Open assets/hero.png in another tab.
  2. Overwrite both files on the server without going through this thread, for example from a terminal, an editor, or another thread in the same checkout.
  3. Look at each tab, then switch to another file tab and back. Click Refresh workspace files.

B. Image embedded in a Markdown preview

  1. Open README.md in the Files panel and switch it to the rendered view.
  2. Ask the agent in this thread to overwrite the image, for example cp hero-v2.png assets/hero.png.
  3. When the turn finishes, compare the rendered README with the hero.png tab.

Expected behavior

A file preview shows the file as it is on the server. At the latest, opening the file again or clicking Refresh workspace files shows the current version.

Actual behavior

  • A, text: While the file is open, it keeps the old text and does not update by itself. Clicking Refresh workspace files or opening the file again shows the new text.
  • A, image: The preview keeps the old image while it is open, after switching tabs and opening it again, and after Refresh workspace files. Only reloading the page shows the new image.
  • B: The rendered README keeps the old image even though the agent in this thread changed it. The hero.png tab shows the new image.

A change made by the agent in this thread does refresh an open text file and the image tab. Only changes from anywhere else stay stale.

Mobile very likely has the same problem, also for changes the agent makes in the thread. I did not test it, but in the code the Files screen never refreshes an open file after it changes: open text stays old, and the image loads with cache: "force-cache" and only gets a new URL from the Refresh menu.

Why (source at 4ee6bfd)

The Files panel re-reads an open file only when workspaceMutationId changes, and that is the thread's latest completed command or file change (ChatView.tsx#L4003). Text is re-read on that signal (FilePreviewPanel.tsx#L1040-L1052), and the image preview appends it to its URL (FilePreviewPanel.tsx#L142). A change from outside the thread does not move it, so an open file does not update by itself.

Images also stay old after reopening, because both the client and the browser reuse the signed asset URL by path:

  • The client keeps the URL it got for a thread and path. A newly opened preview reuses it for 5 minutes, an open one gets a new URL every 30 minutes, and an unused entry lives for an hour (assets.ts#L28-L30).
  • The server lets the browser cache the response for an hour (http.ts#L100). Only audio and video get no-store (http.ts#L178).
  • Refresh workspace files re-reads an open text file but skips images and PDFs (FilePreviewPanel.tsx#L1310-L1312), so an open image keeps its URL.

B: the Markdown preview renders images with the chat image component, which asks for a media-file URL without the revision (ChatMarkdown.tsx#L3385-L3390).

Mobile: WorkspaceFileImagePreview.tsx#L21 (force-cache), ThreadFilesRouteScreen.tsx#L647 (new image URL only after Refresh), ThreadFilesRouteScreen.tsx#L660 (the text query has no refresh on change).

Related reports

Not affected in my tests: an HTML preview picks up a CSS file the agent changed, because Chrome gives the sandboxed frame a fresh cache on every load.

Impact

Minor bug or occasional failure

Version or commit

main @ 4ee6bfd (server reports 0.0.45); unmodified server and web.

Environment

Web in Chrome 154 against a local isolated dev server; macOS 27.0.1 (26A434), Apple Silicon; Node 26.9.0; Codex 0.160.0 / GPT-6-Astra for the agent turns. The same code path is used for local and remote environments; I first noticed it on a remote one. Mobile not tested.

Logs or stack traces

No response

Screenshots, recordings, or supporting files

Step B, isolated demo project. The agent overwrote assets/hero.png with v2 in this thread:

Left: README.md rendered in the Files panel still shows Hero v1. Right: the hero.png tab right after shows Hero v2.

Workaround

Text: click Refresh workspace files or open the file again. Images: reload the page. On mobile, use Refresh in the file's menu.

Activity

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

    bugSomething is broken or behaving incorrectly.via-triageFiled through npx t3 triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions