Replay pre-mount file events so resumed watches show existing files - #25
Conversation
When watching resumes at startup, the initial scan runs before the webview has registered its event listeners, and Tauri drops emits that have no listener. The frontend's file list is built purely from live file_change events, so every existing file was silently missing after a restart; live watch events still worked, which made it look like the scan never ran. Per-file upload status icons were lost the same way. The backend now records what it emits: a FileChangeLog (latest event per path, capped at 500 to match the frontend list) and an UploadStatusLog (latest status per relative path, capped at 1000). Recording happens before emitting, so a frontend mounting concurrently sees each event either live or in the backlog, never neither. On mount the frontend registers its listeners first, then pulls get_file_change_backlog / get_upload_status_backlog and merges, with live entries winning conflicts. The change log is cleared on stop_watching and when a new watch starts, mirroring the frontend clearing its list at those points. Bumps version to 0.1.17. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
|
Claude finished @cohogan's task in 2m 8s —— View job Code Review: PR #25 — Replay pre-mount file events
Overall this is a well-structured fix for a real problem — the race between Bug:
|
…backlog # Conflicts: # package.json # src-tauri/Cargo.lock # src-tauri/Cargo.toml # src-tauri/src/lib.rs # src-tauri/src/upload.rs # src-tauri/tauri.conf.json
Review follow-ups on the backlog replay: The frontend fetched the backlogs before the file_upload_status listener was registered (and listen() registration is itself async), leaving the same drop-window the backlog exists to close. Both fetches now wait on the listener registration promises, so every event is seen either live or in the snapshot. New event_backlog integration tests cover the recording paths with MockRuntime: scan records every entry, one entry per path across rescans, cap-and-evict for both logs, latest-status-wins with stable position, start_watching clearing the previous folder's backlog, and graceful no-op when the logs are not managed. Exports the touched types doc-hidden, following the watch_supersede pattern. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Claude finished @cohogan's task in 2m 12s —— View job Code Review: PR #25 — Replay pre-mount file events
The core design is solid — "record before emit, listen before pull" correctly closes the race between Bug:
|
Problem
When the app restarts and resumes watching, the initial folder scan runs during
setup()— before the webview has mounted and registered its event listeners. Tauri drops emits that have no listener, and the frontend's file list is built purely from livefile_changeevents, so after a restart the UI showed no files even though the scan ran and uploads proceeded. Live watch events still worked, which made it look like only the "old" files were missing. Per-file upload status icons were lost the same way. (The "ignore existing files" setting was unrelated — it only gates upload queueing.)Fix
The backend now records what it emits, and the frontend replays the backlog on mount:
FileChangeLogmanaged state: latest event per path, capped at 500 (matching the frontend list cap). Recorded byrecord_and_emit_file_changeat both emit sites (watcher callback and initial scan), exposed viaget_file_change_backlog, cleared onstop_watchingand when a new watch starts — mirroring when the frontend clears its list.UploadStatusLogmanaged state: latest status per relative path, capped at 1000. Recorded insideemit_file_upload_status, exposed viaget_upload_status_backlog.Bumps version to 0.1.17 (0.1.16 is taken by #24).
Verification
cargo checkandcargo clippyclean,tsc --noEmitcleanNote
Conflicts with #24, which rewrites the same functions (
capture_initial_contents→scan_folder_contents, runtime-generic signatures). Suggested order: merge #24 first; this branch then needs a rebase adapting the helpers to be generic overtauri::Runtime.Co-Authored-By: Claude Fable 5 noreply@anthropic.com