Skip to content

Port upstream 0.66.0: preserve Claude threshold warnings across identity gaps - #667

Closed
Finesssee wants to merge 1 commit into
port/upstream-0.66.0from
port/micro-0.66.0-claude-warning-identity-gaps
Closed

Finesssee wants to merge 1 commit into
port/upstream-0.66.0from
port/micro-0.66.0-claude-warning-identity-gaps

Conversation

@Finesssee

Copy link
Copy Markdown
Collaborator

Summary

Claude threshold toasts no longer repeat when the CLI/OAuth source alternates between samples that resolve an account email and samples that cannot (claude:cli:unknown / claude:oauth:unknown). Previously each identity key fired the same high/critical toast once, so alternating samples alerted twice per threshold.

Behavior (session and weekly lanes):

  • An unresolved sample with no fallback history adopts the most recently known account's fired-threshold state when the window resets_at is unchanged and usage has not dropped (remaining has not increased).
  • Otherwise it uses the unresolved scope, but keeps already-fired thresholds once that history has joined an account (shared_with_unresolved), so each threshold fires once across alternation.
  • A resolved sample moves the same lane's unresolved history onto the account (newest episode wins, session depleted/restored baseline follows). Discontinuities (reset change, usage drop, missing reset) start one independent episode.
  • Two different known accounts are never merged; an unresolved sample follows the most recently known account. Token accounts, organization-only and non-CLI/OAuth sources stay independent.

Implementation: new provider-agnostic rust/src/notifications/identity_gaps.rs (WarningScope, NotificationManager::resolve_warning_account); the Claude-specific classification lives in warning_identity.rs::gap_scope; notify_usage_thresholds resolves the toast account per lane before check_session_lane / check_and_notify. NotificationManager toasts are recorded instead of shown under cfg(test).

Upstream reference

  • v0.66.0 release bullet: "Claude: preserve quota-threshold warnings across repeated CLI account-identity gaps instead of re-alerting on each refresh (Claude OAuth quota-warning notifications re-fire every refresh cycle instead of once per threshold crossing steipete/CodexBar#3450)", commit 5f5529ac.
  • Tag-pinned sources: Sources/CodexBar/UsageStore+QuotaWarnings.swift (QuotaWarningState.resetsAt, sharedWithUnresolvedAccount, adoption block in handleQuotaWarningTransition), Sources/CodexBar/PredictivePaceWarnings.swift (reconcileClaudeQuotaWarningOwner, lastClaudeQuotaWarningAccount), Tests/CodexBarTests/ClaudeCredentialQuotaWarningTests.swift (checkIdentitySamples cases, ported as identity_gaps/tests.rs), docs/claude.md.

Ported / Deferred

Ported: session and weekly lanes, all five upstream identity-gap test sequences (with and without reset), plus session-depleted merge and independent-scope tests.
Deferred / differences:

  • Scoped weekly lanes (claude-weekly-scoped-*): this repo does not emit threshold toasts for extra rate windows yet, so nothing to bridge. The mechanism is keyed by window string and applies unchanged once such lanes are notified.
  • Hook path (dispatch_quota_hooks, emit_quota_threshold_hooks) intentionally unchanged: like upstream (hookAccountDiscriminator stays on the source key) it keeps per-source edge baselines whose first sample never fires.
  • Predictive pace warnings keep their existing per-identity keys (upstream commit does not change them).
  • Upstream observedAt ordering is replaced by an in-process observation sequence (samples are processed serially); the local level-based toast model (high/critical/exhausted, cleared below high) replaces upstream remaining-percent threshold lists, with remaining = 100 - used.

Validation

Toolchain cargo +1.98.0, E-core wrappers, slot-1.

  • cargo fmt --all: clean
  • cargo clippy --workspace --all-targets -- -D warnings: pass
  • cargo test -p codexbar (full): 2168 passed, 0 failed, 1 ignored (includes 21 notifications tests: 8 new)
  • cargo test -p codexbar-desktop-tauri: 462 passed, 1 failed: commands::tests::bootstrap_payload_exposes_every_provider_variant (provider catalog size vs active providers; untouched by this change, appears to be a base-branch issue)

Affected areas

  • Rust backend (rust/src/notifications)
  • Tauri shell (commands/providers.rs, commands/warning_identity.rs)
  • Frontend, tray, settings, float bar

UI proof

Not applicable (toast dedupe only; no tray/settings/React change). Unit-level proof: identity_gaps/tests.rs counts toasts per sequence.

@coderabbitai

coderabbitai Bot commented Sep 29, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 1efd48b7-0f48-46ed-ac28-6927d1f24475

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Finesssee

Copy link
Copy Markdown
Collaborator Author

Reviewed by Codex gpt-6-luna (xhigh); verified and validated by Claude

Thermo-nuclear review of this PR: no findings. Warning identity state stays isolated from provider fetching and Claude-specific scope classification stays in the shell. Nothing to fix, no commit. Codex did not run cargo; the diff was reviewed only.

@Finesssee

Copy link
Copy Markdown
Collaborator Author

Adversarial validation (lane-A) at fed9068

Review verdict: the branch at its published head matches the 0.66.0 audit PR-9 spec; local HEAD equals the remote head (fed9068b), so no re-merge or fix commit was needed. The last-known-Claude-account threshold tracking (reconcileClaudeQuotaWarningOwner semantics) preserves fired thresholds across repeated claude:cli:unknown identity gaps (adoption when resets_at is unchanged and remaining has not increased), keeps unresolved and resolved accounts' history separate without merging two known accounts, and starts one independent episode on discontinuities (reset change, remaining increase, missing reset). Toast notifications only; no tray/settings/React change.

Checks at fed9068 (CARGO_TARGET_DIR=W:\cargo-target\lane-a, jobs=4, RUST_TEST_THREADS=4):

  • cargo fmt --all --check: pass.
  • cargo clippy both manifests --all-targets -- -D warnings: only the 3 documented pre-existing main-drift findings; 0 in this PR's diff.
  • cargo test rust manifest: 2168 passed / 0 failed / 1 ignored (warning-identity focused: 7/0).
  • cargo test desktop manifest: only the documented Isolate bootstrap payload test from real settings #684 bootstrap_payload_exposes_every_provider_variant failure (env-dependent baseline on branches without Make the bootstrap catalog test hermetic (#684) #711; expected, hermetic fix lives on release/v0.70.0).

No new code was required; validation-only item.

@Finesssee

Copy link
Copy Markdown
Collaborator Author

Shipped in v0.70.0: this PR's head is included in main via #735 (merge commit 9d0a37a). Closing as integrated.

@Finesssee Finesssee closed this Oct 3, 2026
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