[Website] Keep pending file edits with their filesystem owner - #4008
Merged
Conversation
Contributor
There was a problem hiding this comment.
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/onBeforeFilesystemChangeprops and route all saves through thefilesystemprop. - 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What it does
Keeps every buffered file edit attached to the filesystem that produced it.
PlaygroundFileEditornow writes through itsfilesystemprop, 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
onSaveFileandonBeforeFilesystemChangeprops. 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
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.