fix(client): refresh workspace files after disk changes - #4379
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
ApprovabilityVerdict: Needs human review This PR introduces a new file watching feature with a streaming RPC endpoint, new server-side watch logic including symlink and security handling, and new client-side state management patterns. Despite the "fix" title, this is a new capability spanning multiple layers that warrants human review. You can customize Macroscope's approvability policy. Learn more. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 394b9a9. Configure here.
e98bb71 to
a27510d
Compare
…gdotgg#4379) (#312) Imported from pingdotgg#4379 at a27510d. Open file previews revalidate on mount and subscribe to debounced native filesystem watches so external edits (editors, git, agents) show without a manual refresh. Co-authored-by: omegent-app[bot] <306514130+omegent-app[bot]@users.noreply.github.com> Co-authored-by: Enrico Polanski <16064771+enricopolanski@users.noreply.github.com> Co-authored-by: Patrick Roza <42661+patroza@users.noreply.github.com>
…gdotgg#4379) (#312) Imported from pingdotgg#4379 at a27510d. Open file previews revalidate on mount and subscribe to debounced native filesystem watches so external edits (editors, git, agents) show without a manual refresh. Co-authored-by: omegent-app[bot] <306514130+omegent-app[bot]@users.noreply.github.com> Co-authored-by: Enrico Polanski <16064771+enricopolanski@users.noreply.github.com> Co-authored-by: Patrick Roza <42661+patroza@users.noreply.github.com>
…gdotgg#4379) (#312) Imported from pingdotgg#4379 at a27510d. Open file previews revalidate on mount and subscribe to debounced native filesystem watches so external edits (editors, git, agents) show without a manual refresh. Co-authored-by: omegent-app[bot] <306514130+omegent-app[bot]@users.noreply.github.com> Co-authored-by: Enrico Polanski <16064771+enricopolanski@users.noreply.github.com> Co-authored-by: Patrick Roza <42661+patroza@users.noreply.github.com>
…gdotgg#4379) (#312) Imported from pingdotgg#4379 at a27510d. Open file previews revalidate on mount and subscribe to debounced native filesystem watches so external edits (editors, git, agents) show without a manual refresh. Co-authored-by: omegent-app[bot] <306514130+omegent-app[bot]@users.noreply.github.com> Co-authored-by: Enrico Polanski <16064771+enricopolanski@users.noreply.github.com> Co-authored-by: Patrick Roza <42661+patroza@users.noreply.github.com>
…gdotgg#4379) (#312) Imported from pingdotgg#4379 at a27510d. Open file previews revalidate on mount and subscribe to debounced native filesystem watches so external edits (editors, git, agents) show without a manual refresh. Co-authored-by: omegent-app[bot] <306514130+omegent-app[bot]@users.noreply.github.com> Co-authored-by: Enrico Polanski <16064771+enricopolanski@users.noreply.github.com> Co-authored-by: Patrick Roza <42661+patroza@users.noreply.github.com>
…gdotgg#4379) (#312) Imported from pingdotgg#4379 at a27510d. Open file previews revalidate on mount and subscribe to debounced native filesystem watches so external edits (editors, git, agents) show without a manual refresh. Co-authored-by: omegent-app[bot] <306514130+omegent-app[bot]@users.noreply.github.com> Co-authored-by: Enrico Polanski <16064771+enricopolanski@users.noreply.github.com> Co-authored-by: Patrick Roza <42661+patroza@users.noreply.github.com>
…gdotgg#4379) (#312) Imported from pingdotgg#4379 at a27510d. Open file previews revalidate on mount and subscribe to debounced native filesystem watches so external edits (editors, git, agents) show without a manual refresh. Co-authored-by: omegent-app[bot] <306514130+omegent-app[bot]@users.noreply.github.com> Co-authored-by: Enrico Polanski <16064771+enricopolanski@users.noreply.github.com> Co-authored-by: Patrick Roza <42661+patroza@users.noreply.github.com>
a27510d to
06025a7
Compare

Summary
Verification
vp test run apps/server/src/workspace/WorkspaceFileSystem.test.ts packages/client-runtime/src/state/runtime.test.ts apps/web/src/components/files/projectFilesQueryState.test.tsNote
Medium Risk
New per-open-file WebSocket subscriptions and fs watchers increase server/client load; read caching behavior changes (more refetch on mount) but auth and path-safety rules match existing read paths.
Overview
Workspace file previews now stay in sync when files change on disk outside the app, using native filesystem watches instead of long-lived cached reads.
Server & RPC: Adds a streaming
projects.watchFileRPC (orchestration read scope) backed byWorkspaceFileSystem.watchFile, which debounces directory watches, handles missing files and in-workspace symlink targets, and keeps the same workspace-root escape checks as reads.Client state: Introduces
refreshQueryOnSuccessso aprojectsReadFilequery re-fetches whenever the matchingprojectsWatchFilesubscription emits a success.readFileatoms use zero stale/idle TTL so watchers and queries drop when nothing is mounted; mobile preload applies a 1s idle TTL so preloaded reads still hand off cleanly to the live query.UI:
useProjectFileQueryno longer subscribes whenrelativePathis null, even if the hook is enabled.Reviewed by Cursor Bugbot for commit 06025a7. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Add
projects.watchFilestreaming RPC to auto-refresh workspace file queries on disk changeswatchFilemethod toWorkspaceFileSystemthat emits debouncedProjectFileChangeEventstream entries when a workspace-relative file changes, including symlink target changes; rejects paths that escape the workspace root.projects.watchFileWebSocket RPC (with orchestration read scope required) viaws.tsand the updated contracts inrpc.ts.refreshQueryOnSuccessinruntime.ts— a helper that wraps a query atom with a signal atom so the query auto-refreshes on each success event from the subscription.readFilequeries inprojectCommands.tsto revalidate on mount and refresh automatically when theprojects.watchFilesubscription fires, replacing the previous static query atom family.readFilequeries now have zero idle TTL and stale time, meaning they are evicted immediately when idle; the preload path compensates with a 1sWORKSPACE_FILE_PRELOAD_RETAIN_MSidle TTL.Macroscope summarized 06025a7.