Skip to content

armgit / cua

Public Imported from GitHub
0

Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.

fix(spaces): the web page's usage signals reach the SwiftUI app before Settings is opened (CUA-2291) (#5953)

cua-agents[bot]c3addc032096
diff --git a/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Models/AppModel.swift b/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Models/AppModel.swift
index aff429bfca..30f4424651 100644
--- a/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Models/AppModel.swift
+++ b/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Models/AppModel.swift
@@ -1707,6 +1707,14 @@ public final class AppModel {
readLoginItem()
}
+ /// Reads the usage-data switch alone. The web page gets it with its
+ /// Settings snapshot (`settings.get`) and drops every usage signal while
+ /// that has none, so it cannot wait for the native Settings view's
+ /// `loadSettings` (the page runs signed out, before any Settings view).
+ public func refreshTelemetry() {
+ telemetryInput = telemetry?.status()
+ }
+
/// Reads what Settings shows (telemetry, the coding agents).
public func loadSettings() async {
lumeSource = await backend.lumeSource()
diff --git a/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/WebHost/WebUIBridge.swift b/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/WebHost/WebUIBridge.swift
index 7d40beb5ee..8fb5730f7f 100644
--- a/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/WebHost/WebUIBridge.swift
+++ b/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/WebHost/WebUIBridge.swift
@@ -320,7 +320,9 @@ final class WebUIBridge: NSObject, WKScriptMessageHandlerWithReply {
"agents.removeRoutine", "agents.allowComputer", "agents.revokeComputer":
return try await agentDetail(method, args)
- case "settings.get": return settings()
+ case "settings.get":
+ model.refreshTelemetry()
+ return settings()
case "settings.choose":
let row = try string(args, "row"), option = try string(args, "option")
if row == "update-channel" {
diff --git a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/ViewModelTests.swift b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/ViewModelTests.swift
index 0c753094e3..2dc3bff168 100644
--- a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/ViewModelTests.swift
+++ b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/ViewModelTests.swift
@@ -399,6 +399,17 @@ struct ViewModelTests {
#expect(model.host.formView?.canSubmit == true)
}
+ /// The web page's usage signals (a sign-in's start, the "still waiting" hint)
+ /// wait for the usage-data switch in its Settings snapshot, and the page can
+ /// run signed out before any Settings view loaded it: reading the switch
+ /// alone fills the page's Settings with it.
+ @Test func refreshingTelemetryGivesTheSettingsItsSwitch() {
+ let model = makeModel(telemetry: FixtureTelemetry())
+ #expect(model.telemetryInput == nil)
+ model.refreshTelemetry()
+ #expect(model.telemetryInput?.enabled == true)
+ }
+
/// Settings, Experiments: every switch off except Sharing and Your cloud
/// (on by default); Cua Volume on shows Storage after General, is saved,
/// recorded, and reaches the first run.