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.
Python artificial-intelligencedagdata-sciencedata-visualizationdataflowdeveloper-toolsmachine-learningnotebookspipelinepythonreactivesqlweb-app
Extend `view-as` URI parameter to handle app view in edit mode (#5327)
Ryan Harter284c338bdcaf
diff --git a/frontend/src/core/constants.ts b/frontend/src/core/constants.tsindex 63984ee99b..e1728c4a17 100644--- a/frontend/src/core/constants.ts+++ b/frontend/src/core/constants.ts@@ -40,7 +40,7 @@ export const KnownQueryParams = {accessToken: "access_token",/*** Layout view-as. If the editor is in run-mode, this overrides the current- * layout view.+ * layout view. In edit-mode, can be used to start in present mode.*/viewAs: "view-as",/**diff --git a/frontend/src/mount.tsx b/frontend/src/mount.tsxindex 849067b073..3baab62e7b 100644--- a/frontend/src/mount.tsx+++ b/frontend/src/mount.tsx@@ -9,6 +9,7 @@ import {configOverridesAtom,userConfigAtom,} from "@/core/config/config";+import { KnownQueryParams } from "@/core/constants";import { getFilenameFromDOM } from "@/core/dom/htmlUtils";import { getMarimoCode } from "@/core/meta/globals";import {@@ -273,7 +274,16 @@ function initStore(options: unknown) {// Metastore.set(marimoVersionAtom, parsedOptions.data.version);store.set(showCodeInRunModeAtom, parsedOptions.data.view.showAppCode);- store.set(viewStateAtom, { mode, cellAnchor: null });++ // Check for view-as parameter to start in present mode+ const shouldStartInPresentMode = (() => {+ const url = new URL(window.location.href);+ return url.searchParams.get(KnownQueryParams.viewAs) === "present";+ })();++ const initialViewMode =+ mode === "edit" && shouldStartInPresentMode ? "present" : mode;+ store.set(viewStateAtom, { mode: initialViewMode, cellAnchor: null });store.set(serverTokenAtom, parsedOptions.data.serverToken);// Config