Skip to content

refactor(tui): sum cached and total tokens across all steps in turn summary - #46590

Merged
heimoshuiyu merged 1 commit into
anomalyco:v2from
heimoshuiyu:turn-token-sums
Sep 2, 2026
Merged

heimoshuiyu merged 1 commit into
anomalyco:v2from
heimoshuiyu:turn-token-sums

Conversation

@heimoshuiyu

@heimoshuiyu heimoshuiyu commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

Issue for this PR

Closes #46636

Type of change

  • Refactor / code improvement
  • Bug fix
  • New feature
  • Documentation

What does this PR do?

The + Tokens turn summary mixes two units on one line (#41922): new is
summed across all steps while cached and total are the last step's values.
Nothing on the line marks that difference, so the three numbers read as the
same kind of aggregate when they aren't. This makes all three turn-level sums;
the last step's context is still visible in the expanded table and on the
status bar.

How did you verify your code works?

  • bun test test/cli/tui/session-rows.test.ts in packages/tui — 24 pass, 0 fail

Screenshots / recordings

Multi-step turn with debug.turn_tokens on (11 steps):

Build · GLM-5.3 Flash · 1m 47s

+ Tokens: 11 steps · 50,006 new · 2,456,768 cached · 2,506,774 total

50,006 + 2,456,768 = 2,506,774

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. needs:issue labels Sep 1, 2026
@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • No issue referenced. Please add Closes #<number> linking to the relevant issue.

Please edit this PR description to address the above within 2 hours, or it will be automatically closed.

If you believe this was flagged incorrectly, please let a maintainer know.

@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window.

Feel free to open a new pull request that follows our guidelines.

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Sep 1, 2026
@github-actions github-actions Bot closed this Sep 1, 2026
@heimoshuiyu heimoshuiyu reopened this Sep 1, 2026
@heimoshuiyu heimoshuiyu changed the title fix(tui): sum cached and total tokens across all steps in turn summary refactor(tui): sum cached and total tokens across all steps in turn summary Sep 1, 2026
@heimoshuiyu

Copy link
Copy Markdown
Contributor Author

The unit (linux) failure looks like CI infra flakiness rather than this change:

  • Failing test: shows jump to latest after scrolling one line above the final message (packages/tui/test/app-lifecycle.test.tsx) — Timed out waiting for frame predicate, ~700ms, consistent across three reruns
  • This PR only touches the TurnTokenUsage summary memo; the failing test's fixture contains no assistant messages, so that component never renders in it
  • The same test failed on other branches in the same time window (e.g. stop-handoff), and the test workflow is at 1 success / 10 failures over the last 20 runs repo-wide
  • app-lifecycle.test.tsx passes locally on this branch (23/23)

Happy to rerun once CI stabilizes — or feel free to rerun/override if that's easier.

@heimoshuiyu
heimoshuiyu merged commit 3cfec5a into anomalyco:v2 Sep 2, 2026
8 checks passed
jinhuang712 pushed a commit to jinhuang712/opencode that referenced this pull request Sep 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant