Skip to content

fix(app): refresh artifact panel when agent modifies the open file - #2939

Merged
reachjalil merged 1 commit into
different-ai:devfrom
PriyeshPandey2000:feat/markdown-preview-stale-content
Jul 30, 2026
Merged

fix(app): refresh artifact panel when agent modifies the open file#2939
reachjalil merged 1 commit into
different-ai:devfrom
PriyeshPandey2000:feat/markdown-preview-stale-content

Conversation

@PriyeshPandey2000

@PriyeshPandey2000 PriyeshPandey2000 commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Artifact preview panel showed stale content after the agent modified the open file — only a full app restart cleared it.
  • isSameTranscriptArtifactTargets compared targets only by id, ignoring mtime changes, so the Zustand store never propagated file updates to the panel.
  • staleTime: Infinity with no cache invalidation meant React Query served the initial fetch indefinitely.
  • Fix: include target.updatedAt (file mtime already returned by resolveArtifacts) in the React Query cache key and in the transcript-targets equality check. Add gcTime: 0 so close/reopen also fetches fresh.

Why

When the agent writes a file, the server already returns the updated mtime via resolveArtifacts. That signal existed in the pipeline but was never used to bust the cache or notify the panel.

Issue

Closes #2924

Scope

  • apps/app/src/react-app/domains/session/artifacts/artifact-panel.tsx — add target.updatedAt to query key and setQueryData key; add gcTime: 0
  • apps/app/src/react-app/domains/session/panel/panel-tab-store.ts — include updatedAt in isSameTranscriptArtifactTargets

Testing

Ran

  • pnpm typecheck — pass

Manual

  1. Ask agent to create a .md file, open preview panel, ask agent to modify it — panel updates automatically ✓
  2. Close preview panel while agent modifies file, reopen — shows latest content ✓
  3. Edit file manually via in-panel editor and save — content correct after save ✓
  4. Open non-markdown artifact (image, PDF) — no regression ✓

Evidence

Screenshot 2026-07-21 at 10 01 31 AM

@vercel

vercel Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
openwork-landing Ready Ready Preview, v0 Jul 30, 2026 8:38am
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
openwork-diagnostics Skipped Skipped Jul 30, 2026 8:38am

@vercel
vercel Bot temporarily deployed to Preview – openwork-diagnostics July 21, 2026 05:55 Inactive
@vercel

vercel Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

@PriyeshPandey2000 is attempting to deploy a commit to the Different AI Team on Vercel.

A member of the Team first needs to authorize it.

@PriyeshPandey2000

Copy link
Copy Markdown
Contributor Author

Hi @benjaminshafii , would appreciate a review when you get a chance. Happy to address any feedback.

@reachjalil
reachjalil force-pushed the feat/markdown-preview-stale-content branch from bd460e5 to 88ed8dd Compare July 30, 2026 08:18
@vercel
vercel Bot temporarily deployed to Preview – openwork-diagnostics July 30, 2026 08:18 Inactive
@reachjalil

reachjalil commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator

Rebased the existing PR head onto current dev at
986e618c5d752ba4dd0fc007c94b4811c651c0fd while preserving the original
single-commit patch and authorship.

Current rebased head: 1f33e2d76c890377e5164f4c5edc64d9c004df86.

Validation on the rebased head:

  • pnpm --filter @openwork/app test — 534 passed, 0 failed
  • pnpm --filter @openwork/app typecheck — passed
  • git diff --check — passed

The three Vercel failures are fork authorization statuses rather than code/test
failures. This PR remains open and unmerged for Jalil's review.

Use target.updatedAt (file mtime from server) in the React Query cache
key so the panel re-fetches automatically when the agent writes the
file. Also include updatedAt in isSameTranscriptArtifactTargets so the
Zustand store propagates the change. Add gcTime: 0 so closing and
reopening the panel always loads fresh content.
@reachjalil
reachjalil force-pushed the feat/markdown-preview-stale-content branch from 5395ad0 to 1f33e2d Compare July 30, 2026 08:37
@vercel
vercel Bot temporarily deployed to Preview – openwork-diagnostics July 30, 2026 08:37 Inactive

@reachjalil reachjalil left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks @PriyeshPandey2000 — clean, focused fix for stale artifact previews. Verified against current dev. Appreciate the contribution!

@reachjalil
reachjalil merged commit e94befe into different-ai:dev Jul 30, 2026
5 of 8 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.

[Bug]: Markdown Preview does not reflect latest content after Agent modifies the file

2 participants