Skip to content

refactor(playground): extract state logic into focused hooks#10869

Open
timotheeguerin wants to merge 4 commits into
microsoft:mainfrom
timotheeguerin:playground-state-refactor
Open

refactor(playground): extract state logic into focused hooks#10869
timotheeguerin wants to merge 4 commits into
microsoft:mainfrom
timotheeguerin:playground-state-refactor

Conversation

@timotheeguerin
Copy link
Copy Markdown
Member

Summary

Refactors playground.tsx by extracting scattered state management into focused, testable hooks.

Changes

New File Responsibility
compilation/compile.ts Pure async compile/findOutputFiles/emptyOutputDir
hooks/use-compilation.ts Compile queuing, stale output preservation, markers
hooks/use-monaco-sync.ts Bidirectional Monaco ↔ state sync
hooks/use-debounced-compile.ts Debounced recompile subscription
hooks/use-editor-actions.ts Save, format, file-bug, keybindings

Result

  • playground.tsx: ~600 → ~360 lines (40% reduction)
  • No public API changes (fully backward-compatible)
  • All tests pass, lint clean

Extract compilation, Monaco sync, debounced compile, and editor actions
into dedicated hooks. Move compile utilities to a separate module.

- playground.tsx reduced from ~600 to ~360 lines
- No public API changes (backward-compatible)
- All existing tests pass
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Jun 2, 2026

Open in StackBlitz

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

commit: 77243fe

Tests for useMonacoSync, useDebouncedCompile, and useEditorActions hooks
covering bidirectional sync, debounce behavior, and editor action callbacks.
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 2, 2026

All changed packages have been documented.

  • @typespec/playground
Show changes

@typespec/playground - internal ✏️

Refactor playground component: extract compilation, Monaco sync, debounced compile, and editor actions into dedicated hooks for better maintainability.

@azure-sdk-automation
Copy link
Copy Markdown

azure-sdk-automation Bot commented Jun 2, 2026

You can try these changes here

🛝 Playground 🌐 Website 🛝 VSCode Extension

@timotheeguerin timotheeguerin marked this pull request as ready for review June 2, 2026 18:03
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.

1 participant