Repository navigation
fix(collector): keep records written during a sync with the observed account - #18
Merged
Merged
Conversation
…account A sync notes the login account at its start and then reads session files. Claude Code keeps writing meanwhile, so records stamped after the start fell outside the observed interval and were briefly filed under "未归属". The collector also queued that account on its own, so it reached the server and stayed there as an empty card after the records moved back next run. The collector now confirms the login account again after reading. When it has not changed, the interval extends to that moment and the records (and the statusline quota sample) stay with the account. A switch during the run keeps them unattributed as before. The unattributed account is no longer queued by itself; a push includes it only when pending usage still references it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An account of unknown type with no quota window and zero lifetime requests has nothing to show. The overview no longer lists it, so a leftover "未归属" card disappears without manual archiving. Accounts whose source reports no lifetime totals still show. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Problem
An empty 「未归属」 account card appeared on the overview with zero usage.
A collector sync records the login account at its start, then reads session files. Claude Code keeps writing during that read, so a record stamped a second or two after the start fell outside the observed interval and was filed as unattributed. The collector also queued the unattributed account by itself, so it reached the server. The next run moved the records back to the real account, but the account record stayed, leaving a card with 0 tokens and 0 requests. It only shows up under heavy use, when a record lands inside that window. The collector log also showed repeated 「无法确定状态栏额度采样时的登录账户」 for the same reason.
Behavior
Verification
bun run typecheckbun test tests: 344 pass, 0 failtests/collector-state.test.ts(a record written between the run start and the confirmation) fails onmainand passes here. A second test covers an account switch during a run, where the record stays unattributed.tests/account-order.test.tscovers the overview rule.🤖 Generated with Claude Code