Skip to content

fix(app): reread files when opening a preview - #51036

Merged
Hona merged 1 commit into
anomalyco:v2from
Hona:fresh-file-preview
Sep 24, 2026
Merged

Hona merged 1 commit into
anomalyco:v2from
Hona:fresh-file-preview

Conversation

@Hona

@Hona Hona commented Sep 24, 2026

Copy link
Copy Markdown
Member

browser.preview and file links in the timeline showed old file content. This was true even when you closed and opened the tab again.

Cause

  • useFile().load(path) returns early when the file is already loaded.
  • V2 only watches .git/HEAD and .hg/branch, so the app never gets a filesystem.changed event for workspace files. The stored copy stays until the cache evicts it.
  • Closing a tab does not clear the stored copy.
flowchart LR
  A[browser.preview / file link] --> B["file.load(path)"]
  B -->|already loaded| C[show stored copy ❌]
  B -->|"{ force: true }"| D["GET /api/fs/read"] --> E[show current file ✅]
Loading

Fix

  • openTab in packages/app/src/session/files/open-artifact.tsx now calls file.load(path, { force: true }).
  • While the file loads, the tab keeps the old content on screen, so it does not flash.
void file.load(path, { force: true }).then(() => {
  if (file.get(path)?.loaded) showTab(file.tab(path))
})
  • Adds the regression test e2e/regression/artifact-reopen.spec.ts: open a file, change it, close the tab, open it again, and expect the new content.
Before After

The file on disk says second draft in both images.

@Hona
Hona requested a review from Brendonovich as a code owner September 24, 2026 05:16
Copilot AI lite review requested due to automatic review settings September 24, 2026 05:16

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@Hona
Hona merged commit 7460d85 into anomalyco:v2 Sep 24, 2026
8 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants