Skip to content

Conversation

@bcharleson
Copy link
Contributor

Problem

Cursor usage was always showing 100% used (0% left) regardless of actual usage.

Root Cause

The code was using breakdown.total as the denominator for calculating usage percentage, but breakdown.total represents the used amount (included + bonus credits consumed), not the plan limit.

This caused the calculation to be used/used = 100% instead of used/limit = actual%.

API Response Structure

"plan": {
  "used": 3035,        // credits consumed (cents)
  "limit": 40000,      // actual plan allowance (cents) ← should use this
  "breakdown": {
    "included": 3035,  // included credits used
    "bonus": 0,        // bonus credits used  
    "total": 3035      // total USED (included + bonus), NOT the limit!
  }
}

Fix

Changed to use plan.limit directly instead of breakdown.total ?? plan.limit.

Testing

  • Verified with CLI: now shows correct ~8% used instead of 100%
  • Verified in app UI: shows 92% left correctly

Initialize augmentCookieSourceRaw from UserDefaults in init, matching
the pattern used by other providers. Without this, the cookie source
always falls back to .auto after relaunch, causing users who select
.manual or .off to lose their preference.

Addresses Codex bot review feedback on PR steipete#120.
…ry pattern

- Remove early return for non-session cookies
- Now continues searching other browsers if session cookies not found
- Matches Cursor/Factory behavior: only returns when valid session cookies present
- Prevents false positives from random augmentcode.com cookies
- Add NextAuth and AuthJS cookie variants for broader compatibility
- Add comprehensive comment noting list may not be exhaustive
- Improve logging to help discover missing cookie names
- Log specific matched cookies when found
- Warn users when cookies exist but don't match known session cookies
- Request users report unrecognized cookies to improve detection

This addresses potential authentication failures if Augment uses
non-standard cookie names not in our current list.
- Remove CodexBar 2.app and CodexBar_Dev.app from git (should never be committed)
- Improve .gitignore to catch all app bundle variations (CodexBar_*.app/)
- Add development setup documentation (docs/DEVELOPMENT_SETUP.md)
- Add script to create stable dev signing certificate (Scripts/setup_dev_signing.sh)

This prevents build artifacts from polluting the repository and provides
guidance for reducing keychain permission prompts during development.
Upstream changes:
- feat(vertexai): Add Vertex AI provider with token cost tracking
- feat(vertex): Add direct token cost tracking with _vrtx_ detection
- fix(vertex): Disable direct token cost tracking to avoid double-counting
- docs: Add Vertex AI provider documentation
- style: Fix swiftformat and swiftlint violations

These changes add support for Google Cloud Vertex AI with gcloud OAuth
and token cost tracking from local Claude logs.
…ry pattern

- Remove early return for non-session cookies
- Now continues searching other browsers if session cookies not found
- Matches Cursor/Factory behavior: only returns when valid session cookies present
- Prevents false positives from random augmentcode.com cookies
- Add NextAuth and AuthJS cookie variants for broader compatibility
- Add comprehensive comment noting list may not be exhaustive
- Improve logging to help discover missing cookie names
- Log specific matched cookies when found
- Warn users when cookies exist but don't match known session cookies
- Request users report unrecognized cookies to improve detection

This addresses potential authentication failures if Augment uses
non-standard cookie names not in our current list.
- Detect session expiration (401) and trigger automatic recovery
- Open Augment dashboard in browser to re-authenticate
- Re-import cookies after browser updates them
- Send user notification if automatic recovery fails
- Use modern UserNotifications framework instead of deprecated NSUserNotification
- Improve error handling to try all endpoints before giving up

Fixes issue where users had to manually log out and log back in when session expires.
- Keepalive now runs regardless of whether Augment is enabled
- This ensures automatic session recovery even when provider is disabled
- Added 'Refresh Session' button to Augment menu for manual recovery
- No more need to manually log out and log back in!

