mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-07-26 23:51:14 +02:00
feat: render run citation chip
This commit is contained in:
parent
57d6182ca3
commit
979ad02ef3
2 changed files with 35 additions and 0 deletions
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
import type { ReactNode } from "react";
|
import type { ReactNode } from "react";
|
||||||
import { InlineCitation, UrlCitation } from "@/components/assistant-ui/inline-citation";
|
import { InlineCitation, UrlCitation } from "@/components/assistant-ui/inline-citation";
|
||||||
|
import { RunCitation } from "@/components/citations/run-citation";
|
||||||
import {
|
import {
|
||||||
type CitationToken,
|
type CitationToken,
|
||||||
type CitationUrlMap,
|
type CitationUrlMap,
|
||||||
|
|
@ -21,6 +22,9 @@ export function renderCitationToken(token: CitationToken, ordinalKey: number): R
|
||||||
if (token.kind === "url") {
|
if (token.kind === "url") {
|
||||||
return <UrlCitation key={`citation-url-${ordinalKey}`} url={token.url} />;
|
return <UrlCitation key={`citation-url-${ordinalKey}`} url={token.url} />;
|
||||||
}
|
}
|
||||||
|
if (token.kind === "run") {
|
||||||
|
return <RunCitation key={`citation-run-${token.runId}-${ordinalKey}`} runId={token.runId} />;
|
||||||
|
}
|
||||||
return (
|
return (
|
||||||
<InlineCitation
|
<InlineCitation
|
||||||
key={`citation-${token.isDocsChunk ? "doc-" : ""}${token.chunkId}-${ordinalKey}`}
|
key={`citation-${token.isDocsChunk ? "doc-" : ""}${token.chunkId}-${ordinalKey}`}
|
||||||
|
|
|
||||||
31
surfsense_web/components/citations/run-citation.tsx
Normal file
31
surfsense_web/components/citations/run-citation.tsx
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
"use client";
|
||||||
|
|
||||||
|
import { useSetAtom } from "jotai";
|
||||||
|
import { Database } from "lucide-react";
|
||||||
|
import type { FC } from "react";
|
||||||
|
import { openRunCitationPanelAtom } from "@/atoms/citation/citation-panel.atom";
|
||||||
|
import { Button } from "@/components/ui/button";
|
||||||
|
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
|
||||||
|
|
||||||
|
/** Inline citation badge for a scraper run; opens the run in the citation panel. */
|
||||||
|
export const RunCitation: FC<{ runId: string }> = ({ runId }) => {
|
||||||
|
const openRunPanel = useSetAtom(openRunCitationPanelAtom);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Tooltip>
|
||||||
|
<TooltipTrigger asChild>
|
||||||
|
<Button
|
||||||
|
type="button"
|
||||||
|
variant="ghost"
|
||||||
|
onClick={() => openRunPanel({ runId })}
|
||||||
|
className="ml-0.5 inline-flex h-5 min-w-5 items-center justify-center gap-0.5 rounded-md bg-popover px-1.5 text-[11px] font-medium text-popover-foreground/80 align-baseline"
|
||||||
|
aria-label="View scraper run"
|
||||||
|
>
|
||||||
|
<Database className="size-3" />
|
||||||
|
run
|
||||||
|
</Button>
|
||||||
|
</TooltipTrigger>
|
||||||
|
<TooltipContent>View scraper run</TooltipContent>
|
||||||
|
</Tooltip>
|
||||||
|
);
|
||||||
|
};
|
||||||
Loading…
Add table
Add a link
Reference in a new issue