Skip to content

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

fix(ui): json views should use resolve theme instead of the literal theme which can be `system` (#2168)

Marc Klingen9436c330259b
diff --git a/web/src/components/json-editor.tsx b/web/src/components/json-editor.tsx
index 912e984f7c..7ec38c7bc2 100644
--- a/web/src/components/json-editor.tsx
+++ b/web/src/components/json-editor.tsx
@@ -22,9 +22,9 @@ export function JsonEditor({
lineWrapping?: boolean;
className?: string;
}) {
- const { theme } = useTheme();
- const codeMirrorTheme = theme === "dark" ? tokyoNight : githubLight;
-
+ const { resolvedTheme } = useTheme();
+ const codeMirrorTheme = resolvedTheme === "dark" ? tokyoNight : githubLight;
+
// used to disable linter when field is empty
const [linterEnabled, setLinterEnabled] = useState<boolean>(
!!defaultValue && defaultValue !== "",
diff --git a/web/src/components/ui/CodeJsonViewer.tsx b/web/src/components/ui/CodeJsonViewer.tsx
index c3e106b4c7..f1ecbe8a3c 100644
--- a/web/src/components/ui/CodeJsonViewer.tsx
+++ b/web/src/components/ui/CodeJsonViewer.tsx
@@ -17,7 +17,7 @@ export function JSONView(props: {
}) {
// some users ingest stringified json nested in json, parse it
const parsedJson = deepParseJson(props.json);
- const { theme } = useTheme();
+ const { resolvedTheme } = useTheme();
return (
<div className={cn("rounded-md border", props.className)}>
{props.title ? (
@@ -44,7 +44,7 @@ export function JSONView(props: {
<React18JsonView
src={parsedJson}
theme="github"
- dark={theme === "dark"}
+ dark={resolvedTheme === "dark"}
collapseObjectsAfterLength={20}
collapseStringsAfterLength={500}
displaySize={"collapsed"}