Skip to content

FileSystemObserver implementation#1265

Merged
streamich merged 6 commits into
masterfrom
fsa-watcher
Jul 7, 2026
Merged

FileSystemObserver implementation#1265
streamich merged 6 commits into
masterfrom
fsa-watcher

Conversation

@streamich

Copy link
Copy Markdown
Owner

No description provided.

Copilot AI review requested due to automatic review settings July 7, 2026 12:30

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Implements a working FileSystemObserver for the fs-fsa package, wiring @jsonjoy.com/fs-core’s watcher events into Web File System Access–style change records and extending the observer API to support stopping observations.

Changes:

  • Add unobserve() to the IFileSystemObserver interface and implement observe() / unobserve() / disconnect() in CoreFileSystemObserver.
  • Introduce a concrete FileSystemChangeRecord implementation and batch change delivery via microtasks.
  • Expand observer test coverage substantially (observation lifecycle, batching, terminal events, recursive behavior, sync access handles).

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
packages/fs-fsa/src/types.ts Extends the observer interface with unobserve().
packages/fs-fsa/src/CoreFileSystemSyncAccessHandle.ts Exposes __path consistently for sync access handles (used by observer implementation).
packages/fs-fsa/src/CoreFileSystemObserver.ts Implements observing/unobserving/disconnect, event translation, and record batching.
packages/fs-fsa/src/tests/CoreFileSystemObserver.test.ts Adds comprehensive tests for the new observer behavior and change record semantics.

Comment on lines +50 to +56
const path = (handle as unknown as { __path?: unknown }).__path;
if (typeof path !== 'string')
throw new TypeError("Failed to execute 'observe' on 'FileSystemObserver': Invalid handle.");
const isDirectory = (handle as IFileSystemHandle).kind === 'directory';
const last = path[path.length - 1];
const target = path.length > 1 && (last === '/' || last === '\\') ? path.slice(0, -1) : path;
const ctx = ((handle as any).ctx ?? (handle as any)._ctx) as CoreFsaContext;
@streamich streamich merged commit 42c439c into master Jul 7, 2026
10 checks passed
@streamich streamich deleted the fsa-watcher branch July 7, 2026 12:49
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.

2 participants