forked from elizaOS/eliza
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp-sidebar.tsx
134 lines (130 loc) · 5.81 KB
/
app-sidebar.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
import { useQuery } from "@tanstack/react-query";
import info from "@/lib/info.json";
import {
Sidebar,
SidebarContent,
SidebarFooter,
SidebarGroup,
SidebarGroupContent,
SidebarGroupLabel,
SidebarHeader,
SidebarMenu,
SidebarMenuButton,
SidebarMenuItem,
SidebarMenuSkeleton,
} from "@/components/ui/sidebar";
import { apiClient } from "@/lib/api";
import { NavLink, useLocation } from "react-router";
import { type UUID } from "@elizaos/core";
import { Book, Cog, User } from "lucide-react";
import ConnectionStatus from "./connection-status";
export function AppSidebar() {
const location = useLocation();
const query = useQuery({
queryKey: ["agents"],
queryFn: () => apiClient.getAgents(),
refetchInterval: 5_000,
});
const agents = query?.data?.agents;
return (
<Sidebar>
<SidebarHeader>
<SidebarMenu>
<SidebarMenuItem>
<SidebarMenuButton size="lg" asChild>
<NavLink to="/">
<img
src="/elizaos-icon.png"
width="100%"
height="100%"
className="size-7"
/>
<div className="flex flex-col gap-0.5 leading-none">
<span className="font-semibold">
ElizaOS
</span>
<span className="">v{info?.version}</span>
</div>
</NavLink>
</SidebarMenuButton>
</SidebarMenuItem>
</SidebarMenu>
</SidebarHeader>
<SidebarContent>
<SidebarGroup>
<SidebarGroupLabel>Agents</SidebarGroupLabel>
<SidebarGroupContent>
<SidebarMenu>
{query?.isPending ? (
<div>
{Array.from({ length: 5 }).map(
(_, index) => (
<SidebarMenuItem key={index}>
<SidebarMenuSkeleton />
</SidebarMenuItem>
)
)}
</div>
) : (
<div>
{agents?.map(
(agent: { id: UUID; name: string }) => (
<>
<SidebarMenuItem key={agent.id}>
<NavLink
to={`/chat/${agent.id}`}
>
<SidebarMenuButton
isActive={location.pathname.includes(
agent.id
)}
>
<User />
<span>
{agent.name}
</span>
</SidebarMenuButton>
</NavLink>
</SidebarMenuItem>
<SidebarMenuItem>
<NavLink
to={`/settings/archetypes/${agent.id}`}
>
<SidebarMenuButton>
<Cog /> Change
Agent's Archetype
</SidebarMenuButton>
</NavLink>
</SidebarMenuItem>
</>
)
)}
</div>
)}
</SidebarMenu>
</SidebarGroupContent>
</SidebarGroup>
</SidebarContent>
<SidebarFooter>
<SidebarMenu>
<SidebarMenuItem>
<NavLink
to="https://elizaos.github.io/eliza/docs/intro/"
target="_blank"
>
<SidebarMenuButton>
<Book /> Documentation
</SidebarMenuButton>
</NavLink>
</SidebarMenuItem>
<SidebarMenuItem>
<SidebarMenuButton disabled>
<Cog /> Settings
</SidebarMenuButton>
</SidebarMenuItem>
<ConnectionStatus />
</SidebarMenu>
</SidebarFooter>
</Sidebar>
);
}