fix(claude): preserve claude-swap measurement timestamps - #3485
Conversation
Carry the optional source usageFetchedAt value into account snapshots so repeated reads of a cached measurement do not reset its age. Preserve valid usage and existing refresh-time behavior for older or malformed optional fields. Extracted from #3452; remaining last-good usage and source-selected switching stay separate. Co-authored-by: Persian ROss <37_privacy.blends@icloud.com>
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review in progressClawSweeper is reviewing this revision. This supersedes any previous blocked status. |
|
Codex review: needs maintainer review before merge. Reviewed September 7, 2026, 10:32 PM ET / September 8, 2026, 02:32 UTC. ClawSweeper reviewWhat this changesPreserve claude-swap’s optional measurement timestamp in account usage displays, with regression tests and documentation for the existing fallback. Merge readiness✅ Ready for maintainer review This remains a necessary, focused fix with no blocking findings. The recorded production CLI proof supports readiness, and neither fetched main nor the latest release contains the correction. Priority: P2 Review scores
Verification
How this fits togetherCodexBar reads account usage from the optional claude-swap executable and converts its JSON into shared account snapshots. Those snapshots supply usage values and measurement ages to the app and CLI dashboard. flowchart LR
A[claude-swap account JSON] --> B[Validate account rows]
B --> C{Valid measurement time?}
C -->|Yes| D[Use source time]
C -->|No| E[Use refresh time]
D --> F[Account usage snapshot]
E --> F
F --> G[App and CLI dashboard]
Before mergeNone. Agent review detailsSecurityNone. Review metrics
Technical reviewBest possible solution: Keep measurement age tied to the adapter’s source timestamp while preserving refresh-time behavior for older or malformed payloads. Do we have a high-confidence way to reproduce the issue? Yes: fetched main discards the measurement timestamp and assigns each projected snapshot the poll time. The supplied built-CLI comparison demonstrates that mechanism; this review verified it from source without executing it. Is this the best way to solve the issue? Yes: reusing the existing timestamp parser and shared projection fixes both app and CLI consumers without introducing another freshness model or changing adapter configuration. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 9810f24b0609. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (3 earlier review cycles) |
|
Validation on
Live built-binary proof used only an owned synthetic Exact-head CI passed every job, including both macOS shards, all three Linux builds, lint and the aggregate gate. The current PR head still matches the tested commit and is mergeable. This PR is land-ready; merge authorization remains with the orchestrator. The changelog is collected in #3488, which should land after this PR and the dependency update #3487. No real credentials, browser cookies or personal history were accessed for these proofs. Exact-head receipt tightened: after the unrelated main fast-forward, the committed d519d1a was rebuilt and the same built CLI and signed-app Settings smoke were repeated successfully. |
Repeated claude-swap refreshes displayed cached measurements as freshly updated because the parser discarded
usageFetchedAtand the projection always used the current clock. Preserve the optional source timestamp using the existing parser; older adapters and malformed optional timestamps keep their existing fallback without dropping valid usage windows.Extracted from #3452, with credit to @QuantIntellect. Its remaining last-known usage display and source-chosen account switching stay separate. This changes no adapter arguments, credential access, cache schema, or account activation behavior.
Validation: the regression fails on the baseline and passes after the fix, including fractional timestamps, repeated refreshes, exhausted-window retention, and malformed optional fields. Focused ClaudeSwap suites pass.
make checkpasses using macOS system Bash (Homebrew Bash stalled in the existing signing fixture's here-document). Independent P0–P2 review is clean. The full suite passed all 1,032 selections across 86 groups on the first attempt, with no retries or timeouts. Exact-head CI passes all jobs, including both macOS shards, all three Linux builds, lint and the aggregate gate.Live proof: the actual built CLI
dashboard --identity redactedwith an isolated synthetic adapter reproduced both baseline account timestamps being replaced by the poll time. The candidate preserves each distinct source measurement timestamp and the same quota values. The Developer ID–signed app also launched in an isolated synthetic profile and opened its real Settings menu through native automation. No real provider credentials, browser sessions, or personal history were used.The changelog entry will be carried in #3488 to keep sibling branches independent.