mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-10-08 03:07:53 +00:00
fix: compute subtask tooltip total from todos
Use todo list costs (source of truth) to derive subtasks total in TaskHeader tooltip, de-duping by subtaskId and falling back to history-derived subtaskDetails when needed.
This commit is contained in:
parent
0a245c49a7
commit
25848e6df6
1 changed files with 26 additions and 6 deletions
|
|
@ -131,14 +131,34 @@ const TaskHeader = ({
|
|||
const hasTodos = todos && Array.isArray(todos) && todos.length > 0
|
||||
|
||||
const subtaskCosts = useMemo(() => {
|
||||
if (!subtaskDetails || subtaskDetails.length === 0) {
|
||||
return []
|
||||
const processedSubtasks = new Set<string>()
|
||||
const costs: number[] = []
|
||||
|
||||
const maybeAddCost = (subtaskId: unknown, cost: unknown) => {
|
||||
if (typeof subtaskId !== "string" || subtaskId.length === 0) return
|
||||
if (processedSubtasks.has(subtaskId)) return
|
||||
if (typeof cost !== "number" || !Number.isFinite(cost) || cost <= 0) return
|
||||
|
||||
processedSubtasks.add(subtaskId)
|
||||
costs.push(cost)
|
||||
}
|
||||
|
||||
return subtaskDetails
|
||||
.map((subtask) => subtask.cost)
|
||||
.filter((cost): cost is number => typeof cost === "number" && Number.isFinite(cost))
|
||||
}, [subtaskDetails])
|
||||
// Primary source of truth: visible todos.
|
||||
if (Array.isArray(todos)) {
|
||||
for (const todo of todos) {
|
||||
maybeAddCost((todo as any)?.subtaskId, (todo as any)?.cost)
|
||||
}
|
||||
}
|
||||
|
||||
// Fallback: any remaining subtasks from history-derived details.
|
||||
if (Array.isArray(subtaskDetails)) {
|
||||
for (const subtask of subtaskDetails) {
|
||||
maybeAddCost(subtask.id, subtask.cost)
|
||||
}
|
||||
}
|
||||
|
||||
return costs
|
||||
}, [todos, subtaskDetails])
|
||||
|
||||
const tooltipCostData = useMemo(
|
||||
() =>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue