Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

fix: force auto_instantiate in read mode for wasm (#1555)

Myles Scolnick89ec068b0382
diff --git a/frontend/src/core/mode.ts b/frontend/src/core/mode.ts
index df71e7faf0..d7b0b61e8c 100644
--- a/frontend/src/core/mode.ts
+++ b/frontend/src/core/mode.ts
@@ -4,6 +4,7 @@ import { atom } from "jotai";
import { CellId } from "./cells/ids";
import { store } from "./state/jotai";
import { assertNever } from "@/utils/assertNever";
+import { Logger } from "@/utils/Logger";
/**
* This is the internal mode.
@@ -18,7 +19,8 @@ export type AppMode = "read" | "edit" | "present" | "home";
export function getInitialAppMode(): AppMode {
const tag = document.querySelector("marimo-mode");
if (tag === null || !(tag instanceof HTMLElement)) {
- throw new Error("internal-error: marimo-mode tag not found");
+ Logger.warn("internal-error: marimo-mode tag not found");
+ return "read";
}
const mode = tag.dataset.mode as AppMode | undefined;
diff --git a/frontend/src/core/pyodide/bridge.ts b/frontend/src/core/pyodide/bridge.ts
index 831fca53e5..1d5183973a 100644
--- a/frontend/src/core/pyodide/bridge.ts
+++ b/frontend/src/core/pyodide/bridge.ts
@@ -46,6 +46,7 @@ import { toast } from "@/components/ui/use-toast";
import { generateUUID } from "@/utils/uuid";
import { store } from "../state/jotai";
import { notebookIsRunningAtom } from "../cells/cells";
+import { getInitialAppMode } from "../mode";
export class PyodideBridge implements RunRequests, EditRequests {
static INSTANCE = new PyodideBridge();
@@ -133,7 +134,17 @@ export class PyodideBridge implements RunRequests, EditRequests {
queryParameters: queryParameters,
code: code || fallbackCode || "",
filename,
- userConfig,
+ userConfig: {
+ ...userConfig,
+ runtime: {
+ ...userConfig.runtime,
+ // Force auto_instantiate to true if the initial mode is read
+ auto_instantiate:
+ getInitialAppMode() === "read"
+ ? true
+ : userConfig.runtime.auto_instantiate,
+ },
+ },
});
}