Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 46eaf23711
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| primary = chat | ||
| secondary = nil |
There was a problem hiding this comment.
Keep Copilot chat quota in the chat slot
When premium_interactions is missing, this branch moves the chat window into primary and clears secondary. The menu UI labels primary as Copilot sessionLabel ("Premium") and secondary as weeklyLabel ("Chat") in MenuDescriptor/CopilotProviderDescriptor, so free-plan accounts end up seeing chat usage mislabeled as Premium. Preserve chat in secondary (or make labels dynamic) so the displayed quota type stays accurate.
Useful? React with 👍 / 👎.
46eaf23 to
2948e25
Compare
2948e25 to
4d8a0c2
Compare
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4d8a0c2dcf
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| let entitlement = max(0, monthly ?? 0) | ||
| let remaining = max(0, limited ?? monthly ?? 0) | ||
| let percentRemaining: Double = if entitlement > 0 { | ||
| max(0, min(100, (remaining / entitlement) * 100)) |
There was a problem hiding this comment.
Avoid treating limited-only quotas as fully exhausted
If the API returns limited_user_quotas without monthly_quotas, this code sets entitlement to 0 and then forces percentRemaining to 0, which later becomes usedPercent = 100. In that scenario users with non-zero limited quota are displayed as fully depleted. Because both fields are decoded as optional, this input is already considered valid by the parser, so the snapshot builder should avoid emitting a 100%-used window when no denominator is available.
Useful? React with 👍 / 👎.
| primary = nil | ||
| secondary = chat |
There was a problem hiding this comment.
Set primary window when Copilot only reports chat quota
When premium quota is absent but chat quota exists, this branch stores chat in secondary and leaves primary nil. Downstream paths that rely on snapshot.primary (for example UsageStore.handleSessionQuotaTransition) then skip processing entirely, so chat-only Copilot accounts lose quota-transition behavior despite having usage data. Populating primary in this fallback avoids that regression.
Useful? React with 👍 / 👎.
e9fbae3 to
a239f0f
Compare
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a239f0f472
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Sources/CodexBar/UsageStore.swift
Outdated
| func handleSessionQuotaTransition(provider: UsageProvider, snapshot: UsageSnapshot) { | ||
| guard let primary = snapshot.primary else { return } | ||
| let currentRemaining = primary.remainingPercent | ||
| guard let sessionWindow = snapshot.primary ?? snapshot.secondary else { return } |
There was a problem hiding this comment.
Keep session notifications tied to primary quota only
This fallback now treats secondary as the session window when primary is missing, which happens for Copilot chat-only plans after this change (CopilotUsageFetcher explicitly sets primary = nil, secondary = chat). In that case, monthly chat quota changes will trigger "session depleted/restored" notifications, so users with session notifications enabled can receive misleading alerts for a non-session limit.
Useful? React with 👍 / 👎.
a239f0f to
7d45086
Compare
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7d45086401
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| let entitlement = max(0, monthly ?? limited ?? 0) | ||
| let remaining = max(0, limited ?? monthly ?? 0) |
There was a problem hiding this comment.
Avoid forcing 0% usage when monthly quota is missing
In makeQuotaSnapshot, the monthly == nil && limited != nil path sets both entitlement and remaining from limited, which guarantees percentRemaining == 100 and therefore reports usedPercent == 0 for every such response. That fabricates an always-unused window for free-plan payloads that only include limited_user_quotas, so the menu/highest-usage ranking can underreport real pressure and skip warning scenarios.
Useful? React with 👍 / 👎.
| primary = nil | ||
| secondary = chatWindow |
There was a problem hiding this comment.
Map chat-only Copilot quota into primary window
When premium data is absent, this branch leaves primary nil and stores chat quota only in secondary. The session notification pipeline (UsageStore.handleSessionQuotaTransition) is keyed to snapshot.primary, so chat-only Copilot accounts never produce depleted/restored session transitions even when their only quota window changes state. Falling back to chat as primary (or adding a transition fallback) avoids disabling notifications for free-plan users.
Useful? React with 👍 / 👎.
GitHub's /copilot_internal/user API returns null for assigned_date and quota_reset_date on trial/free Copilot plans, causing a DecodingError.valueNotFound when decoding the JSON response. This change makes both fields optional (String?) to handle null values gracefully. Fixes steipete#162 (cherry picked from commit 8a470bd)
7d45086 to
e642584
Compare
Summary
This PR fixes Copilot usage handling for free-plan accounts where the API response shape differs from paid-plan payloads.
Related Issue
possibly fixes #162
What changed
monthly_quotaslimited_user_quotasWhy
Free-plan Copilot responses can omit usable
quota_snapshots, which previously caused incorrect UI output (for example:Copilot error: The data couldn’t be read because it is missing).Note
AI-assisted, tested locally.