import type { ThreadContextRecord } from "@t3tools/contracts"; import { Link } from "@tanstack/react-router"; import { MessagesSquareIcon } from "lucide-react"; import { useThreadShell } from "~/state/entities"; import { ContextChip, ContextChipLabel } from "./ContextChip"; import { Tooltip, TooltipPopup, TooltipTrigger } from "./ui/tooltip"; /** * Inline chip for an attached thread, in the composer and in sent messages. Prefers the * live title so a renamed thread never shows a stale label, and opens the thread on click. */ export function ThreadContextChip(props: { record: Pick; copyMarkdown?: string; }) { const { environmentId, threadId } = props.record; const shell = useThreadShell({ environmentId, threadId }); const title = shell?.title?.trim() || props.record.title; return ( } aria-label={`Thread, ${title}`} data-markdown-copy={props.copyMarkdown} className="no-underline" > {title} } /> {shell ? "Open thread" : "Thread no longer available"} ); }