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: home edit mode with separated backend (#5235)

Dylan Madisetti8c6262a6dded
diff --git a/frontend/src/core/runtime/__tests__/createWsUrl.test.ts b/frontend/src/core/runtime/__tests__/createWsUrl.test.ts
index 5de8d2b5a1..fc5f3728b7 100644
--- a/frontend/src/core/runtime/__tests__/createWsUrl.test.ts
+++ b/frontend/src/core/runtime/__tests__/createWsUrl.test.ts
@@ -34,10 +34,11 @@ describe("RuntimeManager.getWsURL", () => {
const runtime = new RuntimeManager({
url: "http://marimo.app/nested/?foo=bar",
});
+ window.history.pushState({}, "", "/nested/?file=test.py");
const sessionId = "1234" as SessionId;
const url = runtime.getWsURL(sessionId);
expect(url.toString()).toBe(
- "ws://marimo.app/nested/ws?foo=bar&session_id=1234",
+ "ws://marimo.app/nested/ws?foo=bar&session_id=1234&file=test.py",
);
expect(url.searchParams.get(KnownQueryParams.sessionId)).toBe(sessionId);
});
diff --git a/frontend/src/core/runtime/runtime.ts b/frontend/src/core/runtime/runtime.ts
index f2d00ebcfb..ab1b7d247e 100644
--- a/frontend/src/core/runtime/runtime.ts
+++ b/frontend/src/core/runtime/runtime.ts
@@ -32,7 +32,19 @@ export class RuntimeManager {
const wsUrl = asWsUrl(this.config.url);
const baseUrl = new URL(wsUrl);
const searchParams = new URLSearchParams(baseUrl.search);
+ const currentParams = new URLSearchParams(window.location.search);
+
searchParams.set(KnownQueryParams.sessionId, sessionId);
+
+ // Move over window level parameters to the WebSocket URL
+ // if they are "known" query params.
+ for (const lookup in KnownQueryParams) {
+ const key = KnownQueryParams[lookup as keyof typeof KnownQueryParams];
+ const value = currentParams.get(key);
+ if (value !== null) {
+ searchParams.set(key, value);
+ }
+ }
return new URL(
urlJoin(wsUrl.split("?")[0], `ws?${searchParams.toString()}`),
);