-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Refine Claude Team seat tier display #1965
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
Open
hegelty
wants to merge
1
commit into
steipete:main
Choose a base branch
from
hegelty:agent/claude-team-seat-tier
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
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
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,98 @@ | ||
| import Foundation | ||
| import Testing | ||
| @testable import CodexBar | ||
| @testable import CodexBarCore | ||
|
|
||
| struct ClaudeTeamTierRefinementTests { | ||
| private static func makeOAuthUsageResponse() throws -> OAuthUsageResponse { | ||
| let json = """ | ||
|
|
||
| { | ||
| "five_hour": { | ||
| "utilization": 7, | ||
| "resets_at": "2025-12-23T16:00:00.000Z" | ||
| }, | ||
| "seven_day": { | ||
| "utilization": 21, | ||
| "resets_at": "2025-12-29T23:00:00.000Z" | ||
| } | ||
| } | ||
|
|
||
| """ | ||
| return try ClaudeOAuthUsageFetcher._decodeUsageResponseForTesting(Data(json.utf8)) | ||
| } | ||
|
|
||
| @Test | ||
| func `oauth team login method is not refined when web extras are disabled`() async throws { | ||
| let usageResponse = try Self.makeOAuthUsageResponse() | ||
| let fetcher = ClaudeUsageFetcher( | ||
| browserDetection: BrowserDetection(cacheTTL: 0), | ||
| environment: [:], | ||
| dataSource: .oauth, | ||
| useWebExtras: false) | ||
|
|
||
| let fetchOverride: @Sendable (String, Bool) async throws -> OAuthUsageResponse = { _, _ in | ||
| usageResponse | ||
| } | ||
| let loadCredsOverride: @Sendable ( | ||
| [String: String], | ||
| Bool, | ||
| Bool) async throws -> ClaudeOAuthCredentials = { _, _, _ in | ||
| ClaudeOAuthCredentials( | ||
| accessToken: "access-token", | ||
| refreshToken: nil, | ||
| expiresAt: Date(timeIntervalSinceNow: 3600), | ||
| scopes: ["user:profile"], | ||
| rateLimitTier: "claude_team", | ||
| subscriptionType: nil) | ||
| } | ||
| let transport = ProviderHTTPTransportHandler { _ in | ||
| Issue.record("Claude web account lookup should not run when web extras are disabled") | ||
| throw URLError(.badServerResponse) | ||
| } | ||
|
|
||
| let snapshot = try await ClaudeWebHTTPTransport.$overrideForTesting.withValue(transport) { | ||
| try await ClaudeUsageFetcher.$fetchOAuthUsageOverride.withValue(fetchOverride) { | ||
| try await ClaudeUsageFetcher.$loadOAuthCredentialsOverride.withValue(loadCredsOverride) { | ||
| try await fetcher.loadLatestUsage(model: "sonnet") | ||
| } | ||
| } | ||
| } | ||
|
|
||
| #expect(snapshot.loginMethod == "Claude Team") | ||
| #expect(snapshot.accountEmail == nil) | ||
| } | ||
|
|
||
| @Test | ||
| func `generic team login method refines only when web account email matches`() { | ||
| let refined = ClaudeUsageFetcher._refinedLoginMethodForTesting( | ||
| current: "Claude Team", | ||
| currentAccountEmail: " Primary@Example.com ", | ||
| web: "Claude Team Premium", | ||
| webAccountEmail: "primary@example.com") | ||
|
|
||
| #expect(refined == "Claude Team Premium") | ||
| } | ||
|
|
||
| @Test | ||
| func `generic team login method ignores web tier from a different account`() { | ||
| let refined = ClaudeUsageFetcher._refinedLoginMethodForTesting( | ||
| current: "Claude Team", | ||
| currentAccountEmail: "primary@example.com", | ||
| web: "Claude Team Premium", | ||
| webAccountEmail: "other@example.com") | ||
|
|
||
| #expect(refined == "Claude Team") | ||
| } | ||
|
|
||
| @Test | ||
| func `generic team login method ignores web tier when account cannot be verified`() { | ||
| let refined = ClaudeUsageFetcher._refinedLoginMethodForTesting( | ||
| current: "Claude Team", | ||
| currentAccountEmail: nil, | ||
| web: "Claude Team Standard", | ||
| webAccountEmail: "primary@example.com") | ||
|
|
||
| #expect(refined == "Claude Team") | ||
| } | ||
| } |
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fresh evidence: this version now verifies only the email before accepting the web seat label. For a Claude user who belongs to multiple Team orgs under the same email, the web extras path can be pointed at or auto-select one organization while the primary CLI snapshot still carries another
accountOrganization; this guard then accepts the web tier and the merge keeps the primary organization, producing an Org A label with a Standard/Premium tier sourced from Org B. Compare the primary/web organization as well, or skip refinement when the primary org is known and differs.Useful? React with 👍 / 👎.