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: more defensive restart in wasm (#1018)

Myles Scolnick37819f3a82ed
diff --git a/frontend/src/components/editor/actions/useRestartKernel.tsx b/frontend/src/components/editor/actions/useRestartKernel.tsx
index 0b7e23b1be..7f27065d2a 100644
--- a/frontend/src/components/editor/actions/useRestartKernel.tsx
+++ b/frontend/src/components/editor/actions/useRestartKernel.tsx
@@ -10,7 +10,7 @@ export function useRestartKernel() {
openConfirm({
title: "Restart Kernel",
description:
- "This will restart the Python kernel. You'll lose all data that's in memory.",
+ "This will restart the Python kernel. You'll lose all data that's in memory. You will also lose any unsaved changes, so make sure to save your work before restarting.",
variant: "destructive",
confirmAction: (
<AlertDialogDestructiveAction
diff --git a/frontend/src/core/pyodide/bridge.ts b/frontend/src/core/pyodide/bridge.ts
index fe354d44d6..7965a34703 100644
--- a/frontend/src/core/pyodide/bridge.ts
+++ b/frontend/src/core/pyodide/bridge.ts
@@ -224,6 +224,12 @@ export class PyodideBridge implements RunRequests, EditRequests {
};
sendRestart = async (): Promise<null> => {
+ // Save first
+ const code = await this.readCode();
+ if (code.contents) {
+ notebookFileStore.saveFile(code.contents);
+ fallbackFileStore.saveFile(code.contents);
+ }
window.location.reload();
return null;
};
diff --git a/frontend/src/core/pyodide/worker/worker.ts b/frontend/src/core/pyodide/worker/worker.ts
index 6601212a4b..722fbefa6c 100644
--- a/frontend/src/core/pyodide/worker/worker.ts
+++ b/frontend/src/core/pyodide/worker/worker.ts
@@ -218,6 +218,7 @@ rpc.addMessageListener("consumerReady", async () => {
const namesThatRequireSync = new Set<keyof RawBridge>([
"save",
+ "save_app_config",
"rename_file",
"create_file_or_directory",
"delete_file_or_directory",