Skip to content

feat(playground): add multi-file editor with file explorer#10353

Closed
JoshLove-msft wants to merge 4 commits intomicrosoft:mainfrom
JoshLove-msft:feat/playground-file-explorer
Closed

feat(playground): add multi-file editor with file explorer#10353
JoshLove-msft wants to merge 4 commits intomicrosoft:mainfrom
JoshLove-msft:feat/playground-file-explorer

Conversation

@JoshLove-msft
Copy link
Copy Markdown
Contributor

Multi-file editor support for the TypeSpec playground

Adds the ability to work with multiple input files in the playground editor.

Changes

  • Multi-file state: Added files, selectedFile, and normalized accessors to PlaygroundState
  • useMonacoModels hook: Manages Monaco editor model lifecycle per file (create/update/dispose)
  • File tree explorer: Shows in the editor panel when multiple input files exist, using the existing FileTreeExplorer component
  • Multi-file compile: Writes all files to BrowserHost virtual FS and clears stale .tsp files before each compilation
  • EditorPanel wiring: Passes inputFiles, selectedInputFile, onSelectedInputFileChange from playground state
  • Tests: 13 tests for usePlaygroundState multi-file support

Follow-up work

  • Per-file diagnostics mapping (map diagnostics to correct Monaco model based on source file)
  • GitHub spec loader (load TypeSpec files from the specs repo)

JoshLove-msft and others added 3 commits April 12, 2026 19:48
Add files, selectedFile to PlaygroundState. Normalize single-file
content into files Record. Update compile function to write all
files to virtual FS.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Add useMonacoModels hook for managing multiple Monaco editor models
- Add file tree explorer panel that shows when multiple input files exist
- Update EditorPanel to accept inputFiles, selectedInputFile props
- Wire multi-file compile: write all files to BrowserHost, clear stale ones
- Add normalized multi-file accessors to playground state

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- 13 tests for usePlaygroundState multi-file support
- Tests cover: files normalization, isMultiFile, selectedFile defaults,
  onSelectedFileChange, onFilesChange, onFileContentChange
- Add changeset for @typespec/playground

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…e-explorer

# Conflicts:
#	packages/playground/src/react/playground.tsx
#	pnpm-lock.yaml
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Apr 17, 2026

Open in StackBlitz

npm i https://pkg.pr.new/@typespec/playground@10353

commit: 1b0ad35

@github-actions
Copy link
Copy Markdown
Contributor

All changed packages have been documented.

  • @typespec/playground
Show changes

@typespec/playground - feature ✏️

Add multi-file editor with file explorer support

@azure-sdk
Copy link
Copy Markdown
Collaborator

You can try these changes here

🛝 Playground 🌐 Website 🛝 VSCode Extension

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I had a pr experimenting adding this a few weeks ago but held on as unsure it was that valuable and to find the correct UI for it so we don't make this even more crowded(playground already getting tight on small screen).

What motivated this?

Not fully sure what it's supposed to look like in your pr as it doesn't seem to work in the preview playground

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ha yeah I see it is not working. The motivation for this is to ultimately be able to load in specs from the rest spec repo.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

you can already do that with the import it just combine them into one file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants