import { Bot, Crown } from 'lucide-react'; import { useNavigate } from 'react-router-dom'; import type { TeamDetailResponse, TeamMemberInfo, AgentRecord } from '@/api'; import { Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarMenu, SidebarMenuButton, SidebarMenuItem, } from '@/components/ui/sidebar'; import { useTranslation } from '@/i18n/useI18n'; interface TeamSidebarProps { /** Resolved team detail (leader + members) — drives all rendering. */ team: TeamDetailResponse; /** * The session id currently shown in the chat area. Used both for * highlighting the active row and for deciding whether the row * being clicked is already the current one. */ currentSessionId: string; } /** * Secondary sidebar shown next to the chat area whenever the open * session participates in a team. * * Built on the shared shadcn `Sidebar` primitives so it visually * matches the main page sidebar (same paddings, item heights, * active-row treatment, etc.). Renders the leader at the top * followed by every member; all rows are clickable. * * Clicking the leader row navigates to * `/chat//` (drops the URL's * optional `:memberId` slot so the chat area falls back to the * leader session). Clicking a member row navigates to * `/chat///` — the * outer URL slots stay the same so the main page sidebar does not * collapse; only the chat area reroutes to the member's session. * * Both `leaderAgentId` and `leaderSessionId` are derived from the * passed `team` prop, so the parent only needs to know which * session is currently active. * * @param team - Resolved team detail. * @param currentSessionId - Session id currently shown in the chat * area; used to drive row highlighting. * @returns A vertical sidebar element. */ export function TeamSidebar({ team, currentSessionId }: TeamSidebarProps) { const { t } = useTranslation(); const navigate = useNavigate(); const leaderAgentId = team.leader_agent?.id ?? null; const leaderSessionId = team.team.session_id; const goToLeader = () => { if (!leaderAgentId) return; navigate(`/chat/${leaderAgentId}/${leaderSessionId}`); }; const goToMember = (memberAgentId: string) => { if (!leaderAgentId) return; navigate(`/chat/${leaderAgentId}/${leaderSessionId}/${memberAgentId}`); }; const renderLeader = (leader: AgentRecord) => ( {leader.data.name} ); const renderMember = (member: TeamMemberInfo) => ( goToMember(member.agent.id)} > {member.agent.data.name} ); return (
{t('common.team')} {team.team.data.name}
{team.leader_agent && ( {t('common.leader')} {renderLeader(team.leader_agent)} )} {t('team-sidebar.membersHeading')} {team.members.length === 0 ? (

{t('team-sidebar.noMembers')}

) : ( {team.members.map(renderMember)} )}
); }