-
Notifications
You must be signed in to change notification settings - Fork 1.8k
feat: hide untouched Antigravity model families #2875
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
Sources/CodexBarCore/Providers/Antigravity/AntigravityQuotaFamilyVisibility.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| import Foundation | ||
|
|
||
| /// Antigravity reports every model family the plan covers, so an account that only runs Gemini still | ||
| /// receives a Claude/GPT pair pinned at 0%. Display surfaces hide a family once no lane in it reports | ||
| /// known usage above zero. Menu bar and icon selection rank by highest used, so an untouched family | ||
| /// never wins there and this stays a display-only filter. | ||
| public enum AntigravityQuotaFamilyVisibility { | ||
| /// Window IDs that display surfaces should drop. Empty when every family is untouched, so a card | ||
| /// or widget right after a reset still renders its lanes instead of an empty list. | ||
| public static func idleWindowIDs(in snapshot: UsageSnapshot) -> Set<String> { | ||
| let windows = (snapshot.extraRateWindows ?? []) | ||
| .filter { AntigravityStatusSnapshot.isQuotaSummaryWindowID($0.id) } | ||
| guard !windows.isEmpty else { return [] } | ||
| let families = Dictionary(grouping: windows, by: Self.familyKey) | ||
| let idleFamilies = families.filter { _, lanes in | ||
| lanes.allSatisfy { !$0.usageKnown || $0.window.usedPercent <= 0 } | ||
| } | ||
| guard idleFamilies.count < families.count else { return [] } | ||
| return Set(idleFamilies.values.flatMap { lanes in lanes.map(\.id) }) | ||
| } | ||
|
|
||
| /// Classifies a lane the same way the widget row resolver does: the bucket ID carries the family and | ||
| /// survives a display-text change, so it wins over the rendered title. A group with neither signal | ||
| /// falls back to the title with its bucket suffix removed, which keeps an unfamiliar family's lanes | ||
| /// on one key so a reset lane never hides while its active sibling stays. | ||
| private static func familyKey(_ namedWindow: NamedRateWindow) -> String { | ||
| // Provider-specific by design: these tokens are Antigravity's own quota families, not CodexBar providers. | ||
| let id = namedWindow.id.lowercased() | ||
| if id.contains("gemini") { | ||
| return "gemini" | ||
| } | ||
| if id.contains("3p") || id.contains("third-party") { | ||
| return "claude-gpt" | ||
| } | ||
| let title = namedWindow.title.lowercased() | ||
| if title.contains("gemini") { | ||
| return "gemini" | ||
| } | ||
| if title.contains("claude") || title.contains("gpt") { | ||
| return "claude-gpt" | ||
| } | ||
| // Titles render as a group title plus a bucket title, so drop the bucket half to key per family. | ||
| for suffix in Self.bucketTitleSuffixes where title.hasSuffix(suffix) { | ||
| let stripped = String(title.dropLast(suffix.count)).trimmingCharacters(in: .whitespaces) | ||
| if !stripped.isEmpty { | ||
| return stripped | ||
| } | ||
| } | ||
| return title | ||
| } | ||
|
|
||
| private static let bucketTitleSuffixes = [" 5-hour", " weekly"] | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.