Skip to content

fix(client): refresh workspace files after disk changes - #4379

Open
PixPMusic wants to merge 5 commits into
pingdotgg:mainfrom
PixPMusic:fix/client-refresh-workspace-file-on-open
Open

fix(client): refresh workspace files after disk changes#4379
PixPMusic wants to merge 5 commits into
pingdotgg:mainfrom
PixPMusic:fix/client-refresh-workspace-file-on-open

Conversation

@PixPMusic

@PixPMusic PixPMusic commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Summary

  • revalidate cached workspace files whenever a preview opens
  • subscribe mounted file queries to debounced native filesystem change events instead of polling contents
  • dispose file queries and watchers when no preview is mounted
  • skip file queries entirely when no web preview path is selected

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.ts
  • targeted contracts, server, client-runtime, web, and mobile typechecks
  • targeted formatting and lint checks
  • isolated web and iOS verification covering external edits while open and unmount → disk edit → remount

Note

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 RPC projects.watchFile.

Client runtime: readFile query atoms are wired to refreshQueryOnSuccess, 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.watchFile streaming RPC to auto-refresh workspace file queries on disk changes

  • Adds a watchFile method to WorkspaceFileSystem that emits debounced ProjectFileChangeEvent stream entries when a workspace-relative file changes, including symlink target changes; rejects paths that escape the workspace root.
  • Exposes this as a streaming projects.watchFile WebSocket RPC (with orchestration read scope required) via ws.ts and the updated contracts in rpc.ts.
  • Introduces refreshQueryOnSuccess in runtime.ts — a helper that wraps a query atom with a signal atom so the query auto-refreshes on each success event from the subscription.
  • Wires readFile queries in projectCommands.ts to revalidate on mount and refresh automatically when the projects.watchFile subscription fires, replacing the previous static query atom family.
  • Risk: readFile queries now have zero idle TTL and stale time, meaning they are evicted immediately when idle; the preload path compensates with a 1s WORKSPACE_FILE_PRELOAD_RETAIN_MS idle TTL.

Macroscope summarized a27510d.

@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: c7aef252-5e7c-4e51-b60c-df95a7121470

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Jul 23, 2026
Comment thread apps/web/src/components/files/FilePreviewPanel.tsx Outdated
Comment thread packages/client-runtime/src/state/runtime.ts
@macroscopeapp

macroscopeapp Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: 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.

@github-actions github-actions Bot added size:L 100-499 changed lines (additions + deletions). and removed size:M 30-99 changed lines (additions + deletions). labels Jul 23, 2026
Comment thread apps/server/src/workspace/WorkspaceFileSystem.ts Outdated
Comment thread packages/client-runtime/src/state/projectCommands.ts

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ 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.

Comment thread packages/client-runtime/src/state/projectCommands.ts
@PixPMusic
PixPMusic force-pushed the fix/client-refresh-workspace-file-on-open branch from e98bb71 to a27510d Compare August 3, 2026 16:07
patroza added a commit to patroza/t3code that referenced this pull request Aug 4, 2026
…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>
patroza added a commit to patroza/t3code that referenced this pull request Aug 4, 2026
…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>
patroza added a commit to patroza/t3code that referenced this pull request Aug 4, 2026
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant