Skip to content

Upgrade the website playground: examples, multi-file tabs, Prettier, esm.sh imports - #190

Merged
trueadm merged 6 commits into
mainfrom
playground-upgrade
Jul 20, 2026
Merged

trueadm merged 6 commits into
mainfrom
playground-upgrade

Conversation

@trueadm

@trueadm trueadm commented Jul 19, 2026 •

Copy link
Copy Markdown
Collaborator

What

A major upgrade to the /playground page, plus one small octane/compiler fix it surfaced.

Examples dropdown

14 curated workspaces grouped by topic, covering the TSRX and TSX API surface: counter (new whitespace-friendly default), keyed lists, inputs + @switch, branch-local hooks, context, portals, dynamic tags <{expr}>, Suspense + use() (both dialects), multi-file parallel use(), transitions/deferred values, ViewTransition, form actions, a zustand-via-esm.sh demo, and an OctaneCompat demo — a real React 19 host (App.react.tsx, mounted by react-dom from esm.sh) rendering a compiled Octane island with its own @try/@pending Suspense. A unit test compiles every example variant warning-free through the real pipeline, so the dropdown can't rot.

Multi-file workspaces

Svelte-REPL-style file tabs with sibling imports (static and dynamic), per-file undo history, per-file compiled output, and a v2 share-hash format ({v:2, l, e, f}) — old single-file links still decode. .react.tsx marks React-host files, compiled with sucrase's automatic react-jsx transform instead of the octane compiler.

Third-party imports (esm.sh + import map)

Bare specifiers rewrite to https://esm.sh/<pkg>?external=octane. The sandbox bootstrap (now a classic script) installs a single import map before any module loads, pinning octane/octane/react to locally built blob modules — so @octanejs/* bindings from the CDN share the singleton runtime — and the react family to pinned esm.sh builds. The runtime ships as a code-split JSON manifest (octane + octane/react entries over a shared core chunk; react external, so pure-octane sessions stay fully offline). The sandbox CSP loosens to exactly script-src … https://esm.sh; everything else (fetch/XHR, forms, navigation) stays blocked, and the consent gate for shared links is unchanged.

Prettier button

Client-side prettier/standalone + @tsrx/prettier-plugin (.tsrx) / typescript plugin (.tsx), matching repo style, with Ctrl/Cmd-Shift-F. Bare prettier is vite-aliased to prettier/standalone to satisfy the plugin's import { doc } from 'prettier'; the estree plugin rides along because standalone sources its core option definitions from it.

octane/compiler browser-eval fix

compiler/vite.js and compiler/bundler.js used named imports from node:*, which throw at module evaluation against a dev server's externalized shims — so importing octane/compiler in a browser dev graph crashed (latent on main; dev doesn't tree-shake the entry's re-exports). They now use namespace imports (member access only throws if a Node-only path actually runs). No behavior change in Node; changeset included (patch).

Router remount workaround

Diagnosed a pre-existing bug where the first router event after SSR hydration remounts the whole route tree (tracked separately, being fixed in its own session). The playground absorbs it by priming router.load() at boot before the editor exists, and a sessionStorage own-hash record keeps reloads/remounts of your own code from re-hitting the shared-link consent gate. Both are annotated for removal once the root cause lands.

Testing

  • pnpm test: 1213 files / 11,677 tests green, including new suites: playground-modules.test.ts (specifier policy, sibling resolution, cycles, sucrase, ordering), playground-examples.test.ts (every example compiles warning-free + hash round-trip), playground-format.test.ts (style + idempotence), and updated sandbox/hash/route-shell tests.
  • e2e (ssr-hydration.e2e.test.ts, real Chromium against dev + production preview): existing counter/warning tests updated, plus new coverage — multi-file example via the dropdown (tabs, sibling module, tab switching), Format button, gated multi-file share link → consent → run, and a network-guarded OctaneCompat end-to-end test (react-dom host + island data + events across the boundary; skips with a logged reason if esm.sh is unreachable).
  • pnpm typecheck and pnpm format:check green; evals corpus regenerated for the lockfile change.

🤖 Generated with Claude Code


Note

