From bcbb0099f45b50980208d71ebcdd7f88a78dfe49 Mon Sep 17 00:00:00 2001 From: CREDO23 Date: Mon, 22 Jun 2026 22:36:26 +0200 Subject: [PATCH] feat: anchor deliverable cards for scroll jumps --- .../chat-artifacts/ui/artifact-anchor.tsx | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 surfsense_web/features/chat-artifacts/ui/artifact-anchor.tsx diff --git a/surfsense_web/features/chat-artifacts/ui/artifact-anchor.tsx b/surfsense_web/features/chat-artifacts/ui/artifact-anchor.tsx new file mode 100644 index 000000000..a6e1a390d --- /dev/null +++ b/surfsense_web/features/chat-artifacts/ui/artifact-anchor.tsx @@ -0,0 +1,20 @@ +import type { ToolCallMessagePartComponent, ToolCallMessagePartProps } from "@assistant-ui/react"; +import { ARTIFACT_ANCHOR_ATTR } from "../lib/scroll-to-artifact"; + +/** + * Wrap a body tool component so its rendered card carries a DOM anchor keyed by + * tool call id. The artifacts sidebar uses it to scroll a deliverable back into + * view. The wrapper is layout-neutral — the card keeps its own margins. + */ +export function withArtifactAnchor( + Tool: ToolCallMessagePartComponent +): ToolCallMessagePartComponent { + function AnchoredTool(props: ToolCallMessagePartProps) { + return ( +
+ +
+ ); + } + return AnchoredTool; +}