ruff/playground
Andrew Gallant 3bf4dae452 [ty] Make auto-import work in the playground
It turned out that we weren't quite funneling the new completion data
all the way through.

I followed the docs for [`CompletionItem`] for the Monaco editor. It's
similar, but not identical, to the LSP protocol specification.

[`CompletionItem`]: https://microsoft.github.io/monaco-editor/typedoc/interfaces/languages.CompletionItem.html
2025-09-19 14:35:51 -04:00
..
api Revert "Update NPM Development dependencies" (#19730) 2025-08-04 07:33:58 +00:00
ruff Update dependency monaco-editor to ^0.53.0 (#20395) 2025-09-15 13:47:51 +02:00
shared [ty] Add semantic token provider to playground (#19232) 2025-07-10 07:50:28 +02:00
ty [ty] Make auto-import work in the playground 2025-09-19 14:35:51 -04:00
.gitignore Remove all useEffect usages (#12659) 2024-08-08 13:16:38 +02:00
.prettierignore Rename Red Knot (#17820) 2025-05-03 19:49:15 +02:00
eslint.config.mjs Red Knot Playground (#12681) 2025-03-18 17:17:11 +01:00
package-lock.json Update dependency monaco-editor to ^0.53.0 (#20395) 2025-09-15 13:47:51 +02:00
package.json Revert "Update NPM Development dependencies" (#19730) 2025-08-04 07:33:58 +00:00
README.md [docs] Typo fix for playground (#18929) 2025-06-24 21:01:48 -04:00
tsconfig.json Rename Red Knot (#17820) 2025-05-03 19:49:15 +02:00
tsconfig.node.json Rename Red Knot (#17820) 2025-05-03 19:49:15 +02:00

playground

In-browser playground for Ruff. Available https://play.ruff.rs/.

Getting started

Install the NPM dependencies with npm install, and run the development server with npm start --workspace ruff-playground or npm start --workspace ty-playground. You may need to restart the server after making changes to Ruff or ty to re-build the WASM module.

To run the datastore, which is based on Workers KV, install the Wrangler CLI, then run npx wrangler dev --local from the ./playground/api directory. Note that the datastore is only required to generate shareable URLs for code snippets. The development datastore does not require Cloudflare authentication or login, but in turn only persists data locally.

Architecture

The playground is implemented as a single-page React application powered by Vite, with the editor experience itself powered by Monaco.

The playground stores state in localStorage, but supports persisting code snippets to a persistent datastore based on Workers KV and exposed via a Cloudflare Worker.

The playground design is originally based on Tailwind Play, with additional inspiration from the Biome Playground.

Known issues

Stack overflows

If you see stack overflows in the playground, build the WASM module in release mode: npm run --workspace ty-playground build:wasm.