Medium Risk
Changes core controlled-select event timing and broad playground execution surface (sandbox, CSP, CDN imports); compiler import shape is low risk in Node but affects every dev import of octane/compiler.

Overview
The /playground page becomes a multi-file REPL: file tabs, sibling imports, per-file undo and compiled output, a v2 share hash (legacy single-file links still decode), an examples dropdown (14 curated workspaces), client-side Prettier (TSRX/TSX), esm.sh bare imports with an import map pinning octane to local blobs, and .react.tsx host files via sucrase for the OctaneCompat demo. CSP and sandbox wiring expand only as needed for esm.sh; shared links still require explicit Run consent, with sessionStorage and a router load() priming workaround until a separate hydration remount fix lands.

octane gains two patch-level runtime/tooling fixes bundled with the playground work: controlled <select> no longer restores on a microtask between native input and change (picks stay visible until change runs, with a task fallback for lone input), and octane/compiler re-exports use namespace node:* imports so browser dev graphs can evaluate vite.js/bundler.js without named-import shim failures. Eval train manifest overlay lockfile hashes and root lockfile/catalog entries (es-module-lexer, sucrase, website dev deps) are refreshed to match.

Reviewed by Cursor Bugbot for commit 2423c7a. Bugbot is set up for automated code reviews on this repo. Configure here.

@vercel

vercel Bot commented Jul 19, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
octane-website Ready Ready Preview, Comment Jul 20, 2026 10:01am
octane-website-mcp Ready Ready Preview, Comment Jul 20, 2026 10:01am

Request Review

@vercel
vercel Bot temporarily deployed to Preview – octane-website-mcp July 19, 2026 22:39 Inactive
@vercel
vercel Bot temporarily deployed to Preview – octane-website July 19, 2026 22:40 Inactive
Comment thread website/src/lib/playground-examples.ts Resolved
@vercel
vercel Bot temporarily deployed to Preview – octane-website-mcp July 19, 2026 23:12 Inactive
@vercel
vercel Bot temporarily deployed to Preview – octane-website July 19, 2026 23:13 Inactive

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 416214c. Configure here.

Comment thread website/src/lib/playground-sandbox.ts Resolved
@vercel
vercel Bot temporarily deployed to Preview – octane-website-mcp July 19, 2026 23:27 Inactive
@vercel
vercel Bot temporarily deployed to Preview – octane-website July 19, 2026 23:29 Inactive
trueadm and others added 4 commits July 20, 2026 00:29
…esm.sh imports

- Examples dropdown: 14 curated workspaces covering the TSRX/TSX surface
  (control flow, branch-local hooks, context, portals, dynamic tags,
  Suspense + use(), multi-file parallel use(), transitions, ViewTransition,
  form actions, zustand via esm.sh, and an OctaneCompat React-host demo),
  each gated by a test that compiles it warning-free through the real pipeline.
- Multi-file workspaces: virtual file tabs with sibling imports, per-file
  undo history and compiled output, and a v2 share-hash format (v1 links
  still decode). `.react.tsx` marks React-host files compiled with sucrase.
- Third-party imports: bare specifiers rewrite to esm.sh with
  `?external=octane`; the sandbox bootstrap installs an import map pinning
  octane (and octane/react) to locally built blob modules, so bindings share
  the singleton runtime. The runtime now ships as a code-split JSON manifest
  (octane + octane/react entries over a shared core chunk) and the sandbox
  CSP permits exactly module loads from esm.sh, nothing else.
- Format button: client-side prettier/standalone + @tsrx/prettier-plugin
  (vite-aliased bare `prettier` to the standalone build), repo style output.
- octane/compiler: vite.js and bundler.js now import node builtins in
  namespace form so evaluating the compiler entry in a browser dev server
  (externalized node:* shims) no longer throws; no behavior change in Node.
- Worked around the first-router-event-after-hydration route-tree remount
  (tracked separately) by priming router.load() at playground boot, and
  added sessionStorage own-hash trust so reloads of your own code never
  re-hit the shared-link consent gate.

Co-Authored-By: Claude Fable 5 <[email protected]>
…xamples

