Elffuss BraidHub

kikocis/continue public

ad9b2d0f49b2 · 2.0 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 | null;
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 {selectedProfile === null ? (
29 "Create your first agent"
30 ) : configLoading ? (
31 <span className="text-description flex flex-row items-center">
32 <ArrowPathIcon
33 className={cn(
34 "text-description mr-1.5 h-3 w-3",
35 configLoading && "animate-spin-slow",
36 )}
37 />
38 Loading
39 </span>
40 ) : (
41 <>
42 <div className="h-3 w-3 flex-shrink-0 select-none">
43 <AssistantIcon size={3} assistant={selectedProfile} />
44 </div>
45 <span
46 className={`line-clamp-1 select-none break-all ${isToolbarExpanded ? "xs:hidden sm:line-clamp-1" : ""}`}
47 >
48 {selectedProfile.title}
49 </span>
50 </>
51 )}
52 </div>
53 <ChevronDownIcon
54 className="h-2 w-2 flex-shrink-0 select-none"
55 aria-hidden="true"
56 />
57 </ListboxButton>
58 );
59}