Skip to content

[Website] Keep pending file edits with their filesystem owner - #4008

Merged
adamziel merged 2 commits into
trunkfrom
file-editor-filesystem-ownership
Jul 11, 2026
Merged

[Website] Keep pending file edits with their filesystem owner#4008
adamziel merged 2 commits into
trunkfrom
file-editor-filesystem-ownership

Conversation

@adamziel

@adamziel adamziel commented Jul 11, 2026

Copy link
Copy Markdown
Collaborator

What it does

Keeps every buffered file edit attached to the filesystem that produced it.

PlaygroundFileEditor now writes through its filesystem prop, flushes a pending edit when that filesystem is replaced or the editor unmounts, and reloads editor state when the filesystem identity changes. Writes within one filesystem stay ordered; an unrelated filesystem does not wait behind them.

This removes the optional onSaveFile and onBeforeFilesystemChange props. A caller must provide the filesystem that owns both reads and writes.

Rationale

The old unmount cleanup claimed to flush pending work. It only cleared the debounce timer, so closing the editor could discard the last edit.

The website callers also bypassed the filesystem prop and saved through callbacks that read mutable client references. If filesystem A was replaced by filesystem B while an edit was pending, A's buffer could be written into B when both filesystems contained the same path. Keeping the filesystem object as the sole owner makes that redirect impossible.

Testing instructions

npm exec nx run playground-components:e2e
npm exec nx run playground-components:build:vite
npm exec nx run-many -t lint typecheck -p playground-components playground-website playground-personal-wp

The component E2E tests cover unmount before the debounce expires, A-to-B replacement with the same path, ordered writes to A, and an independent write to B while A is stalled.

Copilot AI 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.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Updates PlaygroundFileEditor to ensure buffered edits are written through the owning filesystem instance (including flushing on unmount/filesystem swap) and updates website/personal-wp callers plus E2E harness/tests to match the new ownership model.

Changes:

  • Remove onSaveFile / onBeforeFilesystemChange props and route all saves through the filesystem prop.
  • Introduce per-filesystem/per-path write serialization and flush pending edits on unmount/filesystem replacement.
  • Expand the E2E harness/tests to cover filesystem swapping, unmount flushing, and ordered writes.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
packages/playground/website/src/components/site-manager/site-file-browser/index.tsx Removes custom save/filesystem-change callbacks, relying solely on the provided filesystem.
packages/playground/personal-wp/src/components/site-manager/site-file-browser/index.tsx Same as website: removes callback-based writes and uses filesystem ownership.
packages/playground/components/src/e2e-harnesses/file-editor-harness.tsx Adds dual filesystems, mount/unmount controls, and a write gate for ordering tests.
packages/playground/components/src/PlaygroundFileEditor/playground-file-editor.tsx Implements pending-save ownership, flush-on-unmount/swap, and per-path write serialization.
packages/playground/components/e2e/tests/playground-file-editor.spec.ts Adds E2E coverage for unmount flushing, filesystem swapping, and ordered writes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@adamziel
adamziel merged commit 1bdf94c into trunk Jul 11, 2026
53 checks passed
@adamziel
adamziel deleted the file-editor-filesystem-ownership branch July 11, 2026 10:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment