Recalculate stale accounting snapshots on launch - #7
Merged
Conversation
Backtthefuture
marked this pull request as ready for review
July 21, 2026 08:04
canyexuanfan
added a commit
to canyexuanfan/TokenStep-Windows
that referenced
this pull request
Jul 31, 2026
镜像同步至 upstream HEAD a44b2e9(PR Backtthefuture#6 + Backtthefuture#7),包含: - 1b54e5c Calibrate token accounting and Agent activity · codexAccountingRevision=8 计量校准 · 新增 AgentWorkViews/DailyAgentWork 模型 · 实验来源采集器(ZCode/Hermes/WorkBuddy) · 节奏卡底部指标改版(Agent Token/近7日均) · tokenToolColor/orderedToolEntries 扩展 - 2f50c67 Recalculate stale accounting on launch · UsageSnapshotRefreshPolicy 启动自动校准 · DataService.requiresImmediateCodexRecalibration 后续将在 windows/ 目录用 Rust+JS 移植跨平台功能。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
Root cause
After upgrading to 0.1.44, the app loaded a revision-4 snapshot generated 24 seconds earlier. Startup only checked snapshot age, so it waited for the 300-second timer before running the revision-8 collector. During that window the UI displayed the old inflated 543,213,648-token total instead of the recalibrated value around 188 million.
User impact
When a future collector accounting revision changes, TokenStep now starts recalculation immediately on launch and shows its normal syncing state instead of waiting several minutes with stale accounting. Current-revision snapshots and empty/new installations do not enter a refresh loop.
Validation
./script/test_usage_recalibration_migration.sh./script/test_codex_cumulative_collector.sh./script/test_ccswitch_proxy_collector.sh./script/render_agent_work_card.shCFBundleShortVersionString=0.1.45andCFBundleVersion=0.1.45git diff --checkLocal SwiftPM XCTest execution is unavailable because this machine only has Command Line Tools and its PackageDescription linkage is incomplete; GitHub Actions on macOS-15 will run the full XCTest suite.