The keepalive will:
1. Detect when session expires (401 errors)
2. Automatically open Augment in browser to re-authenticate
3. Re-import fresh cookies
4. Verify the new session is valid
5. Send notification if recovery fails
- Reduce keepalive check interval from 5 minutes to 1 minute for faster detection
- Reduce minimum refresh interval from 2 minutes to 1 minute
- Throw sessionExpired error on 401 responses instead of generic networkError
- Add immediate recovery trigger in UsageStore when sessionExpired detected
- Automatically recover sessions without manual logout/login required
- Add onSessionRecovered callback to AugmentSessionKeepalive
- Automatically refresh Augment usage after session recovery completes
- Ensures menu updates with fresh data after recovery
- Fixes issue where error message persisted after successful recovery
- Add AuggieCLIProbe to fetch credits from 'auggie account status'
- Add BinaryLocator.resolveAuggieBinary() to locate auggie CLI
- Update AugmentProviderDescriptor to try CLI first, fallback to web
- Parse billing cycle end date from CLI output
- Eliminates browser cookie prompts for users with auggie CLI installed
- Faster and more reliable than web scraping
- Add automatic session recovery when Augment cookies expire
- Add manual 'Refresh Session' button in menu bar
- Trigger usage refresh after successful session recovery
- Add CookieHeaderStore for encrypted cookie storage
- Add ZaiTokenStore for encrypted token storage
- Always-on keepalive monitoring for Augment sessions
- Replace print() statements with proper CodexBarLog.logger() calls
- Add static logger instances for augment-keepalive and session-keepalive
- Maintain backward compatibility with existing logger callback
- All 358 tests passing
Merging 9 commits from upstream (2cd166f..d0a79d9):
- Fix Claude OAuth scope errors
- Linux platform compatibility fixes
- Augment CLI macOS gating
- Browser cookie source detection hardening
- Non-macOS provider stub alignment

All changes are compatible with our Augment integration.
No conflicts expected - our changes are in different areas.

Upstream changes enhance cross-platform compatibility without
affecting our Augment session keepalive and cookie management.
…eepalive

This merge brings comprehensive Augment integration improvements:

🚀 CLI Integration
- Add support for 'auggie account status' CLI command
- Eliminates browser cookie prompts for CLI users
- Faster and more reliable than web scraping
- Automatic fallback to web if CLI unavailable
- Parses billing cycle end date from CLI output

🔄 Session Keepalive
- Automatic session recovery when Augment cookies expire
- Manual 'Refresh Session' button in menu
- Triggers usage refresh after successful recovery
- Always-on keepalive monitoring

🔐 Encrypted Credential Storage
- Secure keychain storage for cookies and tokens
- Automatic migration from old storage format

All 364 tests passing ✅
Ensures all 12 provider icons are verified in ProviderIconResourcesTests
- Merged upstream changes including new providers (Amp, JetBrains, Kimi, OpenCode, Synthetic)
- Updated ProviderIconResourcesTests to verify all 17 provider icons
- Fixed duplicate function in StatusItemController+Actions
- Cleaned up merge artifacts (duplicate files)
- Your Augment integration was already merged upstream (PR steipete#142)

New providers added upstream:
- Amp provider
- JetBrains AI provider
- Kimi provider (2 variants)
- OpenCode provider
- Synthetic provider

Major upstream improvements:
- Config-backed CLI output
- Provider sidebar redesign
- Beta update channel
- Keychain access gating
- File logging support
- Menu bar metric preferences
- Token account multi-account support
breakdown.total represents the USED amount (included + bonus credits consumed),
not the plan limit. This was causing usage to always show 100% (used/used)
instead of the correct percentage (used/limit).

API response structure:
- plan.used: credits consumed (in cents)
- plan.limit: actual plan allowance (in cents)
- breakdown.total: same as used, NOT the limit
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5179e60a26

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +156 to +158
case .daily:
// Check every hour for daily mode
return 3600

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Ensure daily keepalive actually fires

With daily mode, SessionKeepaliveManager.calculateCheckInterval polls on a fixed 3600‑second cadence, while shouldRefreshSession only triggers when the current time is within 5 minutes of the scheduled hour/minute. If the task starts at a minute offset more than 5 minutes away from the target time, each hourly check will repeat that offset and never enter the 5‑minute window (e.g., start at 10:10 for a 10:00 schedule), so the daily refresh never runs. Consider computing the next scheduled fire time (and sleeping until then) or polling more frequently so the scheduled window is guaranteed to be hit.

Useful? React with 👍 / 👎.

Prevents 'resource fork, Finder information, or similar detritus not allowed' errors during code signing by using ditto --norsrc to copy the app bundle and strip all extended attributes and resource forks before final signing.
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