Show separate Codex usage pools
This commit is contained in:
1 parent
7ee88dfd9c
commit
00538cc19b
4 files changed
+119
-28
No files matched your search
@@ -891,6 +891,10 @@ data class UsageSnapshot(
|
||||
val setup: String,
|
||||
/** That machine's current label. */
|
||||
val setupName: String,
|
||||
/** Provider-specific billing pool, such as Codex's regular or Luna Reserve pool. */
|
||||
val limitId: String?,
|
||||
/** Provider-specific human-facing pool name, when supplied. */
|
||||
val limitName: String?,
|
||||
/**
|
||||
* What came back: "ok", "notLoggedIn", "unreachable" or "failed".
|
||||
*
|
||||
@@ -912,6 +916,8 @@ fun fetchUsage(settings: ServerSettings): List<UsageSnapshot> =
|
||||
provider = snapshot.getString("provider"),
|
||||
setup = snapshot.optString("setup"),
|
||||
setupName = snapshot.optString("setupName"),
|
||||
limitId = snapshot.optString("limitId").ifEmpty { null },
|
||||
limitName = snapshot.optString("limitName").ifEmpty { null },
|
||||
// Unknown to an older backend, and unknown is not "fine": defaulting to "ok" would
|
||||
// draw an empty card as a healthy one.
|
||||
state = snapshot.optString("state").ifEmpty { "failed" },
|
||||
|
||||
@@ -108,7 +108,7 @@ private fun UsageBody(state: LoadState<List<UsageSnapshot>>) {
|
||||
// read as a section of their own. Small and quiet, because the numbers
|
||||
// below are what somebody opened this to see.
|
||||
Text(
|
||||
"${snapshot.setupName.ifEmpty { snapshot.setup }} · ${snapshot.provider}",
|
||||
usageSectionTitle(snapshot),
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
)
|
||||
@@ -127,6 +127,20 @@ private fun UsageBody(state: LoadState<List<UsageSnapshot>>) {
|
||||
}
|
||||
}
|
||||
|
||||
private fun usageSectionTitle(snapshot: UsageSnapshot): String {
|
||||
val machine = snapshot.setupName.ifEmpty { snapshot.setup }
|
||||
val provider = snapshot.provider
|
||||
val pool =
|
||||
if (provider == "codex" && snapshot.limitId != "codex") {
|
||||
when (snapshot.limitName) {
|
||||
"gpt-reserve" -> "Luna Reserve"
|
||||
null -> snapshot.limitId
|
||||
else -> snapshot.limitName
|
||||
}
|
||||
} else null
|
||||
return listOfNotNull(machine, provider, pool).joinToString(" · ")
|
||||
}
|
||||
|
||||
/**
|
||||
* Anything other than numbers: why this machine has none.
|
||||
*
|
||||
|
||||
Reference in new issue
Block a user