Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

ThreadContextChip.tsx

35 lines1.3 KB

1import type { ThreadContextRecord } from "@t3tools/contracts";
2import { Link } from "@tanstack/react-router";
3import { MessagesSquareIcon } from "lucide-react";
4​
5import { useThreadShell } from "~/state/entities";
6import { ContextChip, ContextChipLabel } from "./ContextChip";
7import { Tooltip, TooltipPopup, TooltipTrigger } from "./ui/tooltip";
8​
9export function ThreadContextChip(props: {
10 record: Pick<ThreadContextRecord, "environmentId" | "threadId" | "title">;
11 copyMarkdown?: string;
12}) {
13 const { environmentId, threadId } = props.record;
14 const shell = useThreadShell({ environmentId, threadId });
15 const title = shell?.title?.trim() || props.record.title;
16 return (
17 <Tooltip>
18 <TooltipTrigger
19 render={
20 <ContextChip
21 kind="thread"
22 render={<Link to="/$environmentId/$threadId" params={{ environmentId, threadId }} />}
23 aria-label={`Thread, ${title}`}
24 data-markdown-copy={props.copyMarkdown}
25 className="no-underline"
26 >
27 <MessagesSquareIcon />
28 <ContextChipLabel>{title}</ContextChipLabel>
29 </ContextChip>
30 }
31 />
32 <TooltipPopup side="top">{shell ? "Open thread" : "Thread no longer available"}</TooltipPopup>
33 </Tooltip>
34 );