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: cache rtc value to avoid weird initialization states (#4997)

Myles Scolnickb84ec11be3a5
diff --git a/frontend/src/core/rtc/state.ts b/frontend/src/core/rtc/state.ts
index d2d5cd2a8f..1e2c1078f4 100644
--- a/frontend/src/core/rtc/state.ts
+++ b/frontend/src/core/rtc/state.ts
@@ -1,6 +1,7 @@
/* Copyright 2024 Marimo. All rights reserved. */
import { atomWithStorage } from "jotai/utils";
import { getFeatureFlag } from "../config/feature-flag";
+import { once } from "lodash-es";
/**
* The username for the current user when using real-time collaboration.
@@ -10,7 +11,10 @@ export const usernameAtom = atomWithStorage<string>("marimo:rtc:username", "");
/**
* Whether RTC is enabled.
+ *
+ * This is cached on page-load because this UI can get into
+ * weird states, so we require a page reload to take effect.
*/
-export function isRtcEnabled() {
+export const isRtcEnabled = once(() => {
return getFeatureFlag("rtc_v2");
-}
+});