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>

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
Increases server read traffic for open file previews (no long-lived read cache) and adds per-subscriber filesystem watchers; behavior is scoped to mounted file queries with zero idle TTL.
Overview
Workspace file previews now stay in sync with disk when files change outside T3 Code (editor saves, git, etc.), instead of serving long-lived cached reads.
Server: Adds
WorkspaceFileSystem.watchFile— debounced native directory watches with workspace-root safety checks and symlink-aware paths — and exposes it as the streaming RPCprojects.watchFile.Client runtime:
readFilequery atoms are wired torefreshQueryOnSuccess, which re-fetches file contents when the watch stream signals a change. File reads use zero stale/idle TTL so mounted previews always revalidate; watch subscriptions dispose when nothing is subscribed.Web/mobile: Skips file queries when no path is selected; mobile preload uses a 1s idle TTL on read atoms so preloads survive handoff to the preview consumer.
Reviewed by Cursor Bugbot for commit a27510d. 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 a27510d.