diff --git a/site/src/pages/AgentsPage/AgentsSidebar.stories.tsx b/site/src/pages/AgentsPage/AgentsSidebar.stories.tsx index a2efccfea7..54184d7e83 100644 --- a/site/src/pages/AgentsPage/AgentsSidebar.stories.tsx +++ b/site/src/pages/AgentsPage/AgentsSidebar.stories.tsx @@ -240,6 +240,46 @@ export const RunningChatPreservesSpinner: Story = { }, }; +// When a root chat is idle but has a running child, the chevron +// should still be scoped to the icon area hover, not the full row. +export const IdleParentWithRunningChild: Story = { + args: { + chats: [ + buildChat({ + id: "idle-parent", + title: "Idle parent agent", + status: "waiting", + }), + buildChat({ + id: "running-child", + title: "Running sub-agent", + status: "running", + parent_chat_id: "idle-parent", + root_chat_id: "idle-parent", + }), + ], + }, + parameters: { + reactRouter: reactRouterParameters({ + location: { + path: "/agents/running-child", + pathParams: { agentId: "running-child" }, + }, + routing: agentsRouting, + }), + }, + play: async ({ canvasElement }) => { + const canvas = within(canvasElement); + + // The parent's toggle should use icon-only hover scope because + // its child is actively running. + const toggle = canvas.getByTestId("agents-tree-toggle-idle-parent"); + await expect(toggle).toBeInTheDocument(); + await expect(toggle.className).toMatch(/\binvisible\b/); + await expect(toggle.className).toContain("group-hover/icon:visible"); + }, +}; + export const ActiveChatAncestryExpanded: Story = { args: { chats: [ diff --git a/site/src/pages/AgentsPage/AgentsSidebar.tsx b/site/src/pages/AgentsPage/AgentsSidebar.tsx index 0969789c60..965337b0f5 100644 --- a/site/src/pages/AgentsPage/AgentsSidebar.tsx +++ b/site/src/pages/AgentsPage/AgentsSidebar.tsx @@ -327,7 +327,14 @@ const ChatTreeNode = memo(({ chat, isChildNode }) => { }`; const isArchivingThisChat = isArchiving && archivingChatId === chat.id; const isExpanded = normalizedSearch ? true : (expandedById[chatID] ?? false); - const isExecuting = chat.status === "pending" || chat.status === "running"; + const isExecuting = + chat.status === "pending" || + chat.status === "running" || + (hasChildren && + childIDs.some((id) => { + const c = chatById.get(id); + return c?.status === "pending" || c?.status === "running"; + })); return (