Elffuss BraidHub

kikocis/continue public

627d7d0d1f85 · 1.9 KiBRawPermalink
1import { ChevronDownIcon } from "@heroicons/react/24/outline";
2import { ArrowPathIcon } from "@heroicons/react/24/solid";
3import type { ProfileDescription } from "core/config/ConfigHandler";
4import { useAppSelector } from "../../redux/hooks";
5import { fontSize } from "../../util";
6import { cn } from "../../util/cn";
7import { useLump } from "../mainInput/Lump/LumpContext";
8import { ListboxButton } from "../ui";
9import { AssistantIcon } from "./AssistantIcon";
10
11interface SelectedAssistantButtonProps {
12 selectedProfile: ProfileDescription;
13}
14
15export function SelectedAssistantButton({
16 selectedProfile,
17}: SelectedAssistantButtonProps) {
18 const { isToolbarExpanded } = useLump();
19 const configLoading = useAppSelector((store) => store.config.loading);
20
21 return (
22 <ListboxButton
23 data-testid="assistant-select-button"
24 className="text-description border-none bg-transparent hover:brightness-125"
25 style={{ fontSize: fontSize(-3) }}
26 >
27 <div className="flex flex-row items-center gap-1.5">
28 {configLoading ? (
29 <span className="text-description flex flex-row items-center">
30 <ArrowPathIcon
31 className={cn(
32 "text-description mr-1.5 h-3 w-3",
33 configLoading && "animate-spin-slow",
34 )}
35 />
36 Loading
37 </span>
38 ) : (
39 <>
40 <div className="h-3 w-3 flex-shrink-0 select-none">
41 <AssistantIcon size={3} assistant={selectedProfile} />
42 </div>
43 <span
44 className={`line-clamp-1 select-none break-all ${isToolbarExpanded ? "xs:hidden sm:line-clamp-1" : ""}`}
45 >
46 {selectedProfile.title}
47 </span>
48 </>
49 )}
50 </div>
51 <ChevronDownIcon
52 className="h-2 w-2 flex-shrink-0 select-none"
53 aria-hidden="true"
54 />
55 </ListboxButton>
56 );
57}