8000 fix(collector): keep records written during a sync with the observed account by InfinityPacer · Pull Request #18 · InfinityPacer/meterleaf · GitHub
[go: up one dir, main page]

Skip to content

fix(collector): keep records written during a sync with the observed account - #18

Merged
InfinityPacer merged 2 commits into
mainfrom
fix/collector-unattributed-race
Sep 28, 2026
Merged

InfinityPacer merged 2 commits into
mainfrom
fix/collector-unattributed-race

Conversation

@InfinityPacer
Copy link
Copy Markdown
Owner

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

  • After reading session files (and the statusline cache), the collector checks the login account again. If it is unchanged, the observed interval extends to that moment, so those records and the statusline sample stay with the account. A switch during the run still leaves them unattributed.
  • The unattributed account is no longer queued on its own. A push includes it only when pending usage still references it, so a brief intermediate state never reaches the server.
  • The overview leaves out accounts of unknown type that have no quota window and zero lifetime requests. The existing leftover card disappears. Accounts whose source reports no lifetime totals still show.

Verification

  • bun run typecheck
  • bun test tests: 344 pass, 0 fail
  • New regression test tests/collector-state.test.ts (a record written between the run start and the confirmation) fails on main and passes here. A second test covers an account switch during a run, where the record stays unattributed.
  • tests/account-order.test.ts covers the overview rule.

🤖 Generated with Claude Code

InfinityPacer and others added 2 commits September 28, 2026 09:48
…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>
@InfinityPacer
InfinityPacer merged commit 152698a into main Sep 28, 2026
2 checks passed
@InfinityPacer
InfinityPacer deleted the fix/collector-unattributed-race branch September 28, 2026 01:50
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

0