Skip to content

Files Changed: per-session file watcher for reliable external-change refresh - #845

Merged
jeonghun-jj-lee merged 7 commits into
mainfrom
844-file-watcher-bridge
Sep 7, 2026
Merged

jeonghun-jj-lee merged 7 commits into
mainfrom
844-file-watcher-bridge

Conversation

@jeonghun-jj-lee

Copy link
Copy Markdown
Contributor

Closes #844

Per-session targeted FileWatcherBridge in the extension host that watches every file the session has touched (via VS Code's native FileSystemWatcher with RelativePattern for arbitrary paths). When any watched file is created, changed, or deleted, the bridge posts fs-diff-invalidate to the chat iframe, which bumps diff_version and triggers the existing server-diff refetch chain.

Changes

  • accumulate-diffs.ts: Added crossProjectStatus to MergeOpts — cross-project files can be marked as deleted by the filesystem watcher
  • accumulate-diffs.test.ts: 3 new tests for crossProjectStatus override logic
  • file_watcher_bridge.ts: New FileWatcherBridge class — per-directory watchers, debounced events, idempotent watch set
  • chat_panel.ts: Wires FileWatcherBridge, handles watch-files / fs-diff-invalidate messages, disposes on cleanup
  • session.tsx: Sends watch-files reactively from reviewDiffs(), listens for fs-diff-invalidate, maintains crossProjectStatus map

@jeonghun-jj-lee jeonghun-jj-lee added the enhancement New feature or request label Sep 6, 2026
@coderabbitai

coderabbitai Bot commented Sep 6, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Team

Run ID: 6ad83e12-3536-4d12-8e4c-cffcf0f619f1


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.

Extends MergeOpts with an optional crossProjectStatus map that overrides
the status of cross-project files in the merged output (e.g. 'deleted'
from a filesystem watcher notification).

Tests: 3 new cases (override, no-match, empty map).

Part of #844
Per-session targeted file watcher using per-directory VS Code
FileSystemWatchers. Events are filtered against the watched file set
and debounced (300ms per file). The watch set is idempotent — calling
updateWatchSet() replaces the set, adding/removing watchers as needed.

Part of #844
…lowlists

- Import and instantiate FileWatcherBridge in ChatPanel constructor
- Handle 'watch-files' messages from the iframe (updates watch set)
- Add 'watch-files' to Lane 1 allowlist (iframe → extension)
- Add 'fs-diff-invalidate' to Lane 2 allowlist (extension → iframe)
- Both renderHtml and renderTransitionHtml updated
- Bridge disposed via the disposables array on panel cleanup

Part of #844
…egration

- Add crossProjectStatus signal for tracking deleted cross-project files
- Listen for fs-diff-invalidate from the FileWatcherBridge: update
  crossProjectStatus on deletion/recreation and bump diff_version
- Send watch-files reactively whenever reviewDiffs() recomputes
- Pass crossProjectStatus into mergeServerAndToolDiffs

Part of #844
Add build:app step and dist/app/ copy to both local and remote rebuild
scripts, plus the appBundleDir VS Code setting. Ref #822.
The amicode service (#822) was booting on an ephemeral port, which meant
every window reload gave the iframe a new origin. This destroyed the
app's localStorage on each reload — losing Developer Tools repo paths,
titlebar positions, and all other persisted app state.

Fix: derive the service port as opencodePort + 1 (e.g. 43117 → 43118).
The origin stays stable across reloads, so localStorage persists. Falls
back to ephemeral if the derived port is busy (the service always boots).

Changes:
- server.ts: start() accepts optional port (0 = ephemeral, the default)
- amicode_service_wiring.ts: port option threaded through, with fallback
- extension.ts: passes configuredPort + 1 when the engine port is pinned

Part of #844
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Files Changed: per-session file watcher for reliable external-change refresh

1 participant