diff --git a/tests/e2e/agent-chat-sessions-navigation.spec.ts b/tests/e2e/agent-chat-sessions-navigation.spec.ts index 9569529d464..59398c34390 100644 --- a/tests/e2e/agent-chat-sessions-navigation.spec.ts +++ b/tests/e2e/agent-chat-sessions-navigation.spec.ts @@ -111,7 +111,7 @@ test("Coordinator agent switching preserves drafts and opens one conversation on const editor = page.getByTestId("task-chat-composer-input").locator('[contenteditable="true"]'); const contacts = page.getByRole("complementary", { name: "Chat contacts", exact: true }); const switchTo = async (name: string) => { - const contact = contacts.getByRole("link", { name: new RegExp(`^${name}`) }); + const contact = contacts.getByRole("link", { name: `Open chat with ${name}`, exact: true }); await contact.click(); await expect(contact).toHaveAttribute("aria-current", "page"); }; @@ -165,12 +165,12 @@ test("secondary chat navigation preserves layout, unique conversations, history, }); const sidebar = page.getByRole("complementary", { name: "Chat contacts", exact: true }); const nav = sidebar.getByRole("navigation", { name: "Agent conversations" }); - const alphaLink = nav.getByRole("link", { name: /^Alpha/ }); - const betaLink = nav.getByRole("link", { name: /^Beta/ }); + const alphaLink = nav.getByRole("link", { name: "Open chat with Alpha", exact: true }); + const betaLink = nav.getByRole("link", { name: "Open chat with Beta", exact: true }); await expect(alphaLink).toHaveAttribute("aria-current", "page"); expect(await json(await request.get(f.chatPath))).toBeNull(); expect(await json(await request.get(`/api/companies/${f.company.id}/heartbeat-runs`))).toHaveLength(0); - await expect(nav.getByRole("link")).toHaveText([/^Alpha/, /^Beta/, /^Delta/, /^Epsilon/, /^Gamma/, /^Zeta/]); + await expect(nav.getByRole("link", { name: /^View overview for / })).toHaveText([/^Alpha/, /^Beta/, /^Delta/, /^Epsilon/, /^Gamma/, /^Zeta/]); const landingBounds = await sidebar.boundingBox(); const chatListPath = `/api/companies/${f.company.id}/chats`; const betaPath = `${chatListPath}/${f.agents[1].id}`; @@ -194,7 +194,7 @@ test("secondary chat navigation preserves layout, unique conversations, history, expect(await json(await request.get(chatListPath))).toHaveLength(1); await alphaLink.click(); await expect(alphaLink).toHaveAttribute("aria-current", "page"); - await expect(nav.getByRole("link")).toHaveText([/^Alpha/, /^Beta/, /^Delta/, /^Epsilon/, /^Gamma/, /^Zeta/]); + await expect(nav.getByRole("link", { name: /^View overview for / })).toHaveText([/^Alpha/, /^Beta/, /^Delta/, /^Epsilon/, /^Gamma/, /^Zeta/]); const editor = page.getByTestId("task-chat-composer-input").locator('[contenteditable="true"]'); await editor.fill("Unsent draft for Alpha"); await betaLink.click(); @@ -206,13 +206,13 @@ test("secondary chat navigation preserves layout, unique conversations, history, await search.fill("No matching agent"); await expect(sidebar.getByText("No agents found", { exact: true })).toBeVisible(); await search.fill("Beta"); - await expect(nav.getByRole("link")).toHaveCount(1); + await expect(nav.getByRole("link", { name: /^View overview for / })).toHaveCount(1); await expect(betaLink).toBeVisible(); await search.press("Escape"); - await expect(nav.getByRole("link")).toHaveCount(6); + await expect(nav.getByRole("link", { name: /^View overview for / })).toHaveCount(6); await page.reload(); await expect(editor).toContainText("Unsent draft for Alpha"); - await expect(nav.getByRole("link")).toHaveCount(6); + await expect(nav.getByRole("link", { name: /^View overview for / })).toHaveCount(6); await page.getByRole("link", { name: /^Chat(?:\s|$)/ }).click(); await expect(alphaLink).toHaveAttribute("aria-current", "page"); @@ -234,9 +234,14 @@ test("secondary chat navigation preserves layout, unique conversations, history, await expect(page.getByText("Background activity", { exact: true })).toBeVisible(); expect((await json(await request.get(betaPath))).id).toBe(beta.id); expect(await json(await request.get(chatListPath))).toHaveLength(1); + await nav.getByRole("link", { name: "View overview for Beta", exact: true }).click(); + await expect(page).toHaveURL(/\/agents\/[^/]+\/overview$/); await json(await request.post(`/api/agents/${f.agents[1].id}/terminate`)); await page.goto(`/${f.company.issuePrefix}/chats`); - await expect(betaLink).toContainText("Terminated"); + const betaRow = nav.locator(".agent-contact-row").filter({ + has: page.getByRole("link", { name: "Open chat with Beta", exact: true }), + }); + await expect(betaRow).toContainText("Terminated"); await betaLink.click(); await expect(page).toHaveURL(new RegExp(`/chats/${f.agents[1].id}$`)); await expect(page.getByText("Background activity", { exact: true })).toBeVisible(); diff --git a/tests/e2e/conference-room-typing-intro.spec.ts b/tests/e2e/conference-room-typing-intro.spec.ts index a4b2bcf7c72..dcbfa56e9f1 100644 --- a/tests/e2e/conference-room-typing-intro.spec.ts +++ b/tests/e2e/conference-room-typing-intro.spec.ts @@ -182,10 +182,11 @@ async function assertOnlyChatExists(page: Page, companyName: string) { expect(await agentsRes.json()).toEqual([ expect.objectContaining({ id: chats[0].conversationAgentId, name: fixtureAgentName }), ]); - const contacts = page.getByRole("navigation", { name: "Agent conversations" }).getByRole("link"); - await expect(contacts).toHaveCount(1); + const contacts = page.getByRole("navigation", { name: "Agent conversations" }); + const chatLinks = contacts.getByRole("link", { name: /^Open chat with / }); + await expect(chatLinks).toHaveCount(1); await expect(contacts.getByText(fixtureAgentName, { exact: true })).toBeVisible(); - await expect(contacts).toHaveAttribute("aria-current", "page"); + await expect(chatLinks).toHaveAttribute("aria-current", "page"); await expect(page.getByTestId("task-chat-composer-add")).toBeVisible(); } diff --git a/ui/src/components/AgentConversationSidebar.tsx b/ui/src/components/AgentConversationSidebar.tsx index 5f1b93bba22..dc3edec2f4f 100644 --- a/ui/src/components/AgentConversationSidebar.tsx +++ b/ui/src/components/AgentConversationSidebar.tsx @@ -27,6 +27,7 @@ export interface AgentConversationSidebarProps { onRetry?: () => void; initialSearch?: string; onSelect?: (agent: Agent, signal?: AbortSignal) => void | Promise; + onOpenOverview?: () => void; onBrowse?: () => void; onAddChat?: (agent: Agent, signal?: AbortSignal) => void | Promise; historyLoading?: boolean; @@ -42,7 +43,7 @@ const NO_PINNED_AGENTS: readonly string[] = []; const contactRowClassName = "agent-pin-row agent-contact-pin-row group/agent-pin relative rounded-md"; /** Searchable navigation for one conversation per agent. */ -export function AgentConversationSidebar({ agents, compact = false, mobileSwitcher = false, existingChatAgentIds, availableAgents = agents, activeId, activeAgent: providedActiveAgent, previews = {}, unreadAgentIds = [], unreadMessageCounts, loading = false, error, onRetry, initialSearch = "", onSelect, onBrowse, onAddChat, historyLoading, historyError, onRetryHistory, onCreateAgent, renderAgentAction, pinnedAgentIds = NO_PINNED_AGENTS, onReorderPins }: AgentConversationSidebarProps) { +export function AgentConversationSidebar({ agents, compact = false, mobileSwitcher = false, existingChatAgentIds, availableAgents = agents, activeId, activeAgent: providedActiveAgent, previews = {}, unreadAgentIds = [], unreadMessageCounts, loading = false, error, onRetry, initialSearch = "", onSelect, onOpenOverview, onBrowse, onAddChat, historyLoading, historyError, onRetryHistory, onCreateAgent, renderAgentAction, pinnedAgentIds = NO_PINNED_AGENTS, onReorderPins }: AgentConversationSidebarProps) { const navigate = useNavigate(); const [pickerOpen, setPickerOpen] = useState(false); const [search, setSearch] = useState(initialSearch); @@ -167,19 +168,24 @@ export function AgentConversationSidebar({ agents, compact = false, mobileSwitch const unreadCount = unreadMessageCounts?.get(agent.id) ?? 0; const hasUnread = unreadCount > 0 || unreadIds.has(agent.id); const canReorder = pinnedIds.has(agent.id) && !!onReorderPins; - const content = <> { if (onSelect) { event.preventDefault(); onSelect(agent); } }} - className={cn("agent-contact-row flex min-w-0 items-center gap-3 rounded-md px-2.5 py-3 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring", renderAgentAction && hasUnread && "pr-12", canReorder && "pr-20", activeId === agent.id ? "bg-accent text-accent-foreground" : "group-hover/agent-pin:bg-accent/60 group-focus-within/agent-pin:bg-accent/60")}> - - - {agent.name} + const routeRef = encodeURIComponent(agent.status === "terminated" ? agent.id : agentRouteRef(agent)); + const content = <>
+ { if (onSelect) { event.preventDefault(); onSelect(agent); } }} + className="shrink-0 after:absolute after:inset-0 after:rounded-md focus-visible:outline-none focus-visible:after:ring-2 focus-visible:after:ring-inset focus-visible:after:ring-ring"> + + + + {agent.name} {agent.status === "terminated" ? "Terminated" : agent.title ?? agent.role} {unreadCount > 0 ? {unreadCount} : unreadIds.has(agent.id) && } - {renderAgentAction?.(agent)}; +
{renderAgentAction?.(agent)}; return {content}; diff --git a/ui/src/components/AgentConversationsSidebar.tsx b/ui/src/components/AgentConversationsSidebar.tsx index 17642f1b103..55ab756e1a6 100644 --- a/ui/src/components/AgentConversationsSidebar.tsx +++ b/ui/src/components/AgentConversationsSidebar.tsx @@ -97,6 +97,7 @@ export function AgentConversationsSidebar({ compact = false, mobileSwitcher = fa historyError={historyAgents.find(result => queryViewKind(result) === "error")?.error} onRetryHistory={() => { historyAgents.filter(result => result.isError).forEach(result => { void result.refetch(); }); }} onAddChat={compact || mobileSwitcher ? undefined : openChat} + onOpenOverview={isMobile ? () => setSidebarOpen(false) : undefined} onSelect={agent => { navigate(`/chats/${encodeURIComponent(agent.status === "terminated" ? agent.id : agentRouteRef(agent))}`); if (isMobile) setSidebarOpen(false);