Skip to content

feat(website): add an Octane version combobox to the playground - #2244

Merged
domgan-oai merged 3 commits into
mainfrom
feat/playground-version-combobox
Oct 27, 2026
Merged

domgan-oai merged 3 commits into
mainfrom
feat/playground-version-combobox

Conversation

@trueadm

@trueadm trueadm commented Oct 26, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Adds the Octane version combobox from #1022 to the playground toolbar. It covers main and published releases. Commit and PR revisions are not included: they need a build host, which the issue makes conditional on sponsorship (details below).

  • main (the default) still uses the compiler and runtime manifest bundled with the website build.
  • A published release loads its compiler from esm.sh/octane@X/compiler into the page. The sandbox import map points every runtime entry (octane, octane/internal/client, octane/react, octane/signals, octane/signals/client) at esm.sh/octane@X/...?external=react,react-dom. esm.sh splits a package's internals into one module per file, so all entries import the same dist/runtime.mjs and share one runtime instance. external=react,react-dom leaves React bare, so the sandbox's pinned React is the only copy.
  • URL: ?version=0.16.0, alongside the existing workspace hash. Missing or main means main. The URL is the source of truth:
    • Choosing a version loads its toolchain first and writes the URL only after the load succeeds.
    • A URL change (back/forward, a pasted link) loads whatever version it names.
    • A failed load keeps the running toolchain and preview, shows the error and a Retry button next to the control, and never falls back to another version.
  • Combobox: built on @octanejs/base-ui/combobox, using the deep subpath import the issue suggests.
    • Typing filters the list. Click or Enter commits a choice; Escape restores the active label.
    • It has a native <label>, a live status region for loading, and an alert for errors.
    • The release list comes from npm when the popup first opens, so a visit that never opens it makes no registry request (this also keeps e2e offline). Deprecated releases are left out; those are the unrelated 2015 [email protected].
  • Older releases: compiled imports of a runtime entry that release does not ship fail with "octane/signals" is not shipped by the selected Octane version. A release without compileTypesInspection shows that in the Types pane instead of crashing.

Why commit/PR revisions are not in this PR

I tested the feasibility condition from the issue:

  • https://esm.sh/gh/octanejs/octane@<sha>/packages/octane/src/index.ts returns HTTP 500 "repo is too large", so esm.sh cannot serve a revision directly.
  • pkg.pr.new (which esm.sh /pr/ would serve) needs a CI job that builds and publishes every PR/commit. That is a project-funded build, which the issue blocks until a host sponsors it.

So the combobox accepts main and exact releases only. Any other version value gets an actionable error.

Validation

  • pnpm typecheck:files on all changed website files: clean
  • pnpm format:files on the changed files
  • targeted tests: website/tests/playground-version.test.ts (new), playground.test.ts, playground-modules.test.ts, playground-runtime.test.ts, playground-examples.test.ts: 124 passed. Coverage:
    • the version param contract
    • release-list filtering and sorting
    • esm.sh import-map construction, including older releases that lack entries
    • unpublished, no-compiler and esm.sh-failure errors
    • compile-cache invalidation when the compiler changes
    • rejection of runtime entries a release does not ship
    • the sandbox init {imports} path, which drops non-esm.sh URLs
    • the route renders a labelled combobox that defaults to main and shows a pasted ?version=
  • Checked by hand in a browser on a fresh worktree dev server:
    • main runs, with no npm or esm.sh requests on a plain visit
    • filtering, then ArrowDown+Enter loads 0.16.0; the URL becomes ?version=0.16.0#<same workspace hash> and the editor keeps its contents
    • ?version=0.2.7 restores on load and the counter is interactive, so hooks work across octane and octane/internal/client
    • Escape cancels a draft
    • Back returns to main
    • ?version=0.0.99 shows "[email protected] is not published on npm." with Retry and runs nothing
    • a pasted ?version=0.16.0#<hash> link in a new tab restores both, keeps the shared-code consent gate, and runs after approval
    • the mobile toolbar fits
  • pnpm test / pnpm format:check / pnpm typecheck across the whole repo: left to CI
  • perf-review: not applicable (website only; no packages/octane/src, compiler output, or binding hot path)
  • concise-code:
    • It reuses the existing sandbox protocol: init carries imports instead of a manifest, and the import-map code is shared.
    • It reuses the existing compile cache, keyed by compiler identity.
    • Rejected: a separate per-release runtime-manifest builder (esm.sh already splits shared modules); eager release fetching (an extra request on every visit); and URL-first navigation for selections (that would leave the URL naming a version that failed to load).

