Skip to content

fix token totals#306

Merged
rajbos merged 4 commits intomainfrom
fix-token-totals
Feb 25, 2026
Merged

fix token totals#306
rajbos merged 4 commits intomainfrom
fix-token-totals

Conversation

@rajbos
Copy link
Owner

@rajbos rajbos commented Feb 25, 2026

This pull request improves the robustness and accuracy of Copilot token usage tracking and display, especially in the face of evolving API formats and malformed log lines. It introduces better handling for new token reporting formats, adds a regex-based fallback for extracting token usage from corrupted logs, and polishes the webview UI for clarity and consistency.

Token Usage Tracking Improvements:

  • Updated the cache version and token extraction logic in CopilotTokenTracker to support new and upcoming API formats, including tokens at result.promptTokens/outputTokens and nested under result.metadata [1] [2] [3] [4] [5].
  • Added a regex-based fallback (extractPerRequestUsageFromRawLines) to recover token usage from log lines that fail JSON parsing, ensuring more accurate stats even with malformed logs [1] [2] [3] [4].
  • Improved cache key generation in development mode to prevent cache conflicts between VS Code windows by using a unique session-based identifier.

Webview and UI Enhancements:

  • Refined the metrics table in the details webview to always show total tokens, regardless of actual usage data availability, making stats more consistent.
  • Improved the logviewer UI to clearly display actual token usage per turn and in summary cards, with better formatting and removal of merge conflict artifacts [1] [2].
  • Enhanced layout robustness in the logviewer by adjusting word-break behavior for editor and date fields, and by dynamically adjusting the grid layout based on available data [1] [2] [3] [4].

@rajbos rajbos enabled auto-merge February 25, 2026 14:02
@rajbos rajbos merged commit b13a59d into main Feb 25, 2026
14 checks passed
@rajbos rajbos deleted the fix-token-totals branch February 25, 2026 14:04
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