Conversation
|
| do { try apiKeys.set(nil, for: provider) } | ||
| catch { | ||
| apiConnectionErrors[provider] = APIKeySession.message(for: error) | ||
| return | ||
| } |
There was a problem hiding this comment.
Disconnect retains a pending key
If saving a new key fails and Keychain deletion also fails when the user selects Disconnect, this early return leaves the submitted key in memory. The app still offers “Retry saving key,” which can later save a key the user tried to discard. Clear the pending entry on Disconnect even if the existing connection must remain intact.
Prompt To Fix With AI
This is a comment left during a code review.
Path: Sources/MeterUsage/Core/AppCoordinator.swift
Line: 360-364
Comment:
**Disconnect retains a pending key**
If saving a new key fails and Keychain deletion also fails when the user selects Disconnect, this early return leaves the submitted key in memory. The app still offers “Retry saving key,” which can later save a key the user tried to discard. Clear the pending entry on Disconnect even if the existing connection must remain intact.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.| func retrySavedAPIKey(_ provider: Provider) async { | ||
| guard provider.isOrganizationAPI, !isDemoMode, | ||
| !testingAPIProviders.contains(provider), | ||
| let source = usageSources.first(where: { $0.provider == provider }) else { return } | ||
| if let pendingKey = pendingAPIKeys[provider] { | ||
| await connectAPI(provider, key: pendingKey) | ||
| return | ||
| } | ||
| do { try apiKeys.restore(provider) } |
There was a problem hiding this comment.
Queued recovery undoes Disconnect
If a saved-key read failed at launch and a launcher key is also present, the user can select Restore saved connection and then Disconnect before the restore task runs. This method does not check whether Disconnect invalidated that task. It can fall back to the launcher key and reconnect after the user disconnected.
Prompt To Fix With AI
This is a comment left during a code review.
Path: Sources/MeterUsage/Core/AppCoordinator.swift
Line: 372-380
Comment:
**Queued recovery undoes Disconnect**
If a saved-key read failed at launch and a launcher key is also present, the user can select Restore saved connection and then Disconnect before the restore task runs. This method does not check whether Disconnect invalidated that task. It can fall back to the launcher key and reconnect after the user disconnected.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.ce8d21e to
86be289
Compare
What changed
OpenAI and Anthropic organization API monitors show reported spend and tokens for today and the last 30 UTC calendar days, separate from coding-assistant quotas and local estimates. Settings provides masked key entry, endpoint tests, saved connections in MeterUsage-owned macOS Keychain items, and recovery without re-entering an unreadable saved key. OpenAI API spend also appears in the side notch without a quota percentage.
This branch is rebased onto
mainat79a6cc9, preserving its accent themes and Codex pricing changes. Successful Disconnect now invalidates queued saved-key recovery, so a delayed restore cannot reconnect using a launcher key.Before and after
Existing synthetic side-notch fixtures from the original feature implementation: Codex and OpenAI API. These are historical captures, not runtime proof for the rebased build. No new runtime capture was taken for this coordinator fix.
Verification
Validated source:
86be289a80a655e761ffdfe1b21c0d2960f5b778, against base79a6cc90a9f496ad6d0c81b37789c511714dfe11.swift buildpassed,swift testpassed all 412 tests, andbash Scripts/make-app.shproduced the release bundle and passed strict signature verification.986b24a57100d5672bf87b0e0e0f850bca9adbf347ee1452b5ca1c0cbaa3f34c.git diff --checkpassed. GitHub reports the rebased branch has no base conflicts.Risks or follow-up
86be289), including Build and Test. Independent review completed against the current base/head and confirmed the queued-recovery fix and preservation of both sides during rebase. It returned a fix-then-ship verdict for the separate failed-delete finding below.python3 scripts/documentation.py --checkcould not run because that script is absent from the repository.Model(s): GPT-6.1-Sol (current update and independent review)
Harness: T3 Code through Codex