Update and centralize TUI subscription labels (#49079)

## What changed

Use a shared subscription label mapping for status and analytics views. Rename
`Pro Extra` to `Pro 200`, `Pro Standard` to `Pro 100`, and `Pro Max` to `Pro 500`,
while preserving the existing differences between status and analytics labels
for other plans.

## Testing

Update the status plan-label test expectations for the three Pro tiers.

GitOrigin-RevId: 47af1e7d56ef9f7701caff8af315f530087920b8
This commit is contained in:
Eric Traut
2026-09-28 20:59:25 +00:00
committed by copyberry
parent 011f803f3c
commit fe50d010e2
5 changed files with 53 additions and 78 deletions
+4 -21
View File
@@ -102,27 +102,10 @@ impl AnalyticsView {
])
.areas(inner);
let account = self.live.as_ref().and_then(|live| live.account_label());
let plan = self.account.ready().map(|plan| {
use codex_protocol::account::PlanType;
match plan {
PlanType::Free => "Free",
PlanType::Go => "Go",
PlanType::Plus => "Plus",
PlanType::Pro => "Pro Extra",
PlanType::ProLite => "Pro Standard",
PlanType::ProMax => "Pro Max",
PlanType::Team
| PlanType::Business
| PlanType::SelfServeBusinessProLite
| PlanType::SelfServeBusinessUsageBased => "Business",
PlanType::Enterprise
| PlanType::Ent26
| PlanType::EnterpriseCbpAutomation
| PlanType::EnterpriseCbpUsageBased => "Enterprise",
PlanType::Edu | PlanType::EduPlus | PlanType::EduPro => "Education",
PlanType::Unknown => "Account",
}
});
let plan = self
.account
.ready()
.map(|plan| crate::subscription::SubscriptionDisplay::Analytics.label(*plan));
let heading = Line::from(vec![
plan.map(|plan| format!("Usage · {plan}"))
.unwrap_or_else(|| "Usage".into())
+4 -21
View File
@@ -56,27 +56,10 @@ impl AnalyticsView {
));
}
}
let plan = self.account.ready().map(|plan| {
use codex_protocol::account::PlanType;
match plan {
PlanType::Free => "Free",
PlanType::Go => "Go",
PlanType::Plus => "Plus",
PlanType::Pro => "Pro Extra",
PlanType::ProLite => "Pro Standard",
PlanType::ProMax => "Pro Max",
PlanType::Team
| PlanType::Business
| PlanType::SelfServeBusinessProLite
| PlanType::SelfServeBusinessUsageBased => "Business",
PlanType::Ent26
| PlanType::EnterpriseCbpAutomation
| PlanType::EnterpriseCbpUsageBased
| PlanType::Enterprise => "Enterprise",
PlanType::Edu | PlanType::EduPlus | PlanType::EduPro => "Education",
PlanType::Unknown => "Account",
}
});
let plan = self
.account
.ready()
.map(|plan| crate::subscription::SubscriptionDisplay::Analytics.label(*plan));
if let Some(plan) = plan {
lines.push(center(
plan.set_style(secondary_style()).into(),
+1
View File
@@ -209,6 +209,7 @@ mod status;
mod status_indicator_widget;
mod streaming;
mod style;
mod subscription;
mod system_motion;
mod task_mentions;
mod temporary_structured_request;
+6 -36
View File
@@ -98,27 +98,9 @@ pub(crate) fn compose_account_display(
}
pub(crate) fn plan_type_display_name(plan_type: PlanType) -> String {
if plan_type == PlanType::EnterpriseCbpAutomation {
"Enterprise (Automation)".to_string()
} else if plan_type == PlanType::SelfServeBusinessProLite {
"Business Premium".to_string()
} else if plan_type.is_team_like() {
"Business".to_string()
} else if plan_type.is_business_like() {
"Enterprise".to_string()
} else if plan_type == PlanType::Pro {
"Pro Extra".to_string()
} else if plan_type == PlanType::ProMax {
"Pro Max".to_string()
} else if plan_type == PlanType::ProLite {
"Pro Standard".to_string()
} else if plan_type == PlanType::EduPlus {
"Edu Plus".to_string()
} else if plan_type == PlanType::EduPro {
"Edu Pro".to_string()
} else {
title_case(format!("{plan_type:?}").as_str())
}
crate::subscription::SubscriptionDisplay::Status
.label(plan_type)
.to_string()
}
pub(crate) fn format_tokens_compact(value: i64) -> String {
@@ -198,18 +180,6 @@ pub(crate) fn format_reset_timestamp(
}
}
fn title_case(s: &str) -> String {
if s.is_empty() {
return String::new();
}
let mut chars = s.chars();
let Some(first) = chars.next() else {
return String::new();
};
let rest = chars.as_str().to_ascii_lowercase();
first.to_uppercase().collect::<String>() + &rest
}
#[cfg(test)]
mod tests {
use super::*;
@@ -233,9 +203,9 @@ mod tests {
(PlanType::Free, "Free"),
(PlanType::Go, "Go"),
(PlanType::Plus, "Plus"),
(PlanType::Pro, "Pro Extra"),
(PlanType::ProLite, "Pro Standard"),
(PlanType::ProMax, "Pro Max"),
(PlanType::Pro, "Pro 200"),
(PlanType::ProLite, "Pro 100"),
(PlanType::ProMax, "Pro 500"),
(PlanType::Team, "Business"),
(PlanType::SelfServeBusinessUsageBased, "Business"),
(PlanType::Business, "Enterprise"),
+38
View File
@@ -0,0 +1,38 @@
//! Subscription labels for TUI surfaces, preserving status-specific plan detail.
use codex_protocol::account::PlanType;
pub(crate) enum SubscriptionDisplay {
Status,
Analytics,
}
impl SubscriptionDisplay {
pub(crate) fn label(&self, plan: PlanType) -> &'static str {
match (plan, self) {
(PlanType::Free, _) => "Free",
(PlanType::Go, _) => "Go",
(PlanType::Plus, _) => "Plus",
(PlanType::Pro, _) => "Pro 200",
(PlanType::ProLite, _) => "Pro 100",
(PlanType::ProMax, _) => "Pro 500",
(PlanType::Team | PlanType::SelfServeBusinessUsageBased, _) => "Business",
(PlanType::Business, Self::Status) => "Enterprise",
(PlanType::SelfServeBusinessProLite, Self::Status) => "Business Premium",
(PlanType::Business | PlanType::SelfServeBusinessProLite, Self::Analytics) => {
"Business"
}
(PlanType::EnterpriseCbpAutomation, Self::Status) => "Enterprise (Automation)",
(PlanType::EnterpriseCbpAutomation, Self::Analytics)
| (PlanType::Enterprise | PlanType::Ent26 | PlanType::EnterpriseCbpUsageBased, _) => {
"Enterprise"
}
(PlanType::Edu, Self::Status) => "Edu",
(PlanType::EduPlus, Self::Status) => "Edu Plus",
(PlanType::EduPro, Self::Status) => "Edu Pro",
(PlanType::Edu | PlanType::EduPlus | PlanType::EduPro, Self::Analytics) => "Education",
(PlanType::Unknown, Self::Status) => "Unknown",
(PlanType::Unknown, Self::Analytics) => "Account",
}
}
}