Skip to content

fix(chat): refresh artifact previews from disk - #179

Draft
matt2e wants to merge 4 commits into
mainfrom
update-artifacts
Draft

fix(chat): refresh artifact previews from disk#179
matt2e wants to merge 4 commits into
mainfrom
update-artifacts

Conversation

@matt2e

@matt2e matt2e commented Aug 24, 2026

Copy link
Copy Markdown
Collaborator

Category: fix
User Impact: Artifact previews now stay aligned with files that are updated on disk.
Problem: Open artifact previews could become stale when the same file was rewritten outside the normal chat tool-event flow, especially for images cached by the webview. Solution: Add a filesystem fingerprint command and use it in the artifact viewer to refresh or warn when the displayed file changes, while preserving the last good preview during recovery.

File changes

src-tauri/Cargo.toml
Adds the Windows filesystem API feature needed to read file change-time metadata.

src-tauri/src/commands/system.rs
Adds a stat_file Tauri command that returns stable file identity metadata off the async runtime thread, plus coverage for timestamp and directory edge cases.

src-tauri/src/lib.rs
Registers the new stat_file command with the Tauri invoke handler.

src/features/chat/ui/ArtifactViewer.tsx
Tracks artifact file fingerprints, polls visible artifacts for on-disk changes, reloads text and image previews safely, and shows a reloadable warning when the preview diverges from disk.

src/features/chat/ui/tests/ArtifactViewer.test.tsx
Expands artifact viewer tests to cover polling, stale preview recovery, image cache busting, reload behavior, and failure states.

src/shared/api/system.ts
Exposes the new file-stat command to the renderer with typed metadata fields.

src/shared/i18n/locales/en/chat.json
Adds English copy for the stale-preview warning and reload action.

src/shared/i18n/locales/es/chat.json
Adds Spanish copy for the stale-preview warning and reload action.

matt2e added 4 commits August 24, 2026 16:34
Poll open artifact fingerprints while visible, reload stable text and image changes without flicker, and retain last-good content behind an explicit divergence warning when disk reads fail.

Adapted from Brandon Sherman's format-patch attached to BOT-1675.

Signed-off-by: Matt Toohey <contact@matttoohey.com>
Track cross-platform change times and signed pre-epoch mtimes, serialize forced refreshes against polling, and only accept image fingerprints after the rendered cache-busted source decodes. Cover metadata-preserving rewrites, refresh races, image URL validation, and empty-file recovery.

Signed-off-by: Matt Toohey <contact@matttoohey.com>
Recheck image fingerprints after asynchronous decode before accepting cache-busted content, and run polled metadata inspection on Tokio's blocking pool.

Add focused coverage for decode-time file changes and async metadata execution.

Signed-off-by: Matt Toohey <contact@matttoohey.com>
Poll visible artifacts every ten seconds while Berd is unfocused, check immediately when focus returns, and restore the foreground interval. Cover background timing and focus recovery.

Signed-off-by: Matt Toohey <contact@matttoohey.com>
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.

1 participant