mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-06-26 21:39:43 +02:00
feat: anchor deliverable cards for scroll jumps
This commit is contained in:
parent
87224b0239
commit
bcbb0099f4
1 changed files with 20 additions and 0 deletions
20
surfsense_web/features/chat-artifacts/ui/artifact-anchor.tsx
Normal file
20
surfsense_web/features/chat-artifacts/ui/artifact-anchor.tsx
Normal file
|
|
@ -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 (
|
||||
<div {...{ [ARTIFACT_ANCHOR_ATTR]: props.toolCallId }} className="scroll-mt-4">
|
||||
<Tool {...props} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
return AnchoredTool;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue