Skip to content

Filesystem watch (Phase 2): streaming WatchDir - #3

Open
col wants to merge 7 commits into
feat/filesystemfrom
feat/filesystem-watch
Open

Filesystem watch (Phase 2): streaming WatchDir#3
col wants to merge 7 commits into
feat/filesystemfrom
feat/filesystem-watch

Conversation

@col

@col col commented Jun 13, 2026

Copy link
Copy Markdown
Owner

Summary

Adds live directory watching to E2bEx.Filesystem via the envd streaming WatchDir RPC — message-first, like Commands.start/PTY.

  • E2bEx.Filesystem.watch_dir/4{:ok, %WatchHandle{}}, pushing {ref, {:fs_event, %E2bEx.FilesystemEvent{}}} to a subscriber as changes happen; ends with a terminal {ref, {:error, %E2bEx.Error{}}} if the stream fails or closes.
  • E2bEx.FilesystemEvent{name, type (:create|:write|:remove|:rename|:chmod), entry} (the %EntryInfo{} is included when include_entry: true).
  • E2bEx.Filesystem.WatchHandlestop/1 ends the watch (no terminal message), cancelling the stream.
  • E2bEx.Filesystem.WatchServer — internal streaming GenServer, modeled on Commands.HandleServer. The key difference: WatchDir frames are a bare WatchDirResponse oneof (start/filesystem/keepalive), not wrapped in an "event" field; and watch has no result, so a closed stream is terminal {:error, …}.

opts: :recursive, :include_entry, :subscriber, plus the usual :user/:timeout_ms/:domain/:port/:base_url.

Notes

  • Stacked PR: based on feat/filesystem (PR Filesystem Phase 1: file operations + content #2, Phase 1). Once Filesystem Phase 1: file operations + content #2 merges to main, this rebases onto main. Phase 1 code is untouched here — only watch_dir/4/spawn_watch/3 were added to filesystem.ex.
  • The streaming-skeleton duplication with HandleServer is a deliberate, documented choice (deferred unification) to avoid touching the shipped Commands/PTY path.
  • Out of scope: the polling watcher RPCs (CreateWatcher/GetWatcherEvents/RemoveWatcher).

Spec: docs/superpowers/specs/2026-06-13-e2b-filesystem-watch-design.md · Plan: docs/superpowers/plans/2026-06-13-e2b-filesystem-watch.md

Test Plan

  • mix test — 163 tests, 0 failures
  • mix compile --warnings-as-errors clean
  • Coverage: FilesystemEvent.from_api/1 (all event types + nested entry); WatchHandle.stop/1 (live + dead); watch_dir/4 streaming (chunked incremental decode, entry present/absent, keepalive-ignored, defaults, pre-start non-2xx error, mid-stream trailer error, post-start truncated-frame malformed, stop/1 no-terminal)
  • Manual: watch a real sandbox dir and touch/edit/remove files

🤖 Generated with Claude Code

col and others added 7 commits June 13, 2026 15:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant