Feature/product platform foundation v0.62 #1
@@ -237,16 +237,9 @@ export default function ScenarioForm() {
|
||||
|
||||
const branchScoped = useBranchScopedFixture();
|
||||
// Toggle to control when the experiment view is visible vs production
|
||||
const [showExperimentView, setShowExperimentView] = useState(
|
||||
typeof window !== "undefined" ? (() => {
|
||||
const saved = sessionStorage?.getItem("ce-show-experiment");
|
||||
// Only default to true if user explicitly toggled ON (saved === "true")
|
||||
// or has an active investigation context (session exists with situationGraph)
|
||||
if (saved === "true") return true;
|
||||
const session = getSession();
|
||||
return Boolean(session?.situationGraph);
|
||||
})() : false,
|
||||
);
|
||||
// Always start false for SSR-safe deterministic first render.
|
||||
// sessionStorage reads are deferred to useEffect (after mount).
|
||||
const [showExperimentView, setShowExperimentView] = useState(false);
|
||||
|
||||
// Use fixture branches as the authoritative source when available
|
||||
const BRANCHES = useMemo(() => branchScoped.getBranches(), [branchScoped]);
|
||||
@@ -309,6 +302,20 @@ export default function ScenarioForm() {
|
||||
setStatus("success");
|
||||
}, []);
|
||||
|
||||
/* Restore experiment view preference from storage (after hydration) ─ */
|
||||
useEffect(() => {
|
||||
if (typeof window === "undefined") return;
|
||||
const savedExp = sessionStorage?.getItem("ce-show-experiment");
|
||||
if (savedExp === "true") {
|
||||
setShowExperimentView(true);
|
||||
return;
|
||||
}
|
||||
const session = getSession();
|
||||
if (session?.situationGraph) {
|
||||
setShowExperimentView(true);
|
||||
}
|
||||
}, []);
|
||||
|
||||
/* Restore facilitator dismiss preference (Experiment 05) ─── */
|
||||
useEffect(() => {
|
||||
if (typeof window === "undefined") return;
|
||||
|
||||
Reference in New Issue
Block a user