Risk / follow-ups

  • A shared link chooses which published Octane release the page loads from esm.sh before the visitor consents. That is project-published code, not the sender's, and it runs before consent the same way the bundled compiler already does. User code still runs only after consent, inside the opaque-origin sandbox.
  • Transitive dependency ranges of old releases (for example @tsrx/core@^0.1.x) resolve when esm.sh builds them, so only octane itself is pinned exactly. The repo's @tsrx/core patches do not apply to published releases.
  • Commit/PR previews are still open on feat: add an Octane version, commit, and PR combobox to the playground #1022, blocked on a sponsored build host (see above). This PR says "Refs" rather than "Fixes" so the issue stays open.

Provenance

  • An agent produced this diff (agent-authored)

🤖 Generated with Claude Code


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.


Note

Medium Risk
Loads third-party compiler/runtime from esm.sh and npm based on URL before user consent; sandbox init now accepts external import URLs (non-esm.sh entries are filtered).

Overview
Adds an Octane version picker to the website playground so examples can compile and run against main (bundled compiler + local runtime manifest) or an exact npm release loaded from esm.sh.

The ?version= query param is the source of truth: choosing a release fetches its compiler into the page and initializes the sandbox with esm.sh URLs per runtime entry (?external=react,react-dom), with staged preview swap so a failed load keeps the current toolchain. Module graph building now keys the compile cache on the active compiler and rejects octane/* imports that the selected release does not export.

New PlaygroundVersionCombobox (@octanejs/base-ui) lists releases from npm on first open; lockfile and package audit react-parity.json hashes update for the website’s @octanejs/base-ui dependency.

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

The playground toolbar gets an editable, filterable "Octane version"
combobox built on @octanejs/base-ui/combobox. main (the default) keeps the
compiler and runtime bundled with the website; a published release loads
its compiler and every sandbox runtime entry from esm.sh at that exact
version, so octane and octane/internal/client share one runtime instance.

The `version` query parameter is the source of truth and coexists with
the workspace hash. Choosing a version loads its toolchain before the URL
changes; a failed load keeps the running preview and never falls back to
another version. The release list is fetched from npm on first open.

Commit/PR revisions are not included: esm.sh's GitHub route rejects the
monorepo, and per-revision preview builds stay blocked on a sponsored host.

Refs #1022

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@trueadm
trueadm marked this pull request as ready for review October 26, 2026 19:58
@github-actions github-actions Bot added agent-authored Diff or issue body substantially produced by an AI agent feat PR: new feature or capability labels Oct 26, 2026
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
octane-website-mcp 8c37d1b Commit Preview URL

Branch Preview URL
Oct 26 2026, 08:33 PM

@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.

Stale Bugbot comment from a previous run.

@github-actions

github-actions Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Benchmark report

🟢 No byte growth, no added work, and no timing changes beyond ±3%.

Compares 72467094e, the merge commit's first parent with d54eb57bd on the same runner. Any increase in a js-framework work counter fails this check; byte changes are a report. Wall time is a report: base and head samples alternate in one browser, and an operation is called slower or faster only when the 95% confidence interval of its ratio excludes ±3%. Workflow run

js-framework: 1k/10k row operations

All 20 timed operations (20 without a verdict)
target operation base ms head ms head/base 95% CI
octane-tsrx run 4.600 4.808 +5.6% −8.6% … +30.4% ⚪ within noise
octane-tsrx replace 8.367 8.275 +2.6% −5.2% … +5.1% ⚪ within noise
octane-tsrx add 2.967 3.033 +3.2% ±0.0% … +5.5% ⚪ within noise
octane-tsrx update 0.087 0.085 −3.8% −5.5% … +0.4% ⚪ within noise
octane-tsrx select 0.007 0.008 +0.8% −1.3% … +3.4% ⚪ within noise
octane-tsrx swap 0.021 0.021 +3.0% +0.3% … +4.7% ⚪ within noise
octane-tsrx remove 0.019 0.019 −2.6% −7.2% … +2.9% ⚪ within noise
octane-tsrx runlots 25.175 25.500 −1.1% −3.7% … +3.8% ⚪ within noise
octane-tsrx select_lots 0.007 0.008 +3.5% −3.2% … +8.6% ⚪ within noise
octane-tsrx clear 51.125 52.258 +3.9% +1.3% … +6.4% ⚪ within noise
octane-jsx run 4.350 4.425 −1.0% −6.3% … +3.6% ⚪ within noise
octane-jsx replace 6.558 6.850 +0.7% −2.9% … +4.8% ⚪ within noise
octane-jsx add 3.192 3.250 ±0.0% −1.5% … +3.0% ⚪ within noise
octane-jsx update 0.228 0.232 −1.6% −6.2% … ±0.0% ⚪ within noise
octane-jsx select 0.120 0.120 +1.2% −3.8% … +9.9% ⚪ within noise
octane-jsx swap 0.164 0.158 −2.5% −5.6% … −1.0% ⚪ within noise
octane-jsx remove 0.143 0.139 −2.4% −3.6% … −1.6% ⚪ within noise
octane-jsx runlots 31.167 33.850 +0.7% −1.6% … +5.1% ⚪ within noise
octane-jsx select_lots 1.190 1.188 +1.7% +0.3% … +3.1% ⚪ within noise
octane-jsx clear 56.775 57.450 +1.0% −4.0% … +7.0% ⚪ within noise

All 64 work counters are unchanged.

Application bundle size (bytes)

No changes across 111 measured values.

Public-import reachability bundles (bytes)

No changes across 129 measured values.

A selection's URL write re-entered loadVersion for the version still
loading and cancelled its own load, clearing the status early. A runtime
import failure also left the release installed, so Retry and reselecting
were no-ops. The new sandbox now boots in a hidden slot and replaces the
running one only once its runtime has loaded; the same-version shortcut
skips a load already in flight. Until any toolchain has loaded, the
compiled pane shows nothing rather than main's output.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
octane-website 8c37d1b Commit Preview URL

Branch Preview URL
Oct 26 2026, 08:33 PM

@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 2 potential issues.

Fix All in Cursor

Bugbot Autofix prepared fixes for both issues found in the latest run.

  • ✅ Fixed: URL write still preempts version loads
    • Moved loadingVersion = null from before writeVersion to after compileAndRun so the URL effect's re-entrant loadVersion call hits the already-loading shortcut instead of the same-version branch that increments versionSeq and breaks the final status clear.
  • ✅ Fixed: Hidden sandbox leaks after unmount
    • Added a pendingPreview variable that tracks the in-flight preview during await ready and is destroyed in the cleanup function, so unmount no longer leaves detached iframe listeners alive until the ready timeout.

Create PR

Or push these changes by commenting:

@cursor push 52df57aa36
Preview (52df57aa36)
diff --git a/website/src/pages/playground/Playground.tsrx b/website/src/pages/playground/Playground.tsrx
--- a/website/src/pages/playground/Playground.tsrx
+++ b/website/src/pages/playground/Playground.tsrx
@@ -1246,6 +1246,7 @@
 			let loadingVersion: string | null = null;
 			let failedVersion: { param: string; fromUrl: boolean } | null = null;
 			let previewSlot: HTMLElement | null = null;
+			let pendingPreview: ReturnType<typeof pg.createPreview> | null = null;
 			const loadVersion = async (param: string, fromUrl: boolean) => {
 				const parsed = pgVersion.parseVersionParam(param);
 				const wanted = parsed.ok ? parsed.version : null;
@@ -1291,14 +1292,15 @@
 				slot.style.cssText = 'height:100%;display:none;';
 				previewHost.appendChild(slot);
 				const nextPreview = pg.createPreview(slot, onRuntimeError, next.runtime);
+				pendingPreview = nextPreview;
 				const readyError = await nextPreview.ready;
+				pendingPreview = null;
 				if (disposed || seq !== versionSeq || readyError) {
 					nextPreview.destroy();
 					slot.remove();
 					if (readyError && !disposed && seq === versionSeq) fail(readyError);
 					return;
 				}
-				loadingVersion = null;
 				failedVersion = null;
 				pg.setPlaygroundCompiler(next.compiler);
 				toolchain = {
@@ -1324,7 +1326,10 @@
 				// The status stays up until the new sandbox has run the workspace:
 				// a release's runtime is still downloading from esm.sh until then.
 				await compileAndRun();
-				if (!disposed && seq === versionSeq) setVersionLoading(null);
+				if (!disposed && seq === versionSeq) {
+					loadingVersion = null;
+					setVersionLoading(null);
+				}
 			};
 			controllerRef.current.loadVersion = (param, fromUrl) => {
 				if (!disposed) void loadVersion(param, fromUrl);
@@ -1389,6 +1394,7 @@
 			sourceView?.destroy();
 			outputView?.destroy();
 			astPreview?.destroy();
+			pendingPreview?.destroy();
 			preview?.destroy();
 		};
 	});

You can send follow-ups to the cloud agent here.

Reviewed by Cursor Bugbot for commit cf38dcf. Configure here.

@cursor

cursor Bot commented Oct 26, 2026

Copy link
Copy Markdown

Bugbot Autofix prepared fixes for both issues found in the latest run.

  • ✅ Fixed: Same-version short-circuit drops loads
    • Moved writeVersion after await compileAndRun() to prevent the URL-sync echo from re-entering loadVersion during sandbox setup, added !failedVersion to the early-return condition, and recorded sandbox run errors as version failures so retry/reselection rebuilds the iframe.
  • ✅ Fixed: Release still compiles against main
    • Added a toolchain null-check guard at the top of showOutput so the Compiled pane cannot compile through the module-level activeCompiler (still MAIN_COMPILER) while a release toolchain is loading.

Create PR

Or push these changes by commenting:

@cursor push 7721f192c0
Preview (7721f192c0)
diff --git a/website/src/pages/playground/Playground.tsrx b/website/src/pages/playground/Playground.tsrx
--- a/website/src/pages/playground/Playground.tsrx
+++ b/website/src/pages/playground/Playground.tsrx
@@ -649,6 +649,7 @@
 				// re-tokenize of the output document. syncOutput re-runs this when
 				// the pane is revealed, so it refreshes exactly once, on demand.
 				if (resultModeRef.current.view !== 'compiled') return null;
+				if (!toolchain) return null;
 				if (resultModeRef.current.compiledMode === 'ast') {
 					const { entry, error } = astEntry(currentFile);
 					if (entry && entry.ast !== lastShownAst?.ast) {
@@ -970,9 +971,14 @@
 				// While a shared payload is gated, everything except EXECUTION
 				// happens — the visitor can inspect source and compiled output.
 				if (executionGated) return;
+				let runError: string | null = null;
 				await preview.run(graph).then((r: { error: string | null }) => {
-					if (!disposed && r.error) setError(r.error);
+					if (!disposed && r.error) {
+						setError(r.error);
+						runError = r.error;
+					}
 				});
+				return runError;
 			};
 
 			const scheduleCompile = () => {
@@ -1241,10 +1247,9 @@
 			const loadVersion = async (param: string, fromUrl: boolean) => {
 				const parsed = pgVersion.parseVersionParam(param);
 				const wanted = parsed.ok ? parsed.version : null;
-				if (wanted !== null && wanted === toolchain?.version) {
+				if (wanted !== null && wanted === toolchain?.version && !failedVersion) {
 					// Back on the running version — drop any superseded load.
 					versionSeq++;
-					failedVersion = null;
 					setVersionLoading(null);
 					setVersionError('');
 					return;
@@ -1290,12 +1295,18 @@
 				lastShownCode = null;
 				lastShownAst = null;
 				setActiveVersion(next.version);
-				if (!fromUrl) void writeVersion(next.version);
 				window.clearTimeout(compileDebounceId);
 				// The status stays up until the new sandbox has run the workspace:
 				// a release's runtime is still downloading from esm.sh until then.
-				await compileAndRun();
-				if (!disposed && seq === versionSeq) setVersionLoading(null);
+				const runResult = await compileAndRun();
+				if (disposed || seq !== versionSeq) return;
+				setVersionLoading(null);
+				if (typeof runResult === 'string') {
+					failedVersion = { param, fromUrl };
+					setVersionError(runResult);
+				} else if (!fromUrl) {
+					writeVersion(next.version);
+				}
 			};
 			controllerRef.current.loadVersion = (param, fromUrl) => {
 				if (!disposed) void loadVersion(param, fromUrl);

You can send follow-ups to the cloud agent here.

… sandboxes

The first version load has no running toolchain to keep, so it installs at
once again and compiles while the sandbox boots; only a swap stages behind
readiness. Waiting on readiness for the first load left the compiled pane
empty under a hovering pointer (website integration hover test).

loadingVersion now clears after the swap's compile, so the selection's URL
write no longer takes the same-version path and cancels the load. Unmount
destroys a sandbox still booting in its hidden slot. The dev server
pre-declares the npm leaves @octanejs/base-ui reaches through raw .tsrx,
avoiding a mid-session optimize pass on /playground.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@domgan-oai
domgan-oai merged commit d4cf247 into main Oct 27, 2026
34 checks passed
@domgan-oai
domgan-oai deleted the feat/playground-version-combobox branch October 27, 2026 12:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-authored Diff or issue body substantially produced by an AI agent feat PR: new feature or capability

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants