mirror of
https://github.com/tiennm99/ccs.git
synced 2026-10-11 12:09:03 +00:00
fix(bar): distinguish native Codex subscription rows (#1552)
Distinguishes native Codex subscription rows from pool rows in the bar menu.
This commit is contained in:
1 parent
50f136a1f0
commit
ba7a2abb79
3 files changed
+19
-10
No files matched your search
@@ -401,7 +401,7 @@ struct BarRowView: View {
|
|||||||
/// A native first-party subscription (Claude Code / Codex) — drives the
|
/// A native first-party subscription (Claude Code / Codex) — drives the
|
||||||
/// distinct "subscription" badge + indigo provider chip.
|
/// distinct "subscription" badge + indigo provider chip.
|
||||||
private var isNativeSubscription: Bool {
|
private var isNativeSubscription: Bool {
|
||||||
BarFormatting.isNativeSubscription(provider: row.provider)
|
BarFormatting.isNativeSubscription(row)
|
||||||
}
|
}
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
|
|||||||
@@ -906,13 +906,19 @@ check(
|
|||||||
BarFormatting.providerLabel("codex") == "Codex", "native: providerLabel maps codex -> 'Codex'")
|
BarFormatting.providerLabel("codex") == "Codex", "native: providerLabel maps codex -> 'Codex'")
|
||||||
check(BarFormatting.providerLabel("agy") == "agy", "native: providerLabel passes CLIProxy keys through")
|
check(BarFormatting.providerLabel("agy") == "agy", "native: providerLabel passes CLIProxy keys through")
|
||||||
check(
|
check(
|
||||||
BarFormatting.isNativeSubscription(provider: "claude-code"),
|
BarFormatting.isNativeSubscription(
|
||||||
|
BarSummaryRow(accountId: "claude-code", provider: "claude-code")),
|
||||||
"native: claude-code is a native subscription")
|
"native: claude-code is a native subscription")
|
||||||
check(
|
check(
|
||||||
BarFormatting.isNativeSubscription(provider: "codex"), "native: codex is a native subscription")
|
BarFormatting.isNativeSubscription(BarSummaryRow(accountId: "codex", provider: "codex")),
|
||||||
|
"native: codex is a native subscription")
|
||||||
check(
|
check(
|
||||||
!BarFormatting.isNativeSubscription(provider: "agy"),
|
!BarFormatting.isNativeSubscription(BarSummaryRow(accountId: "agy-a", provider: "agy")),
|
||||||
"native: agy (CLIProxy pool) is NOT a native subscription")
|
"native: agy (CLIProxy pool) is NOT a native subscription")
|
||||||
|
check(
|
||||||
|
!BarFormatting.isNativeSubscription(
|
||||||
|
BarSummaryRow(accountId: "pool-codex-oauth-1", provider: "codex")),
|
||||||
|
"native: codex CLIProxy pool row is NOT a native subscription")
|
||||||
|
|
||||||
// (N6) Grouping: a mixed list splits into native subscriptions (top) and pool
|
// (N6) Grouping: a mixed list splits into native subscriptions (top) and pool
|
||||||
// accounts, preserving backend order within each group.
|
// accounts, preserving backend order within each group.
|
||||||
@@ -922,17 +928,19 @@ do {
|
|||||||
BarSummaryRow(
|
BarSummaryRow(
|
||||||
accountId: "claude-code", provider: "claude-code", quotaPercentage: 40, quotaStatus: "ok"),
|
accountId: "claude-code", provider: "claude-code", quotaPercentage: 40, quotaStatus: "ok"),
|
||||||
BarSummaryRow(accountId: "pool-b", provider: "ghcp", quotaStatus: "unsupported"),
|
BarSummaryRow(accountId: "pool-b", provider: "ghcp", quotaStatus: "unsupported"),
|
||||||
|
BarSummaryRow(
|
||||||
|
accountId: "pool-codex-oauth-1", provider: "codex", quotaPercentage: 65, quotaStatus: "ok"),
|
||||||
BarSummaryRow(accountId: "codex", provider: "codex", quotaPercentage: 52, quotaStatus: "ok"),
|
BarSummaryRow(accountId: "codex", provider: "codex", quotaPercentage: 52, quotaStatus: "ok"),
|
||||||
]
|
]
|
||||||
let parts = BarFormatting.partitionSubscriptions(mixed)
|
let parts = BarFormatting.partitionSubscriptions(mixed)
|
||||||
check(parts.subscriptions.count == 2, "native: partition pulls 2 subscriptions")
|
check(parts.subscriptions.count == 2, "native: partition pulls 2 subscriptions")
|
||||||
check(parts.pool.count == 2, "native: partition leaves 2 pool accounts")
|
check(parts.pool.count == 3, "native: partition leaves 3 pool accounts")
|
||||||
check(
|
check(
|
||||||
parts.subscriptions.map { $0.provider } == ["claude-code", "codex"],
|
parts.subscriptions.map { $0.provider } == ["claude-code", "codex"],
|
||||||
"native: subscriptions keep backend order (claude-code, codex)")
|
"native: subscriptions keep backend order (claude-code, codex)")
|
||||||
check(
|
check(
|
||||||
parts.pool.map { $0.provider } == ["agy", "ghcp"],
|
parts.pool.map { $0.id } == ["agy:pool-a", "ghcp:pool-b", "codex:pool-codex-oauth-1"],
|
||||||
"native: pool keeps backend order (agy, ghcp)")
|
"native: pool keeps backend order and retains CLIProxy codex row")
|
||||||
}
|
}
|
||||||
|
|
||||||
// (N7) Pool-only list does NOT get split (single "Accounts" header path): both
|
// (N7) Pool-only list does NOT get split (single "Accounts" header path): both
|
||||||
|
|||||||
@@ -165,8 +165,9 @@ public enum BarFormatting {
|
|||||||
/// Code or Codex plan) rather than a CLIProxy-managed OAuth pool account. Drives
|
/// Code or Codex plan) rather than a CLIProxy-managed OAuth pool account. Drives
|
||||||
/// the "Subscriptions" grouping + badge so a user reads "this is MY plan quota",
|
/// the "Subscriptions" grouping + badge so a user reads "this is MY plan quota",
|
||||||
/// not one of the rotating pool credentials.
|
/// not one of the rotating pool credentials.
|
||||||
public static func isNativeSubscription(provider: String) -> Bool {
|
public static func isNativeSubscription(_ row: BarSummaryRow) -> Bool {
|
||||||
provider == "claude-code" || provider == "codex"
|
(row.provider == "claude-code" && row.accountId == "claude-code")
|
||||||
|
|| (row.provider == "codex" && row.accountId == "codex")
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Friendly product label for a provider key. Native subscription keys read as
|
/// Friendly product label for a provider key. Native subscription keys read as
|
||||||
@@ -189,7 +190,7 @@ public enum BarFormatting {
|
|||||||
var subs: [BarSummaryRow] = []
|
var subs: [BarSummaryRow] = []
|
||||||
var pool: [BarSummaryRow] = []
|
var pool: [BarSummaryRow] = []
|
||||||
for row in rows {
|
for row in rows {
|
||||||
if isNativeSubscription(provider: row.provider) {
|
if isNativeSubscription(row) {
|
||||||
subs.append(row)
|
subs.append(row)
|
||||||
} else {
|
} else {
|
||||||
pool.append(row)
|
pool.append(row)
|
||||||
|
|||||||
Reference in new issue
Block a user