Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

chore(web): make Storybook render like the app (#__next scaffold + overlay layers + CSS) (#14490)

Nikita Kabardin0c6926c0d476
diff --git a/web/.storybook/preview.tsx b/web/.storybook/preview.tsx
index 7b8fc1c047..c46c8ae992 100644
--- a/web/.storybook/preview.tsx
+++ b/web/.storybook/preview.tsx
@@ -2,7 +2,12 @@ import { definePreview } from "@storybook/nextjs-vite";
import addonA11y from "@storybook/addon-a11y";
import { useEffect, type ReactNode } from "react";
import { TooltipProvider } from "../src/components/ui/tooltip";
+import { LAYER_ORDER } from "../src/components/ui/layer";
import "../src/styles/globals.css";
+// Mirror the global CSS that _app.tsx imports so vendored components
+// (react18-json-view, streamdown markdown) render identically to the app.
+import "react18-json-view/src/style.css";
+import "streamdown/styles.css";
function StorybookThemeProvider({
children,
@@ -19,8 +24,34 @@ function StorybookThemeProvider({
};
}, [theme]);
+ // Reproduce the app's DOM scaffold so the layout rules in globals.css that are
+ // scoped to `div#__next` / `div#__next > div` (height: 100%) and
+ // `div#__next { isolation: isolate }` actually apply — the app's tables live
+ // inside `#__next > div`, and without this scaffold Storybook only loosely
+ // approximated the height/isolation/stacking context (see _document.tsx +
+ // _app.tsx). `#__next` is given a real viewport height so the `height: 100%`
+ // chain has something to resolve against.
return (
- <div className="bg-background text-foreground min-h-screen">{children}</div>
+ <>
+ <div
+ id="__next"
+ className="bg-background text-foreground"
+ style={{ height: "100vh" }}
+ >
+ <div>{children}</div>
+ </div>
+ {/* Overlay layer containers, declared exactly like _document.tsx: a
+ <div data-overlay-root> sibling AFTER #__next (so it paints on top by
+ DOM order), holding one <div data-layer={name}/> per LAYER_ORDER. This
+ is what the layer system (components/ui/layer.tsx) portals toasts /
+ tooltips / peek into; without it those overlays are absent in
+ Storybook. Positioning/isolation comes from globals.css. */}
+ <div data-overlay-root>
+ {LAYER_ORDER.map((name) => (
+ <div key={name} data-layer={name} />
+ ))}
+ </div>
+ </>
);
}