Skip to content

Commit 7721f19

Browse files
committed
fix(website): prevent version echo from dropping loads and guard compiled pane against wrong compiler
Bug 1 — Same-version short-circuit drops loads: - Move writeVersion after await compileAndRun() so the URL is updated only once the sandbox has finished running, preventing the URL-sync effect from re-entering loadVersion and prematurely clearing loading state. - When compileAndRun reports a sandbox run error, record it as a version failure (failedVersion + versionError) so Retry and reselecting the same version fall through the early return and rebuild the iframe. - Add !failedVersion to the early-return condition so a recorded sandbox failure is not treated as a successful same-version no-op. Bug 2 — Release still compiles against main: - Guard showOutput with a toolchain null check so the Compiled pane cannot compile through the module-level activeCompiler (MAIN_COMPILER) while a release toolchain is still loading.
1 parent 37cac60 commit 7721f19

1 file changed

Lines changed: 17 additions & 6 deletions

File tree

‎website/src/pages/playground/Playground.tsrx‎

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,7 @@ export function Playground() @{
649649
// re-tokenize of the output document. syncOutput re-runs this when
650650
// the pane is revealed, so it refreshes exactly once, on demand.
651651
if (resultModeRef.current.view !== 'compiled') return null;
652+
if (!toolchain) return null;
652653
if (resultModeRef.current.compiledMode === 'ast') {
653654
const { entry, error } = astEntry(currentFile);
654655
if (entry && entry.ast !== lastShownAst?.ast) {
@@ -970,9 +971,14 @@ export function Playground() @{
970971
// While a shared payload is gated, everything except EXECUTION
971972
// happens — the visitor can inspect source and compiled output.
972973
if (executionGated) return;
974+
let runError: string | null = null;
973975
await preview.run(graph).then((r: { error: string | null }) => {
974-
if (!disposed && r.error) setError(r.error);
976+
if (!disposed && r.error) {
977+
setError(r.error);
978+
runError = r.error;
979+
}
975980
});
981+
return runError;
976982
};
977983

978984
const scheduleCompile = () => {
@@ -1241,10 +1247,9 @@ export function Playground() @{
12411247
const loadVersion = async (param: string, fromUrl: boolean) => {
12421248
const parsed = pgVersion.parseVersionParam(param);
12431249
const wanted = parsed.ok ? parsed.version : null;
1244-
if (wanted !== null && wanted === toolchain?.version) {
1250+
if (wanted !== null && wanted === toolchain?.version && !failedVersion) {
12451251
// Back on the running version — drop any superseded load.
12461252
versionSeq++;
1247-
failedVersion = null;
12481253
setVersionLoading(null);
12491254
setVersionError('');
12501255
return;
@@ -1290,12 +1295,18 @@ export function Playground() @{
12901295
lastShownCode = null;
12911296
lastShownAst = null;
12921297
setActiveVersion(next.version);
1293-
if (!fromUrl) void writeVersion(next.version);
12941298
window.clearTimeout(compileDebounceId);
12951299
// The status stays up until the new sandbox has run the workspace:
12961300
// a release's runtime is still downloading from esm.sh until then.
1297-
await compileAndRun();
1298-
if (!disposed && seq === versionSeq) setVersionLoading(null);
1301+
const runResult = await compileAndRun();
1302+
if (disposed || seq !== versionSeq) return;
1303+
setVersionLoading(null);
1304+
if (typeof runResult === 'string') {
1305+
failedVersion = { param, fromUrl };
1306+
setVersionError(runResult);
1307+
} else if (!fromUrl) {
1308+
writeVersion(next.version);
1309+
}
12991310
};
13001311
controllerRef.current.loadVersion = (param, fromUrl) => {
13011312
if (!disposed) void loadVersion(param, fromUrl);

0 commit comments

Comments
 (0)