Skip to content

[Website] Use the shared file explorer in the Blueprint editor - #3990

Merged
adamziel merged 2 commits into
trunkfrom
file-editor-surface-wiring
Jul 10, 2026
Merged

[Website] Use the shared file explorer in the Blueprint editor#3990
adamziel merged 2 commits into
trunkfrom
file-editor-surface-wiring

Conversation

@adamziel

@adamziel adamziel commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

What it does

Uses the shared FileExplorerSidebar in the Blueprint editor, so Blueprint bundles get the same recursive local-directory import and read-only behavior as the reusable file editor surface.

The Blueprint editor's private 512-line explorer and 89-line stylesheet are deleted. currentPath now drives tree selection directly, so the parallel treeFocusPath state is gone as well.

The shared toolbar uses three consistently sized icon buttons, keeping the actions on one line in the narrow Blueprint sidebar. Each button retains an accessible name and browser tooltip.

This PR does not change Site Manager persistence, OPFS lifecycle behavior, or editor ownership. Those concerns do not belong in a component-wiring change.

Rationale

There is no useful distinction between the two explorers. The private Blueprint copy duplicated uploads, previews, selection, and styling, and that duplication is exactly why local directories worked in one editor but not the other.

The shared explorer from #3973 provides the required import and read-only contracts. This PR replaces the duplicate caller and keeps its controls usable at the Blueprint sidebar width.

Testing instructions

npm exec nx -- run-many -t typecheck,lint \
  --projects=playground-components,playground-website
npm exec nx -- run playground-components:build
npm exec nx -- run playground-website:e2e:playwright -- \
  --project chromium \
  --grep 'should edit a blueprint in the blueprint editor and recreate the playground'
@adamziel
adamziel force-pushed the dock-file-editor-surfaces branch from a8c6564 to a10232f Compare July 10, 2026 00:46
@adamziel
adamziel force-pushed the file-editor-surface-wiring branch from 3ac76a4 to 90edf18 Compare July 10, 2026 00:53
@adamziel adamziel changed the title [Website] Reuse shared file explorer in Blueprint and Files panels Jul 10, 2026
@adamziel
adamziel force-pushed the dock-file-editor-surfaces branch from a10232f to f35c004 Compare July 10, 2026 10:06
@adamziel
adamziel force-pushed the file-editor-surface-wiring branch from 90edf18 to 1aceadf Compare July 10, 2026 10:08
@adamziel
adamziel force-pushed the dock-file-editor-surfaces branch from f35c004 to 8011730 Compare July 10, 2026 10:27
@adamziel
adamziel force-pushed the file-editor-surface-wiring branch from 1aceadf to ed1bc6f Compare July 10, 2026 10:28
@adamziel
adamziel force-pushed the dock-file-editor-surfaces branch from 8011730 to da048e2 Compare July 10, 2026 12:16
@adamziel
adamziel force-pushed the file-editor-surface-wiring branch from ed1bc6f to 44690d1 Compare July 10, 2026 12:26
@adamziel
adamziel force-pushed the dock-file-editor-surfaces branch from da048e2 to 12c47f3 Compare July 10, 2026 12:51
@adamziel
adamziel force-pushed the file-editor-surface-wiring branch from 44690d1 to 02d08d3 Compare July 10, 2026 12:52
@adamziel
adamziel force-pushed the dock-file-editor-surfaces branch from 12c47f3 to e488dfa Compare July 10, 2026 18:54
@adamziel
adamziel force-pushed the file-editor-surface-wiring branch from 02d08d3 to 5540f06 Compare July 10, 2026 18:54
@adamziel adamziel changed the title [Website] Reuse the shared file explorer in Blueprint and retain Site Manager editor state Jul 10, 2026
@adamziel
adamziel force-pushed the dock-file-editor-surfaces branch from e488dfa to 7229e8d Compare July 10, 2026 20:33
@adamziel
adamziel force-pushed the file-editor-surface-wiring branch from 5540f06 to 6061c98 Compare July 10, 2026 20:33
@adamziel adamziel changed the title [Website] Replace the Blueprint explorer with the shared file explorer Jul 10, 2026
adamziel added a commit that referenced this pull request Jul 10, 2026
## What it does

Adds an Upload button to the reusable file editor and lets users drop
files or local
directories on the blank area around its file tree. Imports go into the
selected
directory, and dropped directories keep their nested files and
subdirectories.

This PR also:

- adds a `readOnly` option that keeps browsing and previews available
while hiding
  or disabling changes to the filesystem;
- selects and expands to the file currently open in the editor; and
- uses the existing POSIX path helpers without trimming rename input or
treating
`\` as a separator. Empty names, `.`, `..`, and names containing `/` are
still
  rejected.

The Blueprint editor switch remains in #3990.

## Rationale

The file browser has two parts. `FileExplorerSidebar` renders the
header, Upload
button, and space around the tree. `FilePickerTree` renders the rows and
performs
filesystem operations.

Before this PR, dropping a local directory on a tree row worked because
the drop
reached `FilePickerTree`. Dropping the same directory on the surrounding
sidebar did
not reach that code. This PR makes the tree's import operation available
to the
sidebar, so the Upload button, tree-row drops, and background drops all
behave the
same way.

The browser only exposes a drop payload while the drop handler is
running, so the
sidebar captures its entries and files before starting the asynchronous
import.

## Testing instructions

```bash
npm exec nx -- run-many -t test,typecheck,lint,build \
  --projects=playground-components
npm exec nx -- run playground-components:e2e -- --workers=1
```

Manual check:

1. Run `npm exec nx -- run playground-components:dev -- --host 127.0.0.1
--port 5174` and open
`http://127.0.0.1:5174/playwright-file-editor.html`.
2. Select `/wordpress/workspace/subdir`, upload a text file, and confirm
it appears there.
3. Drop a nested local directory on the blank explorer background and
confirm its hierarchy appears under the selected directory.
4. Rename a throwaway entry with surrounding spaces and a backslash and
confirm the name is not rewritten.
Base automatically changed from dock-file-editor-surfaces to trunk July 10, 2026 23:34
@adamziel
adamziel marked this pull request as ready for review July 10, 2026 23:35
@adamziel
adamziel requested review from a team, JanJakes and Copilot July 10, 2026 23:35

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.

Replaces the Blueprint editor’s bespoke file explorer with the shared FileExplorerSidebar / FilePickerTree implementation so Blueprint bundles get the same recursive directory import and read-only behavior as the reusable file editor surface.

Changes:

  • Delete Blueprint editor–specific file explorer component + CSS and wire the editor to the shared components
  • Extend shared explorer/tree to support read-only mode and unified background drop + file-input upload importing
  • Add/adjust Playwright coverage to validate the shared upload/import surface appears and supports nested directory drops

Reviewed changes

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

Show a summary per file
File Description
packages/playground/website/src/components/blueprint-editor/file-explorer.module.css Deleted duplicated Blueprint explorer styles (now using shared explorer surface).
packages/playground/website/src/components/blueprint-editor/file-explorer-sidebar.tsx Deleted duplicated Blueprint explorer implementation (replaced by shared component).
packages/playground/website/src/components/blueprint-editor/BlueprintBundleEditor.tsx Switched Blueprint editor to shared FileExplorerSidebar and removed treeFocusPath state.
packages/playground/website/playwright/e2e/website-ui.spec.ts Added assertion that the shared “Upload files” action is visible in Blueprint editor.
packages/playground/components/src/PlaygroundFileEditor/file-explorer-sidebar.tsx Added upload UI + background drop handling and read-only plumbing; sync tree selection with currentPath.
packages/playground/components/src/FilePickerTree/index.tsx Added readOnly mode, exposed import APIs, improved path normalization and CSS selector escaping, and refactored drop import flow.
packages/playground/components/e2e/tests/playground-file-picker.spec.ts Added e2e coverage for renaming with backslashes/spaces.
packages/playground/components/e2e/tests/playground-file-editor.spec.ts Added e2e coverage for dropping a nested host directory onto the explorer background.
Comments suppressed due to low confidence (2)

packages/playground/components/src/FilePickerTree/index.tsx:681

  • The previous logic rejected dropping a node onto itself (destinationDir === sourcePath) in addition to rejecting descendant drops. After switching to isParentOf(...), the self-drop check is gone, which can allow attempting to move a folder into itself (e.g., drop /a onto /a → move to /a/a), typically resulting in a failing/undefined filesystem move. Add an explicit destinationDir === sourcePath guard (or ensure isParentOf treats equality as invalid) before allowing the drop.
		if (!destinationDir) {
			return { allowed: false, state: 'invalid', destination: null };
		}
		if (sourcePath) {
			if (isParentOf(sourcePath, destinationDir)) {
				return { allowed: false, state: 'invalid', destination: null };
			}
		}
		return { allowed: true, state: 'valid', destination: destinationDir };

packages/playground/components/src/PlaygroundFileEditor/file-explorer-sidebar.tsx:1

  • This <button> is missing an explicit type=\"button\". If this sidebar is ever rendered inside a <form>, the default type=\"submit\" can trigger unintended submissions. Set type=\"button\" on the create-file and create-folder buttons (the upload button already does this).
import React, {

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

Comment thread packages/playground/components/src/FilePickerTree/index.tsx
@adamziel
adamziel force-pushed the file-editor-surface-wiring branch from 767f3e1 to 0082791 Compare July 10, 2026 23:44
@adamziel
adamziel merged commit 33f0e82 into trunk Jul 10, 2026
52 checks passed
@adamziel
adamziel deleted the file-editor-surface-wiring branch July 10, 2026 23:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment