From 9ea6e3eacd1452877ac8c39cd092f1c01053caa7 Mon Sep 17 00:00:00 2001 From: CREDO23 Date: Mon, 22 Jun 2026 22:37:33 +0200 Subject: [PATCH] feat: add artifacts toggle button --- .../ui/artifacts-toggle-button.tsx | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 surfsense_web/features/chat-artifacts/ui/artifacts-toggle-button.tsx diff --git a/surfsense_web/features/chat-artifacts/ui/artifacts-toggle-button.tsx b/surfsense_web/features/chat-artifacts/ui/artifacts-toggle-button.tsx new file mode 100644 index 000000000..a99836d30 --- /dev/null +++ b/surfsense_web/features/chat-artifacts/ui/artifacts-toggle-button.tsx @@ -0,0 +1,47 @@ +"use client"; + +import { useAtomValue, useSetAtom } from "jotai"; +import { LayersIcon } from "lucide-react"; +import { Button } from "@/components/ui/button"; +import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip"; +import { cn } from "@/lib/utils"; +import { + artifactsPanelOpenAtom, + chatArtifactsAtom, + toggleArtifactsPanelAtom, +} from "../state/artifacts-panel.atom"; + +/** Header toggle that opens the artifacts sidebar. Hidden when the thread has none. */ +export function ArtifactsToggleButton() { + const artifacts = useAtomValue(chatArtifactsAtom); + const isOpen = useAtomValue(artifactsPanelOpenAtom); + const toggle = useSetAtom(toggleArtifactsPanelAtom); + + if (artifacts.length === 0) return null; + + const label = isOpen ? "Hide artifacts" : "Show artifacts"; + + return ( + + + + + {label} + + ); +}