diff --git a/doc/PRODUCT.md b/doc/PRODUCT.md index 82397c60a51..edb386e8083 100644 --- a/doc/PRODUCT.md +++ b/doc/PRODUCT.md @@ -95,7 +95,8 @@ The current issue model includes stable issue identifiers, parent/sub-issues, bl When an agent creates a subtask or follow-up task, its source task's feed shows a linked card at creation time with the current title, task number, and status. -The Tasks tab keeps the full relationship list. +The Tasks tab keeps the full relationship list and shows each task once. Project +groups omit tasks already shown in the other sections and disappear when empty. Agent-owned tasks show **In Progress** only while a task-linked run is queued or running. When execution ends, their visible status reflects recovery diff --git a/ui/src/components/task-detail/TaskDetailTasksPanel.test.tsx b/ui/src/components/task-detail/TaskDetailTasksPanel.test.tsx index 866efd786db..d44142013cf 100644 --- a/ui/src/components/task-detail/TaskDetailTasksPanel.test.tsx +++ b/ui/src/components/task-detail/TaskDetailTasksPanel.test.tsx @@ -58,17 +58,77 @@ describe("TaskDetailTasksPanel", () => { expect(container.textContent).toContain("No tasks yet."); }); - it("keeps subtask membership separate from creation membership, including overlap", () => { + it("shows overlapping next actions and other subtasks only in the subtask section", () => { const manual = task("manual-child"); - const overlap = task("created-child", { projectId: project.id }); + const overlap = task("created-child", { projectId: project.id, status: "in_progress" }); + const completed = task("completed-child", { projectId: project.id, status: "done" }); const followup = task("other-parent", { parentId: "elsewhere", projectId: project.id }); - render({ subtasks: [manual, overlap], createdTasks: [overlap, followup], projects: [project] }); - expect(container.querySelectorAll('[data-task-id="created-child"]')).toHaveLength(2); + render({ subtasks: [manual, overlap, completed], createdTasks: [{ ...overlap }, followup, { ...completed }], projects: [project] }); + expect(container.querySelectorAll('[data-task-id="created-child"]')).toHaveLength(1); + expect(container.querySelectorAll('[data-task-id="completed-child"]')).toHaveLength(1); expect(container.querySelectorAll('[data-task-id="manual-child"]')).toHaveLength(1); const group = container.querySelector('section[aria-label="Board UI"]')!; expect(group.textContent).toContain("other-parent"); + expect(group.textContent).not.toContain("created-child"); + expect(group.textContent).not.toContain("completed-child"); expect(group.textContent).not.toContain("manual-child"); expect(container.querySelectorAll('[role="progressbar"]')).toHaveLength(1); + expect(container.querySelector('[role="progressbar"]')?.getAttribute("aria-valuenow")).toBe("33"); + act(() => (container.querySelector('section[aria-label="Subtasks"] button') as HTMLButtonElement).click()); + expect(container.querySelector('[data-task-id="created-child"]')).toBeNull(); + expect(container.querySelector('[data-task-id="other-parent"]')).not.toBeNull(); + }); + + it.each([project.id, null])("hides a project group when all its tasks are subtasks (project %s)", (projectId) => { + const child = task("child", { projectId }); + render({ subtasks: [child, { ...child }], createdTasks: [{ ...child }, child], projects: [project] }); + expect(container.querySelectorAll('[data-task-id="child"]')).toHaveLength(1); + expect([...container.querySelectorAll('h2')].map((heading) => heading.textContent)).toEqual(["Subtasks"]); + expect(container.textContent).not.toContain("No tasks yet."); + }); + + it("does not repeat a subtask's root blocker in a project group", () => { + const blocker = task("blocker", { identifier: "PAP-11", projectId: project.id }); + const child = task("child", { + status: "blocked", + blockerAttention: { + state: "needs_attention", + reason: "attention_required", + unresolvedBlockerCount: 1, + coveredBlockerCount: 0, + stalledBlockerCount: 0, + attentionBlockerCount: 1, + sampleBlockerIdentifier: blocker.identifier, + sampleStalledBlockerIdentifier: null, + terminalBlocker: blocker, + }, + }); + render({ subtasks: [child], createdTasks: [blocker], projects: [project] }); + expect(container.querySelectorAll('a[href="/issues/PAP-11"]')).toHaveLength(1); + expect(container.querySelector('[data-task-id="blocker"]')).toBeNull(); + expect(container.querySelector('section[aria-label="Board UI"]')).toBeNull(); + }); + + it("keeps task and project lookups linear for large overlapping lists", () => { + let lookups = 0; + const readId = (id: string) => { + if (++lookups > 12000) throw new Error("Too many task and project lookups"); + return id; + }; + const projects = Array.from({ length: 120 }, (_, index) => ({ + ...project, get id() { return readId(`project-${index}`); }, name: `Project ${index}`, + })); + const tasks = Array.from({ length: 800 }, (_, index) => task(`task-${index}`, { + projectId: `project-${index % projects.length}`, + })); + for (let index = 0; index < tasks.length; index++) { + Object.defineProperty(tasks[index], "id", { get: () => readId(`task-${index}`) }); + } + render({ subtasks: tasks.slice(0, 600), createdTasks: tasks, projects }); + const rows = [...container.querySelectorAll('[data-task-id]')]; + expect(rows).toHaveLength(800); + expect(new Set(rows.map((row) => row.getAttribute("data-task-id"))).size).toBe(800); + expect(lookups).toBeLessThan(12000); }); it("hides absent subtasks and puts unowned tasks under No project without a link or progress", () => { @@ -124,4 +184,24 @@ describe("TaskDetailTasksPanel", () => { expect(container.querySelector('section[aria-label="Created from"]')).toBeNull(); expect(container.textContent).toContain("No tasks yet."); }); + + it("does not repeat the creation source or ancestors in project groups", () => { + render({ + ancestors, + createdFrom: { + issue: ancestors[0], + run: null, + agent: null, + }, + subtasks: [], + createdTasks: [task("parent", { projectId: project.id }), task("root"), task("followup", { projectId: project.id })], + projects: [project], + }); + expect(container.querySelectorAll('a[href="/issues/PAP-2"]')).toHaveLength(1); + expect(container.querySelectorAll('a[href="/issues/root"]')).toHaveLength(1); + expect(container.querySelector('[data-task-id="parent"]')).toBeNull(); + expect(container.querySelector('[data-task-id="root"]')).toBeNull(); + expect(container.querySelector('[data-task-id="followup"]')).not.toBeNull(); + expect(container.querySelector('section[aria-label="No project"]')).toBeNull(); + }); }); diff --git a/ui/src/components/task-detail/TaskDetailTasksPanel.tsx b/ui/src/components/task-detail/TaskDetailTasksPanel.tsx index 8f3f91738f4..f364ad879de 100644 --- a/ui/src/components/task-detail/TaskDetailTasksPanel.tsx +++ b/ui/src/components/task-detail/TaskDetailTasksPanel.tsx @@ -6,7 +6,7 @@ import { projectRouteRef } from "@/lib/utils"; import { issueStatusOrder } from "@/lib/issue-filters"; import { Button } from "@/components/ui/button"; import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "@/components/ui/collapsible"; -import { RelationNavigationList, TaskDetailSubtasksPanel, TaskDetailTaskList } from "./TaskDetailRelationsPanel"; +import { RelationNavigationList, resolveTaskDetailSubtaskState, TaskDetailSubtasksPanel, TaskDetailTaskList } from "./TaskDetailRelationsPanel"; import { IssueCreatedFromNote } from "./IssueCreatedFromNote"; function TaskGroup({ name, projectPath, children }: { name: string; projectPath?: string; children: ReactNode }) { @@ -49,12 +49,22 @@ export interface TaskDetailTasksPanelProps { } export function TaskDetailTasksPanel({ ancestors = [], createdFrom = null, subtasks, createdTasks, projects, isLoading, hasError, onRetry, issueLinkState }: TaskDetailTasksPanelProps) { + const visibleAncestors = ancestors.filter((item) => item.id !== createdFrom?.issue.id); const sortedSubtasks = sortTasks(subtasks); + const displayedTaskIds = new Set([ + ...(createdFrom ? [createdFrom.issue.id] : []), + ...ancestors.map((item) => item.id), + ...sortedSubtasks.map((item) => item.id), + ]); + const { rootBlocker } = resolveTaskDetailSubtaskState(sortedSubtasks); + if (rootBlocker) displayedTaskIds.add(rootBlocker.id); + const projectsById = new Map(projects.map((project) => [project.id, project])); const groups = new Map(); for (const item of sortTasks(createdTasks)) { + if (displayedTaskIds.has(item.id)) continue; const key = item.projectId ?? "no-project"; const project = item.projectId - ? projects.find((candidate) => candidate.id === item.projectId) ?? item.project + ? projectsById.get(item.projectId) ?? item.project : null; const group = groups.get(key) ?? { name: project?.name ?? (item.projectId ? "Project" : "No project"), @@ -71,10 +81,10 @@ export function TaskDetailTasksPanel({ ancestors = [], createdFrom = null, subta )} - {ancestors.length > 0 && ( + {visibleAncestors.length > 0 && (