Skip to content

fix(task-board): don't count unpriced runs in the task-cost run count - #6177

Merged
pedrofrxncx merged 1 commit into
mainfrom
fix/task-cost-run-count-excludes-unpriced-w1
Aug 18, 2026
Merged

fix(task-board): don't count unpriced runs in the task-cost run count#6177
pedrofrxncx merged 1 commit into
mainfrom
fix/task-cost-run-count-excludes-unpriced-w1

Conversation

@pedrofrxncx

@pedrofrxncx pedrofrxncx commented Aug 18, 2026

Copy link
Copy Markdown
Collaborator

Follows #6154/#6159 (the task-cost chip and its plural fix).

Bug: TaskCost in task-dialog.tsx summed cost only over threads with a non-null costUsd, but reported the run count as (threads ?? []).length — every linked thread, including ones with no finish part yet (still running, or crashed before completing one, per parseCostUsd/the cost lateral join in apps/api/src/storage/task-board.ts). A task with one priced run and one still-running thread showed "$X in 2 runs", but the total only ever covered the one priced run — the tooltip explicitly claims the total is "across all {runs} of its runs", which was false.

Fix: extracted the count/total logic into a pure summarizeTaskCost() helper (task-cost.ts) and made the run count priced.length instead of the full thread list, so the displayed count always matches what the total actually sums.

Regression test: task-cost.test.tssummarizeTaskCost([priced, unpriced, priced]) now asserts runCount: 2, not 3.

To confirm: bun test apps/web/src/layouts/task-board/task-cost.test.ts

Locally verified: bun run fmt, bunx tsc --noEmit in apps/web (one pre-existing, unrelated mustache type error on main, nothing in the touched files), bunx oxlint on the three changed files (0 warnings/errors), and the targeted test above. Full CI validates the rest.


Summary by cubic

Fixes the task board cost chip to count only runs that recorded costUsd, so the run count matches the summed total. Previously it summed priced threads but reported the count of all threads, including still-running or crashed ones.

  • Extracts summarizeTaskCost() in task-cost.ts and uses it in TaskCost; the chip is hidden when no priced runs exist.
  • Adds task-cost.test.ts to cover exclusion of unpriced threads and null cases; task-dialog.tsx is refactored to consume the helper.

Written for commit 7615a9a. Summary will update on new commits.

Review in cubic

The task-cost chip (#6154/#6159) summed only threads with a recorded costUsd but reported the count of ALL linked threads, including ones with no finish part yet (still running, or crashed before one). A task with 1 priced run and 1 still-running thread showed "$X in 2 runs", claiming the total covered a run it never touched.

Extracted the count/total logic into a pure summarizeTaskCost() helper and fixed it to count only priced threads, with a unit test covering the mismatch.
@pedrofrxncx
pedrofrxncx enabled auto-merge (squash) August 18, 2026 14:39
@pedrofrxncx
pedrofrxncx merged commit 1c17bcd into main Aug 18, 2026
27 checks passed
@pedrofrxncx
pedrofrxncx deleted the fix/task-cost-run-count-excludes-unpriced-w1 branch August 18, 2026 14:44
decocms Bot pushed a commit that referenced this pull request Aug 18, 2026
PR: #6177 fix(task-board): don't count unpriced runs in the task-cost run count
Bump type: patch

- decocms (apps/api/package.json): 4.226.3 -> 4.226.4
- @decocms/native (apps/native/package.json): 4.226.3 -> 4.226.4

Deploy-Scope: web
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant