import { Link } from "@tanstack/react-router"; import { ChartLineUpIcon, ChatCircleIcon, GithubLogoIcon, KanbanIcon, PlusIcon, SlackLogoIcon, XIcon, } from "@phosphor-icons/react"; import type { Icon } from "@phosphor-icons/react"; import type { SessionUser } from "@/lib/api"; import type { AgentSource, AgentThread } from "@/lib/agents/types"; import { SidebarUserMenu } from "@/components/SidebarUserMenu"; import { SidebarCollapseButton, SidebarFrame, useSidebarLayout, } from "@/components/sidebar-layout"; import { groupThreads } from "@/lib/agents/api"; import { useAgentThreads, useDeleteAgentThread } from "@/lib/agents/queries"; import { cn } from "@/lib/utils"; const SOURCE_META: Record = { dashboard: { icon: ChatCircleIcon, label: "Started from the dashboard" }, github: { icon: GithubLogoIcon, label: "Triggered from GitHub" }, slack: { icon: SlackLogoIcon, label: "Triggered from Slack" }, linear: { icon: KanbanIcon, label: "Triggered from Linear" }, }; interface AgentsSidebarProps { user: SessionUser; activeThreadId?: string; } const NAV = [{ to: "/my-settings", label: "Dashboard", icon: ChartLineUpIcon }] as const; export function AgentsSidebar({ user, activeThreadId }: AgentsSidebarProps) { const threadsQuery = useAgentThreads(); const threads = threadsQuery.data ?? []; const groups = groupThreads(threads); const layout = useSidebarLayout(); return (
open-swe
New Agent
); } function ThreadGroup({ label, threads, activeThreadId, }: { label: string; threads: AgentThread[]; activeThreadId?: string; }) { if (threads.length === 0) return null; return (
{label}
{threads.map((thread) => ( ))}
); } function ThreadRow({ thread, isActive }: { thread: AgentThread; isActive: boolean }) { const deleteThread = useDeleteAgentThread(); const badge = thread.diffStats && thread.diffStats.additions > 0 ? `+${thread.diffStats.additions}` : null; const isDeleting = deleteThread.isPending && deleteThread.variables === thread.id; const onDelete = (e: React.MouseEvent) => { e.preventDefault(); e.stopPropagation(); if (isDeleting) return; if (!window.confirm(`Delete "${thread.title}"? This cannot be undone.`)) return; deleteThread.mutate(thread.id); }; const source = thread.source && thread.source !== "dashboard" ? SOURCE_META[thread.source] : null; const SourceIcon = source?.icon; return ( {source && SourceIcon && ( {source.label} )} {thread.title} {badge && ( {badge} )} ); } export function AgentsShell({ user, activeThreadId, children, }: { user: SessionUser; activeThreadId?: string; children: React.ReactNode; }) { return (
{children}
); }