Tree panel mode lives in the root layout: no open-then-close on session open

The persisted mode (lh:tree-panel-mode) was read inside TreePanel — a
per-page component that remounts on every session navigation. First
paint rendered the SSR-safe "list" default, then the mount effect
applied the stored mode: with the animated frame, opening a session
visibly opened the panel and then closed it. The mode now lives in a
root-layout provider (the SidebarProvider pattern) and survives
navigations untouched — the panel mounts already in the right mode.
The default stays "list" so SSR and first client render agree; the
stored preference applies once, on provider mount.
This commit is contained in:
amosblomqvist
2026-09-02 02:43:28 +03:00
parent 8dda21ce1b
commit fe88fa87ec
2 changed files with 36 additions and 13 deletions
+4 -1
View File
@@ -2,6 +2,7 @@ import type { Metadata } from "next";
import "katex/dist/katex.min.css";
import "./globals.css";
import { AppShell, SidebarProvider } from "@/components/sidebar";
import { TreePanelModeProvider } from "@/components/tree-panel";
export const metadata: Metadata = {
title: "Learning Harness",
@@ -13,7 +14,9 @@ export default function RootLayout({ children }: { children: React.ReactNode })
<html lang="en" className="dark">
<body className="min-h-dvh antialiased">
<SidebarProvider>
<AppShell>{children}</AppShell>
<TreePanelModeProvider>
<AppShell>{children}</AppShell>
</TreePanelModeProvider>
</SidebarProvider>
</body>
</html>