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-macos): open the viewer when ready, let the Space toolbar overflow, and unclip onboarding (#5016)

injaneity0f921000ba77
diff --git a/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Models/AppModel.swift b/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Models/AppModel.swift
index 8305c546fd..61739e6295 100644
--- a/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Models/AppModel.swift
+++ b/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Models/AppModel.swift
@@ -776,7 +776,10 @@ public final class AppModel {
let pendingId = "pending:\(UUID().uuidString.lowercased())"
startCreate(args, os: plan.image.os, pendingId: pendingId, select: plan.openDesktop)
// A failure stays on its row.
- Task { _ = try? await followCreate(args, pendingId: pendingId) }
+ Task {
+ guard let id = try? await followCreate(args, pendingId: pendingId), plan.openDesktop else { return }
+ WebUIWindowController.actions?.openSpace(id)
+ }
}
/// Runs a create from the core's create arguments: the native sheet's
diff --git a/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Views/OnboardingView.swift b/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Views/OnboardingView.swift
index e42437bf6a..4772032ef5 100644
--- a/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Views/OnboardingView.swift
+++ b/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Views/OnboardingView.swift
@@ -236,7 +236,7 @@ public struct OnboardingView: View {
// A failed setup shows under the form, not inside its scroll.
VStack(alignment: .leading, spacing: 8) {
HostFormView(host: onboarding.host, buttons: false, showsFailure: false)
- .frame(height: 230)
+ .frame(minHeight: 230, maxHeight: .infinity)
if let failure = onboarding.host.setupFailure {
HostSetupFailureView(failure: failure, retrying: onboarding.host.settingUp) {
Task { await onboarding.setUpHost() }
@@ -371,7 +371,7 @@ public struct OnboardingView: View {
ScrollView { agentGrid }
.scrollIndicators(.automatic)
}
- .frame(maxHeight: Self.agentsListHeight)
+ .frame(maxHeight: Self.agentsListHeight, alignment: .top)
.accessibilityIdentifier("agents-list")
Divider()
HStack(spacing: 16) {
@@ -404,7 +404,7 @@ public struct OnboardingView: View {
if on { onboarding.agentSelection.insert(a.id) } else { onboarding.agentSelection.remove(a.id) }
}))
.toggleStyle(.checkbox)
- .lineLimit(1)
+ .fixedSize(horizontal: false, vertical: true)
.help([a.mcpConfig ?? a.skillsDir ?? "", a.error ?? ""].filter { !$0.isEmpty }.joined(separator: " \u{b7} "))
}
}
@@ -607,7 +607,7 @@ struct PromptTicker: View {
static let speed: CGFloat = rowHeight / 4
var body: some View {
- let height = Self.rowHeight * CGFloat(Self.visibleRows)
+ let height = Self.rowHeight * CGFloat(Self.visibleRows + 1)
Group {
if reduceMotion || motionStill {
rows(Array(prompts.prefix(Self.visibleRows)))
@@ -621,8 +621,8 @@ struct PromptTicker: View {
.frame(height: height, alignment: .top)
.clipped()
.mask(LinearGradient(stops: [
- .init(color: .clear, location: 0), .init(color: .black, location: 0.25),
- .init(color: .black, location: 0.75), .init(color: .clear, location: 1),
+ .init(color: .clear, location: 0), .init(color: .black, location: 0.125),
+ .init(color: .black, location: 0.875), .init(color: .clear, location: 1),
], startPoint: .top, endPoint: .bottom))
}
.onHover { inside in
diff --git a/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Views/SpaceDetailView.swift b/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Views/SpaceDetailView.swift
index ed5ed40722..5f00919ae7 100644
--- a/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Views/SpaceDetailView.swift
+++ b/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Views/SpaceDetailView.swift
@@ -254,8 +254,18 @@ struct SpaceDetailView: View {
@ToolbarContentBuilder private func toolbar(_ detail: AppSpaceDetail) -> some ToolbarContent {
ToolbarItemGroup {
+ let more = detail.actions.filter { !$0.primary && $0.id != .cancel && $0.id != .power }
+ if !more.isEmpty {
+ Menu {
+ ForEach(Array(more.enumerated()), id: \.offset) { _, action in
+ actionButton(action)
+ }
+ } label: {
+ Label("More actions", systemImage: "ellipsis.circle")
+ }
+ }
ForEach(Array(detail.actions.enumerated()), id: \.offset) { _, action in
- actionButton(action)
+ if !more.contains(action) { actionButton(action) }
}
}
}
diff --git a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/onboarding-host-form.png b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/onboarding-host-form.png
index 76f7c80afe..113fb415d6 100644
Binary files a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/onboarding-host-form.png and b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/onboarding-host-form.png differ
diff --git a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/ViewModelTests.swift b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/ViewModelTests.swift
index 908ad2b74a..a88abd5760 100644
--- a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/ViewModelTests.swift
+++ b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/ViewModelTests.swift
@@ -732,7 +732,8 @@ struct ViewModelTests {
/// The new Space is in the list, the notch and the selection the moment
/// Create is pressed, follows the SDK's progress, and hands over to the
/// registry row when ready; nothing waits on the create to show it.
- @Test func createShowsTheSpaceAtOnceAndFollowsItsProgress() async throws {
+ @Test(.serialized, arguments: [false, true])
+ func createShowsTheSpaceAtOnceAndFollowsItsProgress(openWhenReady: Bool) async throws {
let backend = FixtureSpacesBackend()
backend.holdCreates = true
// Held after the pull; `ready` comes on release.
@@ -742,14 +743,20 @@ struct ViewModelTests {
SpaceCreateProgress(phase: "ready", fraction: nil, detail: ""),
]
let model = makeModel(backend)
+ var opened: [String] = []
+ let previous = WebUIWindowController.actions
+ WebUIWindowController.actions = WebUIActions(openSpace: { if $0 == "local:fresh" { opened.append($0) } }, openMain: {})
+ defer { WebUIWindowController.actions = previous }
await model.refresh()
await model.openNewSpace()
let w = model.wizard
w.send(.next)
w.send(.next)
w.send(.setName(name: "fresh"))
+ w.send(.setOpenWhenReady(on: openWhenReady))
w.send(.next)
let plan = w.view.plan
+ #expect(plan.openDesktop == openWhenReady)
model.create(plan)
// Synchronously, before the create has done anything.
let row = try #require(model.sidebar.sections.flatMap(\.rows).first { $0.name == "fresh" })
@@ -775,6 +782,9 @@ struct ViewModelTests {
#expect(ids.contains("local:fresh") && !ids.contains(row.id), "\(ids)")
#expect(model.creates.pending.isEmpty)
if plan.openDesktop { #expect(model.selectedSpaceId == "local:fresh") }
+ try await waitUntil { opened == (openWhenReady ? ["local:fresh"] : []) }
+ try await Task.sleep(for: .milliseconds(100))
+ #expect(opened == (openWhenReady ? ["local:fresh"] : []))
}
/// A failed create stays on its row with the reason until it is removed.