Open History to see the last commit
1import { findSearchTokenRanges, splitSearchText } from "@t3tools/shared/paletteSearch";
2import type { EnvironmentThreadSearchMatch } from "@t3tools/client-runtime/state/thread-search";
3
4import { AppText as Text } from "../../components/ui/AppText";
5import { cn } from "../../lib/cn";
6
7export function ThreadSearchMatchExcerpt(props: {
8 readonly match: EnvironmentThreadSearchMatch;
9 readonly query: string;
10 readonly selected?: boolean;
11 readonly compact?: boolean;
12 readonly sidebar?: boolean;
13}) {
14 const isUser = props.match.source === "user";
15 const parts = splitSearchText(
16 props.match.snippet,
17 findSearchTokenRanges(props.match.snippet, props.query),
18 );
19 return (
20 <Text
21 className={cn(
22 props.compact ? "text-sm" : "text-xs",
23 props.selected
24 ? "text-thread-selected-foreground-muted"
25 : props.sidebar
26 ? "text-drawer-foreground-muted"
27 : "text-foreground-muted",
28 )}
29 numberOfLines={1}
30 >
31 <Text
32 className={cn(
33 props.compact ? "text-sm font-t3-medium" : "text-xs font-t3-medium",
34 props.selected
35 ? "text-thread-selected-foreground"
36 : isUser
37 ? props.sidebar
38 ? "text-drawer-foreground-muted"
39 : "text-foreground-secondary"
40 : "text-adaptive-emerald-600-400",
41 )}
42 >
43 {isUser ? "You:" : "Agent:"}{" "}
44 </Text>
45 {parts.map((part) => (
46 <Text
47 className={cn(
48 props.compact ? "text-sm" : "text-xs",
49 part.highlighted && "font-t3-bold",
50 props.selected
51 ? "text-thread-selected-foreground"
52 : part.highlighted
53 ? props.sidebar
54 ? "text-drawer-foreground"
55 : "text-foreground"
56 : props.sidebar
57 ? "text-drawer-foreground-muted"
58 : "text-foreground-muted",
59 )}
60 key={part.start}
61 >
62 {part.text}
63 </Text>
64 ))}
65 </Text>
66 );
67}