Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.
Rust agentai-agentapplecomputer-usecomputer-use-agentcontainerizationcuadesktop-automationhacktoberfestlumemacosmanusoperatorswiftvirtualizationvirtualization-frameworkwindowswindows-sandbox
spaces: show 'Teams until <date>' and Resume plan after a cancel (CUA-1710) (#5272)
Francesco Bonaccia6b8ef0aa730
diff --git a/apps/cua-spaces-desktop/src/native/generated/cua_spaces_ffi.ts b/apps/cua-spaces-desktop/src/native/generated/cua_spaces_ffi.tsindex a116b005a7..9fbd19e79c 100644--- a/apps/cua-spaces-desktop/src/native/generated/cua_spaces_ffi.ts+++ b/apps/cua-spaces-desktop/src/native/generated/cua_spaces_ffi.ts@@ -36055,7 +36055,8 @@ export type AppTeamInput = {*/role: string,/**- * `free`, `teams`, ...+ * `free`, `teams`, ... After the plan is cancelled but while it still+ * runs, `teams@<RFC 3339 end>`.*/plan: string,/**diff --git a/libs/cua/crates/cua-host/src/spaces_api.rs b/libs/cua/crates/cua-host/src/spaces_api.rsindex 906e369f38..b06ba7d86c 100644--- a/libs/cua/crates/cua-host/src/spaces_api.rs+++ b/libs/cua/crates/cua-host/src/spaces_api.rs@@ -29,6 +29,10 @@ pub struct ApiOrg {/// `free`, `pro`, `teams`, ...#[serde(default)]pub plan: String,+ /// When a cancelled plan that is still running ends (RFC 3339). Empty+ /// while the plan renews.+ #[serde(default)]+ pub plan_ends_at: Option<String>,#[serde(default)]pub status: String,#[serde(default)]diff --git a/libs/cua/crates/cua-spaces-app-core/src/teams.rs b/libs/cua/crates/cua-spaces-app-core/src/teams.rsindex 858a2e2428..0c4726d986 100644--- a/libs/cua/crates/cua-spaces-app-core/src/teams.rs+++ b/libs/cua/crates/cua-spaces-app-core/src/teams.rs@@ -28,6 +28,9 @@ pub const INVITED: &str = "(Invited)";/// The button that opens the account app's team page.pub const MANAGE_TEAM: &str = "Manage team";+/// The button on a cancelled plan; the account app (Billing) renews it in Stripe.+pub const RESUME_PLAN: &str = "Resume plan";+/// The button that opens the account app's billing page.pub const MANAGE_BILLING: &str = "Billing and plans";@@ -55,7 +58,8 @@ pub struct TeamInput {pub name: String,/// The account's role in it.pub role: String,- /// `free`, `teams`, ...+ /// `free`, `teams`, ... After the plan is cancelled but while it still+ /// runs, `teams@<RFC 3339 end>`.pub plan: String,/// Paid seats.pub seats: i64,@@ -135,12 +139,40 @@ fn role_label(role: &str) -> String {}}-fn plan_label(plan: &str) -> &'static str {- match plan {- "teams" | "team" => "Teams plan",- "pro" => "Pro plan",+/// `plan` and, when the plan is cancelled but still running, its end date.+fn split_plan(plan: &str) -> (&str, Option<String>) {+ match plan.split_once('@') {+ Some((p, ends)) => (p, short_date(ends)),+ None => (plan, None),+ }+}++/// `2026-11-14T12:00:00Z` as `14 Nov 2026` (the date as the API wrote it).+fn short_date(rfc3339: &str) -> Option<String> {+ const MONTHS: [&str; 12] = [+ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec",+ ];+ let mut d = rfc3339.get(..10)?.split('-');+ let year = d.next()?.parse::<u32>().ok()?;+ let month = d.next()?.parse::<usize>().ok()?;+ let day = d.next()?.parse::<u32>().ok()?;+ Some(format!(+ "{day} {} {year}",+ MONTHS.get(month.checked_sub(1)?)?+ ))+}++fn plan_label(plan: &str) -> String {+ let (plan, ends) = split_plan(plan);+ let name = match plan {+ "teams" | "team" => "Teams",+ "pro" => "Pro",// An unknown plan is Free.- _ => "Free plan",+ _ => return "Free plan".into(),+ };+ match ends {+ Some(date) => format!("{name} until {date}"),+ None => format!("{name} plan"),}}@@ -214,6 +246,13 @@ pub fn rows(input: &TeamsInput) -> Vec<SettingsRow> {plan_label(&t.plan)));out.push(head);+ if split_plan(&t.plan).1.is_some() {+ let mut note = row(&format!("team:{}:ending", t.id), Text, "Plan ends");+ note.value = Some("The team keeps working until then".into());+ note.button = Some(RESUME_PLAN.into());+ note.link_url = Some(format!("{app}/billing"));+ out.push(note);+ }for (i, m) in t.members.iter().enumerate() {let mut r = row(&format!("team:{}:member:{i}", t.id), Text, &m.email);r.value = Some(role_label(&m.role));@@ -292,6 +331,32 @@ mod tests {assert_eq!(flat[3], ("[email protected]".into(), Some("(Invited)".into())));}+ #[test]+ fn a_cancelled_plan_says_when_it_ends_and_offers_resume() {+ let mut t = team("Acme Inc", "acme");+ t.plan = "teams@2026-11-14T12:00:00Z".into();+ let rows = rows(&input(vec![t]));+ assert_eq!(+ rows[0].value.as_deref(),+ Some("Owner \u{b7} Teams until 14 Nov 2026 \u{b7} 3 seats")+ );+ let ending = rows.iter().find(|r| r.label == "Plan ends").unwrap();+ assert_eq!(+ ending.value.as_deref(),+ Some("The team keeps working until then")+ );+ assert_eq!(ending.button.as_deref(), Some(RESUME_PLAN));+ assert_eq!(+ ending.link_url.as_deref(),+ Some("https://app.cua.ai/billing")+ );+ assert_eq!(+ plan_label("pro@2026-02-03T00:00:00Z"),+ "Pro until 3 Feb 2026"+ );+ assert_eq!(plan_label("teams@garbage"), "Teams plan");+ }+#[test]fn the_name_falls_back_to_the_alias() {let rows = rows(&input(vec![team("", "acme")]));diff --git a/libs/cua/crates/cua-spaces-ffi/src/app_core.rs b/libs/cua/crates/cua-spaces-ffi/src/app_core.rsindex b656cade7d..3d32bb9186 100644--- a/libs/cua/crates/cua-spaces-ffi/src/app_core.rs+++ b/libs/cua/crates/cua-spaces-ffi/src/app_core.rs@@ -1988,7 +1988,12 @@ fn teams_input(s: cua_host::spaces_api::TeamsSnapshot, account_app_url: String)alias: t.org.alias,name: t.org.name,role: t.org.role,- plan: t.org.plan,+ // STOPGAP (CUA-1710): the generated record has no field for+ // the end date yet, so it rides on the plan as `teams@<RFC 3339>`.+ plan: match t.org.plan_ends_at.as_deref().filter(|e| !e.is_empty()) {+ Some(ends) => format!("{}@{ends}", t.org.plan),+ None => t.org.plan,+ },seats: t.org.seats,members: t.members@@ -2974,6 +2979,7 @@ mod teams_tests {name: "".into(),role: "admin".into(),plan: "teams".into(),+ plan_ends_at: None,status: "active".into(),seats: 3,features: vec!["team_machines".into()],diff --git a/libs/cua/crates/cua-spaces-ffi/src/app_core_types.rs b/libs/cua/crates/cua-spaces-ffi/src/app_core_types.rsindex a83d9c6bb2..0ab00e127d 100644--- a/libs/cua/crates/cua-spaces-ffi/src/app_core_types.rs+++ b/libs/cua/crates/cua-spaces-ffi/src/app_core_types.rs@@ -9910,7 +9910,8 @@ pub struct AppTeamInput {pub name: String,/// The account's role in it.pub role: String,- /// `free`, `teams`, ...+ /// `free`, `teams`, ... After the plan is cancelled but while it still+ /// runs, `teams@<RFC 3339 end>`.pub plan: String,/// Paid seats.pub seats: i64,diff --git a/libs/spaces-app-swift/Sources/CuaSpacesFFI/CuaSpacesFFI.swift b/libs/spaces-app-swift/Sources/CuaSpacesFFI/CuaSpacesFFI.swiftindex 56cb3c43cd..b649c673b5 100644--- a/libs/spaces-app-swift/Sources/CuaSpacesFFI/CuaSpacesFFI.swift+++ b/libs/spaces-app-swift/Sources/CuaSpacesFFI/CuaSpacesFFI.swift@@ -36329,7 +36329,8 @@ public struct AppTeamInput: Equatable, Hashable {*/public var role: String/**- * `free`, `teams`, ...+ * `free`, `teams`, ... After the plan is cancelled but while it still+ * runs, `teams@<RFC 3339 end>`.*/public var plan: String/**@@ -36355,7 +36356,8 @@ public struct AppTeamInput: Equatable, Hashable {* The account's role in it.*/role: String,/**- * `free`, `teams`, ...+ * `free`, `teams`, ... After the plan is cancelled but while it still+ * runs, `teams@<RFC 3339 end>`.*/plan: String,/*** Paid seats.