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: failed-payment notice in Settings, Teams (CUA-1743) (#5282)
Francesco Bonacci29d8e644ef28
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 9fbd19e79c..51a1c6931e 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@@ -36067,7 +36067,15 @@ export type AppTeamInput = {/*** Pending invites' emails (only owners and admins can read them).*/- invites: Array<string>+ invites: Array<string>,+ /**+ * The team's last payment failed and it is in its grace period.+ */+ paymentFailed: boolean,+ /**+ * The end of the grace period (RFC 3339), when known.+ */+ paymentFailedUntil?: string}/**@@ -36098,7 +36106,9 @@ const FfiConverterTypeAppTeamInput = (() => {plan: FfiConverterString.read(from),seats: FfiConverterInt64.read(from),members: FfiConverterSequenceTypeAppTeamPersonInput.read(from),- invites: FfiConverterSequenceString.read(from)+ invites: FfiConverterSequenceString.read(from),+ paymentFailed: FfiConverterBool.read(from),+ paymentFailedUntil: FfiConverterOptionalString.read(from)};}write(value: TypeName, into: RustBuffer): void {@@ -36110,6 +36120,8 @@ const FfiConverterTypeAppTeamInput = (() => {FfiConverterInt64.write(value.seats, into);FfiConverterSequenceTypeAppTeamPersonInput.write(value.members, into);FfiConverterSequenceString.write(value.invites, into);+ FfiConverterBool.write(value.paymentFailed, into);+ FfiConverterOptionalString.write(value.paymentFailedUntil, into);}allocationSize(value: TypeName): number {return FfiConverterString.allocationSize(value.id) +@@ -36119,7 +36131,9 @@ const FfiConverterTypeAppTeamInput = (() => {FfiConverterString.allocationSize(value.plan) +FfiConverterInt64.allocationSize(value.seats) +FfiConverterSequenceTypeAppTeamPersonInput.allocationSize(value.members) +- FfiConverterSequenceString.allocationSize(value.invites);+ FfiConverterSequenceString.allocationSize(value.invites) ++ FfiConverterBool.allocationSize(value.paymentFailed) ++ FfiConverterOptionalString.allocationSize(value.paymentFailedUntil);}};diff --git a/apps/cua-spaces-desktop/test/teams.test.ts b/apps/cua-spaces-desktop/test/teams.test.tsindex 66a268f8cd..0a61258f4e 100644--- a/apps/cua-spaces-desktop/test/teams.test.ts+++ b/apps/cua-spaces-desktop/test/teams.test.ts@@ -17,7 +17,7 @@ const tagged = (tag: string) =>const READ = {accountAppUrl: "https://app.cua.ai",- state: { tag: "Ready", inner: { teams: [{ id: "o1", alias: "acme", name: "", role: "owner", plan: "teams", seats: 3, members: [], invites: ["[email protected]"] }] } },+ state: { tag: "Ready", inner: { teams: [{ id: "o1", alias: "acme", name: "", role: "owner", plan: "teams", seats: 3, members: [], invites: ["[email protected]"], paymentFailed: false, paymentFailedUntil: undefined }] } },} as unknown as AppTeamsInput;function context(o: { signedIn?: boolean; fail?: string; current?: string } = {}) {diff --git a/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Models/AppServices.swift b/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Models/AppServices.swiftindex 61967eeadf..4b9ec31d34 100644--- a/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Models/AppServices.swift+++ b/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Models/AppServices.swift@@ -431,7 +431,7 @@ public final class FixtureTeams: TeamsReading, @unchecked Sendable {id: "o1", alias: "acme", name: "Acme Inc", role: "owner", plan: "teams", seats: 3,members: [AppTeamPersonInput(email: "[email protected]", role: "owner"),AppTeamPersonInput(email: "[email protected]", role: "member")],- invites: ["[email protected]"]),+ invites: ["[email protected]"], paymentFailed: false, paymentFailedUntil: nil),]), currentTeamId: nil)}diff --git a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/ViewModelTests.swift b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/ViewModelTests.swiftindex ee74f1c0dd..052ce93851 100644--- a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/ViewModelTests.swift+++ b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/ViewModelTests.swift@@ -1381,7 +1381,7 @@ struct ViewModelTests {AppTeamInput(id: "o1", alias: "acme", name: "", role: "owner", plan: "teams", seats: 3,members: [AppTeamPersonInput(email: "[email protected]", role: "owner"),AppTeamPersonInput(email: "[email protected]", role: "member")],- invites: ["[email protected]"]),+ invites: ["[email protected]"], paymentFailed: false, paymentFailedUntil: nil),])await model.loadSettings()let rows = model.settingsPage.sections.flatMap(\.rows)diff --git a/libs/cua/crates/cua-host/src/spaces_api.rs b/libs/cua/crates/cua-host/src/spaces_api.rsindex b06ba7d86c..e2014f4c67 100644--- a/libs/cua/crates/cua-host/src/spaces_api.rs+++ b/libs/cua/crates/cua-host/src/spaces_api.rs@@ -33,8 +33,12 @@ pub struct ApiOrg {/// while the plan renews.#[serde(default)]pub plan_ends_at: Option<String>,+ /// `active`, `grace` (a payment failed), ...#[serde(default)]pub status: String,+ /// While `status` is `grace`: when the plan lapses (RFC 3339).+ #[serde(default)]+ pub grace_until: Option<String>,#[serde(default)]pub seats: i64,/// Paid features the org has (`team_machines`, `space_sharing`,@@ -976,7 +980,7 @@ mod tests {Json(json!({"sub":"u1","email":"[email protected]","orgs":[- {"id":"o1","alias":"acme","name":"Acme Inc","role":"owner","plan":"teams","status":"active","seats":3},+ {"id":"o1","alias":"acme","name":"Acme Inc","role":"owner","plan":"teams","status":"grace","grace_until":"2026-11-03T10:00:00Z","seats":3},{"id":"o2","alias":"side","role":"member","plan":"free","status":"none","seats":0}],"entitlements":{"sub":"u1","plan":"pro","status":"active","warnings":[],"later":1}diff --git a/libs/cua/crates/cua-spaces-app-core/src/teams.rs b/libs/cua/crates/cua-spaces-app-core/src/teams.rsindex 0c4726d986..64bd4f181d 100644--- a/libs/cua/crates/cua-spaces-app-core/src/teams.rs+++ b/libs/cua/crates/cua-spaces-app-core/src/teams.rs@@ -34,6 +34,13 @@ 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";+/// The button that opens the account app's billing page from the+/// failed-payment notice.+pub const UPDATE_PAYMENT: &str = "Update payment method";++/// The settings row of the failed-payment notice.+pub const PAYMENT_FAILED_ROW: &str = "payment-failed";+/// The line when the account is in no team.pub const NO_TEAMS: &str ="You're not in a team yet. Create one or accept an invite in the account app.";@@ -66,6 +73,12 @@ pub struct TeamInput {pub members: Vec<TeamPersonInput>,/// Pending invites' emails (only owners and admins can read them).pub invites: Vec<String>,+ /// The team's last payment failed and it is in its grace period.+ #[serde(default)]+ pub payment_failed: bool,+ /// The end of the grace period (RFC 3339), when known.+ #[serde(default)]+ pub payment_failed_until: Option<String>,}/// Where Teams stand.@@ -176,6 +189,31 @@ fn plan_label(plan: &str) -> String {}}+/// The notice above a team in grace: owners are told to act (and get the+/// billing button), everyone else who to ask.+fn payment_notice(t: &TeamInput, app: &str) -> SettingsRow {+ let by = t+ .payment_failed_until+ .as_deref()+ .and_then(short_date)+ .map(|d| format!(" by {d}"))+ .unwrap_or_default();+ let mut r = row(PAYMENT_FAILED_ROW, Text, "Payment failed");+ if t.role == "owner" {+ r.value = Some(format!(+ "Your last payment failed. Update your payment method{by} to keep Teams."+ ));+ r.button = Some(UPDATE_PAYMENT.into());+ r.link_url = Some(format!("{app}/billing"));+ } else {+ r.value = Some(format!(+ "The last payment for {} failed. The owner needs to update the payment method{by} to keep Teams.",+ t.display_name()+ ));+ }+ r+}+fn base(input: &TeamsInput) -> String {let url = input.account_app_url.trim().trim_end_matches('/');if url.starts_with("https://") {@@ -239,6 +277,9 @@ pub fn rows(input: &TeamsInput) -> Vec<SettingsRow> {1 => " \u{b7} 1 seat".into(),n => format!(" \u{b7} {n} seats"),};+ if t.payment_failed {+ out.push(payment_notice(t, &app));+ }let mut head = row(&format!("team:{}", t.id), Text, t.display_name());head.value = Some(format!("{} \u{b7} {}{seats}",@@ -301,6 +342,8 @@ mod tests {},],invites: vec!["[email protected]".into()],+ payment_failed: false,+ payment_failed_until: None,}}@@ -357,6 +400,49 @@ mod tests {assert_eq!(plan_label("teams@garbage"), "Teams plan");}+ #[test]+ fn an_owner_in_grace_is_told_to_update_the_payment_method() {+ let mut t = team("Acme Inc", "acme");+ t.payment_failed = true;+ t.payment_failed_until = Some("2026-11-03T10:00:00Z".into());+ let rows = rows(&input(vec![t]));+ assert_eq!(rows[0].id, "payment-failed");+ assert_eq!(+ rows[0].value.as_deref(),+ Some(+ "Your last payment failed. Update your payment method by 3 Nov 2026 to keep Teams."+ )+ );+ assert_eq!(rows[0].button.as_deref(), Some("Update payment method"));+ assert_eq!(+ rows[0].link_url.as_deref(),+ Some("https://app.cua.ai/billing")+ );+ assert_eq!(rows[1].id, "team:o1");+ }++ #[test]+ fn a_member_in_grace_is_told_who_acts_and_gets_no_button() {+ let mut t = team("Acme Inc", "acme");+ t.role = "member".into();+ t.payment_failed = true;+ let rows = rows(&input(vec![t]));+ assert_eq!(+ rows[0].value.as_deref(),+ Some(+ "The last payment for Acme Inc failed. The owner needs to update the payment method to keep Teams."+ )+ );+ assert_eq!(rows[0].button, None);+ assert_eq!(rows[0].link_url, None);+ }++ #[test]+ fn a_team_in_good_standing_has_no_notice() {+ let rows = rows(&input(vec![team("Acme Inc", "acme")]));+ assert!(rows.iter().all(|r| r.id != "payment-failed"));+ }+#[test]fn the_name_falls_back_to_the_alias() {let rows = rows(&input(vec![team("", "acme")]));@@ -438,6 +524,8 @@ mod tests {seats: 0,members: vec![],invites: vec![],+ payment_failed: false,+ payment_failed_until: None,}}diff --git a/libs/cua/crates/cua-spaces-ffi/src/app_core.rs b/libs/cua/crates/cua-spaces-ffi/src/app_core.rsindex 3d32bb9186..a8b8cec55b 100644--- a/libs/cua/crates/cua-spaces-ffi/src/app_core.rs+++ b/libs/cua/crates/cua-spaces-ffi/src/app_core.rs@@ -2004,6 +2004,8 @@ fn teams_input(s: cua_host::spaces_api::TeamsSnapshot, account_app_url: String)}).collect(),invites: t.invites.into_iter().map(|i| i.email).collect(),+ payment_failed: t.org.status == "grace",+ payment_failed_until: t.org.grace_until,}).collect(),},@@ -2980,7 +2982,8 @@ mod teams_tests {role: "admin".into(),plan: "teams".into(),plan_ends_at: None,- status: "active".into(),+ status: "grace".into(),+ grace_until: Some("2026-11-03T10:00:00Z".into()),seats: 3,features: vec!["team_machines".into()],},@@ -2997,9 +3000,12 @@ mod teams_tests {};let input = teams_input(snapshot, "https://app.cua.ai".into());let rows = core::teams::rows(&input);- assert_eq!(rows[0].label, "acme");- assert_eq!(rows[2].label, "[email protected]");- assert_eq!(rows[2].value.as_deref(), Some("(Invited)"));+ // The grace notice (this account is an admin, not the owner) comes first.+ assert_eq!(rows[0].id, "payment-failed");+ assert!(rows[0].value.as_deref().unwrap().contains("by 3 Nov 2026"));+ assert_eq!(rows[1].label, "acme");+ assert_eq!(rows[3].label, "[email protected]");+ assert_eq!(rows[3].value.as_deref(), Some("(Invited)"));}}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 0ab00e127d..26a79d2de7 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@@ -9918,6 +9918,10 @@ pub struct AppTeamInput {pub members: Vec<AppTeamPersonInput>,/// Pending invites' emails (only owners and admins can read them).pub invites: Vec<String>,+ /// The team's last payment failed and it is in its grace period.+ pub payment_failed: bool,+ /// The end of the grace period (RFC 3339), when known.+ pub payment_failed_until: Option<String>,}/// `teams::TeamsState`.diff --git a/libs/spaces-app-swift/Sources/CuaSpacesFFI/CuaSpacesFFI.swift b/libs/spaces-app-swift/Sources/CuaSpacesFFI/CuaSpacesFFI.swiftindex b649c673b5..660e5efb23 100644--- a/libs/spaces-app-swift/Sources/CuaSpacesFFI/CuaSpacesFFI.swift+++ b/libs/spaces-app-swift/Sources/CuaSpacesFFI/CuaSpacesFFI.swift@@ -36342,6 +36342,14 @@ public struct AppTeamInput: Equatable, Hashable {* Pending invites' emails (only owners and admins can read them).*/public var invites: [String]+ /**+ * The team's last payment failed and it is in its grace period.+ */+ public var paymentFailed: Bool+ /**+ * The end of the grace period (RFC 3339), when known.+ */+ public var paymentFailedUntil: String?// Default memberwise initializers are never public by default, so we// declare one manually.@@ -36364,7 +36372,13 @@ public struct AppTeamInput: Equatable, Hashable {*/seats: Int64, members: [AppTeamPersonInput],/*** Pending invites' emails (only owners and admins can read them).- */invites: [String]) {+ */invites: [String],+ /**+ * The team's last payment failed and it is in its grace period.+ */paymentFailed: Bool,+ /**+ * The end of the grace period (RFC 3339), when known.+ */paymentFailedUntil: String?) {self.id = idself.alias = aliasself.name = name@@ -36373,6 +36387,8 @@ public struct AppTeamInput: Equatable, Hashable {self.seats = seatsself.members = membersself.invites = invites+ self.paymentFailed = paymentFailed+ self.paymentFailedUntil = paymentFailedUntil}@@ -36398,7 +36414,9 @@ public struct FfiConverterTypeAppTeamInput: FfiConverterRustBuffer {plan: FfiConverterString.read(from: &buf),seats: FfiConverterInt64.read(from: &buf),members: FfiConverterSequenceTypeAppTeamPersonInput.read(from: &buf),- invites: FfiConverterSequenceString.read(from: &buf)+ invites: FfiConverterSequenceString.read(from: &buf),+ paymentFailed: FfiConverterBool.read(from: &buf),+ paymentFailedUntil: FfiConverterOptionString.read(from: &buf))}@@ -36411,6 +36429,8 @@ public struct FfiConverterTypeAppTeamInput: FfiConverterRustBuffer {FfiConverterInt64.write(value.seats, into: &buf)FfiConverterSequenceTypeAppTeamPersonInput.write(value.members, into: &buf)FfiConverterSequenceString.write(value.invites, into: &buf)+ FfiConverterBool.write(value.paymentFailed, into: &buf)+ FfiConverterOptionString.write(value.paymentFailedUntil, into: &buf)}}