fix(chat): refresh artifact previews from disk - #179
Draft
matt2e wants to merge 4 commits into
Draft
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_fileTauri 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_filecommand 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.