- The OctaneCompat e2e no longer runtime-skips when esm.sh is unreachable
  (the lint gate bans skip modifiers); an up-front probe now turns an
  unreachable CDN into an immediate, clearly-attributed failure instead.
- Bugbot: the OctaneCompat Island created its fetch promise in the parent
  body every render, so unrelated updates (the click counter) resuspended
  the @Try boundary. The Island — and both Suspense examples, which taught
  the same antipattern — now create the promise AT the use() call site,
  where octane's parallel-use memoization keys it by deps; only changed
  inputs refetch. Verified in-browser: island clicks keep the data visible,
  Refetch still refetches.
- The examples dropdown's "Custom" placeholder is now a static hidden
  option instead of a conditional branch inside <select>, so the option
  list never reconciles.

Co-Authored-By: Claude Fable 5 <[email protected]>
Bugbot: a late runtime-error from a superseded run (e.g. a timer firing
after a recompile) could post after the newer run's clean render and stick
in the error banner. The sandbox now stamps runtime-error messages with the
originating run's generation and the parent drops any that don't match the
current run; covered by a unit test driving the postMessage protocol.

Co-Authored-By: Claude Fable 5 <[email protected]>
Main's fix for the first-post-hydration-update remount (#192) makes the
playground's boot-time router.load() prime unnecessary — the first hash
write no longer tears down the route tree. Verified in-browser: the
preview iframe survives the first replaceState and example switches
across hash writes keep the original instance.

Co-Authored-By: Claude Fable 5 <[email protected]>
@trueadm
trueadm force-pushed the playground-upgrade branch from 9801aa6 to 85c8896 Compare July 19, 2026 23:35
@vercel
vercel Bot temporarily deployed to Preview – octane-website-mcp July 19, 2026 23:35 Inactive
@vercel
vercel Bot temporarily deployed to Preview – octane-website July 19, 2026 23:36 Inactive
Browsers request <link rel=manifest> anonymously by default, so on
SSO-protected Vercel preview deployments the manifest fetch loses its
auth cookie, gets redirected to the vercel.com login, and surfaces as a
CORS error in the console on every page. crossorigin="use-credentials"
makes the manifest request carry cookies; same-origin production
requests are unaffected.

Co-Authored-By: Claude Fable 5 <[email protected]>
@vercel
vercel Bot temporarily deployed to Preview – octane-website-mcp July 19, 2026 23:41 Inactive
@vercel
vercel Bot temporarily deployed to Preview – octane-website July 19, 2026 23:42 Inactive
…k gap

A real browser pick (popup commit, keyboard typeahead) dispatches trusted
`input` and `change` in SEPARATE tasks with microtask checkpoints between
them. The controlled-select restore ran in that gap, snapping the
selection back to the rendered value before `change` dispatched — so
every controlled select's onChange read the OLD value and user picks
could never commit. Synthetic events (tests, Playwright selectOption)
dispatch both in one task and never hit the gap, which is how the whole
suite stayed green while real users couldn't switch the playground's
examples dropdown.

The `input` dispatch now marks the pick in flight on the element (the
same window design as checkable activation): the `change` dispatch owns
the after-handlers restore, and a task fallback settles sequences whose
`change` never completes (stopped propagation below the root, or a
synthetic lone `input`). Regression test drives the real two-task event
sequence and failed before the fix; the input-only settle test moves
from the microtask to the task boundary it now guarantees.

Also gives the playground's example dropdown a custom chevron with
breathing room from the right edge (appearance: none + inline SVG).

Co-Authored-By: Claude Fable 5 <[email protected]>
@vercel
vercel Bot temporarily deployed to Preview – octane-website-mcp July 20, 2026 10:00 Inactive
@vercel
vercel Bot temporarily deployed to Preview – octane-website July 20, 2026 10:01 Inactive
@trueadm
trueadm merged commit d388e80 into main Jul 20, 2026
22 checks passed
@trueadm
trueadm deleted the playground-upgrade branch July 20, 2026 10:08

This branch was previously deployed

2 inactive deployments
Preview – octane-website — 2423c7ae Deployed Jul 20, 2026 by vercel[bot]
Preview – octane-website-mcp — 2423c7ae Deployed Jul 20, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant