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: set initial mode for islands (#6950)

Myles Scolnick8258ef950344
diff --git a/frontend/src/core/islands/main.ts b/frontend/src/core/islands/main.ts
index b90edd19e5..0b67c61e31 100644
--- a/frontend/src/core/islands/main.ts
+++ b/frontend/src/core/islands/main.ts
@@ -36,6 +36,7 @@ import {
} from "../kernel/handlers";
import { queryParamHandlers } from "../kernel/queryParamHandlers";
import { RuntimeState } from "../kernel/RuntimeState";
+import { initialModeAtom } from "../mode";
import type { RequestId } from "../network/DeferredRequestRegistry";
import { requestClientAtom } from "../network/requests";
import { store } from "../state/jotai";
@@ -57,6 +58,7 @@ import { dismissIslandsLoadingToast, toastIslandsLoading } from "./toast";
export async function initialize() {
// Setup networking
store.set(requestClientAtom, IslandsPyodideBridge.INSTANCE);
+ store.set(initialModeAtom, "read");
// This will display all the static HTML content.
initializePlugins();
diff --git a/frontend/src/plugins/core/sanitize.ts b/frontend/src/plugins/core/sanitize.ts
index e7c12a0c4d..348092eacb 100644
--- a/frontend/src/plugins/core/sanitize.ts
+++ b/frontend/src/plugins/core/sanitize.ts
@@ -18,7 +18,14 @@ const sanitizeHtmlAtom = atom<boolean>((get) => {
return false;
}
- const isInAppMode = getInitialAppMode() === "read";
+ let isInAppMode = true;
+ try {
+ isInAppMode = getInitialAppMode() === "read";
+ } catch {
+ // If it fails to get the initial app mode, we default to sanitizing.
+ return true;
+ }
+
// Apps need to run javascript and load external resources.
if (isInAppMode) {
return false;