Skip to content

fix(clients): count every call behind a folded tool burst in the step summary - #834

Merged
huichen merged 1 commit into
mainfrom
fix/step-run-nested-count
Sep 25, 2026
Merged

huichen merged 1 commit into
mainfrom
fix/step-run-nested-count

Conversation

@huichen

@huichen huichen commented Sep 25, 2026

Copy link
Copy Markdown
Collaborator

The bug

The folded run's summary badge (🔧×3 · 🧠×2) contradicted the rows the same line reveals when tapped. Reported from a real reply:

🔧×3 · 🧠×2  ^
  运行 2 次
  已思考
  已写入
  已运行
  已思考

2 + 1 + 1 = 4 tool calls underneath, badge said 3.

Why

A run folds projected step rows, and one of those rows can itself be a same-kind burst the shared projection already collapsed (count: 2 + two children, rendered as "运行 2 次"). Both clients counted rows, so that burst scored as one call. The desktop did this on purpose (ReplySteps.tsx said "Mobile counts projected step rows…"), so the two clients agreed — but both disagreed with the list they reveal.

The fix

Count the work, not the rows: a tool step contributes its count — the same number its own label prints when opened — defaulting to 1. Reasoning steps still count 1.

  • mobile/src/components/TimelineCard.tsx — stepRunCounts
  • desktop/src/features/agent/ReplySteps.tsx — the tools sum

The failure count is untouched: a collapsed burst holds completed calls only.

Tests

  • New mobile case reproducing the reported reply (burst(2) + thought + write + run + thought → ×4 · ×2), asserting the expanded rows add up to the summary.
  • Desktop burst case updated (×1·×1 → ×2·×1).

Falsified before fixing: the new mobile test failed as ×3 · ×2, and reverting the desktop sum made its burst test fail as ×1 · ×1.

Checked: mobile jest (TimelineCard, ChatScreen, ComposerDock), tsc --noEmit, eslint; desktop vitest (ReplySteps, MessageBlock.compaction), tsc --noEmit, eslint.

… summary

A folded run of steps showed a wrench count that disagreed with the list the
user gets by tapping it. A run folds projected step rows, and one of those rows
can itself be a same-kind burst the projection already collapsed ("运行 2 次"
with two children) — counting rows scored that burst as a single call, so a run
of 2 + 1 + 1 calls read ×3. Both clients did this deliberately (the desktop
matched mobile on purpose), which left the badge contradicting the rows right
underneath it.

Count the work instead: a tool step contributes its `count` — the same number
its own label prints when opened — defaulting to 1 (reasoning steps still count
1). Desktop's ReplySteps and mobile's stepRunCounts now agree with their
expanded lists. The failure count is unaffected: a collapsed burst is completed
calls only.

Falsified before fixing: the new mobile test failed as ×3 · ×2, and reverting
the desktop sum made its burst test fail as ×1 · ×1.
@huichen
huichen enabled auto-merge (squash) September 25, 2026 12:39
@huichen
huichen merged commit 65ac1f4 into main Sep 25, 2026
12 checks passed
@huichen
huichen deleted the fix/step-run-nested-count branch September 25, 2026 12:43
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