fix: Show detailing indicator by including detail tasks in listInitiativeTasks

listInitiativeTasks was filtering out detail tasks server-side, so the
detailAgentByPhase mapping could never resolve agent.taskId to a phaseId.
Move the filter to client-side (displayTasks) so detail tasks are available
for agent mapping but excluded from counts and display grouping.
This commit is contained in:
Lukas May
2026-03-03 13:25:29 +01:00
parent 0ab7b54ad7
commit 3e678f2591
3 changed files with 19 additions and 7 deletions

View File

@@ -132,7 +132,7 @@ export function taskProcedures(publicProcedure: ProcedureBuilder) {
.query(async ({ ctx, input }) => {
const taskRepository = requireTaskRepository(ctx);
const tasks = await taskRepository.findByInitiativeId(input.initiativeId);
return tasks.filter((t) => t.category !== 'detail');
return tasks;
}),
listPhaseTasks: publicProcedure

View File

@@ -117,11 +117,17 @@ export function ExecutionTab({
);
const allTasks = allTasksQuery.data ?? [];
// Filter out detail tasks for display (counts/grouping), keep allTasks unfiltered for detailAgentByPhase
const displayTasks = useMemo(
() => allTasks.filter((t) => t.category !== "detail"),
[allTasks],
);
// Group tasks and counts by phaseId
const { taskCountsByPhase, tasksByPhase } = useMemo(() => {
const counts: Record<string, { complete: number; total: number }> = {};
const grouped: Record<string, typeof allTasks> = {};
for (const task of allTasks) {
const grouped: Record<string, typeof displayTasks> = {};
for (const task of displayTasks) {
const pid = task.phaseId;
if (!pid) continue;
if (!counts[pid]) counts[pid] = { complete: 0, total: 0 };
@@ -131,7 +137,7 @@ export function ExecutionTab({
grouped[pid].push(task);
}
return { taskCountsByPhase: counts, tasksByPhase: grouped };
}, [allTasks]);
}, [displayTasks]);
// Map phaseId → most recent active detail agent
const detailAgentByPhase = useMemo(() => {

View File

@@ -58,17 +58,23 @@ function PipelineTabInner({ initiativeId, phases, phasesLoading }: PipelineTabPr
const agentsQuery = trpc.listAgents.useQuery();
const allAgents = agentsQuery.data ?? [];
// Group tasks by phaseId
// Filter out detail tasks for display (counts/grouping), keep allTasks unfiltered for detailAgentByPhase
const displayTasks = useMemo(
() => allTasks.filter((t) => t.category !== "detail"),
[allTasks],
);
// Group display tasks by phaseId
const tasksByPhase = useMemo(() => {
const map: Record<string, SerializedTask[]> = {};
for (const task of allTasks) {
for (const task of displayTasks) {
if (task.phaseId) {
if (!map[task.phaseId]) map[task.phaseId] = [];
map[task.phaseId].push(task);
}
}
return map;
}, [allTasks]);
}, [displayTasks]);
// Map phaseId → most recent active detail agent
const detailAgentByPhase = useMemo(() => {