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
refactor(spaces-macos): delete the native SwiftUI views (CUA-2334) (#5999)
cua-agents[bot]6df77f678d17
diff --git a/apps/cua-spaces-macos/README.md b/apps/cua-spaces-macos/README.mdindex 3774ee3e8c..d6f910ef13 100644--- a/apps/cua-spaces-macos/README.md+++ b/apps/cua-spaces-macos/README.md@@ -95,8 +95,7 @@ UI tests (XCUITest) need Xcode: `xcodegen generate` (project.yml), thenEnvironment (debug builds only; release builds ignore every `CUA_SPACES_*` hook):`CUA_SPACES_FIXTURES=1` runs on fixtures (no daemon, no Space, an in-memory login item whose status `CUA_SPACES_LOGIN_ITEM` sets: `enabled`, `notRegistered`, `requiresApproval`, `notFound`; a relay allowance `CUA_SPACES_RELAY_USAGE` sets: `reached`, `team`, `none`, default the free plan within it);-`CUA_SPACES_START_VIEW` opens `new-space`, `keyvault`, `approval`, `settings` (presses ⌘,), `device-approval` (with `CUA_SPACES_APPROVE_CODE`), `device-enroll`, `device-enroll-code`,-`onboarding`, `stream` (the Space detail at its Stream section), `window-pip` (the same, with the first window popped out), `teleport-picker` (the Space's teleport picker; set `CUA_TELEPORT_APP_ROOTS` to fixture apps for images), `run-timeline` (an agent run's conversation from the Space's Agents section; fixtures give `local:aurora` two runs) or a notch state (`notch-open`, which springs+`CUA_SPACES_START_VIEW` opens the web UI window at a page (`new-space`, `keyvault`, `approval`, `settings`, `settings-devices`, `settings-about`, `device-approval`, `device-enroll`, `onboarding`, `space`, `this-machine`; see `AppEnvironment.applyStartView`) or a notch state (`notch-open`, which springsopen 1.5 s after launch, `notch-hover`, `notch-permission`,`notch-drag-target`, `notch-drop`); `CUA_SPACES_SELECT`selects a Space; `CUA_SPACES_CREATE=<image>[,<name>]` creates one on thisdiff --git a/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Views/AgentsViews.swift b/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Views/AgentsViews.swiftdeleted file mode 100644index df2017757d..0000000000--- a/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Views/AgentsViews.swift+++ /dev/null@@ -1,251 +0,0 @@-// SPDX-License-Identifier: FSL-1.1-MIT-// Copyright (c) 2026 Cua AI, Inc.--import CuaSDK-import CuaSpacesFFI-import SwiftUI--/// One line: text, trailing text, up to two buttons and a switch.-struct LineRow: View {- let line: AppLineView- var onOpen: (() -> Void)?- var onAction: (() -> Void)?- var onSecondary: (() -> Void)?- var onToggle: (() -> Void)?-- var body: some View {- HStack(spacing: 8) {- if let onOpen {- Button(line.text, action: onOpen).buttonStyle(.link).lineLimit(1)- } else {- Text(line.text).lineLimit(1)- }- Spacer(minLength: 8)- Text(line.trailing).foregroundStyle(.secondary).lineLimit(1)- if let on = line.on, let onToggle {- Toggle(line.text, isOn: Binding(get: { on }, set: { _ in onToggle() }))- .labelsHidden().toggleStyle(.switch).controlSize(.mini)- }- if let label = line.actionLabel, let onAction { Button(label, action: onAction).controlSize(.small) }- if let label = line.secondaryLabel, let onSecondary { Button(label, action: onSecondary).controlSize(.small) }- }- }-}--/// "Agents": persistent agents and the selected one's memory, routines and-/// access to this computer. Every word is the app core's.-struct AgentsPageView: View {- @Bindable var model: PersistentModel- /// Settings → Agents, where agents get their provider keys.- var openAgentKeys: (() -> Void)?-- var body: some View {- let v = model.agentsView()- Form {- Section(v.title) {- if v.rows.isEmpty { Text(v.emptyText).foregroundStyle(.secondary) }- ForEach(v.rows, id: \.name) { r in- HStack {- Button(r.name) { act(.select(name: r.name)) }.buttonStyle(.link)- Spacer()- Text("\(r.detail), \(r.state)").foregroundStyle(.secondary).lineLimit(1)- Button(r.actionLabel) { act(r.actionLabel == "Resume" ? .resume(name: r.name) : .pause(name: r.name)) }- .controlSize(.small)- }- }- }- if let d = v.detail {- Section {- Picker(d.name, selection: Binding(get: { d.tabs.first(where: \.selected)?.tab ?? .memory },- set: { act(.setTab(tab: $0)) })) {- ForEach(d.tabs, id: \.label) { Text($0.label).tag($0.tab) }- }- .pickerStyle(.segmented)- .labelsHidden()- } header: {- Text("\(d.name), \(d.subtitle)")- }- switch d.tabs.first(where: \.selected)?.tab ?? .memory {- case .memory: memory(d)- case .routines: routines(d)- case .access: access(d)- }- }- if let e = v.error { Text(e).foregroundStyle(.red) }- if let openAgentKeys {- Section {- HStack {- Text("Agents need a provider key to run.").foregroundStyle(.secondary)- Spacer()- Button("Add a provider key", action: openAgentKeys)- .accessibilityIdentifier("agents-add-provider-key")- }- }- }- }- .formStyle(.grouped)- .task { await model.loadAgents() }- }-- private func act(_ a: AppAgentsAction) { Task { await model.send(a) } }-- @ViewBuilder private func memory(_ d: AppAgentDetailView) -> some View {- if let f = d.file {- Section(f.path) {- ScrollView { Text(f.text).font(.system(.body, design: .monospaced)).textSelection(.enabled) }- .frame(maxHeight: 240)- ForEach(f.versions, id: \.id) { l in LineRow(line: l, onAction: { act(.restore(version: l.id)) }) }- Button(f.closeLabel) { act(.closeFile) }- }- } else {- Section {- if d.memory.isEmpty { Text(d.memoryEmpty).foregroundStyle(.secondary) }- ForEach(d.memory, id: \.id) { l in LineRow(line: l, onOpen: { act(.openFile(path: l.id)) }) }- }- }- }-- @ViewBuilder private func routines(_ d: AppAgentDetailView) -> some View {- Section {- if d.routines.isEmpty { Text(d.routinesEmpty).foregroundStyle(.secondary) }- ForEach(d.routines, id: \.id) { l in- LineRow(line: l, onAction: { act(.removeRoutine(id: l.id)) }, onToggle: { act(.toggleRoutine(id: l.id)) })- }- }- Section {- TextField("Title", text: Binding(get: { d.form.title }, set: { act(.setTitle(title: $0)) }))- TextField("Prompt", text: Binding(get: { d.form.prompt }, set: { act(.setPrompt(prompt: $0)) }))- Picker("Schedule", selection: Binding(get: { d.form.schedule }, set: { act(.setSchedule(schedule: $0)) })) {- Text("Every N minutes").tag(AppRoutineScheduleKind.every)- Text("Every day").tag(AppRoutineScheduleKind.daily)- Text("Every week").tag(AppRoutineScheduleKind.weekly)- }- if d.form.schedule == .every {- Stepper("\(d.form.minutes) minutes", value: Binding(get: { Int(d.form.minutes) },- set: { act(.setMinutes(minutes: UInt32(max(1, $0)))) }), in: 1...1440)- } else {- TextField("Time", text: Binding(get: { d.form.time }, set: { act(.setTime(time: $0)) }))- }- if d.form.schedule == .weekly {- Picker("Day", selection: Binding(get: { d.form.weekday }, set: { act(.setWeekday(weekday: $0)) })) {- ForEach(["mon", "tue", "wed", "thu", "fri", "sat", "sun"], id: \.self) { Text($0).tag($0) }- }- }- Button(d.addRoutineLabel) { act(.addRoutine) }.disabled(!d.canAddRoutine)- }- }-- @ViewBuilder private func access(_ d: AppAgentDetailView) -> some View {- Section {- if d.access.isEmpty { Text(d.accessEmpty).foregroundStyle(.secondary) }- ForEach(d.access, id: \.id) { l in LineRow(line: l, onAction: { act(.revokeComputer(machine: l.id)) }) }- if let label = d.allowThisMachineLabel, let machine = model.thisMachine {- Button(label) { act(.allowComputer(machine: machine)) }- }- }- if !d.audit.isEmpty {- Section { ForEach(d.audit, id: \.id) { LineRow(line: $0) } }- }- }-}--/// "Volume": Open in Finder, sync per device, conflicts, requests and-/// grants. Not a file browser: Finder is.-struct DrivePageView: View {- @Bindable var model: PersistentModel-- var body: some View {- let v = model.driveView()- Form {- if let label = v.openLabel {- Section {- HStack(spacing: 12) {- if let line = v.mountLine {- Text(line).foregroundStyle(.secondary).lineLimit(1).truncationMode(.middle)- .help(v.mountPath ?? line)- }- Spacer()- Button(label) { act(.openVolume(mounted: v.mountPath)) }- .buttonStyle(.borderedProminent)- .controlSize(.large)- .disabled(v.busy)- .accessibilityIdentifier("drive-open-in-finder")- }- }- }- if !v.requests.isEmpty {- Section(v.requestsTitle) {- ForEach(v.requests, id: \.id) { l in- LineRow(line: l, onAction: { act(.approve(id: l.id)) }, onSecondary: { act(.deny(id: l.id)) })- }- }- }- Section(v.grantsTitle) {- if v.grants.isEmpty { Text(v.grantsEmpty).foregroundStyle(.secondary) }- ForEach(v.grants, id: \.id) { l in LineRow(line: l, onAction: { act(.revoke(id: l.id)) }) }- }- if !v.devices.isEmpty || v.syncNote != nil {- Section(v.devicesTitle) {- ForEach(v.devices, id: \.id) { LineRow(line: $0) }- if let note = v.syncNote {- Text(note).foregroundStyle(v.syncError ? AnyShapeStyle(.red) : AnyShapeStyle(.secondary))- .lineLimit(1).help(note)- }- }- }- if !v.conflicts.isEmpty {- Section(v.conflictsTitle) {- ForEach(v.conflicts, id: \.path) { c in- HStack(spacing: 8) {- Text(c.text).lineLimit(1).truncationMode(.middle)- Spacer(minLength: 8)- Text(c.trailing).foregroundStyle(.secondary).lineLimit(1)- if let label = c.openLabel, let path = c.reveal {- Button(label) { act(.reveal(path: path)) }.controlSize(.small)- }- Button(c.resolveLabel) { act(.resolve(path: c.path)) }.controlSize(.small)- }- }- }- }- if let e = v.error { Text(e).foregroundStyle(.red) }- }- .formStyle(.grouped)- .task { await model.sendDrive(nil) }- // The sync status changes on its own (other devices, uploads).- .task {- while !Task.isCancelled {- try? await Task.sleep(for: .seconds(5))- await model.refreshDriveSync()- }- }- }-- private func act(_ a: AppDriveAction) { Task { await model.sendDrive(a) } }-}--/// "Notifications": the daemon's feed, one line each.-struct NotificationsPageView: View {- @Bindable var model: PersistentModel-- var body: some View {- let v = model.notificationsView()- Form {- Section(v.title) {- if v.rows.isEmpty { Text(v.emptyText).foregroundStyle(.secondary) }- ForEach(v.rows, id: \.id) { l in- HStack(spacing: 10) {- if let key = CuaKey.image {- Image(nsImage: key).resizable().interpolation(.high).frame(width: 20, height: 20).accessibilityHidden(true)- }- Text(l.text).lineLimit(1).fontWeight(l.on == true ? .semibold : .regular)- Spacer()- Text(l.trailing).foregroundStyle(.secondary)- }- }- if let label = v.markAllLabel { Button(label) { Task { await model.markAllRead() } } }- }- }- .formStyle(.grouped)- }-}diff --git a/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Views/CommandPaletteView.swift b/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Views/CommandPaletteView.swiftdeleted file mode 100644index 0f9d39b8ec..0000000000--- a/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Views/CommandPaletteView.swift+++ /dev/null@@ -1,246 +0,0 @@-// SPDX-License-Identifier: FSL-1.1-MIT-// Copyright (c) 2026 Cua AI, Inc.--import CuaSpacesFFI-import SwiftUI--/// The shared keyboard shortcuts: the core's `appKeybindings`, which are-/// the React UI's `keybindings.json`, so both bind the same keys.-enum SharedShortcuts {- static let keys: [String: String] = Dictionary(- appKeybindings().map { ($0.command, $0.key) }, uniquingKeysWith: { first, _ in first })-- private static func parts(_ command: String) -> (key: String, mods: [String])? {- guard let spec = keys[command] else { return nil }- var parts = spec.lowercased().split(separator: "+").map(String.init)- guard let key = parts.popLast(), key.count == 1 else { return nil }- return (key, parts)- }-- /// `mod+k` as ⌘K.- static func shortcut(_ command: String) -> KeyboardShortcut? {- guard let (key, mods) = parts(command), let ch = key.first else { return nil }- var modifiers: EventModifiers = []- if mods.contains("mod") { modifiers.insert(.command) }- if mods.contains("alt") { modifiers.insert(.option) }- if mods.contains("shift") { modifiers.insert(.shift) }- return KeyboardShortcut(KeyEquivalent(ch), modifiers: modifiers)- }-- /// `mod+shift+l` as "⌘⇧L".- static func label(_ command: String) -> String? {- guard let (key, mods) = parts(command) else { return nil }- let marks = [("mod", "⌘"), ("alt", "⌥"), ("shift", "⇧")].filter { mods.contains($0.0) }.map(\.1)- return marks.joined() + key.uppercased()- }-}--/// A page ⌘1–4 go to (the shared keybindings' `nav.*` commands).-struct NavTarget: Identifiable {- let command: String- let label: String- let symbol: String- var id: String { command }-- @MainActor static func all(_ model: AppModel) -> [NavTarget] {- [NavTarget(command: "nav.spaces", label: "Spaces", symbol: "square.grid.2x2"),- NavTarget(command: "nav.machines", label: "Computers", symbol: "server.rack"),- NavTarget(command: "nav.agents", label: "Agents", symbol: "person.2"),- NavTarget(command: "nav.keyvault", label: model.chrome.keyvaultTitle, symbol: "key")]- }-}--extension AppModel {- /// Goes to the page a `nav.*` command names.- public func go(_ command: String) {- switch command {- case "nav.spaces": selection = sidebar.selectedId.map { .space($0) }- case "nav.machines": selection = .machines- case "nav.agents": selection = .agents- case "nav.keyvault":- if let first = keyvault.sidebar.categories.first {- selection = .keyvault(.category(category: first.category))- }- default: break- }- }-}--/// View: Command Palette and ⌘1–4, with the shared keys. The web UI-/// window handles these keys itself while it is in front; from anywhere-/// else (a Space's window) they open it at the page.-struct NavigationCommands: View {- let model: AppModel-- var body: some View {- Button("Command Palette…") { inMain(.home) }- .keyboardShortcut(SharedShortcuts.shortcut("commandPalette.toggle"))- Divider()- ForEach(NavTarget.all(model)) { target in- Button(target.label) { inMain(MainUIRouter.route(forNav: target.command)) }- .keyboardShortcut(SharedShortcuts.shortcut(target.command))- }- }-- private func inMain(_ route: MainUIRoute?) {- if WebUIWindowController.shared?.window?.isKeyWindow == true { return }- guard model.startup.isReady, model.onboarding.completed else { return }- MainUIRouter(model: model).open(route ?? .home)- }-}--/// The command palette (⌘K): actions, pages and your Spaces, matched as you-/// type in the core's order (`appPaletteRank`, the React palette's too).-struct CommandPaletteView: View {- let model: AppModel- @State private var query = ""- @State private var active = 0- @FocusState private var focused: Bool-- struct Command: Identifiable {- let id: String- let entry: AppPaletteEntry- var symbol: String?- var osIcon: String?- var shortcut: String?- let run: () -> Void- }-- var body: some View {- let all = commands- let results = appPaletteRank(entries: all.map(\.entry), query: query).map { all[Int($0)] }- let current = min(active, max(0, results.count - 1))- VStack(spacing: 0) {- HStack(spacing: 8) {- Image(systemName: "magnifyingglass").foregroundStyle(.secondary)- TextField("Search for a Space or command", text: $query)- .textFieldStyle(.plain)- .font(.title3)- .focused($focused)- .onSubmit { run(results, current) }- .onKeyPress(.downArrow) { active = (current + 1) % max(1, results.count); return .handled }- .onKeyPress(.upArrow) { active = (current - 1 + max(1, results.count)) % max(1, results.count); return .handled }- .accessibilityIdentifier("palette-search")- }- .padding(.horizontal, 14)- .padding(.vertical, 12)- Divider()- if results.isEmpty {- Text("No matches")- .foregroundStyle(.secondary)- .frame(maxWidth: .infinity, maxHeight: .infinity)- } else {- ScrollViewReader { scroller in- ScrollView {- LazyVStack(alignment: .leading, spacing: 0) {- ForEach(Array(results.enumerated()), id: \.element.id) { i, cmd in- if i == 0 || results[i - 1].entry.group != cmd.entry.group {- Text(cmd.entry.group)- .font(.caption.weight(.medium))- .foregroundStyle(.secondary)- .padding(.horizontal, 10)- .padding(.top, 8)- .padding(.bottom, 2)- }- row(cmd, active: i == current)- .id(cmd.id)- .contentShape(.rect)- .onTapGesture { run(results, i) }- .onHover { if $0 { active = i } }- }- }- .padding(6)- }- .onChange(of: current) { _, i in- if results.indices.contains(i) { scroller.scrollTo(results[i].id) }- }- }- }- }- .frame(width: 560, height: 420)- .onChange(of: query) { active = 0 }- .onExitCommand { model.showingPalette = false }- .onAppear { focused = true }- .accessibilityIdentifier("command-palette")- }-- private func row(_ cmd: Command, active: Bool) -> some View {- HStack(spacing: 10) {- Group {- if let os = cmd.osIcon {- OsIconImage(id: os, size: 13)- } else if let symbol = cmd.symbol {- Image(systemName: symbol)- }- }- .foregroundStyle(.secondary)- .frame(width: 18)- Text(cmd.entry.label).lineLimit(1)- Spacer(minLength: 8)- if let hint = cmd.entry.hint {- Text(hint).font(.callout).foregroundStyle(.secondary)- }- if let shortcut = cmd.shortcut {- Text(shortcut).font(.callout.monospaced()).foregroundStyle(.secondary)- }- }- .padding(.horizontal, 10)- .frame(height: 30)- .background(active ? Color.primary.opacity(0.08) : .clear, in: .rect(cornerRadius: 6))- .accessibilityElement(children: .combine)- .accessibilityAddTraits(active ? .isSelected : [])- }-- private func run(_ results: [Command], _ i: Int) {- guard results.indices.contains(i) else { return }- model.showingPalette = false- results[i].run()- }-- private var commands: [Command] {- func entry(_ group: String, _ label: String, hint: String? = nil, keywords: String? = nil) -> AppPaletteEntry {- AppPaletteEntry(group: group, label: label, hint: hint, keywords: keywords)- }- let chrome = model.chrome- var out: [Command] = [- Command(id: "space:new", entry: entry("Actions", chrome.newSpaceLabel, keywords: "create add"),- symbol: "plus", shortcut: "⌘N") { Task { await model.openNewSpace() } },- Command(id: "machine:add", entry: entry("Actions", "Add a computer", keywords: "connect computer address"),- symbol: "plus.rectangle.on.rectangle") {- model.selection = .machines- Task { await model.openAddMachine() }- },- ]- if let signIn = chrome.signInLabel {- out.append(Command(id: "session:signIn", entry: entry("Actions", signIn, keywords: "account log in cloud"),- symbol: "person.crop.circle") { Task { await model.beginSignIn() } })- }- out += NavTarget.all(model).map { t in- Command(id: "nav:\(t.command)", entry: entry("Go to", t.label, keywords: "page"), symbol: t.symbol,- shortcut: SharedShortcuts.label(t.command)) { model.go(t.command) }- }- out += [- Command(id: "nav:notifications", entry: entry("Go to", "Notifications", keywords: "page"), symbol: "bell") {- model.selection = .notifications- },- Command(id: "nav:settings", entry: entry("Go to", chrome.settingsLabel, keywords: "page preferences"),- symbol: "gearshape", shortcut: SharedShortcuts.label("nav.settings")) { MainUIRouter(model: model).openSettings() },- Command(id: "nav:checklist", entry: entry("Go to", "Getting started", keywords: "checklist steps tour help first"),- symbol: "checklist") { model.openGettingStarted() },- ]- let rows = appSidebar(spaces: model.spaces, query: "", selectedId: "").sections.flatMap(\.rows)- for space in model.realSpaces {- let row = rows.first { $0.id == space.id }- let hint = row.map { CoreMessages.text($0.statusText) }- let keywords = "\(row?.osIcon ?? "") \(hint ?? "")"- out.append(Command(id: "space:open:\(space.id)", entry: entry("Spaces", "Open \(space.name)", hint: hint, keywords: keywords),- osIcon: row?.osIcon) { model.selection = .space(space.id) })- if let power = appPowerButton(space: space), power.enabled, !power.busy {- let label = power.turnOn ? "Start \(space.name)" : "Stop \(space.name)"- out.append(Command(id: "space:power:\(space.id)", entry: entry("Spaces", label, hint: hint, keywords: keywords),- osIcon: row?.osIcon) { model.setPower(space, on: power.turnOn) })- }- }- return out- }-}diff --git a/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Views/ConnectCloudSheet.swift b/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Views/ConnectCloudSheet.swiftdeleted file mode 100644index ebf8302767..0000000000--- a/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Views/ConnectCloudSheet.swift+++ /dev/null@@ -1,104 +0,0 @@-// SPDX-License-Identifier: FSL-1.1-MIT-// Copyright (c) 2026 Cua AI, Inc.--import CuaSpacesFFI-import SwiftUI--/// "Connect a cloud": one row per provider (a check mark when this Mac has-/// its sign-in) plus "No cloud", the region, project or environment, what-/// the selected provider touches, Test (creates nothing) and Connect. Every-/// word and decision is the core's (`appCloudConnectView`); this sheet-/// renders it.-public struct ConnectCloudSheet: View {- @Bindable var cloud: CloudModel-- public init(cloud: CloudModel) {- self.cloud = cloud- }-- public var body: some View {- let v = cloud.view- VStack(spacing: 0) {- Form {- Section {- Picker(v.title, selection: Binding(- get: { v.rows.first(where: \.selected)?.id ?? "" },- set: { id in Task { await cloud.send(.select(name: id)) } })) {- ForEach(v.rows, id: \.id) { row in- HStack(spacing: 6) {- Text(row.title)- Text(row.detail).foregroundStyle(.secondary)- if row.found {- Image(systemName: "checkmark").foregroundStyle(.secondary)- .accessibilityLabel("Sign-in found")- }- }- .tag(row.id)- }- }- .pickerStyle(.radioGroup)- .labelsHidden()- .accessibilityIdentifier("cloud-providers")- }- if v.field != nil {- Section {- if let f = v.field { text(f) { await cloud.send(.setValue(text: $0)) } }- if let f = v.profileField { text(f) { await cloud.send(.setProfile(text: $0)) } }- if let f = v.tokenField {- SecureField(f.label, text: Binding(get: { cloud.token }, set: { cloud.setToken($0) }),- prompt: Text(f.placeholder))- .accessibilityIdentifier("cloud-field-\(f.id)")- }- Toggle(v.makeDefaultLabel, isOn: Binding(- get: { v.makeDefault },- set: { on in Task { await cloud.send(.setMakeDefault(on: on)) } }))- }- }- if !v.touches.isEmpty {- Section("What Cua will touch") {- ForEach(v.touches, id: \.self) { line in- Text(line).font(.callout).foregroundStyle(.secondary)- }- }- }- if !v.checks.isEmpty || v.result != nil {- Section {- ForEach(v.checks, id: \.text) { check in- Label(check.text, systemImage: check.ok ? "checkmark.circle" : "xmark.circle")- .foregroundStyle(check.ok ? Color.primary : Color.red)- }- if let result = v.result {- Text(result).foregroundStyle(.secondary)- .accessibilityIdentifier("cloud-test-result")- }- }- }- if let error = v.error {- Text(error).foregroundStyle(.red).font(.callout)- }- }- .formStyle(.grouped)- Divider()- HStack {- Button(v.cancelLabel) { cloud.showing = false }- .keyboardShortcut(.cancelAction)- Spacer()- Button(v.testLabel) { Task { await cloud.send(.test) } }- .disabled(!v.canTest)- .help(v.testHelp)- Button(v.connectLabel) { Task { await cloud.send(.connect) } }- .keyboardShortcut(.defaultAction)- .disabled(!v.canConnect)- }- .padding(14)- }- .frame(width: 480, height: 440)- .navigationTitle(v.title)- }-- private func text(_ f: AppCloudField, _ set: @escaping (String) async -> Void) -> some View {- TextField(f.label, text: Binding(get: { f.value }, set: { v in Task { await set(v) } }),- prompt: Text(f.placeholder))- .accessibilityIdentifier("cloud-field-\(f.id)")- }-}diff --git a/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Views/DevicesViews.swift b/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Views/DevicesViews.swiftdeleted file mode 100644index c774d42332..0000000000--- a/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Views/DevicesViews.swift+++ /dev/null@@ -1,233 +0,0 @@-// SPDX-License-Identifier: FSL-1.1-MIT-// Copyright (c) 2026 Cua AI, Inc.--import CuaSDK-import CuaSpacesFFI-import SwiftUI--/// "Enroll This Device": Sign in again, or Approve from another device-/// (the one-time code shows while this Mac waits). The core's-/// `appEnrollView`.-struct EnrollSheet: View {- @Bindable var devices: DevicesModel-- var body: some View {- if let v = devices.enrollView {- VStack(alignment: .leading, spacing: 14) {- Text(v.title).font(.headline)- Text(v.lede).foregroundStyle(.secondary)- if !v.options.isEmpty {- VStack(spacing: 8) {- ForEach(v.options, id: \.title) { o in- Button {- Task { await devices.chooseEnroll(o.method) }- } label: {- HStack(spacing: 10) {- Image(systemName: o.method == .signIn ? "person.crop.circle" : "number")- .font(.title3)- .frame(width: 24)- VStack(alignment: .leading, spacing: 2) {- Text(o.title)- Text(o.detail).font(.caption).foregroundStyle(.secondary)- }- Spacer()- Image(systemName: "chevron.right").foregroundStyle(.tertiary)- }- .contentShape(Rectangle())- .padding(10)- }- .buttonStyle(.plain)- .background(.quaternary.opacity(0.5), in: RoundedRectangle(cornerRadius: 8))- .accessibilityIdentifier("enroll-\(o.method == .signIn ? "sign-in" : "approve")")- }- }- }- if let code = v.code {- Text(code)- .font(.system(size: 30, weight: .semibold, design: .monospaced))- .textSelection(.enabled)- .frame(maxWidth: .infinity)- .padding(.vertical, 6)- .accessibilityIdentifier("enroll-code")- }- if let help = v.codeHelp {- Text((try? AttributedString(markdown: help)) ?? AttributedString(help))- .font(.callout).foregroundStyle(.secondary).fixedSize(horizontal: false, vertical: true)- }- if let status = v.status {- HStack(spacing: 8) {- if v.busy { ProgressView().controlSize(.small) }- if v.done { Image(systemName: "checkmark.circle.fill").foregroundStyle(.green) }- Text(status).foregroundStyle(.secondary)- }- }- if let error = v.error {- Text(error).foregroundStyle(.red).lineLimit(3)- }- HStack {- Spacer()- if let back = v.backLabel { Button(back) { devices.backEnroll() } }- Button(v.closeLabel) { devices.closeEnroll() }- .keyboardShortcut(v.done ? .defaultAction : .cancelAction)- }- }- .padding(20)- .frame(width: 440)- }- }-}--/// A device asking to join (or to be re-verified): its name, the code it-/// shows, Approve (Touch ID or the login password first) and Deny. The-/// core's `appApproveView`.-struct DeviceApprovalSheet: View {- @Bindable var devices: DevicesModel-- var body: some View {- if let v = devices.approvalView {- VStack(alignment: .leading, spacing: 14) {- HStack(spacing: 10) {- Image(systemName: "laptopcomputer.and.iphone").font(.title2).foregroundStyle(.secondary)- Text(v.title).font(.headline)- }- Text(v.message).foregroundStyle(.secondary).fixedSize(horizontal: false, vertical: true)- if v.needsCode {- TextField(v.codeLabel, text: Binding(get: { v.code }, set: { devices.setCode($0) }),- prompt: Text(v.codePlaceholder))- .font(.system(size: 20, weight: .medium, design: .monospaced))- .textFieldStyle(.roundedBorder)- .disabled(v.busy)- .onSubmit { Task { await devices.approve() } }- .accessibilityIdentifier("approve-code")- }- if let error = v.error {- Text(error).foregroundStyle(.red).lineLimit(2)- }- HStack {- if v.busy { ProgressView().controlSize(.small) }- Spacer()- Button(v.denyLabel) { Task { await devices.deny() } }- .disabled(v.busy)- .accessibilityIdentifier("approve-deny")- Button {- Task { await devices.approve() }- } label: {- Label(v.approveLabel, systemImage: "touchid")- }- .buttonStyle(.borderedProminent)- .keyboardShortcut(.defaultAction)- .disabled(!v.canApprove)- .accessibilityIdentifier("approve-approve")- }- }- .padding(20)- .frame(width: 420)- }- }-}--/// The main window's slim bar when this Mac needs enrolling or-/// re-verifying (the core's banner).-struct DevicesBanner: View {- @Bindable var devices: DevicesModel-- var body: some View {- if let b = devices.banner {- HStack(spacing: 8) {- Image(systemName: b.tone == .critical ? "exclamationmark.triangle.fill" : "exclamationmark.circle")- .foregroundStyle(b.tone == .critical ? .red : .orange)- Text(b.text).lineLimit(1).truncationMode(.tail).help(b.text)- Spacer(minLength: 8)- if let label = b.actionLabel {- Button(label) { devices.startEnroll(in: .main) }- .controlSize(.small)- .accessibilityIdentifier("banner-enroll")- }- }- .font(.callout)- .padding(.horizontal, 12)- .padding(.vertical, 7)- .background(.bar)- .overlay(alignment: .bottom) { Divider() }- .accessibilityIdentifier("devices-banner")- }- }-}--/// The relay allowance for the month is used up: one line above the main-/// window with Upgrade, until dismissed. Nothing stops at the limit, so it-/// only says so. The words are the core's (`appRelayUsageView`).-struct RelayAllowanceBanner: View {- @Bindable var devices: DevicesModel- @Environment(\.openURL) private var openURL-- var body: some View {- if let notice = devices.relayNotice {- HStack(spacing: 8) {- Text(notice.text).lineLimit(2).foregroundStyle(.secondary).help(notice.text)- Spacer(minLength: 8)- if let url = notice.upgradeUrl.flatMap(URL.init(string:)) {- Button(notice.upgrade) {- devices.recordUpsell("upsell_meter_click")- openURL(url)- }- .controlSize(.small)- .accessibilityIdentifier("relay-upgrade")- }- Button {- devices.dismissRelayNotice()- } label: {- Image(systemName: "xmark")- }- .buttonStyle(.borderless)- .controlSize(.small)- .accessibilityLabel(notice.dismiss)- .accessibilityIdentifier("relay-dismiss")- }- .font(.callout)- .padding(.horizontal, 12)- .padding(.vertical, 7)- .background(.bar)- .overlay(alignment: .bottom) { Divider() }- .accessibilityIdentifier("relay-allowance")- .onAppear { devices.recordUpsell("upsell_meter_shown") }- }- }-}--/// Sharing is for teams (CUA-1883): one line, once, saying who can no longer-/// open a shared computer, with "Invite to your team". The words are the-/// app core's; closing it tells the account it was seen.-struct ShareRemovalBanner: View {- @Bindable var model: AppModel- @Environment(\.openURL) private var openURL-- var body: some View {- if let note = model.shareRemovalNote {- HStack(spacing: 8) {- Text(note.text).lineLimit(2).foregroundStyle(.secondary).help(note.text)- Spacer(minLength: 8)- if let url = URL(string: note.action.url) {- Button(note.action.label) { openURL(url) }- .controlSize(.small)- .accessibilityIdentifier("share-removal-invite")- }- Button {- model.dismissShareRemovalNote()- } label: {- Image(systemName: "xmark")- }- .buttonStyle(.borderless)- .controlSize(.small)- .accessibilityLabel(note.dismiss)- .accessibilityIdentifier("share-removal-dismiss")- }- .font(.callout)- .padding(.horizontal, 12)- .padding(.vertical, 7)- .background(.bar)- .overlay(alignment: .bottom) { Divider() }- .accessibilityIdentifier("share-removal")- }- }-}diff --git a/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Views/GettingStartedView.swift b/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Views/GettingStartedView.swiftdeleted file mode 100644index 711f34d09e..0000000000--- a/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Views/GettingStartedView.swift+++ /dev/null@@ -1,81 +0,0 @@-// SPDX-License-Identifier: FSL-1.1-MIT-// Copyright (c) 2026 Cua AI, Inc.--import CuaSpacesFFI-import SwiftUI--/// The getting-started checklist: the core's rows (`appChecklistView`),-/// each step's button, and × to close it (Getting Started in the Help menu-/// or the command palette opens it again).-struct GettingStartedView: View {- let model: AppModel-- var body: some View {- let view = model.checklist.view- Form {- Section {- ForEach(view.rows, id: \.step) { row in- ChecklistRowView(row: row) {- Task { await model.runChecklistStep(row.step) }- }- }- } header: {- HStack(alignment: .firstTextBaseline, spacing: 10) {- VStack(alignment: .leading, spacing: 2) {- Text(view.title).font(.headline)- Text(view.detail).font(.callout).foregroundStyle(.secondary)- }- Spacer()- Text(view.progress)- .font(.callout.monospacedDigit())- .foregroundStyle(.secondary)- .accessibilityIdentifier("checklist-progress")- Button {- model.checklist.send(.dismiss)- model.selection = model.sidebar.selectedId.map { .space($0) }- } label: {- Image(systemName: "xmark")- }- .buttonStyle(.borderless)- .help(view.closeLabel)- .accessibilityLabel(view.closeLabel)- .accessibilityIdentifier("checklist-close")- }- .padding(.bottom, 4)- }- }- .formStyle(.grouped)- .navigationTitle(view.title)- .onAppear { model.checklist.send(.shown) }- }-}--/// One step: a tick when done, its title and line, and its button until done.-struct ChecklistRowView: View {- let row: AppChecklistRow- let action: () -> Void-- var body: some View {- HStack(spacing: 12) {- Image(systemName: row.done ? "checkmark.circle.fill" : "circle")- .font(.title3)- .foregroundStyle(row.done ? Color.accentColor : Color.secondary)- .accessibilityHidden(true)- VStack(alignment: .leading, spacing: 2) {- Text(row.title)- .strikethrough(row.done)- .foregroundStyle(row.done ? .secondary : .primary)- Text(row.detail)- .font(.callout)- .foregroundStyle(.secondary)- }- Spacer(minLength: 8)- if !row.done {- Button(row.action, action: action)- }- }- .accessibilityElement(children: .combine)- .accessibilityValue(row.done ? "Done" : "")- .accessibilityIdentifier("checklist-step")- }-}diff --git a/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Views/ImageField.swift b/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Views/ImageField.swiftdeleted file mode 100644index 32a6de5a45..0000000000--- a/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Views/ImageField.swift+++ /dev/null@@ -1,106 +0,0 @@-// SPDX-License-Identifier: FSL-1.1-MIT-// Copyright (c) 2026 Cua AI, Inc.--import CuaSDK-import CuaSpacesFFI-import SwiftUI--/// The New Space image field: any image reference, with the catalog's-/// presets as suggestions under it. Filtering, the highlighted row, what-/// Return picks and validation are the app core's (`AppImageFieldView`);-/// the Tauri app draws the same view.-struct ImageField: View {- let field: AppWizardField- let view: AppImageFieldView- let send: (AppWizardAction) -> Void-- var body: some View {- LabeledContent(field.label) {- HStack(spacing: 4) {- TextField(field.label, text: Binding(get: { view.text },- set: { send(.setImageText(text: $0)) }),- prompt: field.placeholder.map(Text.init))- .labelsHidden()- .multilineTextAlignment(.trailing)- .autocorrectionDisabled()- .onKeyPress(.downArrow) { send(.moveImageSuggestion(delta: 1)); return .handled }- .onKeyPress(.upArrow) { send(.moveImageSuggestion(delta: -1)); return .handled }- .onKeyPress(.return) {- guard view.open else { return .ignored }- send(.pickImageSuggestion)- return .handled- }- .onKeyPress(.escape) {- guard view.open else { return .ignored }- send(.dismissImageSuggestions)- return .handled- }- .accessibilityIdentifier("image-field")- Button {- send(view.open ? .dismissImageSuggestions : .openImageSuggestions)- } label: {- Image(systemName: "chevron.up.chevron.down")- }- .buttonStyle(.borderless)- .accessibilityLabel("Show images")- }- .popover(isPresented: Binding(get: { view.open },- set: { if !$0 { send(.dismissImageSuggestions) } }),- arrowEdge: .bottom) {- SuggestionList(groups: view.groups, send: send)- }- }- if let error = field.error {- Text(error).foregroundStyle(.red).font(.callout)- }- }-}--/// The presets, grouped by catalog group, one line a row: the ref, then-/// the image's name.-private struct SuggestionList: View {- let groups: [AppSuggestionGroup]- let send: (AppWizardAction) -> Void-- var body: some View {- ScrollView {- VStack(alignment: .leading, spacing: 0) {- ForEach(groups, id: \.id) { group in- Text(group.label)- .font(.caption.weight(.medium))- .foregroundStyle(.secondary)- .padding(.horizontal, 8)- .padding(.top, 6)- .padding(.bottom, 2)- ForEach(group.rows, id: \.imageRef) { row in- HStack(spacing: 12) {- Text(row.imageRef).lineLimit(1).truncationMode(.middle)- Spacer(minLength: 0)- Text(row.label)- .foregroundStyle(row.highlighted ? AnyShapeStyle(.white.opacity(0.85))- : AnyShapeStyle(.secondary))- .lineLimit(1)- }- .foregroundStyle(row.highlighted ? AnyShapeStyle(.white) : AnyShapeStyle(.primary))- .padding(.horizontal, 8)- .padding(.vertical, 3)- .background(row.highlighted ? Color.accentColor : .clear,- in: RoundedRectangle(cornerRadius: 5))- .contentShape(Rectangle())- .onTapGesture { send(.chooseImage(imageRef: row.imageRef)) }- .accessibilityAddTraits(row.highlighted ? .isSelected : [])- }- }- }- .padding(5)- }- .frame(width: 420, height: height)- .focusable(false)- }-- /// Fits the rows, up to a scrolling maximum.- private var height: CGFloat {- let rows = groups.reduce(0) { $0 + $1.rows.count }- return min(260, CGFloat(groups.count) * 24 + CGFloat(rows) * 22 + 10)- }-}diff --git a/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Views/KeyvaultViews.swift b/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Views/KeyvaultViews.swiftdeleted file mode 100644index ef0af231e4..0000000000--- a/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Views/KeyvaultViews.swift+++ /dev/null@@ -1,747 +0,0 @@-// SPDX-License-Identifier: FSL-1.1-MIT-// Copyright (c) 2026 Cua AI, Inc.--import CuaSDK-import CuaSpacesFFI-import SwiftUI--/// The Keyvault, as a sidebar and list: the sidebar picks a category or an-/// app; this pane lists it. The vault list is a password manager's: items-/// grouped by the app they came from, each with a lock. Everything shown is-/// derived by the core from what the broker returned; nothing here decides-/// access and no secret value is ever here.-struct KeyvaultDetail: View {- @Bindable var keyvault: KeyvaultModel- let selection: KvSelection-- var body: some View {- let page = keyvault.page- Group {- if !page.ready {- unavailable(page)- } else {- let list = keyvault.list- if list.vault {- VaultList(keyvault: keyvault, page: page)- } else if case .app = selection {- ContentUnavailableView { Text(list.emptyText ?? "") }- } else {- CategoryList(keyvault: keyvault, page: page)- }- }- }- .navigationTitle(keyvault.list.title.isEmpty ? "Keyvault" : keyvault.list.title)- .task(id: keyvault.overview.items.count) { await keyvault.loadIcons() }- .onAppear { keyvault.selection = selection }- .onChange(of: selection) { _, new in keyvault.selection = new }- .task(id: "kv-poll") {- while !Task.isCancelled {- await keyvault.refresh()- try? await Task.sleep(for: .seconds(5))- }- }- .safeAreaInset(edge: .top) { banners(page) }- }-- @ViewBuilder private func banners(_ page: KvPage) -> some View {- VStack(spacing: 0) {- if let banner = page.disabledBanner { Banner(text: banner, error: true) }- if let notice = page.resetNotice { Banner(text: notice, error: false) }- if let error = keyvault.error { Banner(text: error, error: true) }- if let key = keyvault.recoveryKey { Banner(text: kvRecoveryKeyText(key: key), error: false) }- }- }-- private func unavailable(_ page: KvPage) -> some View {- ContentUnavailableView {- Text(page.unavailableTitle ?? "The Keyvault is unavailable")- } description: {- Text(page.message ?? "")- } actions: {- if let form = page.form {- CredentialForm(keyvault: keyvault, form: form)- }- }- }-}--/// Set up or unlock: one button for Touch ID, or secure fields for a-/// passphrase (twice for setup) when the daemon cannot use the OS key store.-struct CredentialForm: View {- @Bindable var keyvault: KeyvaultModel- let form: KvCredentialForm-- var body: some View {- VStack(spacing: 8) {- if form.method == .passphrase {- PassphraseFields(keyvault: keyvault, form: form)- }- Button(form.submitLabel) { Task { await keyvault.submitCredential() } }- .buttonStyle(.glassProminent)- .keyboardShortcut(.defaultAction)- .disabled(!keyvault.canSubmitCredential)- Text(keyvault.passphraseCheck?.hint ?? form.help)- .font(.caption)- .foregroundStyle(.secondary)- .multilineTextAlignment(.center)- .fixedSize(horizontal: false, vertical: true)- }- .textFieldStyle(.roundedBorder)- .frame(width: 340)- .onSubmit { Task { await keyvault.submitCredential() } }- }-}--/// The passphrase and, at setup, its confirmation, typed into the model's-/// fields (`submitCredential` reads and clears them).-struct PassphraseFields: View {- @Bindable var keyvault: KeyvaultModel- let form: KvCredentialForm- @FocusState private var focused: Bool-- var body: some View {- SecureField(form.passphraseLabel ?? "", text: $keyvault.passphrase)- .focused($focused)- .onAppear { focused = true }- if let confirm = form.confirmLabel {- SecureField(confirm, text: $keyvault.passphraseConfirm)- }- }-}--/// The passphrase form as a sheet on the New UI window (`keyvault.setup`,-/// `keyvault.unlockVault`): the same fields and hint as `CredentialForm`,-/// with Cancel. `done(true)` sends it; the bridge then submits as the-/// SwiftUI form does, so the passphrase stays in this process.-struct PassphraseSheet: View {- @Bindable var keyvault: KeyvaultModel- let form: KvCredentialForm- let done: (Bool) -> Void-- var body: some View {- VStack(alignment: .leading, spacing: 8) {- Text(form.mode == .setup ? "Set up Keyvault" : "Unlock Keyvault")- .font(.headline)- Text(form.help)- .font(.callout)- .foregroundStyle(.secondary)- .fixedSize(horizontal: false, vertical: true)- .padding(.bottom, 4)- PassphraseFields(keyvault: keyvault, form: form)- Text(keyvault.passphraseCheck?.hint ?? " ")- .font(.caption)- .foregroundStyle(.secondary)- .fixedSize(horizontal: false, vertical: true)- HStack {- Spacer()- Button("Cancel", role: .cancel) { done(false) }- .keyboardShortcut(.cancelAction)- Button(form.submitLabel) { done(true) }- .keyboardShortcut(.defaultAction)- .disabled(!keyvault.canSubmitCredential)- }- .padding(.top, 4)- }- .textFieldStyle(.roundedBorder)- .padding(20)- .frame(width: 380)- .onSubmit { if keyvault.canSubmitCredential { done(true) } }- }-}--struct Banner: View {- let text: String- let error: Bool-- var body: some View {- Text(text)- .font(.callout)- .frame(maxWidth: .infinity, alignment: .leading)- .padding(.horizontal, 16).padding(.vertical, 8)- .background(error ? Color.red.opacity(0.12) : Color.accentColor.opacity(0.10))- }-}--/// The vault list: apps, their sites and items, each with a lock; checkboxes-/// select items, a site or a whole app for the batch bar (lock, unlock,-/// delete). Search matches a domain, a key, an app or a type.-struct VaultList: View {- @Bindable var keyvault: KeyvaultModel- let page: KvPage-- var body: some View {- let view = keyvault.vaultView- VStack(spacing: 0) {- SearchBar(keyvault: keyvault, view: view)- if view.namesHidden { HiddenNames(view: view, keyvault: keyvault) }- if let empty = view.emptyText {- ContentUnavailableView { Text(empty) }- } else {- List {- ForEach(VaultLine.lines(view), id: \.id) { line in- VaultLineRow(line: line, keyvault: keyvault, blocked: page.disabled)- .listRowSeparator(.visible)- }- }- .listStyle(.inset)- .accessibilityIdentifier("vault-list")- }- }- .safeAreaInset(edge: .bottom) {- if view.selection.count > 0 { BatchBar(keyvault: keyvault, selection: view.selection, blocked: page.disabled) }- }- .sheet(item: $keyvault.unlockPrompt) { pending in- UnlockPromptSheet(prompt: pending.prompt) { answer in Task { await keyvault.answerUnlock(answer) } }- }- .sheet(item: $keyvault.deleteConfirm) { pending in- DeleteConfirmSheet(confirm: pending.confirm,- onDelete: { Task { await keyvault.confirmDelete() } },- onCancel: { keyvault.deleteConfirm = nil })- }- }-}--/// Search by domain, key, app or type, and Select All.-struct SearchBar: View {- let keyvault: KeyvaultModel- let view: KvVaultView-- var body: some View {- HStack(spacing: 10) {- HStack(spacing: 6) {- Image(systemName: "magnifyingglass").foregroundStyle(.secondary)- TextField(view.searchPrompt, text: Binding(get: { keyvault.query }, set: { keyvault.query = $0 }))- .textFieldStyle(.plain)- .accessibilityIdentifier("vault-search")- if !keyvault.query.isEmpty {- Button { keyvault.query = "" } label: {- Image(systemName: "xmark.circle.fill").foregroundStyle(.secondary)- }- .buttonStyle(.plain)- .accessibilityLabel("Clear search")- }- }- .padding(.horizontal, 8).padding(.vertical, 5)- .background(RoundedRectangle(cornerRadius: 7).fill(Color.secondary.opacity(0.12)))- if view.canSelectAll {- Button(view.selection.count == view.shown ? "Select None" : "Select All") {- keyvault.send(view.selection.count == view.shown ? .clear : .selectAll)- }- .buttonStyle(.link)- .accessibilityIdentifier("vault-select-all")- }- }- .padding(.horizontal, 16).padding(.vertical, 10)- }-}--/// The names are hidden until the user confirms with Touch ID.-struct HiddenNames: View {- let view: KvVaultView- let keyvault: KeyvaultModel-- var body: some View {- HStack(spacing: 10) {- Image(systemName: "eye.slash").foregroundStyle(.secondary)- Text(view.hiddenNote ?? "").foregroundStyle(.secondary).lineLimit(2)- Spacer()- Button(view.showNamesLabel) { Task { await keyvault.showItems() } }- .disabled(keyvault.busy)- .accessibilityIdentifier("vault-show-items")- }- .padding(.horizontal, 16).padding(.vertical, 10)- .background(.bar)- .overlay(alignment: .bottom) { Divider() }- }-}--/// One line of the flattened list: an app, a site, the files of an app, or-/// an item. The core decides what is open.-enum VaultLine: Identifiable {- case app(KvVaultApp)- case site(KvVaultApp, KvVaultSite)- case files(KvVaultApp, KvVaultFiles)- case item(KvVaultRow, indent: Int)-- var id: String {- switch self {- case .app(let a): return "app:\(a.key)"- case .site(_, let s): return "site:\(s.key)"- case .files(_, let f): return "files:\(f.key)"- case .item(let r, _): return "item:\(r.id)"- }- }-- static func lines(_ view: KvVaultView) -> [VaultLine] {- var out: [VaultLine] = []- for app in view.apps {- out.append(.app(app))- guard app.open else { continue }- for site in app.sites {- out.append(.site(app, site))- if site.open { out += site.rows.map { .item($0, indent: 2) } }- }- if let files = app.files {- out.append(.files(app, files))- if files.open { out += files.rows.map { .item($0, indent: 2) } }- }- }- return out- }-}--struct VaultLineRow: View {- let line: VaultLine- let keyvault: KeyvaultModel- let blocked: Bool-- var body: some View {- switch line {- case .app(let app):- GroupRow(indent: 0, selected: app.selected, open: app.open,- onSelect: { keyvault.send(.toggleGroup(key: app.key)) },- onOpen: { keyvault.send(.toggleOpen(key: app.key)) }) {- AppIcon(keyvault: keyvault, providerId: app.providerId, name: app.name)- } title: {- Text(app.name).font(.headline).lineLimit(1)- } detail: {- Text(app.summary)- } trailing: {- updated(app.updated)- LockButton(state: app.lock, name: app.name, unlock: app.unlockIds, lock: app.lockIds,- keyvault: keyvault, blocked: blocked)- }- case .site(_, let site):- GroupRow(indent: 1, selected: site.selected, open: site.open,- onSelect: { keyvault.send(.toggleGroup(key: site.key)) },- onOpen: { keyvault.send(.toggleOpen(key: site.key)) }) {- SiteIcon(keyvault: keyvault, site: site.site)- } title: {- Text(site.site).lineLimit(1)- } detail: {- Text(site.counts)- } trailing: {- updated(site.updated)- LockButton(state: site.lock, name: site.site, unlock: site.unlockIds, lock: site.lockIds,- keyvault: keyvault, blocked: blocked)- }- case .files(_, let files):- GroupRow(indent: 1, selected: files.selected, open: files.open,- onSelect: { keyvault.send(.toggleGroup(key: files.key)) },- onOpen: { keyvault.send(.toggleOpen(key: files.key)) }) {- Image(systemName: "folder").foregroundStyle(.secondary).frame(width: 20)- } title: {- Text("Files").lineLimit(1)- } detail: {- Text("\(files.count) file\(files.count == 1 ? "" : "s")")- } trailing: {- LockButton(state: files.lock, name: "files", unlock: files.unlockIds, lock: files.lockIds,- keyvault: keyvault, blocked: blocked)- }- case .item(let row, let indent):- ItemRow(row: row, indent: indent, keyvault: keyvault, blocked: blocked)- }- }-- private func updated(_ text: String) -> some View {- Text(text).font(.caption).foregroundStyle(.secondary).lineLimit(1)- }-}--/// A checkbox that is one of off, on or mixed.-struct TriCheckbox: View {- let state: KvTri- let label: String- let action: () -> Void-- var body: some View {- Button(action: action) {- Image(systemName: state == .on ? "checkmark.square.fill" : state == .mixed ? "minus.square.fill" : "square")- .foregroundStyle(state == .off ? Color.secondary : Color.accentColor)- .imageScale(.large)- }- .buttonStyle(.plain)- .accessibilityLabel(label)- .accessibilityValue(state == .on ? "selected" : state == .mixed ? "some selected" : "not selected")- }-}--/// An app, a site or a file group: checkbox, disclosure, icon, name, detail.-struct GroupRow<Icon: View, Title: View, Detail: View, Trailing: View>: View {- let indent: Int- let selected: KvTri- let open: Bool- let onSelect: () -> Void- let onOpen: () -> Void- @ViewBuilder let icon: Icon- @ViewBuilder let title: Title- @ViewBuilder let detail: Detail- @ViewBuilder let trailing: Trailing-- init(indent: Int, selected: KvTri, open: Bool, onSelect: @escaping () -> Void, onOpen: @escaping () -> Void,- @ViewBuilder icon: () -> Icon, @ViewBuilder title: () -> Title, @ViewBuilder detail: () -> Detail,- @ViewBuilder trailing: () -> Trailing) {- self.indent = indent; self.selected = selected; self.open = open- self.onSelect = onSelect; self.onOpen = onOpen- self.icon = icon(); self.title = title(); self.detail = detail(); self.trailing = trailing()- }-- var body: some View {- HStack(spacing: 8) {- TriCheckbox(state: selected, label: "Select", action: onSelect)- Button(action: onOpen) {- Image(systemName: open ? "chevron.down" : "chevron.right")- .font(.caption.weight(.semibold)).foregroundStyle(.secondary).frame(width: 12)- }- .buttonStyle(.plain)- .accessibilityLabel(open ? "Collapse" : "Expand")- icon- title- detail.font(.callout).foregroundStyle(.secondary).lineLimit(1)- Spacer(minLength: 8)- trailing- }- .padding(.leading, CGFloat(indent) * 22)- .padding(.vertical, 3)- .contentShape(Rectangle())- .onTapGesture(perform: onOpen)- }-}--/// One secret: its type icon, its key, its domain in grey, when it was-/// saved in grey, and its lock. Never its value.-struct ItemRow: View {- let row: KvVaultRow- let indent: Int- let keyvault: KeyvaultModel- let blocked: Bool-- var body: some View {- HStack(spacing: 8) {- TriCheckbox(state: row.selected ? .on : .off, label: "Select \(row.title)") {- keyvault.send(.toggle(id: row.id))- }- Image(systemName: row.symbol).foregroundStyle(.secondary).frame(width: 20)- .help(row.kindLabel)- VStack(alignment: .leading, spacing: 1) {- Text(row.title).lineLimit(1).truncationMode(.middle)- if !row.subtitle.isEmpty {- Text(row.subtitle).font(.caption).foregroundStyle(.secondary).lineLimit(1)- }- }- Spacer(minLength: 8)- Text(row.updated).font(.caption).foregroundStyle(.secondary).lineLimit(1)- LockButton(state: row.locked ? .locked : .unlocked, name: row.title,- unlock: row.locked && !row.identityProvider ? [row.id] : [],- lock: row.locked ? [] : [row.id], keyvault: keyvault, blocked: blocked,- help: row.lockHelp)- }- .padding(.leading, CGFloat(indent) * 22)- .padding(.vertical, 2)- .contentShape(Rectangle())- .onTapGesture { keyvault.send(.toggle(id: row.id)) }- .accessibilityElement(children: .contain)- .accessibilityIdentifier("vault-item-\(row.id)")- }-}--/// The lock: closed while every use needs approval, open once unattended-/// access is allowed. A click flips it for what it stands for (an item, a-/// site, an app); unlocking asks first, then Touch ID once.-struct LockButton: View {- let state: KvLock- let name: String- let unlock: [String]- let lock: [String]- let keyvault: KeyvaultModel- let blocked: Bool- var help: String?-- var body: some View {- Button {- Task {- if state == .unlocked { await keyvault.lock(ids: lock) }- else if !unlock.isEmpty { await keyvault.requestUnlock(ids: unlock, name: unlock.count == 1 ? name : nil) }- }- } label: {- Image(systemName: state.symbol)- .imageScale(.medium)- .foregroundStyle(state == .locked ? Color.secondary : Color.orange)- .opacity(state == .mixed ? 0.55 : 1)- .frame(width: 22, height: 22)- }- .buttonStyle(.plain)- .disabled(blocked || keyvault.busy || (state == .locked && unlock.isEmpty))- .help(help ?? (state == .unlocked ? "Unlocked. Click to lock." : state == .mixed ? "Some unlocked. Click to unlock the rest." : "Locked. Click to allow unattended access."))- .accessibilityLabel(state == .unlocked ? "Lock \(name)" : "Unlock \(name)")- .accessibilityValue(state == .unlocked ? "unlocked" : state == .mixed ? "partly unlocked" : "locked")- }-}--extension KvLock {- /// The SF Symbol: the core's, mirrored here for the closed and open lock.- var symbol: String {- switch self {- case .locked: return "lock.fill"- case .unlocked: return "lock.open"- case .mixed: return "lock.open"- }- }-}--/// The batch bar: what the selection can do, together.-struct BatchBar: View {- let keyvault: KeyvaultModel- let selection: KvVaultSelection- let blocked: Bool-- var body: some View {- HStack(spacing: 10) {- Text(selection.title).fontWeight(.medium)- Button("Clear") { keyvault.send(.clear) }.buttonStyle(.link)- Spacer()- Button { Task { await keyvault.lock(ids: selection.lockIds) } } label: {- Label("Lock", systemImage: "lock.fill")- }- .disabled(!selection.canLock || keyvault.busy)- .accessibilityIdentifier("batch-lock")- Button { Task { await keyvault.requestUnlock(ids: selection.unlockIds) } } label: {- Label("Unlock", systemImage: "lock.open")- }- .disabled(!selection.canUnlock || blocked || keyvault.busy)- .help(selection.alwaysAsk > 0 ? "Identity provider sessions always ask and stay locked." : "")- .accessibilityIdentifier("batch-unlock")- Button(role: .destructive) { keyvault.requestDelete(ids: selection.ids) } label: {- Label("Delete", systemImage: "trash")- }- .disabled(keyvault.busy)- .accessibilityIdentifier("batch-delete")- }- .padding(.horizontal, 16).padding(.vertical, 10)- .background(.bar)- .overlay(alignment: .top) { Divider() }- }-}--/// A site's icon (the browser's own, else Google's when allowed), else the-/// globe. It asks for the icon once, as it first appears.-struct SiteIcon: View {- let keyvault: KeyvaultModel- let site: String-- var body: some View {- Group {- if let image = keyvault.siteIcons[site] {- Image(nsImage: image).resizable().interpolation(.high).clipShape(RoundedRectangle(cornerRadius: 3))- .frame(width: 16, height: 16)- } else {- Image(systemName: "globe").foregroundStyle(.secondary)- }- }- .frame(width: 20)- .accessibilityHidden(true)- .task(id: site) { await keyvault.siteIcon(site) }- }-}--/// An app's icon from the cache, else its first letter.-struct AppIcon: View {- let keyvault: KeyvaultModel- let providerId: String- let name: String-- var body: some View {- Group {- if let image = keyvault.icons[providerId] {- Image(nsImage: image).resizable().interpolation(.high)- } else {- RoundedRectangle(cornerRadius: 5).fill(Color.secondary.opacity(0.18))- .overlay(Text(String(name.prefix(1)).uppercased()).font(.system(size: 11, weight: .semibold)))- }- }- .frame(width: 22, height: 22)- .accessibilityHidden(true)- }-}--/// "Allow unattended access?": what unlocking allows, then Deny, Allow or-/// Never ask again. Touch ID comes next, from the daemon.-struct UnlockPromptSheet: View {- let prompt: KvUnlockPrompt- let onAnswer: (UnlockAnswer) -> Void-- var body: some View {- VStack(alignment: .leading, spacing: 14) {- HStack(alignment: .top, spacing: 12) {- Image(systemName: "lock.open.fill").font(.system(size: 26)).foregroundStyle(.orange)- VStack(alignment: .leading, spacing: 2) {- Text(prompt.title).font(.headline)- Text(prompt.subject).foregroundStyle(.secondary).lineLimit(1).truncationMode(.middle)- }- }- Text(prompt.message).fixedSize(horizontal: false, vertical: true)- HStack {- Button(prompt.neverAsk) { onAnswer(.neverAskAgain) }- .accessibilityIdentifier("unlock-never-ask")- Spacer()- Button(prompt.deny) { onAnswer(.deny) }- .keyboardShortcut(.cancelAction)- .accessibilityIdentifier("unlock-deny")- Button(prompt.allow) { onAnswer(.allow) }- .keyboardShortcut(.defaultAction)- .buttonStyle(.borderedProminent)- .accessibilityIdentifier("unlock-allow")- }- }- .padding(20)- .frame(width: 440)- }-}--/// "Delete 3 items?": says when live copies in Spaces are wiped too.-struct DeleteConfirmSheet: View {- let confirm: KvDeleteConfirm- let onDelete: () -> Void- let onCancel: () -> Void-- var body: some View {- VStack(alignment: .leading, spacing: 14) {- HStack(alignment: .top, spacing: 12) {- Image(systemName: "trash").font(.system(size: 24)).foregroundStyle(.red)- Text(confirm.title).font(.headline)- }- Text(confirm.message).fixedSize(horizontal: false, vertical: true)- HStack {- Spacer()- Button(confirm.cancel, action: onCancel).keyboardShortcut(.cancelAction)- Button(confirm.confirm, role: .destructive, action: onDelete)- .keyboardShortcut(.defaultAction)- .accessibilityIdentifier("delete-confirm")- }- }- .padding(20)- .frame(width: 420)- }-}--/// Waiting, Access or Recent.-struct CategoryList: View {- @Bindable var keyvault: KeyvaultModel- let page: KvPage-- var body: some View {- let list = keyvault.list- ScrollViewReader { proxy in- Form {- if !list.pending.isEmpty {- Section {- ForEach(list.pending, id: \.id) { p in- HStack {- Text("\(p.caller) (\(p.badge.text)) \u{b7} \(p.summary) \u{b7} \(p.wants)")- .lineLimit(1).help(p.claims.joined(separator: "\n"))- Spacer()- Button(page.labels.deny) { Task { await keyvault.deny(p.id) } }- Button(page.labels.review) { keyvault.openApproval(p.id) }- .disabled(page.disabled || keyvault.busy)- }- }- }- }- if !list.access.isEmpty {- Section {- if page.revokeAll {- HStack {- Spacer()- Button(page.labels.revokeAll) { Task { await keyvault.run(.revokeGrant(id: "*")) } }- .disabled(keyvault.busy)- }- }- ForEach(list.access, id: \.key) { a in- HStack {- Text(a.detail.isEmpty ? a.text : "\(a.text) \u{b7} \(a.detail)").lineLimit(1).help(a.detail)- Spacer()- // Hides the notch's indicator only; Wipe removes it.- if !a.imports.isEmpty, !keyvault.isDismissed(a) {- Button("Dismiss") { keyvault.dismiss(a.imports) }- .help("Hide from the notch. Access stays until you wipe it.")- }- Button(a.actionLabel) { Task { await keyvault.run(a.command) } }- .disabled(keyvault.busy)- }- .id(a.key)- .listRowBackground(keyvault.focusKey == a.key ? Color.accentColor.opacity(0.12) : nil)- }- }- }- if !list.recent.isEmpty {- Section {- ForEach(list.recent, id: \.decision.entry.seq) { r in- LabeledContent {- Text(r.age).foregroundStyle(.secondary)- } label: {- Text("\(r.decision.verb) \(r.decision.what)").lineLimit(1)- }- }- } footer: {- if let log = page.logStatus { Text(log) }- }- }- if let empty = list.emptyText {- Text(empty).foregroundStyle(.secondary)- }- }- .formStyle(.grouped)- .task(id: keyvault.focusKey) {- // A Space's "Signed in" badge: bring its row forward, then let- // the highlight go.- guard let key = keyvault.focusKey else { return }- withAnimation { proxy.scrollTo(key, anchor: .center) }- try? await Task.sleep(for: .seconds(2))- if keyvault.focusKey == key { withAnimation { keyvault.focusKey = nil } }- }- }- }-}--/// The approval sheet: nothing is selected until the user ticks items;-/// Approve sends exactly those, and the Cua daemon confirms with Touch ID.-struct ApprovalSheet: View {- @Bindable var keyvault: KeyvaultModel-- var body: some View {- let labels = keyvault.page.labels- if let v = keyvault.approvalView {- VStack(alignment: .leading, spacing: 12) {- Text(v.title).font(.headline)- Text("\(v.badge.text) · to \(v.targets) · \(v.wants)")- .foregroundStyle(.secondary)- .help(v.claims.joined(separator: "\n"))- Form {- ForEach(v.rows, id: \.key) { row in- Toggle(isOn: Binding(- get: { row.selected },- set: { _ in keyvault.sendApproval(.toggle(key: row.key)) })) {- Text("\(row.title) \u{b7} \(row.account)").lineLimit(1)- }- .toggleStyle(.checkbox)- }- }- .formStyle(.grouped)- if let reason = v.blockedReason {- Text(reason).font(.callout).foregroundStyle(.secondary)- }- HStack {- Text(labels.confirmNote).font(.callout).foregroundStyle(.secondary)- Spacer()- Button(labels.cancel) { keyvault.approval = nil }.keyboardShortcut(.cancelAction)- Button(labels.deny) { Task { await keyvault.deny(v.requestId) } }- Button(v.approveLabel) { Task { await keyvault.approve() } }- .keyboardShortcut(.defaultAction)- .disabled(!v.canApprove || keyvault.busy)- }- }- .padding(20)- .frame(width: 480, height: 360)- }- }-}diff --git a/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Views/MachinesViews.swift b/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Views/MachinesViews.swiftdeleted file mode 100644index b94a8cced0..0000000000--- a/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Views/MachinesViews.swift+++ /dev/null@@ -1,695 +0,0 @@-// SPDX-License-Identifier: FSL-1.1-MIT-// Copyright (c) 2026 Cua AI, Inc.--import CuaSpacesFFI-import SwiftUI--/// Machines: the hardware. The list in groups (your machines, those-/// offline for 30+ days, team machines) with one line each, and the-/// selected machine's page: its two switches, the Spaces on it as links,-/// New Space here, Details and Remove from account. Everything shown is-/// the core's `machines_view::view` (`AppModel.machinesView`), the same the-/// New UI draws. A Space's own actions (open, start, stop, teleport, drop-/// files) stay on the Space.-struct MachinesPageView: View {- @Bindable var model: AppModel- @State private var selectedId: String?-- /// `selected`: the machine whose page shows first (default: the first).- init(model: AppModel, selected: String? = nil) {- self.model = model- _selectedId = State(initialValue: selected)- }- @State private var query = ""- @State private var oldOpen = false- @State private var removingOld: AppMachinesViewRemoveAll?- @State private var failure: String?-- var body: some View {- let view = model.machinesView- // A cloud host the pool added shows once, in its own section.- let cloudMachines = model.elastic.machineIds- let rows = view.machines.filter { !cloudMachines.contains($0.id) }- let selected = rows.first { $0.id == selectedId } ?? rows.first- HStack(spacing: 0) {- VStack(alignment: .leading, spacing: 0) {- searchField- List(selection: $selectedId) {- ForEach(view.groups, id: \.id) { group in- groupSection(group, view: view)- }- if model.elastic.visible {- Section("Cloud") {- ForEach(model.elastic.hosts) { host in- CloudHostRowView(host: host).selectionDisabled()- }- }- }- }- .listStyle(.sidebar)- .accessibilityIdentifier("machines-list")- if model.elastic.visible {- ElasticSummaryView(elastic: model.elastic)- }- if rows.count <= 1, !model.elastic.visible {- Text("Only this machine so far. Add another to run Spaces on it from here.")- .font(.callout)- .foregroundStyle(.secondary)- .padding(12)- }- }- .frame(width: 300)- Divider()- Group {- if let machine = selected {- MachinePage(model: model, machine: machine, onError: { failure = $0 })- .id(machine.id)- } else {- ContentUnavailableView {- Label("No computers yet", systemImage: "server.rack")- } description: {- Text("Set up a Mac, Linux or Windows computer and it shows here, ready to run Spaces.")- }- }- }- .frame(maxWidth: .infinity, maxHeight: .infinity)- }- .navigationTitle("Computers")- .navigationSubtitle(view.machines.isEmpty ? "" : view.summary)- // Each machine's own daemon checks its health while the page shows- // (This Mac, and your other machines that are online).- .task {- while !Task.isCancelled {- await model.checkMachineHealth()- try? await Task.sleep(for: .seconds(60))- }- }- .toolbar {- ToolbarItem(placement: .primaryAction) {- Button {- Task { await model.openAddMachine() }- } label: {- Label("Add a computer", systemImage: "plus")- }- .help("Add a computer")- .accessibilityIdentifier("machines-add")- }- }- .alert(removingOld?.confirm.title ?? "", isPresented: Binding(- get: { removingOld != nil }, set: { if !$0 { removingOld = nil } })) {- if let all = removingOld {- Button(all.confirm.confirmLabel, role: .destructive) {- removingOld = nil- Task {- for r in all.removes {- do {- try await model.removeMachine(machine: r.machine, device: r.device)- } catch {- failure = LiveSpacesBackend.words(error)- return- }- }- }- }- Button(all.confirm.cancelLabel, role: .cancel) { removingOld = nil }- }- } message: {- Text(removingOld?.confirm.message ?? "")- }- .alert("Couldn\u{2019}t change the machine", isPresented: Binding(- get: { failure != nil }, set: { if !$0 { failure = nil } })) {- Button("OK") { failure = nil }- } message: {- Text(failure ?? "")- }- }-- private var searchField: some View {- HStack(spacing: 6) {- Image(systemName: "magnifyingglass").foregroundStyle(.secondary)- TextField("Search machines", text: $query)- .textFieldStyle(.plain)- .accessibilityIdentifier("machines-search")- }- .padding(.horizontal, 8)- .frame(height: 28)- .background(.background, in: .rect(cornerRadius: 7))- .overlay(RoundedRectangle(cornerRadius: 7).strokeBorder(.separator))- .padding(.horizontal, 12)- .padding(.top, 12)- .padding(.bottom, 4)- }-- private func matches(_ m: AppMachinesViewMachine) -> Bool {- let q = query.trimmingCharacters(in: .whitespaces).lowercased()- return q.isEmpty || "\(m.name) \(m.line)".lowercased().contains(q)- }-- @ViewBuilder- private func groupSection(_ group: AppMachinesViewGroup, view: AppMachinesView) -> some View {- let rows = group.ids.compactMap { id in view.machines.first { $0.id == id } }.filter(matches)- if !rows.isEmpty {- let open = !group.collapsed || oldOpen || !query.isEmpty- Section {- if open {- ForEach(rows, id: \.id) { m in- MachineRowView(machine: m).tag(m.id)- }- }- } header: {- if group.collapsed {- HStack {- Button {- oldOpen.toggle()- } label: {- Label(group.title, systemImage: open ? "chevron.down" : "chevron.right")- }- .buttonStyle(.plain)- .accessibilityIdentifier("machines-group-\(group.id)")- Spacer()- if let all = group.removeAll {- Button(all.label) { removingOld = all }- .buttonStyle(.link)- .font(.caption)- .accessibilityIdentifier("machines-remove-old")- }- }- } else {- Text(group.title).accessibilityIdentifier("machines-group-\(group.id)")- }- }- }- }-}--/// A cloud host the pool added: name, cloud and type with its state, and-/// what it costs an hour.-struct CloudHostRowView: View {- let host: ElasticHostRow-- var body: some View {- HStack(spacing: 10) {- Image(systemName: "cloud")- .foregroundStyle(.secondary)- .frame(width: 30, height: 30)- .background(.fill.tertiary, in: .rect(cornerRadius: 7))- VStack(alignment: .leading, spacing: 2) {- Text(host.name).lineLimit(1)- Text("\(host.kindLine) \u{00B7} \(host.stateWord)")- .font(.callout)- .foregroundStyle(.secondary)- .lineLimit(1)- }- Spacer(minLength: 4)- Text("\(ElasticSpend.money(host.usdPerHour, perHour: true))/h")- .font(.callout.monospacedDigit())- .foregroundStyle(.secondary)- }- .padding(.vertical, 3)- .opacity(host.running ? 1 : 0.6)- .accessibilityIdentifier("cloud-host-row")- }-}--/// One quiet line (what the clouds cost now and this month) and the last-/// few scaling events in small text.-struct ElasticSummaryView: View {- let elastic: ElasticModel-- var body: some View {- VStack(alignment: .leading, spacing: 3) {- if let spend = elastic.spend {- Text(spend.line)- .font(.callout.monospacedDigit())- .foregroundStyle(.secondary)- .accessibilityIdentifier("elastic-summary")- }- ForEach(elastic.events) { e in- Text("\(e.text) \u{00B7} \(Self.ago(e.at))")- .font(.caption)- .foregroundStyle(.tertiary)- .lineLimit(1)- }- }- .frame(maxWidth: .infinity, alignment: .leading)- .padding(12)- .accessibilityIdentifier("elastic-events")- }-- static func ago(_ at: Int, now: Date = Date()) -> String {- let f = RelativeDateTimeFormatter()- f.unitsStyle = .short- return f.localizedString(for: Date(timeIntervalSince1970: TimeInterval(at)), relativeTo: now)- }-}--/// The OS mark for a page row's system (`os-macos`, ..., `computer`).-/// The OS mark for a machine's system (`os-macos`, ..., `computer`).-private func osIcon(_ os: String) -> String { os.isEmpty ? "computer" : "os-\(os)" }--/// The green dot of a machine that can be used now, grey otherwise;-/// orange or red while it has issues (`health` `warn`, `fail`).-private struct StatusDot: View {- let online: Bool- var health: String = ""- var size: CGFloat = 8- var body: some View {- Circle().fill(color).frame(width: size, height: size)- }-- private var color: Color {- switch health {- case "fail": .red- case "warn": .orange- default: online ? .green : .secondary.opacity(0.5)- }- }-}--/// One machine: its dot, name ("This Mac" beside this one), its one line,-/// and its system's mark.-struct MachineRowView: View {- let machine: AppMachinesViewMachine-- var body: some View {- HStack(spacing: 10) {- StatusDot(online: machine.online, health: machine.health)- VStack(alignment: .leading, spacing: 1) {- HStack(spacing: 6) {- Text(machine.name).fontWeight(.medium).lineLimit(1)- if let badge = machine.badge {- Text(badge)- .font(.caption2.weight(.medium))- .foregroundStyle(.secondary)- .padding(.horizontal, 5)- .padding(.vertical, 1)- .background(.fill.tertiary, in: .rect(cornerRadius: 4))- }- }- Text(machine.line)- .font(.callout)- .foregroundStyle(.secondary)- .lineLimit(1)- .accessibilityIdentifier("machine-line")- }- Spacer(minLength: 4)- OsIconImage(id: osIcon(machine.os), size: 14).foregroundStyle(.tertiary)- }- .padding(.vertical, 2)- .accessibilityElement(children: .combine)- .accessibilityIdentifier("machine-row")- }-}--/// A machine's page: name and rename, status, the two switches, the Spaces-/// on it, New Space here, Details and Remove from account.-struct MachinePage: View {- @Bindable var model: AppModel- let machine: AppMachinesViewMachine- let onError: (String) -> Void- @State private var renaming = false- @State private var newName = ""- @State private var removing: AppMachinesViewRemove?- @State private var detailsOpen = false- @State private var fullLog: HostLog?-- private var host: HostModel { model.host }-- var body: some View {- if machine.current, host.form != nil {- // This Mac's setup form takes the page while it shows.- HostFormView(host: host)- } else {- page- }- }-- private var page: some View {- let m = machine- let panel = host.panel- return ScrollView {- VStack(alignment: .leading, spacing: 0) {- HStack(spacing: 6) {- Text(m.name).font(.title2.weight(.semibold)).lineLimit(1).textSelection(.enabled)- if let r = m.rename {- Button {- newName = m.name- renaming = true- } label: {- Image(systemName: "pencil")- }- .buttonStyle(.borderless)- .help(r.title)- .accessibilityLabel(r.title)- .accessibilityIdentifier("machine-rename")- }- }- HStack(spacing: 6) {- StatusDot(online: m.online, size: 7)- Text(m.status)- if let by = m.sharedBy {- Text("\u{b7}").foregroundStyle(.tertiary)- Text(by)- }- }- .foregroundStyle(.secondary)- .padding(.top, 4)- .accessibilityIdentifier("machine-status")-- if !m.issues.isEmpty {- Text(m.issuesTitle)- .font(.callout.weight(.semibold))- .foregroundStyle(.secondary)- .padding(.top, 22)- .padding(.bottom, 8)- card {- ForEach(Array(m.issues.enumerated()), id: \.element.id) { i, issue in- if i > 0 { Divider() }- issueRow(issue)- }- }- .accessibilityIdentifier("machine-issues")- }-- card {- if let notice = m.notice {- HStack(spacing: 8) {- Image(systemName: "info.circle")- Text(notice).fixedSize(horizontal: false, vertical: true)- Spacer(minLength: 8)- if m.current, let action = m.noticeAction {- Button(action.label) { Task { await host.run(action.id) } }- .disabled(host.busy || !action.enabled)- }- }- .font(.callout)- .foregroundStyle(.secondary)- .padding(.horizontal, 16)- .padding(.vertical, 10)- .accessibilityIdentifier("machine-notice")- Divider()- }- ForEach(Array(m.toggles.enumerated()), id: \.element.id) { i, t in- if i > 0 { Divider() }- toggleRow(t, dimmed: !t.editable && m.togglesNote == nil)- }- if let note = m.togglesNote {- Divider()- Label(note, systemImage: m.team ? "person.2" : "lock")- .font(.callout)- .foregroundStyle(.secondary)- .padding(.horizontal, 16)- .padding(.vertical, 9)- .accessibilityIdentifier("machine-toggles-note")- }- }- .padding(.top, 22)-- if m.current {- // What needs the owner now: permissions to grant, a- // switch that failed.- if panel.permissionsTitle != nil || host.actionFailure != nil {- VStack(alignment: .leading, spacing: 8) {- if let title = panel.permissionsTitle {- Text(title).font(.callout.weight(.semibold)).foregroundStyle(.secondary)- card {- PermissionRows(rows: panel.permissions, openLabel: panel.openSettingsLabel)- .padding(.horizontal, 16).padding(.vertical, 8)- }- }- if let failure = host.actionFailure {- HostSetupFailureView(failure: failure, retrying: host.busy) {- Task { await host.retryFailedAction() }- }- }- }- .padding(.top, 20)- }- if let progress = host.progress {- HostSetupProgressView(text: progress).padding(.top, 12)- }- }-- Text(m.spacesTitle)- .font(.callout.weight(.semibold))- .foregroundStyle(.secondary)- .padding(.top, 28)- .padding(.bottom, 8)- card {- ForEach(Array(spaceRows(m).enumerated()), id: \.element.id) { i, s in- if i > 0 { Divider() }- Button {- model.select(s.id)- } label: {- HStack(spacing: 8) {- Text(s.name).font(.system(.callout, design: .monospaced)).lineLimit(1)- if let label = s.label {- Text(label).font(.caption2).foregroundStyle(.secondary)- .padding(.horizontal, 5)- .background(.quaternary, in: RoundedRectangle(cornerRadius: 4))- }- if !s.os.isEmpty {- Text("\u{b7}").foregroundStyle(.tertiary)- Text(s.os).foregroundStyle(.secondary).lineLimit(1)- }- Spacer(minLength: 8)- StatusDot(online: s.running, size: 7)- Text(s.status).font(.callout).foregroundStyle(.secondary)- Image(systemName: "chevron.right").font(.caption).foregroundStyle(.tertiary)- }- .contentShape(Rectangle())- .padding(.horizontal, 16)- .padding(.vertical, 10)- }- .buttonStyle(.plain)- .help("Open \(s.name)")- .accessibilityIdentifier("machine-space-\(s.id)")- }- if let empty = m.spacesEmpty {- Text(empty).font(.callout).foregroundStyle(.secondary)- .padding(.horizontal, 16).padding(.vertical, 12)- }- Divider()- HStack {- Button {- Task { await model.openNewSpace(on: m.newSpace.on) }- } label: {- Label(m.newSpace.label, systemImage: "plus")- }- .disabled(!m.newSpace.enabled)- .help(m.newSpace.help ?? "")- .accessibilityIdentifier("machine-new-space")- Spacer()- }- .padding(.horizontal, 12)- .padding(.vertical, 10)- }-- DisclosureGroup(isExpanded: $detailsOpen) {- VStack(alignment: .leading, spacing: 16) {- card {- ForEach(Array(m.details.enumerated()), id: \.element.label) { i, f in- if i > 0 { Divider() }- HStack(alignment: .firstTextBaseline) {- Text(f.label).foregroundStyle(.secondary).frame(width: 140, alignment: .leading)- Text(f.value).textSelection(.enabled)- Spacer()- }- .padding(.horizontal, 16)- .padding(.vertical, 9)- }- }- if m.current { logs(panel) }- }- .padding(.top, 8)- } label: {- Text(m.detailsTitle).font(.callout.weight(.semibold)).foregroundStyle(.secondary)- }- .padding(.top, 24)- .accessibilityIdentifier("machine-details")-- if let r = m.remove {- Button(r.label, role: .destructive) { removing = r }- .buttonStyle(.borderless)- .foregroundStyle(.red)- .disabled(!r.enabled)- .help(r.help ?? "")- .padding(.top, 28)- .accessibilityIdentifier("machine-remove")- }- }- .frame(maxWidth: 620, alignment: .leading)- .padding(.horizontal, 36)- .padding(.vertical, 28)- .frame(maxWidth: .infinity, alignment: .leading)- }- .alert(m.rename?.title ?? "", isPresented: $renaming) {- TextField("Name", text: $newName)- Button(m.rename?.confirmLabel ?? "Rename") { rename() }- Button("Cancel", role: .cancel) {}- }- .alert(removing?.confirm.title ?? "", isPresented: Binding(- get: { removing != nil }, set: { if !$0 { removing = nil } })) {- if let r = removing {- Button(r.confirm.confirmLabel, role: .destructive) {- removing = nil- remove(r)- }- Button(r.confirm.cancelLabel, role: .cancel) { removing = nil }- }- } message: {- Text(removing?.confirm.message ?? "")- }- .sheet(item: $fullLog) { log in- switch log {- case .access:- HostLogSheet(title: panel.recentTitle ?? "", rows: panel.recentAll,- backgroundRows: panel.recentWithBackground) { fullLog = nil }- case .activity:- HostLogSheet(title: panel.activityTitle ?? "", rows: panel.activityAll,- backgroundRows: nil) { fullLog = nil }- }- }- .accessibilityIdentifier("machine-page")- }-- /// A rounded card, as the page's groups are drawn.- private func card<Content: View>(@ViewBuilder _ content: () -> Content) -> some View {- VStack(alignment: .leading, spacing: 0, content: content)- .frame(maxWidth: .infinity, alignment: .leading)- .background(.background.secondary, in: .rect(cornerRadius: 10))- .overlay(RoundedRectangle(cornerRadius: 10).strokeBorder(.separator))- }-- private func toggleRow(_ t: AppMachinesViewToggle, dimmed: Bool) -> some View {- HStack(spacing: 20) {- VStack(alignment: .leading, spacing: 1) {- Text(t.label).fontWeight(.medium)- Text(t.help).font(.callout).foregroundStyle(.secondary)- }- .opacity(dimmed ? 0.5 : 1)- Spacer()- Toggle(t.label, isOn: Binding(get: { t.on }, set: { _ in flip(t) }))- .labelsHidden()- .toggleStyle(.switch)- .disabled(!t.editable || !t.enabled || host.busy)- }- .padding(.horizontal, 16)- .padding(.vertical, 14)- .accessibilityIdentifier("machine-toggle-\(t.id)")- }-- /// One issue: its mark, one sentence, and its fix when there is one- /// here (a System Settings pane, or This Mac's host action).- private func issueRow(_ issue: AppMachinesViewIssue) -> some View {- HStack(alignment: .firstTextBaseline, spacing: 10) {- Image(systemName: issue.level == "fail" ? "xmark.octagon.fill"- : issue.level == "info" ? "info.circle" : "exclamationmark.triangle.fill")- .foregroundStyle(issue.level == "fail" ? Color.red : issue.level == "info" ? Color.secondary : Color.orange)- .accessibilityLabel(issue.level == "fail" ? "Problem" : issue.level == "info" ? "Note" : "Warning")- Text(issue.text).fixedSize(horizontal: false, vertical: true)- Spacer(minLength: 12)- if let action = issue.action {- Button(action.label) { fix(action) }- .buttonStyle(.bordered)- .controlSize(.small)- .disabled(action.hostAction != nil && (!machine.current || host.busy))- .accessibilityIdentifier("machine-issue-fix-\(issue.id)")- }- }- .padding(.horizontal, 16)- .padding(.vertical, 10)- .accessibilityIdentifier("machine-issue-\(issue.id)")- }-- /// Its shared desktop first, then its Spaces: every row a Space row.- private struct SpaceRowItem {- let id: String, name: String, os: String, status: String, running: Bool, label: String?- }-- private func spaceRows(_ m: AppMachinesViewMachine) -> [SpaceRowItem] {- let desktop = m.desktop.map {- SpaceRowItem(id: $0.id, name: $0.name, os: $0.os, status: $0.status, running: $0.running, label: $0.label)- }- return (desktop.map { [$0] } ?? [])- + m.spaces.map { SpaceRowItem(id: $0.id, name: $0.name, os: $0.os, status: $0.status, running: $0.running, label: nil) }- }-- private func fix(_ action: AppMachinesViewIssueAction) {- if action.appUpdate {- // Restart into the Cua Spaces update already downloaded.- model.updates.installUpdate()- } else if let url = action.url {- PermissionRows.open(url)- } else if let id = action.hostAction, machine.current {- Task {- await host.run(id)- await model.checkMachineHealth()- }- }- }-- /// This Mac's switch: its actions in order, or the setup form.- private func flip(_ t: AppMachinesViewToggle) {- if let profile = t.setup {- host.openForm()- host.send(.setProfile(profile: profile))- return- }- Task { for a in t.actions { await host.run(a) } }- }-- @ViewBuilder- private func logs(_ panel: AppHostPanelView) -> some View {- if let title = panel.recentTitle, !panel.recent.isEmpty {- VStack(alignment: .leading, spacing: 6) {- Text(title).font(.callout.weight(.semibold)).foregroundStyle(.secondary)- card {- TimedRows(rows: panel.recent).padding(.horizontal, 16).padding(.vertical, 6)- }- if let more = panel.recentMore { ShowAllButton(label: more) { fullLog = .access } }- }- }- if let title = panel.activityTitle, !panel.activity.isEmpty {- VStack(alignment: .leading, spacing: 6) {- Text(title).font(.callout.weight(.semibold)).foregroundStyle(.secondary)- card {- TimedRows(rows: panel.activity).padding(.horizontal, 16).padding(.vertical, 6)- }- if let more = panel.activityMore { ShowAllButton(label: more) { fullLog = .activity } }- }- }- }-- private func rename() {- guard let r = machine.rename else { return }- let name = newName.trimmingCharacters(in: .whitespacesAndNewlines)- guard !name.isEmpty, name != machine.name else { return }- Task {- if r.target == "device" {- await model.devices.rename(id: r.id, to: name)- await model.refresh()- return- }- do {- try await model.renameMachine(id: r.id, name: name)- } catch {- onError(LiveSpacesBackend.words(error))- }- }- }-- private func remove(_ r: AppMachinesViewRemove) {- Task {- if r.host {- await host.run(.remove)- return- }- do {- try await model.removeMachine(machine: r.machine, device: r.device)- } catch {- onError(LiveSpacesBackend.words(error))- }- }- }-}diff --git a/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Views/MainWindow.swift b/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Views/MainWindow.swiftdeleted file mode 100644index 9c8f3797ba..0000000000--- a/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Views/MainWindow.swift+++ /dev/null@@ -1,633 +0,0 @@-// SPDX-License-Identifier: FSL-1.1-MIT-// Copyright (c) 2026 Cua AI, Inc.--import CuaSDK-import CuaSpacesFFI-import SwiftUI--/// The main window: a sidebar of Spaces and the Keyvault (with its global-/// switch), and the selected item's detail. Rows are one line; the-/// sections, search, selection fallback and dimming are the core's. ⌘K-/// opens the command palette.-public struct MainWindow: View {- @Bindable var model: AppModel-- public init(model: AppModel) {- self.model = model- }-- public var body: some View {- let chrome = model.chrome- NavigationSplitView {- Sidebar(model: model)- .navigationSplitViewColumnWidth(min: 200, ideal: 230, max: 300)- } detail: {- detail- .safeAreaInset(edge: .top, spacing: 0) {- VStack(spacing: 0) {- DevicesBanner(devices: model.devices)- ShareRemovalBanner(model: model)- RelayAllowanceBanner(devices: model.devices)- if let error = model.rosterError {- SpacesDiscoveryNotice(error: error)- }- }- }- }- .overlay(alignment: .bottomTrailing) { SignInToastView(model: model) }- .background(WindowReader { model.dropTargets.window = $0 })- .searchable(text: $model.query, placement: .sidebar, prompt: chrome.searchPlaceholder)- .toolbar {- ToolbarItem(placement: .primaryAction) {- Button {- Task { await model.openNewSpace() }- } label: {- Label(chrome.newSpaceLabel, systemImage: "plus")- }- .keyboardShortcut("n", modifiers: .command)- .help(chrome.newSpaceLabel)- }- }- .sheet(isPresented: $model.showingNewSpace) {- NewSpaceWizardView(wizard: model.wizard,- onCreate: { model.create($0) },- onAdd: { url, token, name in- try await model.addByAddress(url: url, token: token, name: name)- },- onCancel: { model.cancelNewSpace() },- cloud: model.cloud,- onRuntimeSwitch: { await model.applyRuntimeSwitch($0) })- }- .sheet(isPresented: $model.showingPalette) {- CommandPaletteView(model: model)- }- .sheet(item: approvalBinding) { _ in- ApprovalSheet(keyvault: model.keyvault)- }- .sheet(isPresented: devicesSheet(\.enroll) { model.devices.enrollSurface }) {- EnrollSheet(devices: model.devices)- }- .sheet(isPresented: devicesSheet(\.approval) { model.devices.approvalSurface }) {- DeviceApprovalSheet(devices: model.devices)- }- // Opening the window refreshes at once; the app keeps polling the- // roster and the Keyvault every 10 s while it runs (see start()).- .task {- await model.refresh()- await model.keyvault.refresh()- await model.reloadShareRemovals()- }- // The relay allowance: at once (and on every sign-in or out), every- // 5 minutes, and when the app comes to the front.- .task(id: model.devices.signedIn) {- while !Task.isCancelled {- await model.devices.readRelayUsage()- try? await Task.sleep(for: DevicesModel.relayUsagePoll)- }- }- .onReceive(NotificationCenter.default.publisher(for: NSApplication.didBecomeActiveNotification)) { _ in- Task { await model.devices.readRelayUsage(maxAge: DevicesModel.relayUsageFocusAge) }- }- }-- /// The main window's copy of a Devices sheet (Settings has its own).- private func devicesSheet<T>(_ key: ReferenceWritableKeyPath<DevicesModel, T?>,- surface: @escaping () -> DevicesSurface) -> Binding<Bool> {- let devices = model.devices- return Binding(get: { devices[keyPath: key] != nil && surface() == .main },- set: { if !$0 { devices[keyPath: key] = nil } })- }-- private var approvalBinding: Binding<KvApprovalState?> {- Binding(get: { model.keyvault.approval }, set: { model.keyvault.approval = $0 })- }-- @ViewBuilder private var detail: some View {- switch model.selection {- case .space:- if let space = model.selectedSpace {- if model.detail(space).isHost {- ThisMachineView(host: model.host)- } else {- SpaceDetailView(model: model, space: space)- .id(space.id)- }- } else {- EmptySpaces(model: model)- }- case .keyvault(let selection):- KeyvaultDetail(keyvault: model.keyvault, selection: selection)- case .agents:- AgentsPageView(model: model.persistent, openAgentKeys: {- MainUIRouter(model: model).openSettings(.path("/settings/connected-apps"))- })- .onAppear {- model.recordFeature("agents_page_open")- let id = model.sidebar.thisMachine?.id- model.persistent.thisMachine = id?.hasPrefix("relay:") == true ? id : nil- }- case .drive where model.chrome.volumeLabel != nil:- DrivePageView(model: model.persistent)- case .drive:- EmptySpaces(model: model)- case .notifications:- NotificationsPageView(model: model.persistent)- case .machines:- MachinesPageView(model: model)- case .gettingStarted:- GettingStartedView(model: model)- case nil:- EmptySpaces(model: model)- }- }-}--extension KvApprovalState: @retroactive Identifiable {- public var id: String { requestId }-}--/// The sidebar: Spaces (one section per location) and the Keyvault.-struct Sidebar: View {- @Bindable var model: AppModel-- /// The Spaces a Keyvault sign-in is live in (read once per draw).- private var signedIn: Set<String> { model.signedInSpaceIds }-- var body: some View {- let sidebar = model.sidebar- let kv = model.keyvault- let checklist = model.checklist.view- List(selection: $model.selection) {- if checklist.visible {- Label(checklist.title, systemImage: "checklist")- .badge(Text(checklist.progress))- .tag(MainSelection.gettingStarted)- .accessibilityIdentifier("sidebar-getting-started")- }- if let row = sidebar.thisMachine {- spaceRow(row)- }- ForEach(sidebar.sections, id: \.title.code) { section in- Section(CoreMessages.text(section.title)) {- ForEach(section.rows, id: \.id) { row in- spaceRow(row)- }- }- }- if let empty = sidebar.emptyText, sidebar.thisMachine == nil, model.rosterError == nil {- Text(CoreMessages.text(empty)).foregroundStyle(.secondary)- }- Section {- ForEach(kv.sidebar.categories, id: \.category) { row in- Label(row.title, systemImage: row.symbol)- .badge(badge(row))- .tag(MainSelection.keyvault(.category(category: row.category)))- }- ForEach(kv.sidebar.apps, id: \.key) { app in- HStack(spacing: 8) {- AppIcon(keyvault: kv, providerId: app.key, name: app.title)- .frame(width: 18, height: 18)- Text(app.title).lineLimit(1)- }- .badge(Int(app.items))- .tag(MainSelection.keyvault(.app(key: app.key)))- }- } header: {- KeyvaultHeader(keyvault: kv, title: model.chrome.keyvaultTitle)- }- Section {- Label("Computers", systemImage: "server.rack").tag(MainSelection.machines)- Label("Agents", systemImage: "person.2").tag(MainSelection.agents)- // Only with the Cua Volume experiment on (the core's chrome).- if let volume = model.chrome.volumeLabel {- Label(volume, systemImage: "externaldrive").tag(MainSelection.drive)- }- Label("Notifications", systemImage: "bell").tag(MainSelection.notifications)- }- }- .listStyle(.sidebar)- .safeAreaInset(edge: .bottom) { SidebarFooter(model: model) }- .onChange(of: model.selection) { _, new in- if case .space(let id) = new { model.send(.select(id: id, now: Int64(Date().timeIntervalSince1970 * 1000))) }- }- }-- /// A Space row; also a drop target for a dragged real window.- private func spaceRow(_ row: AppSidebarRow) -> some View {- SpaceRowView(row: row, subtitle: model.hostLoadLine(row.id),- targeted: model.dropTargets.targetedId == row.id,- signedIn: signedIn.contains(row.id),- onSignedIn: { model.showAccess(spaceId: row.id) }) { on in- if let space = model.spaces.first(where: { $0.id == row.id }) {- model.setPower(space, on: on)- }- }- .onGeometryChange(for: CGRect.self) { $0.frame(in: .global) } action: {- model.dropTargets.setFrame(row.id, $0)- }- .onDisappear { model.dropTargets.removeFrame(row.id) }- .tag(MainSelection.space(row.id))- }-- private func badge(_ row: KvCategoryRow) -> Int { Int(row.badge ?? 0) }-}--/// The sidebar's foot: every sign-in state in one place (the core's-/// `appSignInFooter`): signed in as, waiting for the browser with the code,-/// Open again and Cancel, or why it failed with Try again; and Settings.-struct SidebarFooter: View {- let model: AppModel- @State private var showingDetails = false-- var body: some View {- let f = model.signInFooter- HStack(alignment: .top, spacing: 8) {- VStack(alignment: .leading, spacing: 4) {- switch f.state {- case .starting, .waiting:- HStack(spacing: 6) {- ProgressView().controlSize(.mini)- Text(f.text).lineLimit(2)- }- .accessibilityElement(children: .combine)- .accessibilityIdentifier("sidebar-signin-waiting")- // The code on its own line (it never wraps), then- // Open again and Cancel.- if let code = f.code {- Text("\(f.codeLabel) \(Text(code).font(.callout.monospaced().weight(.semibold)).foregroundStyle(.primary))")- .font(.callout)- .foregroundStyle(.secondary)- .textSelection(.enabled)- .lineLimit(1)- .fixedSize()- .padding(.leading, 20)- }- HStack(spacing: 4) {- if let reopen = f.reopenLabel {- Button(reopen) { model.reopenSignIn() }- .buttonStyle(.link)- .accessibilityIdentifier("sidebar-signin-reopen")- Text("\u{b7}")- }- if let cancel = f.cancelLabel {- Button(cancel) { model.cancelSignIn() }- .buttonStyle(.link)- .accessibilityIdentifier("sidebar-signin-cancel")- }- }- .lineLimit(1)- .fixedSize()- .padding(.leading, 20)- .font(.callout)- .foregroundStyle(.secondary)- case .failed:- HStack(alignment: .firstTextBaseline, spacing: 6) {- Image(systemName: "exclamationmark.triangle")- .foregroundStyle(.red)- Text(f.text)- .lineLimit(4)- .accessibilityIdentifier("sidebar-signin-failed")- }- HStack(spacing: 8) {- if let retry = f.actionLabel {- Button(retry) { Task { await model.beginSignIn() } }- .controlSize(.small)- .accessibilityIdentifier("sidebar-signin-retry")- }- if let detail = f.detail {- Button(f.detailsLabel) { showingDetails.toggle() }- .buttonStyle(.link)- .font(.callout)- .popover(isPresented: $showingDetails) {- Text(detail)- .font(.callout.monospaced())- .textSelection(.enabled)- .frame(width: 280, alignment: .leading)- .padding(12)- }- }- }- .padding(.leading, 20)- case .signedIn:- // "Signed in as", then the whole address on its own line.- VStack(alignment: .leading, spacing: 1) {- Text("Signed in as").font(.caption).foregroundStyle(.secondary)- Text(f.identity ?? f.text)- .lineLimit(1)- .truncationMode(.middle)- }- .help(f.text)- .accessibilityElement(children: .combine)- .accessibilityIdentifier("sidebar-account")- case .signedOut:- HStack(spacing: 8) {- Text(f.text)- .lineLimit(1)- .truncationMode(.middle)- .foregroundStyle(.secondary)- .accessibilityIdentifier("sidebar-account")- Spacer(minLength: 4)- if let label = f.actionLabel {- Button(label) { Task { await model.beginSignIn() } }- .controlSize(.small)- }- }- }- }- .frame(maxWidth: .infinity, alignment: .leading)- SettingsLink {- Image(systemName: "gearshape")- }- .buttonStyle(.borderless)- .help(model.chrome.settingsLabel)- .accessibilityLabel(model.chrome.settingsLabel)- }- .padding(.horizontal, 12)- .padding(.vertical, 8)- .background(.bar)- }-}--/// A failed sign-in's toast: seen wherever the window is, then gone (the-/// sidebar's foot keeps the reason and Try again).-struct SignInToastView: View {- let model: AppModel-- var body: some View {- if let toast = model.signInToast {- HStack(alignment: .top, spacing: 8) {- Image(systemName: "exclamationmark.circle.fill").foregroundStyle(.red)- VStack(alignment: .leading, spacing: 2) {- Text(toast.title).font(.headline)- if let body = toast.body {- Text(body).font(.callout).foregroundStyle(.secondary)- }- }- Button {- model.signInToast = nil- } label: {- Image(systemName: "xmark").font(.caption)- }- .buttonStyle(.borderless)- .accessibilityLabel("Dismiss")- }- .padding(12)- .frame(width: 300, alignment: .leading)- .background(.regularMaterial, in: RoundedRectangle(cornerRadius: 12))- .overlay(RoundedRectangle(cornerRadius: 12).strokeBorder(.separator))- .shadow(radius: 8, y: 2)- .padding(16)- .accessibilityIdentifier("signin-toast")- .task(id: toast) {- try? await Task.sleep(for: .seconds(15))- if model.signInToast == toast { model.signInToast = nil }- }- }- }-}--/// One Space row: its OS icon, the name and a status dot, dimmed when not-/// live, and outlined while a dragged window is over it. A Space that turns-/// off and on has a power button before its dot, shown on hover and on the-/// selected row, and a spinner in its place while it runs.-struct SpaceRowView: View {- let row: AppSidebarRow- /// One short secondary line under the name: how busy one of your- /// machines is ("3 running · 40% CPU", "Paused").- var subtitle: String?- var targeted = false- /// A Keyvault sign-in is live in it: "Signed in", which opens the- /// Keyvault's Access page.- var signedIn = false- var onSignedIn: (() -> Void)?- /// The power button was pressed: turn it on (`true`) or off.- var onPower: ((Bool) -> Void)?- @State private var hovering = false-- var body: some View {- HStack(spacing: 8) {- OsIconImage(id: row.osIcon, size: 13)- .foregroundStyle(.secondary)- .frame(width: 16)- if let subtitle {- VStack(alignment: .leading, spacing: 0) {- Text(row.name).lineLimit(1)- Text(subtitle)- .font(.caption)- .foregroundStyle(.secondary)- .lineLimit(1)- .accessibilityIdentifier("machine-load")- }- } else {- Text(row.name).lineLimit(1)- }- if let place = row.place {- // A Space in your cloud: where it runs.- Text(place)- .font(.callout)- .foregroundStyle(.secondary)- .lineLimit(1)- .truncationMode(.tail)- }- Spacer(minLength: 4)- if let progress = row.progress {- // Being created: the ring and the percentage, no dot.- Text(row.trailing ?? "")- .font(.callout.monospacedDigit())- .foregroundStyle(.secondary)- ProgressRing(permille: progress)- .accessibilityLabel(CoreMessages.text(row.statusText))- } else {- if let trailing = row.trailing {- // The create or the power action failed: why, inline.- Text(trailing)- .font(.callout)- .foregroundStyle(.red)- .lineLimit(1)- .truncationMode(.tail)- .help(trailing)- }- if signedIn {- SignedInBadge { onSignedIn?() }- }- if let power = row.power, let onPower,- hovering || row.selected || power.busy {- PowerButton(button: power) { onPower(power.turnOn) }- }- Circle()- .fill(color)- .frame(width: 7, height: 7)- .accessibilityLabel(CoreMessages.text(row.statusText))- }- }- // A Space one of your machines provides sits under that machine.- .padding(.leading, row.nested ? 18 : 0)- .opacity(row.dim ? 0.5 : 1)- .overlay {- if targeted {- RoundedRectangle(cornerRadius: 5).strokeBorder(Color.accentColor, lineWidth: 2).padding(-3)- }- }- .help(row.detail)- .onHover { hovering = $0 }- }-- private var color: Color {- switch row.status {- case .running, .local: return .green- case .approval: return .orange- case .provisioning: return .blue- case .suspended, .deleting: return .secondary- }- }-}--/// "Signed in": a Keyvault sign-in is live in this Space. Opens the-/// Keyvault's Access page on it.-struct SignedInBadge: View {- let action: () -> Void-- var body: some View {- Button(action: action) {- Label("Signed in", systemImage: "key.fill")- .labelStyle(.titleAndIcon)- .font(.caption2.weight(.medium))- .foregroundStyle(.secondary)- .padding(.horizontal, 5)- .padding(.vertical, 1)- .background(Capsule().fill(.quaternary))- }- .buttonStyle(.plain)- .fixedSize()- .help("Keyvault access is live in this Space. Show it in Keyvault.")- .accessibilityLabel("Signed in. Show in Keyvault")- .accessibilityIdentifier("space-signed-in")- }-}--/// The power button (the core's `AppPowerButton`): the `power` symbol, a-/// small spinner while it runs, the core's words as its tooltip.-struct PowerButton: View {- let button: AppPowerButton- let action: () -> Void-- var body: some View {- Button(action: action) {- if button.busy {- ProgressView().controlSize(.mini)- } else {- Image(systemName: button.symbol)- }- }- .buttonStyle(.borderless)- .disabled(!button.enabled)- .help(CoreMessages.text(button.help))- .accessibilityLabel(CoreMessages.text(button.help))- .accessibilityIdentifier("space-power")- }-}--/// "Keyvault" with the global switch (on = working; off stops every-/// teleport, import and approval; turning it back on asks for Touch ID in-/// the Cua daemon).-struct KeyvaultHeader: View {- let keyvault: KeyvaultModel- let title: String-- var body: some View {- let page = keyvault.page- HStack {- Text(title)- Spacer()- if page.killSwitchVisible {- Toggle(title, isOn: Binding(- get: { !page.disabled },- set: { on in Task { await keyvault.setDisabled(!on) } }))- .toggleStyle(.switch)- .controlSize(.mini)- .labelsHidden()- .disabled(!page.killSwitchEnabled || keyvault.busy)- .help(page.killSwitchHelp)- .accessibilityIdentifier("keyvault-switch")- .padding(.trailing, 6)- }- }- }-}--struct EmptySpaces: View {- let model: AppModel- @State private var stacked = false-- var body: some View {- // Not read yet, or your computers still answering: one quiet line,- // never "Create your first Space" (the core decides).- if let line = model.listView.reachingLine, model.rosterError == nil || model.loaded {- ContentUnavailableView {- Text(line).font(.callout).foregroundStyle(.secondary)- }- .accessibilityIdentifier("spaces-reaching")- } else {- empty- }- }-- @ViewBuilder private var empty: some View {- let chrome = model.chrome- let tiles = stacked ? AnyLayout(VStackLayout(spacing: 12)) : AnyLayout(HStackLayout(spacing: 12))- ContentUnavailableView {- Label(model.rosterError == nil ? chrome.emptyTitle : "Spaces could not be loaded",- systemImage: "desktopcomputer")- } description: {- if model.rosterError == nil { Text(chrome.emptyDetail) }- } actions: {- VStack(spacing: 18) {- if model.rosterError == nil {- tiles {- tile("os-linux", chrome.emptyAction, chrome.emptyLinuxDetail, .linux)- tile("os-macos", chrome.emptyMacosAction, chrome.emptyMacosDetail, .macos)- }- }- Button(chrome.newSpaceLabel) { Task { await model.openNewSpace() } }- .buttonStyle(.glass)- }- .padding(.top, 10)- }- // Neither the actions slot nor this view reports the pane width, so measure a pane-filling frame.- .frame(maxWidth: .infinity)- .onGeometryChange(for: Bool.self) { $0.size.width < 640 } action: { stacked = $0 }- }-- private func tile(_ icon: String, _ name: String, _ detail: String, _ os: AppSpaceOs) -> some View {- Button { Task { await model.openNewSpace(quick: os) } } label: {- HStack(spacing: 12) {- OsIconImage(id: icon, size: 24)- .frame(width: 44, height: 44)- .background(.fill.tertiary, in: .rect(cornerRadius: 10))- VStack(alignment: .leading, spacing: 2) {- Text(name).font(.headline)- Text(detail).font(.callout).foregroundStyle(.secondary)- }- }- .padding(.horizontal, 16)- .frame(width: 288, height: 80, alignment: .leading)- .contentShape(.rect(cornerRadius: 16))- }- .buttonStyle(.plain)- .glassEffect(.regular.interactive(), in: .rect(cornerRadius: 16))- .accessibilityLabel("\(name), \(detail)")- }-}--/// Persistent discovery failure notice above the selected Space.-struct SpacesDiscoveryNotice: View {- let error: String-- var body: some View {- Text(error)- .foregroundStyle(.red)- .padding()- .frame(maxWidth: .infinity, alignment: .leading)- .accessibilityIdentifier("spaces-discovery-error")- }-}diff --git a/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Views/NavigationCommands.swift b/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Views/NavigationCommands.swiftnew file mode 100644index 0000000000..4897d17d9f--- /dev/null+++ b/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Views/NavigationCommands.swift@@ -0,0 +1,90 @@+// SPDX-License-Identifier: FSL-1.1-MIT+// Copyright (c) 2026 Cua AI, Inc.++import CuaSpacesFFI+import SwiftUI++/// The shared keyboard shortcuts: the core's `appKeybindings`, which are+/// the React UI's `keybindings.json`, so both bind the same keys.+enum SharedShortcuts {+ static let keys: [String: String] = Dictionary(+ appKeybindings().map { ($0.command, $0.key) }, uniquingKeysWith: { first, _ in first })++ private static func parts(_ command: String) -> (key: String, mods: [String])? {+ guard let spec = keys[command] else { return nil }+ var parts = spec.lowercased().split(separator: "+").map(String.init)+ guard let key = parts.popLast(), key.count == 1 else { return nil }+ return (key, parts)+ }++ /// `mod+k` as ⌘K.+ static func shortcut(_ command: String) -> KeyboardShortcut? {+ guard let (key, mods) = parts(command), let ch = key.first else { return nil }+ var modifiers: EventModifiers = []+ if mods.contains("mod") { modifiers.insert(.command) }+ if mods.contains("alt") { modifiers.insert(.option) }+ if mods.contains("shift") { modifiers.insert(.shift) }+ return KeyboardShortcut(KeyEquivalent(ch), modifiers: modifiers)+ }++ /// `mod+shift+l` as "⌘⇧L".+ static func label(_ command: String) -> String? {+ guard let (key, mods) = parts(command) else { return nil }+ let marks = [("mod", "⌘"), ("alt", "⌥"), ("shift", "⇧")].filter { mods.contains($0.0) }.map(\.1)+ return marks.joined() + key.uppercased()+ }+}++/// A page ⌘1–4 go to (the shared keybindings' `nav.*` commands).+struct NavTarget: Identifiable {+ let command: String+ let label: String+ let symbol: String+ var id: String { command }++ @MainActor static func all(_ model: AppModel) -> [NavTarget] {+ [NavTarget(command: "nav.spaces", label: "Spaces", symbol: "square.grid.2x2"),+ NavTarget(command: "nav.machines", label: "Computers", symbol: "server.rack"),+ NavTarget(command: "nav.agents", label: "Agents", symbol: "person.2"),+ NavTarget(command: "nav.keyvault", label: model.chrome.keyvaultTitle, symbol: "key")]+ }+}++extension AppModel {+ /// Goes to the page a `nav.*` command names.+ public func go(_ command: String) {+ switch command {+ case "nav.spaces": selection = sidebar.selectedId.map { .space($0) }+ case "nav.machines": selection = .machines+ case "nav.agents": selection = .agents+ case "nav.keyvault":+ if let first = keyvault.sidebar.categories.first {+ selection = .keyvault(.category(category: first.category))+ }+ default: break+ }+ }+}++/// View: Command Palette and ⌘1–4, with the shared keys. The web UI+/// window handles these keys itself while it is in front; from anywhere+/// else (a Space's window) they open it at the page.+struct NavigationCommands: View {+ let model: AppModel++ var body: some View {+ Button("Command Palette…") { inMain(.home) }+ .keyboardShortcut(SharedShortcuts.shortcut("commandPalette.toggle"))+ Divider()+ ForEach(NavTarget.all(model)) { target in+ Button(target.label) { inMain(MainUIRouter.route(forNav: target.command)) }+ .keyboardShortcut(SharedShortcuts.shortcut(target.command))+ }+ }++ private func inMain(_ route: MainUIRoute?) {+ if WebUIWindowController.shared?.window?.isKeyWindow == true { return }+ guard model.startup.isReady, model.onboarding.completed else { return }+ MainUIRouter(model: model).open(route ?? .home)+ }+}diff --git a/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Views/NewSpaceWizardView.swift b/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Views/NewSpaceWizardView.swiftdeleted file mode 100644index 4d9a3b2636..0000000000--- a/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Views/NewSpaceWizardView.swift+++ /dev/null@@ -1,470 +0,0 @@-// SPDX-License-Identifier: FSL-1.1-MIT-// Copyright (c) 2026 Cua AI, Inc.--import CuaSDK-import CuaSpacesFFI-import SwiftUI--/// New Space, as a step-by-step assistant: System, Resources, Options,-/// Summary. Every tile, rule, label and the plan are the core's-/// (`appWizardView`); this sheet renders them.-public struct NewSpaceWizardView: View {- @Bindable var wizard: WizardModel- let onCreate: (AppCreatePlan) -> Void- let onAdd: (String, String?, String?) async throws -> Void- let onCancel: () -> Void- /// "Connect a cloud": the sheet it opens (nil: the link does not show).- let cloud: CloudModel?- /// "Use built-in Lume" (the core's `runtimeSwitch`).- let onRuntimeSwitch: ((AppRuntimeSwitch) async -> Void)?- @State private var switchingRuntime = false- /// A slider's typed value has the keyboard.- @FocusState private var typingValue: Bool-- public init(wizard: WizardModel, onCreate: @escaping (AppCreatePlan) -> Void,- onAdd: @escaping (String, String?, String?) async throws -> Void,- onCancel: @escaping () -> Void, cloud: CloudModel? = nil,- onRuntimeSwitch: ((AppRuntimeSwitch) async -> Void)? = nil) {- self.wizard = wizard- self.onCreate = onCreate- self.onAdd = onAdd- self.onCancel = onCancel- self.cloud = cloud- self.onRuntimeSwitch = onRuntimeSwitch- }-- public var body: some View {- let v = wizard.view- VStack(spacing: 0) {- header(v)- Divider()- Group {- if v.mode == .address {- address(v)- } else {- switch v.step {- case 0: system(v)- case 1: resources(v)- case 2: options(v)- default: summary(v)- }- }- }- .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .top)- Divider()- footer(v).padding(14)- }- .frame(width: 560, height: 520)- .sheet(isPresented: Binding(get: { cloud?.showing ?? false },- set: { if !$0 { cloud?.showing = false } })) {- if let cloud { ConnectCloudSheet(cloud: cloud) }- }- }-- private func header(_ v: AppWizardView) -> some View {- HStack(alignment: .firstTextBaseline) {- Text(v.title).font(.title2.weight(.semibold))- Spacer()- if v.mode == .create {- HStack(spacing: 6) {- ForEach(Array(v.steps.enumerated()), id: \.offset) { _, step in- Text(step.label)- .font(.callout)- .foregroundStyle(step.state == .current ? .primary : .secondary)- }- }- .accessibilityElement(children: .combine)- .accessibilityIdentifier("wizard-steps")- }- }- .padding(.horizontal, 20)- .padding(.vertical, 16)- }-- /// The System step: the core's fields in its order. Everything before- /// the first advanced field, then "Advanced", then the rest.- private func system(_ v: AppWizardView) -> some View {- let main = Array(v.fields.prefix { !$0.advanced })- let advanced = v.fields.filter(\.advanced)- let rest = v.fields.drop { !$0.advanced }.filter { !$0.advanced }- return Form {- Section {- ForEach(main, id: \.id) { systemRow($0, v) }- }- Section {- if !advanced.isEmpty {- DisclosureGroup(v.labels.advanced, isExpanded: Binding(- get: { v.advanced }, set: { _ in wizard.send(.toggleAdvanced) })) {- ForEach(advanced, id: \.id) { systemRow($0, v) }- }- }- ForEach(rest, id: \.id) { systemRow($0, v) }- }- }- .formStyle(.grouped)- }-- @ViewBuilder private func systemRow(_ field: AppWizardField, _ v: AppWizardView) -> some View {- switch field.id {- case "os":- Picker(field.label, selection: Binding(- get: { v.image.os },- set: { wizard.send(.chooseOs(os: $0)) })) {- ForEach(v.osTiles, id: \.id) { tile in- Text(tile.title).tag(osOf(tile.id)).selectionDisabled(!tile.enabled).help(tile.detail)- }- }- .pickerStyle(.segmented)- case "image":- ImageField(field: field, view: v.imageField, send: wizard.send)- case "placement":- // One menu of every machine that can host the Space, a divider- // between This Mac, your machines and your clouds.- Picker(field.label, selection: Binding(- get: { v.placementId },- set: { wizard.send(.choosePlacement(on: $0)) })) {- // A Section per group draws the separators: a Divider among- // the items shifts the menu's indices, so a machine of yours- // chosen showed an empty "Run on".- ForEach(Self.groups(v.placements), id: \.self) { group in- Section {- // Keyed by the line too: an item whose words change- // with the system (Linux's container, Windows' QEMU)- // is a new item, so its tooltip follows.- ForEach(v.placements.filter { $0.group == group }, id: \.self) { option in- Text(option.label)- .tag(option.id)- .selectionDisabled(!option.enabled)- .help(option.detail)- }- }- }- }- .pickerStyle(.menu)- // The closed menu's tooltip is the chosen place's line, for every- // system (it showed only macOS's: the menu kept the first item's).- .help(Self.runOnHelp(v))- .accessibilityIdentifier("wizard-run-on")- if let error = field.error {- HStack(alignment: .firstTextBaseline) {- Text(error).foregroundStyle(.red).font(.callout)- Spacer(minLength: 8)- if let change = v.runtimeSwitch, let onRuntimeSwitch {- Button {- switchingRuntime = true- Task {- await onRuntimeSwitch(change)- switchingRuntime = false- }- } label: {- HStack(spacing: 6) {- if switchingRuntime { ProgressView().controlSize(.small) }- Text(change.label)- }- }- .controlSize(.small)- .disabled(switchingRuntime)- .help(change.detail)- .accessibilityIdentifier("wizard-runtime-switch")- }- }- }- if let hint = v.placementHint {- // How another Mac of yours shows up here.- Text(hint)- .font(.callout)- .foregroundStyle(.secondary)- .fixedSize(horizontal: false, vertical: true)- .accessibilityIdentifier("wizard-other-mac-hint")- }- case "kind":- Picker(field.label, selection: Binding(- get: { v.image.variant },- set: { wizard.send(.chooseKind(kind: $0)) })) {- ForEach(v.kindTiles, id: \.id) { tile in- Text(tile.title)- .tag(tile.id == "vm" ? AppSpaceKind.vm : AppSpaceKind.container)- .selectionDisabled(!tile.enabled)- }- }- case "runtime":- Picker(field.label, selection: Binding(- get: { v.runtime },- set: { wizard.send(.setRuntime(runtime: $0)) })) {- ForEach(v.runtimes, id: \.value) { r in Text(r.label).tag(runtimeOf(r.value)) }- }- .disabled(!v.runtimeEnabled)- case "connect-cloud":- if let cloud {- Button(field.label) { cloud.open() }- .buttonStyle(.link)- .accessibilityIdentifier("wizard-connect-cloud")- }- case "connect-by-address":- Button(field.label) { wizard.send(.showAddress) }- .buttonStyle(.link)- default:- EmptyView()- }- }-- /// The menu's groups, in order.- static func groups(_ options: [AppPlacementOption]) -> [String] {- options.reduce(into: [String]()) { out, o in- if !out.contains(o.group) { out.append(o.group) }- }- }-- private func field(_ v: AppWizardView, _ id: String) -> AppWizardField? {- v.fields.first { $0.id == id }- }-- private func label(_ v: AppWizardView, _ id: String) -> String { field(v, id)?.label ?? "" }-- private func prompt(_ v: AppWizardView, _ id: String) -> Text? { field(v, id)?.placeholder.map(Text.init) }-- private func resources(_ v: AppWizardView) -> some View {- Form {- Section {- resourceSliders(v)- }- if !v.resourceFacts.isEmpty {- Section {- ForEach(v.resourceFacts, id: \.id) { fact in- LabeledContent(fact.label) {- HStack(spacing: 4) {- Text(fact.value).textSelection(.enabled)- if let symbol = fact.symbol {- Image(systemName: symbol)- .foregroundStyle(.orange)- .help(fact.help ?? "")- .accessibilityLabel(fact.help ?? "")- }- }- }- .accessibilityIdentifier("wizard-fact-\(fact.id)")- }- }- }- if let error = v.resourcesError {- Text(error).foregroundStyle(.red).font(.callout)- .accessibilityIdentifier("wizard-resources-error")- }- }- .formStyle(.grouped)- }-- @ViewBuilder private func resourceSliders(_ v: AppWizardView) -> some View {- // In your cloud the machine type sets the size: no sliders.- if field(v, "cpus") != nil {- LabeledContent(label(v, "cpus")) {- HStack {- Slider(value: Binding(get: { Double(v.cpus) },- set: { wizard.send(.setCpus(cpus: UInt32($0.rounded()))) }),- in: Double(v.minCpus)...Double(max(v.maxCpus, v.minCpus + 1)), step: 1)- sliderValue(v, .cpus, v.cpusText, id: "cpus")- }- }- typedError(v, "cpus")- LabeledContent(label(v, "memory")) {- HStack {- Slider(value: Binding(get: { Double(v.memoryGb) },- set: { wizard.send(.setMemory(memoryGb: UInt32($0.rounded()))) }),- in: Double(v.minMemoryGb)...Double(v.maxMemoryGb), step: 1)- sliderValue(v, .memory, v.memoryText, id: "memory")- }- }- typedError(v, "memory")- }- if v.diskEditable {- LabeledContent(label(v, "disk")) {- HStack {- Slider(value: Binding(get: { Double(v.diskGb) },- set: { wizard.send(.setDisk(diskGb: UInt32($0.rounded()))) }),- // Continuous: a GB step over hundreds of GB draws a solid tick rail.- in: Double(v.minDiskGb)...Double(max(v.maxDiskGb, v.minDiskGb + 1)))- .help(v.diskHelp ?? "")- sliderValue(v, .disk, v.diskText, id: "disk")- }- }- typedError(v, "disk")- if v.diskNote != nil || v.diskResetLabel != nil {- HStack(alignment: .firstTextBaseline, spacing: 8) {- if let note = v.diskNote {- Text(note).font(.callout).foregroundStyle(.secondary)- .fixedSize(horizontal: false, vertical: true)- .frame(maxWidth: .infinity, alignment: .leading)- }- if let reset = v.diskResetLabel {- Button(reset) { wizard.send(.resetDisk) }- .controlSize(.small)- .accessibilityIdentifier("wizard-disk-reset")- }- }- }- }- if let gpu = v.gpu { gpuRow(gpu) }- if let price = v.price {- Text(price).foregroundStyle(.secondary).monospacedDigit()- .accessibilityIdentifier("wizard-price")- }- }-- /// A slider's number: click it to type a value. The core checks it- /// against the slider's own limits; Return or leaving the field uses- /// it, Escape keeps the slider's value.- @ViewBuilder private func sliderValue(_ v: AppWizardView, _ f: AppResourceField, _ text: String, id: String) -> some View {- if let edit = v.resourceEdit, edit.field == f {- TextField(label(v, id), text: Binding(get: { edit.text }, set: { wizard.send(.setResourceText(text: $0)) }))- .labelsHidden()- .multilineTextAlignment(.trailing)- .monospacedDigit()- .frame(width: 64)- .focused($typingValue)- .onAppear { typingValue = true }- .onSubmit { wizard.send(.commitResource) }- .onExitCommand { wizard.send(.cancelResource) }- .onChange(of: typingValue) { _, focused in- if !focused { wizard.send(.commitResource) }- }- .accessibilityIdentifier("wizard-\(id)-value-field")- } else {- Button { wizard.send(.editResource(field: f)) } label: {- Text(text).monospacedDigit().frame(width: 64, alignment: .trailing)- .contentShape(Rectangle())- }- .buttonStyle(.plain)- .help("Click to type a value")- .accessibilityIdentifier("wizard-\(id)-value")- }- }-- /// Why a typed value cannot be used (the slider's limits), under it.- @ViewBuilder private func typedError(_ v: AppWizardView, _ id: String) -> some View {- if let error = field(v, id)?.error {- Text(error).foregroundStyle(.red).font(.callout)- .frame(maxWidth: .infinity, alignment: .trailing)- .accessibilityIdentifier("wizard-\(id)-error")- }- }-- /// The GPU checkbox with a small "Learn more"; where this machine- /// cannot, disabled with the reason (tooltip and one quiet line).- @ViewBuilder private func gpuRow(_ gpu: AppGpuRow) -> some View {- HStack(alignment: .firstTextBaseline) {- Toggle(gpu.label, isOn: Binding(get: { gpu.on }, set: { wizard.send(.setGpu(on: $0)) }))- .toggleStyle(.checkbox)- .disabled(!gpu.enabled)- .help(gpu.reason ?? "")- .accessibilityIdentifier("wizard-gpu")- Spacer(minLength: 8)- if let raw = gpu.learnMoreUrl, let url = URL(string: raw) {- Link(gpu.learnMoreLabel, destination: url)- .font(.callout)- .accessibilityIdentifier("wizard-gpu-learn-more")- }- }- if !gpu.enabled, let reason = gpu.reason {- Text(reason).font(.callout).foregroundStyle(.secondary).lineLimit(1)- .accessibilityIdentifier("wizard-gpu-reason")- }- }-- private func options(_ v: AppWizardView) -> some View {- Form {- TextField(label(v, "name"), text: Binding(get: { v.name }, set: { wizard.send(.setName(name: $0)) }),- prompt: prompt(v, "name"))- if let error = field(v, "name")?.error {- Text(error).foregroundStyle(.red).font(.callout)- }- Toggle(label(v, "open-when-ready"), isOn: Binding(- get: { v.openWhenReady }, set: { wizard.send(.setOpenWhenReady(on: $0)) }))- if let note = v.streamNote {- Text(note).foregroundStyle(.secondary)- }- }- .formStyle(.grouped)- }-- private func summary(_ v: AppWizardView) -> some View {- Form {- ForEach(v.summary, id: \.label) { fact in- LabeledContent(fact.label, value: fact.value)- }- }- .formStyle(.grouped)- .accessibilityIdentifier("wizard-summary")- }-- private func address(_ v: AppWizardView) -> some View {- Form {- TextField(label(v, "address"), text: Binding(get: { wizard.state.address.url },- set: { wizard.send(.setAddress(url: $0)) }),- prompt: prompt(v, "address"))- SecureField(label(v, "token"), text: Binding(get: { wizard.state.address.token },- set: { wizard.send(.setToken(token: $0)) }),- prompt: prompt(v, "token"))- TextField(label(v, "address-name"), text: Binding(get: { wizard.state.address.name },- set: { wizard.send(.setAddressName(name: $0)) }),- prompt: prompt(v, "address-name"))- if let price = v.price {- Text(price).foregroundStyle(.secondary).accessibilityIdentifier("wizard-price")- }- if let error = v.address.error {- Text(error).foregroundStyle(.red).font(.callout)- }- }- .formStyle(.grouped)- }-- @ViewBuilder private func footer(_ v: AppWizardView) -> some View {- HStack {- // While the image suggestions are open, or a slider's value is- // typed, Escape and Return are theirs.- let menuOpen = v.mode == .create && (v.imageField.open || v.resourceEdit != nil)- Button(v.labels.cancel, action: onCancel).keyboardShortcut(menuOpen ? nil : .cancelAction)- Spacer()- if v.mode == .address {- Button(v.labels.back) { wizard.send(.hideAddress) }- Button(v.address.submitLabel) {- Task { await wizard.submitAddress(onAdd) }- }- .keyboardShortcut(.defaultAction)- .disabled(!v.address.canSubmit)- } else {- if v.showBack { Button(v.labels.back) { wizard.send(.back) } }- if v.step < 3 {- Button(v.primaryLabel) { wizard.send(.next) }- .keyboardShortcut(menuOpen ? nil : .defaultAction)- .disabled(!v.canContinue)- } else {- Button(v.primaryLabel) { onCreate(v.plan) }- .keyboardShortcut(.defaultAction)- .buttonStyle(.glassProminent)- }- }- }- }-- /// "Run on"'s tooltip: what the chosen place runs the Space on- /// ("Container on this Mac (gVisor when installed)").- static func runOnHelp(_ v: AppWizardView) -> String {- v.placements.first { $0.id == v.placementId }?.detail ?? ""- }-- private func osOf(_ id: String) -> AppSpaceOs {- AppSpaceOs(word: id) ?? .unknown- }-- private func runtimeOf(_ word: String) -> AppRuntime {- switch word {- case "gvisor": return .gvisor- case "runc": return .runc- case "qemu": return .qemu- case "lume": return .lume- // An external runtime provider's name.- case "", "auto": return .auto- default: return .other(word)- }- }-}diff --git a/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Views/OsIconImage.swift b/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Views/OsIconImage.swiftdeleted file mode 100644index 00abaab79b..0000000000--- a/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Views/OsIconImage.swift+++ /dev/null@@ -1,18 +0,0 @@-// SPDX-License-Identifier: FSL-1.1-MIT-// Copyright (c) 2026 Cua AI, Inc.--import CuaSpacesNotchUI-import SwiftUI--/// A Space's OS icon from the core's id: the system symbol when the core-/// names one (macOS: `apple.logo`), else the core's SVG as a template image.-/// The notch tiles' icon view, looked up in the core here.-struct OsIconImage: View {- let id: String- var size: CGFloat = 11-- var body: some View {- NotchOsIconImage(id: id, size: size)- .environment(\.notchOsIcon, NotchModel.osIcon)- }-}diff --git a/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Views/PassphraseSheet.swift b/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Views/PassphraseSheet.swiftnew file mode 100644index 0000000000..4ea8510916--- /dev/null+++ b/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Views/PassphraseSheet.swift@@ -0,0 +1,62 @@+// SPDX-License-Identifier: FSL-1.1-MIT+// Copyright (c) 2026 Cua AI, Inc.++import CuaSpacesFFI+import SwiftUI++/// The passphrase and, at setup, its confirmation, typed into the model's+/// fields (`submitCredential` reads and clears them).+struct PassphraseFields: View {+ @Bindable var keyvault: KeyvaultModel+ let form: KvCredentialForm+ @FocusState private var focused: Bool++ var body: some View {+ SecureField(form.passphraseLabel ?? "", text: $keyvault.passphrase)+ .focused($focused)+ .onAppear { focused = true }+ if let confirm = form.confirmLabel {+ SecureField(confirm, text: $keyvault.passphraseConfirm)+ }+ }+}++/// The passphrase form as a sheet on the web UI window (`keyvault.setup`,+/// `keyvault.unlockVault`): with+/// Cancel. `done(true)` sends it and the bridge submits it, so the passphrase+/// never reaches the page (it stays in this process).+struct PassphraseSheet: View {+ @Bindable var keyvault: KeyvaultModel+ let form: KvCredentialForm+ let done: (Bool) -> Void++ var body: some View {+ VStack(alignment: .leading, spacing: 8) {+ Text(form.mode == .setup ? "Set up Keyvault" : "Unlock Keyvault")+ .font(.headline)+ Text(form.help)+ .font(.callout)+ .foregroundStyle(.secondary)+ .fixedSize(horizontal: false, vertical: true)+ .padding(.bottom, 4)+ PassphraseFields(keyvault: keyvault, form: form)+ Text(keyvault.passphraseCheck?.hint ?? " ")+ .font(.caption)+ .foregroundStyle(.secondary)+ .fixedSize(horizontal: false, vertical: true)+ HStack {+ Spacer()+ Button("Cancel", role: .cancel) { done(false) }+ .keyboardShortcut(.cancelAction)+ Button(form.submitLabel) { done(true) }+ .keyboardShortcut(.defaultAction)+ .disabled(!keyvault.canSubmitCredential)+ }+ .padding(.top, 4)+ }+ .textFieldStyle(.roundedBorder)+ .padding(20)+ .frame(width: 380)+ .onSubmit { if keyvault.canSubmitCredential { done(true) } }+ }+}diff --git a/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Views/RunTimelineView.swift b/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Views/RunTimelineView.swiftdeleted file mode 100644index 45b1ff3038..0000000000--- a/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Views/RunTimelineView.swift+++ /dev/null@@ -1,164 +0,0 @@-// SPDX-License-Identifier: FSL-1.1-MIT-// Copyright (c) 2026 Cua AI, Inc.--import CuaSDK-import CuaSpacesFFI-import SwiftUI--/// A run's conversation, as the web UI's `Timeline`: the prompt as a bubble-/// on the right, the agent's prose, and each stretch of activity as a muted-/// group that shows its summary and last step until opened. It follows the-/// end while the run writes; scrolled up, a pill brings the reader back.-struct RunTimelineView: View {- let timeline: RunTimelineModel- @Environment(\.dismiss) private var dismiss- /// Activity groups the reader opened or closed (by item index).- @State private var toggled: Set<Int> = []- @State private var position = ScrollPosition(edge: .bottom)- @State private var atEnd = true-- var body: some View {- VStack(spacing: 0) {- header- Divider()- content.frame(maxWidth: .infinity, maxHeight: .infinity)- }- .frame(minWidth: 560, idealWidth: 720, minHeight: 420, idealHeight: 640)- .task { await timeline.poll() }- }-- private var header: some View {- HStack(spacing: 12) {- VStack(alignment: .leading, spacing: 2) {- Text(appAgentName(agent: timeline.run.agent)).font(.headline)- Text(appAgentSubtitle(run: timeline.run))- .font(.caption).foregroundStyle(.secondary).lineLimit(1).truncationMode(.tail)- }- Spacer(minLength: 8)- Text(appAgentStatusLabel(status: timeline.status)).font(.caption).foregroundStyle(.secondary)- Button("Done") { dismiss() }.keyboardShortcut(.defaultAction)- }- .padding(.horizontal, 20)- .padding(.vertical, 12)- }-- @ViewBuilder private var content: some View {- if timeline.items.isEmpty, let error = timeline.error {- centered("Couldn't read this run", error)- } else if timeline.items.isEmpty, timeline.loading {- ProgressView().controlSize(.small)- } else {- ZStack(alignment: .bottom) {- ScrollView {- LazyVStack(alignment: .leading, spacing: 4) {- ForEach(Array(timeline.items.enumerated()), id: \.offset) { i, item in- row(i, item).frame(maxWidth: 720, alignment: .leading)- }- if let footer = timeline.footer {- Text(footer.text)- .font(.caption)- .foregroundStyle(footer.failed ? AnyShapeStyle(.red) : AnyShapeStyle(.secondary))- .padding(.top, 4)- .frame(maxWidth: 720, alignment: .leading)- .accessibilityIdentifier("run-timeline-footer")- }- }- .padding(.horizontal, 32)- .padding(.vertical, 24)- .frame(maxWidth: .infinity)- }- .scrollPosition($position)- .defaultScrollAnchor(.bottom, for: .sizeChanges)- .onScrollGeometryChange(for: Bool.self) { g in- g.contentOffset.y + g.containerSize.height >= g.contentSize.height - 32- } action: { _, now in- atEnd = now- }- if !atEnd {- Button {- withAnimation { position.scrollTo(edge: .bottom) }- } label: {- Label(timeline.live ? "Follow the run" : "Jump to latest", systemImage: "arrow.down")- }- .buttonBorderShape(.capsule)- .controlSize(.small)- .padding(.bottom, 16)- }- }- .accessibilityIdentifier("run-timeline")- }- }-- @ViewBuilder private func row(_ i: Int, _ item: AgentTranscriptItem) -> some View {- switch item.kind {- case "user":- HStack {- Spacer(minLength: 80)- Text(item.text)- .textSelection(.enabled)- .padding(.horizontal, 14)- .padding(.vertical, 8)- .background(.quaternary, in: UnevenRoundedRectangle(topLeadingRadius: 16, bottomLeadingRadius: 16,- bottomTrailingRadius: 6, topTrailingRadius: 16))- }- .padding(.vertical, 4)- case "message":- Text(Self.markdown(item.text))- .textSelection(.enabled)- .padding(.vertical, 4)- default:- activity(i, item).padding(.vertical, 2)- }- }-- private func activity(_ i: Int, _ item: AgentTranscriptItem) -> some View {- let open = (i == timeline.openActivity) != toggled.contains(i)- return VStack(alignment: .leading, spacing: 4) {- Button {- if toggled.contains(i) { toggled.remove(i) } else { toggled.insert(i) }- } label: {- HStack(spacing: 6) {- Image(systemName: "chevron.right")- .font(.system(size: 9, weight: .semibold))- .rotationEffect(.degrees(open ? 90 : 0))- Text(item.text).fontWeight(.medium)- if !open, let last = item.steps.last {- Text(last).foregroundStyle(.tertiary).lineLimit(1).truncationMode(.tail)- }- }- .contentShape(Rectangle())- }- .buttonStyle(.plain)- .accessibilityValue(open ? "expanded" : "collapsed")- if open {- VStack(alignment: .leading, spacing: 2) {- ForEach(Array(item.steps.enumerated()), id: \.offset) { _, step in- Text(step)- .font(.system(size: 11.5, design: .monospaced))- .lineLimit(1).truncationMode(.tail)- .help(step)- }- }- .padding(.leading, 14)- .overlay(alignment: .leading) { Rectangle().fill(.separator).frame(width: 1).padding(.leading, 5) }- }- }- .font(.caption)- .foregroundStyle(.secondary)- }-- private func centered(_ title: String, _ detail: String) -> some View {- VStack(spacing: 6) {- Text(title).font(.headline)- Text(detail).font(.callout).foregroundStyle(.secondary).multilineTextAlignment(.center)- }- .frame(maxWidth: 360)- .padding(32)- }-- /// The agent's Markdown, inline styles and links; blocks keep their lines.- static func markdown(_ text: String) -> AttributedString {- (try? AttributedString(markdown: text, options: .init(interpretedSyntax: .inlineOnlyPreservingWhitespace)))- ?? AttributedString(text)- }-}diff --git a/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Views/ShareSheetView.swift b/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Views/ShareSheetView.swiftdeleted file mode 100644index 39add1b504..0000000000--- a/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Views/ShareSheetView.swift+++ /dev/null@@ -1,76 +0,0 @@-// SPDX-License-Identifier: FSL-1.1-MIT-// Copyright (c) 2026 Cua AI, Inc.--import CuaSDK-import CuaSpacesFFI-import SwiftUI--/// "Share": one line per person with a role menu, an email field and Done.-/// Every word is the app core's.-struct ShareSheetView: View {- @Bindable var model: ShareModel- let onDone: () -> Void- @Environment(\.openURL) private var openURL-- var body: some View {- let v = model.view- let gate = model.gate- let closed = v.disabledReason != nil || gate != nil- Form {- if let reason = v.disabledReason ?? gate?.reason {- Text(reason).foregroundStyle(.secondary)- }- if v.disabledReason == nil, let gate, let url = URL(string: gate.action.url) {- Button(gate.action.label) { openURL(url) }- .accessibilityIdentifier("share-see-teams")- }- Section {- HStack {- TextField(v.whoPlaceholder, text: Binding(- get: { v.who },- set: { who in Task { await model.send(.setWho(who: who)) } }))- .textFieldStyle(.roundedBorder)- .disabled(closed)- .onSubmit { Task { await model.send(.submit) } }- roleMenu(v, selection: v.role) { role in Task { await model.send(.setRole(role: role)) } }- Button(v.shareLabel) { Task { await model.send(.submit) } }- .disabled(!v.canShare || closed)- .keyboardShortcut(.defaultAction)- }- if let hint = v.hint { Text(hint).foregroundStyle(.secondary) }- }- Section {- if v.rows.isEmpty { Text(v.emptyText).foregroundStyle(.secondary) }- ForEach(v.rows, id: \.who) { row in- HStack {- Circle().fill(row.connected ? Color.green : Color.secondary.opacity(0.4)).frame(width: 7, height: 7)- Text(row.who).lineLimit(1).truncationMode(.middle)- Spacer()- roleMenu(v, selection: row.role) { role in- Task { await model.send(.changeRole(who: row.who, role: role)) }- }- Button(v.removeLabel) { Task { await model.send(.remove(who: row.who)) } }- .disabled(v.busy)- }- }- }- if let error = v.error { Text(error).foregroundStyle(.red) }- }- .formStyle(.grouped)- .navigationTitle(v.title)- .frame(minWidth: 440, minHeight: 280)- .toolbar {- ToolbarItem(placement: .confirmationAction) { Button(v.doneLabel, action: onDone) }- }- .task { await model.load() }- }-- private func roleMenu(_ v: AppShareSheetView, selection: String, _ change: @escaping (String) -> Void) -> some View {- Picker("", selection: Binding(get: { selection }, set: change)) {- ForEach(v.roles, id: \.id) { Text($0.label).tag($0.id) }- }- .labelsHidden()- .fixedSize()- .disabled(v.busy || v.disabledReason != nil || model.gate != nil)- }-}diff --git a/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Views/SpaceDetailView.swift b/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Views/SpaceDetailView.swiftdeleted file mode 100644index 60882fc5b1..0000000000--- a/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Views/SpaceDetailView.swift+++ /dev/null@@ -1,747 +0,0 @@-// SPDX-License-Identifier: FSL-1.1-MIT-// Copyright (c) 2026 Cua AI, Inc.--import CuaSDK-import CuaSpacesFFI-import CuaSpacesStreaming-import CuaSpacesTeleport-import SwiftUI-import UniformTypeIdentifiers--/// A Space: the live desktop, its facts, then Stream (one row per window,-/// each with its own stream and picture in picture), Agents (one row per-/// coding-agent run) and Teleport.-/// What shows and what is enabled is the core's `appSpaceDetail`.-struct SpaceDetailView: View {- let model: AppModel- let space: AppSpace- @State private var provider: SpaceStreamSourceProviding?- @State private var session: LiveStreamSession?- @State private var pips: StreamPiPSet?- @State private var streams: StreamRowsModel?- @State private var teleport: TeleportModel?- @State private var dropStatus: TeleportDropZone.Status?- @State private var agents: AgentRunsModel?- /// The run whose conversation is open (a sheet).- @State private var openRun: RunTimelineModel?- @State private var sharing: ShareModel?- /// Connect (or Try again) was pressed: the stream opens even with- /// "Connect to the desktop automatically" off.- @State private var connectRequested = false- @State private var providerFailed = false- @Environment(\.openWindow) private var openWindow- private let copy = appSpaceDetailCopy()-- private var deleting: Bool { space.status == .deleting }- /// Off, or being turned off: nothing streams from it.- private var off: Bool { space.power.map { $0.off || $0.turningOn == false } ?? false }- /// What the live parts (stream, polling) restart on.- private var live: String { "\(space.id) \(deleting) \(off)" }- /// Provider creation can fail before a stream session exists.- private var providerPhase: AppStreamPhase { providerFailed ? .failed : .noSession }-- var body: some View {- let detail = model.detail(space)- let wantsStream = model.cover(detail, requested: connectRequested, stream: providerPhase).openStream- ScrollViewReader { scroller in- Form {- if let note = detail.desktopNote {- // One of your machines that does not share its desktop:- // why, in place of the desktop, and what it still does.- DesktopNotSharedSections(model: model, machineId: space.id, note: note,- newSpace: detail.newSpace)- } else {- Section {- PreviewCard(session: detail.canStream ? session : nil) { preview(detail) }- } footer: {- if let error = detail.powerError {- // Turning it off or on failed: why, inline.- Text(error)- .foregroundStyle(.red)- .accessibilityIdentifier("space-power-error")- }- }- }- Section {- FactRows(facts: detail.facts)- }- ForEach(detail.sections, id: \.self) { title in- Section(title) {- switch title {- case "Stream": streamRows- case "Agents":- if let agents { AgentRows(agents: agents, copy: copy, open: open) } else { Text(copy.agentsLoading).foregroundStyle(.secondary) }- default: teleportRow- }- }- .id("section-\(title)")- }- }- .formStyle(.grouped)- .task(id: space.id) {- // Captures: the Stream section at the top of the window once- // its windows are listed (bounded wait).- guard let view = DevHooks.value("CUA_SPACES_START_VIEW"),- ["stream", "window-pip"].contains(view) else { return }- for _ in 0..<120 where streams?.windows == nil {- try? await Task.sleep(for: .milliseconds(250))- }- try? await Task.sleep(for: .milliseconds(300))- scroller.scrollTo("section-Stream", anchor: .top)- }- }- .navigationTitle(detail.title)- .toolbar { toolbar(detail) }- // A delete stops the stream, its pop-outs and the polling at once- // (and a failed one starts them again). Approval also re-evaluates- // the core's eligibility without reopening this detail.- .task(id: "\(live) \(wantsStream)") { await connect(detail) }- // The cover's preview: the shared store's image at once, then one- // no older than the background interval.- .task(id: live) {- guard detail.canStream else { return }- await model.thumbnails.refresh(space.id, maxAge: TimeInterval(SpaceThumbnails.policy.backgroundIntervalMs) / 1000)- }- // Leaving: the last frame is the newest preview there is.- .onDisappear { keepLastFrame() }- .onChange(of: deleting) { _, now in if now { disconnect() } }- .onChange(of: off) { _, now in if now { disconnect() } }- .task(id: live) {- guard detail.showSections else { return }- await model.pollUsage(space.id)- }- .task(id: live) {- guard detail.showSections else { return }- let model = AgentRunsModel(backend: self.model.backend, spaceId: space.id)- model.onRead = { [weak app = self.model] in app?.sawAgentRuns($0) }- agents = model- await model.poll()- }- .sheet(item: $openRun) { RunTimelineView(timeline: $0) }- .task(id: space.id) {- // Captures: an agent run's conversation open (a running one first).- guard DevHooks.value("CUA_SPACES_START_VIEW") == "run-timeline" else { return }- for _ in 0..<40 {- if case .ready(let runs) = agents?.load, let run = runs.first(where: { $0.status == .running }) ?? runs.first {- open(run)- return- }- try? await Task.sleep(for: .milliseconds(250))- }- }- .task(id: space.id) {- // Captures: this Space's own window (its live desktop, with the- // other participants' cursors), as Open does.- guard DevHooks.value("CUA_SPACES_START_VIEW") == "space-window",- detail.canStream else { return }- try? await Task.sleep(for: .seconds(1))- openWindow(id: "space", value: space.id)- }- .task(id: space.id) {- // Captures: the teleport picker open on this Space.- guard DevHooks.value("CUA_SPACES_START_VIEW") == "teleport-picker",- detail.canStream else { return }- try? await Task.sleep(for: .seconds(2))- await openTeleport(entry: nil)- }- .task(id: model.pendingTeleport) {- guard let p = model.pendingTeleport, p.spaceId == space.id else { return }- model.pendingTeleport = nil- await openTeleport(entry: p.entry, files: p.files)- }- // The checklist's Teleport or Share, on this Space.- .task(id: model.detailRequest) {- guard let r = model.detailRequest, r.spaceId == space.id else { return }- model.detailRequest = nil- perform(r.action)- }- .sheet(item: Binding(get: { teleport.map { TeleportSheetItem(model: $0) } },- set: { if $0 == nil { teleport = nil } })) { item in- TeleportPickerSheet(teleport: item.model) { teleport = nil }- }- .sheet(item: Binding(get: { sharing.map { ShareSheetItem(model: $0) } },- set: { if $0 == nil { sharing = nil } })) { item in- ShareSheetView(model: item.model) { sharing = nil }- }- .alert(detail.confirm.title, isPresented: Binding(- get: { model.confirmDeleteId == space.id },- set: { if !$0 { model.confirmDeleteId = nil } })) {- Button(detail.confirm.confirmLabel, role: .destructive) { model.delete(space) }- .disabled(!detail.confirm.confirmEnabled)- // A Space in your cloud: forget it, keep it running there.- if let remove = detail.confirm.removeLabel {- Button(remove) { model.delete(space, removeOnly: true) }- }- Button(detail.confirm.cancelLabel, role: .cancel) {}- } message: {- Text([detail.confirm.message, detail.confirm.disabledReason].compactMap { $0 }.joined(separator: "\n\n"))- }- }-- @ViewBuilder private func preview(_ detail: AppSpaceDetail) -> some View {- StreamPhaseReader(session: detail.canStream ? session : nil) { phase in- let cover = model.cover(detail, requested: connectRequested, stream: session == nil ? providerPhase : phase)- ZStack {- if let session, detail.canStream {- SpaceScreenView(session: session, isInteractive: true, showsControls: false)- }- if cover.kind != .stream {- DesktopCoverView(cover: cover, image: model.thumbnails[space.id],- progress: detail.progress, progressText: detail.progressText,- onAction: { model.devices.startEnroll(in: .main) }) {- press(cover)- }- .transition(.opacity)- }- }- .animation(.easeOut(duration: 0.25), value: cover.kind)- }- }-- /// The cover's button: Connect opens the stream; Try again starts the- /// failed one again.- private func press(_ cover: AppDesktopCover) {- connectRequested = true- providerFailed = false- guard cover.kind == .status, let session else { return }- Task {- await session.stop()- await session.start()- }- }-- /// Keeps the stream's last frame as the Space's preview.- private func open(_ run: AppSpaceAgentRun) {- openRun = RunTimelineModel(backend: model.backend, spaceId: space.id, run: run)- }-- private func keepLastFrame() {- guard let frame = session?.frame, let image = SpaceThumbnails.image(frame) else { return }- model.thumbnails.set(space.id, image)- }-- @ViewBuilder private var streamRows: some View {- if let session, let pips, let streams {- StreamRows(model: streams, session: session, pips: pips)- } else {- Text(copy.streamLoading).foregroundStyle(.secondary)- }- }-- /// The shared drop well (CuaSpacesTeleport), the same one the Swift- /// samples use: files are sent, an app opens the teleport review.- private var teleportRow: some View {- TeleportDropZone(- spaceID: space.id, teleport: model.backend.teleportHandle(), status: dropStatus,- caption: copy.dropCaption, sendFileTitle: copy.sendFile, teleportAppTitle: copy.teleportApp,- symbol: copy.teleportSymbol, activeSymbol: copy.teleportSymbolActive,- onFiles: { urls in Task { await send(urls.map(\.path)) } },- onApp: { entry, files in Task { await openTeleport(entry: entry, files: files) } },- onSendFile: { chooseFiles() },- onTeleportApp: { Task { await openTeleport(entry: nil) } })- .listRowInsets(EdgeInsets(top: 8, leading: 8, bottom: 8, trailing: 8))- }-- private func chooseFiles() {- let panel = NSOpenPanel()- panel.allowsMultipleSelection = true- panel.canChooseDirectories = true- guard panel.runModal() == .OK else { return }- let paths = panel.urls.map(\.path)- Task { await send(paths) }- }-- private func send(_ paths: [String]) async {- guard !paths.isEmpty else { return }- model.recordFeature("file_send")- dropStatus = .working(appDropSendingText(paths: paths))- do {- let files = try await model.backend.sendFiles(id: space.id, paths: paths)- dropStatus = .done(appDropSentText(files: files))- } catch {- dropStatus = .failed(LiveSpacesBackend.words(error))- }- }-- @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- if !more.contains(action) { actionButton(action) }- }- }- }-- @ViewBuilder private func actionButton(_ action: AppDetailAction) -> some View {- let run = { perform(action.id) }- if action.id == .cancel {- // A create still running: a plain "Cancel" (disabled while it- // cleans up; the row and preview say "Cancelling…").- Button(action.label, action: run)- .help(action.help)- .disabled(!action.enabled)- .accessibilityIdentifier("space-cancel-create")- } else if action.busy {- // Its action runs (turning the Space off or on): a spinner.- ProgressView()- .controlSize(.small)- .help(action.help)- .accessibilityLabel(action.help)- } else if let symbol = action.symbol {- Button(role: action.destructive ? .destructive : nil, action: run) {- Label(action.label, systemImage: symbol)- }- .help(action.help)- .disabled(!action.enabled)- } else {- Button(action.label, action: run)- .buttonStyle(.borderedProminent)- .help(action.help)- .disabled(!action.enabled)- .accessibilityIdentifier("space-open")- }- }-- private func perform(_ id: AppDetailActionId) {- switch id {- case .teleport:- model.recordFeature("teleport_app_picker")- Task { await openTeleport(entry: nil) }- case .pip: pips?.toggle(.desktop, sharing: session)- case .share:- sharing = ShareModel(- backend: model.backend, spaceId: space.id, spaceName: space.name,- signedIn: model.identity != nil,- shareable: space.id.hasPrefix("relay:") || (space.sdk?.features.contains("relay_attach") ?? false))- sharing?.hasTeam = model.hasSharingTeam- Task { [weak model] in- // Teams may not have been read yet: the sheet closes or stays open once they are.- await model?.reloadTeams()- sharing?.hasTeam = model?.hasSharingTeam- }- sharing?.telemetry = model.telemetrySink- sharing?.onShared = { [weak model] in model?.checklist.done(.share) }- model.recordFeature("share_open")- case .power:- if let button = appPowerButton(space: space) { model.setPower(space, on: button.turnOn) }- case .delete: model.confirmDeleteId = space.id- case .open:- model.recordFeature("space_open_viewer")- openWindow(id: "space", value: space.id)- case .cancel: model.cancelCreate(space.id)- }- }-- private func connect(_ detail: AppSpaceDetail) async {- // The core decides: auto-connect on, or Connect pressed.- guard session == nil,- model.cover(detail, requested: connectRequested, stream: providerPhase).openStream else { return }- do {- let provider = try await model.backend.streamProvider(id: space.id)- guard !Task.isCancelled else { return }- self.provider = provider- let session = LiveStreamSession(provider: provider)- self.session = session- let pips = StreamPiPSet(provider: provider)- self.pips = pips- streams = StreamRowsModel(space: space, provider: provider, backend: model.backend)- // Captures: pop out the first window's own stream.- if DevHooks.value("CUA_SPACES_START_VIEW") == "window-pip" {- await session.refreshWindows()- if let first = session.windows.first { pips.popOut(.window(first)) }- }- } catch {- guard !Task.isCancelled else { return }- providerFailed = true- model.show(error: "Could not open \(space.name): \(LiveSpacesBackend.words(error))")- }- }-- /// Stops the live desktop, closes its picture-in-picture panels and- /// forgets the window list (the Space is being deleted).- private func disconnect() {- keepLastFrame()- connectRequested = false- providerFailed = false- agents = nil- pips?.popInAll()- if let session { Task { await session.stop() } }- session = nil- pips = nil- streams = nil- provider = nil- }-- private func openTeleport(entry: TeleportCatalogEntry?, files: [String] = []) async {- do {- let context = try await model.backend.teleportContext(id: space.id)- let t = TeleportModel(spaceName: space.name, teleport: context?.0, space: context?.1)- // The review reads saved Keyvault items and a browser's sites- // from the Keyvault, and starts from what was sent last time.- t.keyvault = model.keyvault- t.onTeleported = { [weak model] in model?.checklist.done(.teleport) }- t.rememberedChoices = model.settings.teleportChoices- t.onRemember = { [weak model] choices in- model?.settings.teleportChoices = choices- model?.saveSettings()- }- // From <Space>: the window's own stream, here, in a floating panel.- t.onStreamWindow = { [weak t] id in- if let w = streams?.window(id: id) ?? session?.windows.first(where: { $0.id == id }) {- pips?.popOut(.window(w))- }- if t != nil { teleport = nil }- }- let notch = model.notch- t.onTransfer = { running in- notch.setActivity(hotspot: notch.state.hotspot,- transfer: running ? AppNotchTransfer(sent: nil, total: nil) : nil)- }- // The sheet shows at once; the catalog fills it (cached, ms).- teleport = t- if let entry { t.preselect(entry, files: files) } else { await t.load() }- } catch {- model.show(error: LiveSpacesBackend.words(error))- }- }-}--/// One of your machines that does not share its desktop: the core's line-/// in place of the desktop, then the Spaces it provides. No Stream, Agents-/// or Teleport.-struct DesktopNotSharedSections: View {- let model: AppModel- let machineId: String- let note: String- let newSpace: AppNewSpaceOn?-- var body: some View {- Section {- Text(note)- .foregroundStyle(.secondary)- .fixedSize(horizontal: false, vertical: true)- .accessibilityIdentifier("machine-desktop-note")- }- if newSpace != nil {- Section("Spaces") {- let rows = model.hostedRows(machineId)- if rows.isEmpty {- Text("No Spaces yet").foregroundStyle(.secondary)- }- ForEach(rows, id: \.id) { row in- Button { model.select(row.id) } label: {- SpaceRowView(row: row).contentShape(Rectangle())- }- .buttonStyle(.plain)- }- }- .accessibilityIdentifier("machine-spaces")- }- }-}--/// The live desktop's card: the stream runs flush to the card's edges with-/// only the card's own corner radius (the website's Spaces window). The card-/// sizes to the stream's aspect ratio once it has a frame, else to the-/// default desktop's 16:10 (1280x800), so it does not jump when the stream-/// starts; nothing is letterboxed.-///-/// `listRowInsets` has no effect in a macOS grouped Form, so the row is a-/// clear spacer and the content an overlay grown by the row's inset to the-/// whole card, which clips it to its corner radius. (Grown as the row-/// itself, an AppKit-backed view such as the stream is cut off at the-/// row's top inset; as an overlay it is not.)-struct PreviewCard<Content: View>: View {- /// A macOS grouped Form's row inset on every side.- static var rowInset: CGFloat { 10 }-- var session: LiveStreamSession?- @ViewBuilder var content: Content-- var body: some View {- if let session { Observed(session: session, content: content) } else { Self.card(nil, content) }- }-- static func card(_ size: CGSize?, _ content: Content) -> some View {- let aspect = size.flatMap { $0.width > 0 && $0.height > 0 ? $0.width / $0.height : nil } ?? 16.0 / 10.0- return CardSpacer(aspect: aspect, inset: rowInset) { Color.clear }- .overlay { content.padding(-rowInset) }- }-- private struct Observed: View {- @ObservedObject var session: LiveStreamSession- let content: Content- var body: some View { PreviewCard.card(session.surfaceSize, content) }- }-}--/// A row whose card (the row plus `inset` on every side) is `aspect` wide-/// over high.-struct CardSpacer: Layout {- var aspect: CGFloat- var inset: CGFloat-- func sizeThatFits(proposal: ProposedViewSize, subviews: Subviews, cache: inout ()) -> CGSize {- let width = proposal.width ?? 480- return CGSize(width: width, height: max((width + 2 * inset) / aspect - 2 * inset, 0))- }-- func placeSubviews(in bounds: CGRect, proposal: ProposedViewSize, subviews: Subviews, cache: inout ()) {- for view in subviews { view.place(at: bounds.origin, proposal: ProposedViewSize(bounds.size)) }- }-}--/// The detail's facts, one line each: the full value (and an image's-/// digest) as the tooltip, a copy button after the Image and Identifier-/// values, and the core's warning symbol with its tooltip (an emulated-/// local Space's Architecture).-struct FactRows: View {- let facts: [AppFact]- var write: (String) -> Void = FactCopyModel.pasteboard- /// Snapshots: draw the copy buttons in their "Copied" state.- var copied = false-- var body: some View {- ForEach(facts, id: \.label) { fact in- LabeledContent(fact.label) {- HStack(spacing: 5) {- Text(fact.value)- .lineLimit(1)- .truncationMode(.middle)- .textSelection(.enabled)- .help(fact.help ?? fact.value)- if let warning = fact.warning {- Image(systemName: warning.symbol)- .foregroundStyle(.yellow)- .imageScale(.small)- .help(warning.help)- .accessibilityLabel(warning.help)- }- if let copy = fact.copy {- CopyFactButton(model: FactCopyModel(copy: copy, copied: copied, write: write))- }- }- }- }- }-}--/// A fact's copy button: `doc.on.doc`, then the core's checkmark and-/// "Copied" for its `confirmMs`.-struct CopyFactButton: View {- @StateObject var model: FactCopyModel-- var body: some View {- Button { model.copy() } label: {- Image(systemName: model.symbol)- .contentTransition(.symbolEffect(.replace))- .frame(width: 14, height: 14)- }- .buttonStyle(.borderless)- .foregroundStyle(.secondary)- .help(model.help)- .accessibilityLabel(model.help)- .accessibilityIdentifier("copy-fact")- }-}--/// The Stream section: the core's rows (`appStreamSection`, the same ones-/// the Tauri app draws), the Desktop and one per window, each with its-/// picture-in-picture button.-struct StreamRows: View {- @ObservedObject var model: StreamRowsModel- @ObservedObject var session: LiveStreamSession- @ObservedObject var pips: StreamPiPSet-- var body: some View {- StreamRowList(section: model.section(openKeys: pips.openKeys), image: model.image(for:)) { row in- // What the button does is the core's: close the row's open- // panel (pip.exit), else open one.- let source: StreamSource? = row.kind == .desktop ? .desktop : model.window(id: row.id).map { .window($0) }- guard let source else { return }- switch appStreamPipClick(open: model.openRows(openKeys: pips.openKeys), row: row.id) {- case .close: pips.popIn(source)- case .open: pips.popOut(source, sharing: row.kind == .desktop ? session : nil)- }- }- .task { await model.poll() }- }-}--/// The rows themselves: one line each, the icon (the Space's OS mark for-/// the Desktop, the app's own icon or nothing for a window), the label-/// truncated with its full text as the tooltip, and the icon buttons.-struct StreamRowList: View {- let section: AppStreamSection- let image: (AppStreamRowIcon) -> NSImage?- let perform: (AppStreamRow) -> Void-- var body: some View {- ForEach(section.rows, id: \.id) { row in- HStack(spacing: 8) {- icon(row.icon)- .frame(width: 16, height: 16)- Text(row.label)- .lineLimit(1)- .truncationMode(.tail)- .help(row.help)- .frame(maxWidth: .infinity, alignment: .leading)- ForEach(row.actions, id: \.symbol) { action in- Button { perform(row) } label: {- Image(systemName: action.symbol)- }- .buttonStyle(.borderless)- .help(action.help)- .accessibilityLabel(action.help)- .accessibilityIdentifier(row.kind == .desktop ? "pip-desktop" : "pip-\(row.id)")- }- }- .accessibilityElement(children: .contain)- .accessibilityIdentifier("stream-row-\(row.id)")- }- if let status = section.statusText {- Text(status).foregroundStyle(.secondary)- }- }-- @ViewBuilder private func icon(_ icon: AppStreamRowIcon) -> some View {- switch icon {- case let .os(id):- OsIconImage(id: id, size: 14).foregroundStyle(.secondary)- case .app:- // No icon for the app: nothing, never a stand-in glyph (the- // empty slot keeps the labels aligned).- if let image = image(icon) {- Image(nsImage: image).resizable().interpolation(.high).aspectRatio(contentMode: .fit)- } else {- Color.clear- }- }- }-}--/// The Agents section: one line per run (the agent and what it was asked),-/// its status on the right, the reason as the tooltip. A run opens its-/// conversation.-struct AgentRows: View {- let agents: AgentRunsModel- let copy: AppDetailCopy- var open: (AppSpaceAgentRun) -> Void = { _ in }-- var body: some View {- switch agents.load {- case .loading:- Text(copy.agentsLoading).foregroundStyle(.secondary)- case .failed(let reason):- Text(copy.agentsFailed).foregroundStyle(.secondary).help(reason)- case .ready(let runs) where runs.isEmpty:- Text(copy.agentsEmpty).foregroundStyle(.secondary)- case .ready(let runs):- ForEach(runs, id: \.runId) { run in- Button { open(run) } label: {- LabeledContent {- Text(AgentRunsModel.status(run)).foregroundStyle(.secondary)- } label: {- Text(AgentRunsModel.line(run)).lineLimit(1).truncationMode(.tail)- }- .contentShape(Rectangle())- }- .buttonStyle(.plain)- .help(run.reason)- .accessibilityIdentifier("agent-run-\(run.runId)")- }- }- }-}--struct TeleportSheetItem: Identifiable {- let model: TeleportModel- var id: ObjectIdentifier { ObjectIdentifier(model) }-}--/// A Space's live desktop in its own window ("Open").-struct SpaceWindowView: View {- let model: AppModel- let spaceId: String- @State private var session: LiveStreamSession?- @State private var error: String?- /// The Space was listed while this window was open: once it is gone- /// (deleted), the window closes instead of going blank.- @State private var seen = false- @Environment(\.dismiss) private var dismiss-- var body: some View {- let space = model.spaces.first { $0.id == spaceId }- Group {- if let error {- ZStack {- Rectangle().fill(.quaternary)- Text(error).foregroundStyle(.secondary)- }- } else if let space {- // Open is a request to connect: the same cover as the- // detail's until the first frame.- StreamPhaseReader(session: session) { phase in- let cover = model.cover(model.detail(space), requested: true, stream: phase)- ZStack {- if let session { SpaceScreenView(session: session, isInteractive: true, showsControls: true) }- if cover.kind != .stream {- DesktopCoverView(cover: cover, image: model.thumbnails[spaceId]) {- // Try again.- guard let session else { return }- Task {- await session.stop()- await session.start()- }- }- }- }- }- } else {- ZStack {- Rectangle().fill(.quaternary)- Text(seen ? "This Space was deleted." : "This Space isn\u{2019}t listed on this Mac.")- .foregroundStyle(.secondary)- }- }- }- .frame(minWidth: 640, minHeight: 400)- .navigationTitle(space?.name ?? spaceId)- .onAppear { if space != nil { seen = true } }- .onChange(of: space != nil) { _, listed in- if listed {- seen = true- } else if seen {- dismiss()- }- }- .onChange(of: space?.status == .deleting) { _, deleting in- // Deleting: the stream stops now.- guard deleting, let session else { return }- self.session = nil- Task { await session.stop() }- }- .task(id: spaceId) {- do {- session = LiveStreamSession(provider: try await model.backend.streamProvider(id: spaceId))- } catch {- self.error = LiveSpacesBackend.words(error)- }- }- }-}--/// The Share sheet's identity for `.sheet(item:)`.-private struct ShareSheetItem: Identifiable {- let model: ShareModel- var id: String { model.spaceId }-}diff --git a/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Views/SpaceWindowView.swift b/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Views/SpaceWindowView.swiftnew file mode 100644index 0000000000..be82b64167--- /dev/null+++ b/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Views/SpaceWindowView.swift@@ -0,0 +1,79 @@+// SPDX-License-Identifier: FSL-1.1-MIT+// Copyright (c) 2026 Cua AI, Inc.++import CuaSDK+import CuaSpacesFFI+import CuaSpacesStreaming+import SwiftUI++/// A Space's live desktop in its own window ("Open").+struct SpaceWindowView: View {+ let model: AppModel+ let spaceId: String+ @State private var session: LiveStreamSession?+ @State private var error: String?+ /// The Space was listed while this window was open: once it is gone+ /// (deleted), the window closes instead of going blank.+ @State private var seen = false+ @Environment(\.dismiss) private var dismiss++ var body: some View {+ let space = model.spaces.first { $0.id == spaceId }+ Group {+ if let error {+ ZStack {+ Rectangle().fill(.quaternary)+ Text(error).foregroundStyle(.secondary)+ }+ } else if let space {+ // Open is a request to connect: the same cover as the+ // detail's until the first frame.+ StreamPhaseReader(session: session) { phase in+ let cover = model.cover(model.detail(space), requested: true, stream: phase)+ ZStack {+ if let session { SpaceScreenView(session: session, isInteractive: true, showsControls: true) }+ if cover.kind != .stream {+ DesktopCoverView(cover: cover, image: model.thumbnails[spaceId]) {+ // Try again.+ guard let session else { return }+ Task {+ await session.stop()+ await session.start()+ }+ }+ }+ }+ }+ } else {+ ZStack {+ Rectangle().fill(.quaternary)+ Text(seen ? "This Space was deleted." : "This Space isn\u{2019}t listed on this Mac.")+ .foregroundStyle(.secondary)+ }+ }+ }+ .frame(minWidth: 640, minHeight: 400)+ .navigationTitle(space?.name ?? spaceId)+ .onAppear { if space != nil { seen = true } }+ .onChange(of: space != nil) { _, listed in+ if listed {+ seen = true+ } else if seen {+ dismiss()+ }+ }+ .onChange(of: space?.status == .deleting) { _, deleting in+ // Deleting: the stream stops now.+ guard deleting, let session else { return }+ self.session = nil+ Task { await session.stop() }+ }+ .task(id: spaceId) {+ do {+ session = LiveStreamSession(provider: try await model.backend.streamProvider(id: spaceId))+ } catch {+ self.error = LiveSpacesBackend.words(error)+ }+ }+ }+}diff --git a/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Views/StartupView.swift b/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Views/StartupView.swiftdeleted file mode 100644index dbbbe03ee2..0000000000--- a/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Views/StartupView.swift+++ /dev/null@@ -1,88 +0,0 @@-// SPDX-License-Identifier: FSL-1.1-MIT-// Copyright (c) 2026 Cua AI, Inc.--import AppKit-import SwiftUI--/// The launch, until the live services are in: "Starting Cua…", or what-/// the keychain needs ("Allow Keychain access", "Waiting for Keychain-/// access…"). The words and buttons are `StartupModel.copy`, which New UI's-/// startup screen shows too.-struct StartupView: View {- let startup: StartupModel- @State private var confirmingSignIn = false-- var body: some View {- let copy = startup.copy- VStack(spacing: 14) {- if copy.actions.isEmpty {- ProgressView().controlSize(.regular)- } else {- Image(systemName: "key.fill")- .font(.system(size: 30, weight: .regular))- .foregroundStyle(.secondary)- }- Text(copy.title)- .font(.title2.weight(.semibold))- .multilineTextAlignment(.center)- if !copy.body.isEmpty {- Text(copy.body)- .font(.body)- .foregroundStyle(.secondary)- .multilineTextAlignment(.center)- .fixedSize(horizontal: false, vertical: true)- .frame(maxWidth: 440)- }- if !copy.actions.isEmpty {- HStack(spacing: 10) {- ForEach(Array(copy.actions.enumerated()), id: \.offset) { index, action in- button(action, primary: index == 0)- }- }- .padding(.top, 6)- }- }- .padding(40)- .frame(minWidth: 520, maxWidth: .infinity, minHeight: 360, maxHeight: .infinity)- .accessibilityElement(children: .contain)- .accessibilityIdentifier("startup")- .confirmationDialog("Sign in again?", isPresented: $confirmingSignIn) {- Button("Sign in again") { startup.act(.signInAgain) }- Button("Cancel", role: .cancel) {}- } message: {- Text("This removes the saved sign-in from this Mac's keychain. Nothing else is deleted. "- + "You'll sign in again in your browser.")- }- }-- @ViewBuilder- private func button(_ action: StartupModel.Action, primary: Bool) -> some View {- let label = Self.label(action)- if primary {- Button(label) { press(action) }- .buttonStyle(.borderedProminent)- .keyboardShortcut(.defaultAction)- } else {- Button(label) { press(action) }- .buttonStyle(.bordered)- }- }-- private func press(_ action: StartupModel.Action) {- if action == .signInAgain {- confirmingSignIn = true- } else {- // The keychain prompt shows over the app that asked: be in front.- NSApp.activate()- startup.act(action)- }- }-- static func label(_ action: StartupModel.Action) -> String {- switch action {- case .allowAccess: return "Allow access"- case .tryAgain: return "Try again"- case .signInAgain: return "Sign in again"- }- }-}diff --git a/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Views/TeleportPickerSheet.swift b/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Views/TeleportPickerSheet.swiftdeleted file mode 100644index 6b0a388a90..0000000000--- a/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Views/TeleportPickerSheet.swift+++ /dev/null@@ -1,254 +0,0 @@-// SPDX-License-Identifier: FSL-1.1-MIT-// Copyright (c) 2026 Cua AI, Inc.--import AppKit-import CuaSDK-import CuaSpacesFFI-import SwiftUI--/// "Teleport an app…": pick, choose what moves, review every install, path-/// and secret, then run. The steps and the gate are the core's.-struct TeleportPickerSheet: View {- @Bindable var teleport: TeleportModel- let onClose: () -> Void-- var body: some View {- let s = teleport.state- VStack(alignment: .leading, spacing: 0) {- Text(title(s)).font(.headline).padding(.horizontal, 20).padding(.top, 18).padding(.bottom, 10)- Group {- switch s.step {- case .loading, .planning:- ProgressView().frame(maxWidth: .infinity, maxHeight: .infinity)- case .pick:- pick(s)- case .options:- options(s)- case .consent:- review- case .running:- TeleportRunning(progress: teleport.progress, status: teleport.status)- case .done:- Text("Done").padding(20)- case .error:- Text(s.installPrompt?.message ?? s.error ?? "").foregroundStyle(.secondary).padding(20)- }- }- .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topLeading)- Divider()- footer(s).padding(14)- }- .frame(width: 640, height: 540)- }--- private func title(_ s: AppPickerState) -> String {- if let review = teleport.review { return review.title }- if let entry = s.entry { return entry.name }- return "Teleport an App to \(s.spaceName)"- }-- /// The grid: tabs, search and the core's tiles (the same grid as the- /// Tauri app's), arrow keys and Return.- private func pick(_ s: AppPickerState) -> some View {- VStack(alignment: .leading, spacing: 10) {- Picker("", selection: Binding(get: { teleport.tab }, set: { tab in- teleport.tab = tab- Task { await teleport.loadWindows() }- })) {- ForEach(teleport.tabs, id: \.label) { t in Text(t.label).tag(t.tab) }- }- .pickerStyle(.segmented)- .labelsHidden()- TextField("Search", text: Binding(get: { teleport.query }, set: {- teleport.setQuery($0)- Task { await teleport.loadIcons() }- }))- .textFieldStyle(.roundedBorder)- TeleportGrid(teleport: teleport)- }- .padding(.horizontal, 20)- .task { await teleport.loadWindows() }- }-- private func options(_ s: AppPickerState) -> some View {- Form {- Picker("Move", selection: Binding(- get: { s.moves ?? .appOnly },- set: { teleport.send(.move(moves: $0)) })) {- ForEach(s.entry?.moves ?? [], id: \.self) { m in Text(m.label).tag(m) }- }- .pickerStyle(.radioGroup)- // The core's opt-ins, each unchecked until chosen: "Keep me- // signed in" (the session cookies), "Saved passwords",- // "Browsing history".- ForEach(appPickerSensitiveOptions(state: s), id: \.group) { option in- Toggle(isOn: Binding(get: { option.checked },- set: { teleport.send(.sensitive(group: option.group, value: $0)) })) {- Text(CoreMessages.text(option.label))- Text(CoreMessages.text(option.detail))- }- .toggleStyle(.checkbox)- }- ForEach(s.files, id: \.self) { f in- LabeledContent(appDisplayPath(path: f, home: AppEnvironment.home.path)) {- Button("Remove") { teleport.send(.removeFile(path: f)) }- }- }- }- .formStyle(.grouped)- }-- @ViewBuilder private var review: some View {- if let review = teleport.review {- TeleportReview(teleport: teleport, review: review)- }- }-- @ViewBuilder private func footer(_ s: AppPickerState) -> some View {- HStack {- if let leaves = teleport.review?.leavesText {- Text(leaves).foregroundStyle(.secondary).font(.callout)- }- Spacer()- Button("Cancel", action: onClose).keyboardShortcut(.cancelAction)- switch s.step {- case .pick:- // "Continue", "Teleport to <Space>" or "Stream to This Mac":- // the core's, live with a choosable tile selected.- let primary = teleport.primary- Button(primary.label) {- if let tile = teleport.selectedTile { Task { await teleport.activate(tile) } }- }- .keyboardShortcut(.defaultAction)- .disabled(!primary.enabled)- case .options:- Button("Back") { teleport.send(.back) }- Button("Review") { Task { await teleport.plan() } }- .keyboardShortcut(.defaultAction)- .disabled(!teleport.canPlan)- case .consent:- Button("Back") { teleport.send(.back) }- Button("Teleport") { Task { await teleport.confirm() } }- .keyboardShortcut(.defaultAction)- .disabled(teleport.review?.canConfirm != true)- case .error:- Button("Back") { teleport.send(.back) }- case .done:- Button("Done", action: onClose).keyboardShortcut(.defaultAction)- default:- EmptyView()- }- }- }-}--/// The picker's tiles: a section title per run, three columns of cards-/// (the live preview, the app's icon and one line of name), what the app can-/// take as the tooltip, a dimmed card for one that cannot move. Previews load-/// as tiles appear.-struct TeleportGrid: View {- @Bindable var teleport: TeleportModel- static let columns = 3- @FocusState private var focused: Bool-- var body: some View {- let grid = teleport.grid- ScrollView {- VStack(alignment: .leading, spacing: 12) {- ForEach(Array(grid.sections.enumerated()), id: \.offset) { _, section in- if !section.title.isEmpty {- Text(section.title).font(.subheadline.weight(.semibold)).foregroundStyle(.secondary)- }- LazyVGrid(columns: Array(repeating: GridItem(.flexible(), spacing: 12), count: Self.columns),- alignment: .leading, spacing: 12) {- ForEach(section.tiles, id: \.id) { tile in- TeleportTileView(tile: tile, thumbnail: teleport.thumbnail(for: tile),- icon: teleport.icon(for: tile))- .onTapGesture(count: 2) { Task { await teleport.activate(tile) } }- .onTapGesture { if !tile.disabled { teleport.select(tile.id) } }- .task(id: tile.id) { await teleport.loadThumbnail(tile) }- }- }- }- if let empty = grid.emptyText {- Text(empty).foregroundStyle(.secondary).frame(maxWidth: .infinity).padding(.top, 40)- }- }- .padding(.vertical, 4)- }- .focusable()- .focused($focused)- .focusEffectDisabled()- .onAppear { focused = true }- .onKeyPress(.rightArrow) { teleport.step(1); return .handled }- .onKeyPress(.leftArrow) { teleport.step(-1); return .handled }- .onKeyPress(.downArrow) { teleport.step(Int32(Self.columns)); return .handled }- .onKeyPress(.upArrow) { teleport.step(-Int32(Self.columns)); return .handled }- .task(id: grid.sections.flatMap(\.tiles).map(\.id)) { await teleport.loadIcons() }- }-}--/// One card of the grid.-struct TeleportTileView: View {- let tile: AppPickerTile- let thumbnail: NSImage?- let icon: NSImage?-- var body: some View {- VStack(alignment: .leading, spacing: 6) {- ZStack {- RoundedRectangle(cornerRadius: 8).fill(.quaternary)- if let thumbnail {- Image(nsImage: thumbnail).resizable().aspectRatio(contentMode: .fill)- } else if let icon {- // No window to preview: the app's icon, large.- Image(nsImage: icon).resizable().interpolation(.high).frame(width: 44, height: 44)- }- }- .frame(height: 104)- .clipShape(RoundedRectangle(cornerRadius: 8))- .overlay {- RoundedRectangle(cornerRadius: 8)- .strokeBorder(tile.selected ? Color.accentColor : Color.primary.opacity(0.08),- lineWidth: tile.selected ? 2.5 : 1)- }- HStack(spacing: 6) {- if let icon {- Image(nsImage: icon).resizable().interpolation(.high).frame(width: 16, height: 16)- }- Text(tile.title).lineLimit(1).truncationMode(.tail)- }- .font(.callout)- }- .opacity(tile.disabled ? 0.5 : 1)- .contentShape(Rectangle())- .help(tile.help)- .accessibilityElement(children: .combine)- .accessibilityLabel(tile.title)- .accessibilityHint(tile.help)- .accessibilityAddTraits(tile.selected ? [.isButton, .isSelected] : .isButton)- }-}--/// The run: the bar, and under it the step it is on in words, so the-/// Keychain prompts that come with reading a browser's cookies are expected.-struct TeleportRunning: View {- let progress: Double- let status: String?-- var body: some View {- VStack(alignment: .leading, spacing: 8) {- ProgressView(value: progress)- Text(status ?? " ")- .font(.callout)- .foregroundStyle(.secondary)- .lineLimit(2)- .fixedSize(horizontal: false, vertical: true)- .contentTransition(.opacity)- .animation(.easeInOut(duration: 0.15), value: status)- .accessibilityIdentifier("teleport-run-status")- }- .padding(20)- }-}diff --git a/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Views/TeleportReviewViews.swift b/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Views/TeleportReviewViews.swiftdeleted file mode 100644index 1202542b99..0000000000--- a/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Views/TeleportReviewViews.swift+++ /dev/null@@ -1,321 +0,0 @@-// SPDX-License-Identifier: FSL-1.1-MIT-// Copyright (c) 2026 Cua AI, Inc.--import CuaSpacesFFI-import SwiftUI--/// The consent review, as the vault list again: where it sends from (the-/// live app, or the app's saved Keyvault items), which sites of a browser-/// and which other items, with counts. What the review shows and what is-/// sent are the core's; the SDK's approval check enforces them.-struct TeleportReview: View {- @Bindable var teleport: TeleportModel- let review: AppReviewView-- var body: some View {- Form {- if review.offersVault { source }- switch review.source {- case .vault:- Section("Saved in the Keyvault") { SavedItemsChoice(teleport: teleport) }- case .live:- if review.offersDomains { Section { sites } header: { Text("Sites") } }- if !review.toggles.isEmpty { Section("Also sent") { items } }- }- if review.offersPasswords {- Section {- Toggle(review.passwordsLabel, isOn: Binding(- get: { review.includePasswords },- set: { teleport.send(.togglePasswords(value: $0)) }))- .toggleStyle(.checkbox)- .accessibilityIdentifier("review-passwords")- Text("Off by default. Passwords are re-encrypted for the browser in the Space and need " +- "that browser to have been opened once.")- .font(.caption).foregroundStyle(.secondary)- // The picker only where the Keyvault keeps the choice.- if review.includePasswords && !review.passwordSummary.isEmpty { passwords }- }- }- // What happens, when there is nothing to choose (the core's).- if !review.steps.isEmpty {- Section("What happens") {- ForEach(Array(review.steps.enumerated()), id: \.offset) { _, s in Text(s.summary) }- }- }- Section { summary }- if review.needsAcknowledgement {- Toggle("Send the secrets listed above", isOn: Binding(- get: { review.acknowledged },- set: { teleport.send(.acknowledge(value: $0)) }))- .toggleStyle(.checkbox)- }- if review.offersSaveToKeyvault && review.source == .live {- Toggle("Save to Keyvault for reuse", isOn: Binding(- get: { review.saveToKeyvault },- set: { teleport.send(.saveToKeyvault(value: $0)) }))- .toggleStyle(.checkbox)- .help("Keep these items sealed in your Cua Keyvault, grouped by app. Saving again " +- "updates them instead of adding copies.")- }- if review.needsRelayPlaintextAcknowledgement {- Section {- VStack(alignment: .leading, spacing: 4) {- Toggle("Send without end-to-end encryption", isOn: Binding(- get: { review.acknowledgedRelayPlaintext },- set: { teleport.send(.acknowledgeRelayPlaintext(value: $0)) }))- .toggleStyle(.checkbox)- Text("This Space predates end-to-end sealing. The relay could read these secrets in transit.")- .font(.caption)- .foregroundStyle(.secondary)- }- }- }- }- .formStyle(.grouped)- }-- /// Live app or saved items.- private var source: some View {- Section {- Picker("Send from", selection: Binding(get: { review.source }, set: { s in- Task { await teleport.sendFrom(s) }- })) {- Text(review.liveLabel).tag(AppSendSource.live)- Text(review.vaultLabel).tag(AppSendSource.vault)- }- .pickerStyle(.radioGroup)- .accessibilityIdentifier("review-source")- if !review.sourceNote.isEmpty {- Text(review.sourceNote).font(.caption).foregroundStyle(.secondary)- }- }- }-- /// The browser's sites, with counts.- @ViewBuilder private var sites: some View {- if review.needsDomains {- HStack(spacing: 8) {- ProgressView().controlSize(.small)- Text("Reading the sites\u{2026}").foregroundStyle(.secondary)- }- } else if review.domains.isEmpty && review.domainQuery.isEmpty {- Text("No sites to choose. The cookies listed under Also sent are sent as they are.")- .font(.callout).foregroundStyle(.secondary)- } else {- HStack(spacing: 8) {- Image(systemName: "magnifyingglass").foregroundStyle(.secondary)- TextField("Search sites", text: Binding(get: { review.domainQuery },- set: { teleport.send(.domainQuery(text: $0)) }))- .textFieldStyle(.plain)- Text(review.domainSummary).font(.caption).foregroundStyle(.secondary)- Button("All") { teleport.send(.selectShownDomains(value: true)) }.buttonStyle(.link)- Button("None") { teleport.send(.selectShownDomains(value: false)) }.buttonStyle(.link)- }- .accessibilityIdentifier("review-sites-search")- List {- ForEach(review.domains, id: \.domain) { d in- VStack(alignment: .leading, spacing: 2) {- HStack(spacing: 8) {- TriCheckbox(state: d.selected ? .on : .off, label: "Send \(d.domain)") {- teleport.send(.toggleDomain(domain: d.domain))- }- .disabled(!d.selectable)- Image(systemName: "globe").foregroundStyle(.secondary).frame(width: 18)- Text(d.domain).lineLimit(1)- Text(d.counts).font(.callout).foregroundStyle(.secondary).lineLimit(1)- Spacer(minLength: 8)- if d.identityProvider {- Text("Identity provider").font(.caption).foregroundStyle(.orange)- .help("Its session signs in to other apps. Send it only if you mean to.")- } else if d.signin {- Text("Signs you in").font(.caption).foregroundStyle(.secondary)- }- }- // What cannot be read, greyed, with why.- if d.unavailable > 0 {- Text(d.unavailableNote).font(.caption).foregroundStyle(.tertiary).lineLimit(2)- .padding(.leading, 52)- .accessibilityIdentifier("review-site-unavailable-\(d.domain)")- }- }- .opacity(d.selectable ? 1 : 0.55)- .contentShape(Rectangle())- .onTapGesture { if d.selectable { teleport.send(.toggleDomain(domain: d.domain)) } }- .accessibilityElement(children: .contain)- .accessibilityIdentifier("review-site-\(d.domain)")- }- }- .listStyle(.inset)- .frame(height: min(CGFloat(max(review.domains.count, 1)) * 26 + CGFloat(review.domains.filter { $0.unavailable > 0 }.count) * 14 + 8, 190))- .accessibilityIdentifier("review-sites")- }- }-- /// The saved passwords to pick, as the sites are: a site with how many- /// it holds (reading the app), or each saved password's site and- /// username (from the Keyvault). Never a value.- @ViewBuilder private var passwords: some View {- HStack(spacing: 8) {- Image(systemName: "magnifyingglass").foregroundStyle(.secondary)- TextField("Search saved passwords", text: Binding(get: { review.passwordQuery },- set: { teleport.send(.passwordQuery(text: $0)) }))- .textFieldStyle(.plain)- Text(review.passwordSummary).font(.caption).foregroundStyle(.secondary)- Button("All") { teleport.send(.selectShownPasswords(value: true)) }.buttonStyle(.link)- Button("None") { teleport.send(.selectShownPasswords(value: false)) }.buttonStyle(.link)- }- .accessibilityIdentifier("review-passwords-search")- if review.passwords.isEmpty {- Text("No saved passwords match.").font(.callout).foregroundStyle(.secondary)- } else {- List {- ForEach(review.passwords, id: \.key) { p in- HStack(spacing: 8) {- TriCheckbox(state: p.selected ? .on : .off,- label: "Send \([p.site, p.username].filter { !$0.isEmpty }.joined(separator: " "))") {- teleport.send(.togglePassword(key: p.key))- }- Image(systemName: "key").foregroundStyle(.secondary).frame(width: 18)- Text(p.site).lineLimit(1)- if !p.username.isEmpty {- Text(p.username).font(.callout).foregroundStyle(.secondary).lineLimit(1)- }- Spacer(minLength: 8)- if !p.counts.isEmpty {- Text(p.counts).font(.caption).foregroundStyle(.secondary)- }- }- .contentShape(Rectangle())- .onTapGesture { teleport.send(.togglePassword(key: p.key)) }- .accessibilityElement(children: .contain)- .accessibilityIdentifier("review-password-\(p.key)")- }- }- .listStyle(.inset)- .frame(height: min(CGFloat(max(review.passwords.count, 1)) * 26 + 8, 190))- .accessibilityIdentifier("review-passwords-list")- }- }-- /// The other lines the user can turn off.- private var items: some View {- ForEach(review.toggles, id: \.key) { t in- HStack(alignment: .firstTextBaseline, spacing: 8) {- TriCheckbox(state: t.selected ? .on : .off, label: "Send \(t.label)") {- teleport.send(.toggleItem(key: t.key))- }- VStack(alignment: .leading, spacing: 1) {- Text(t.label)- if !t.detail.isEmpty { Text(t.detail).font(.caption).foregroundStyle(.secondary) }- }- Spacer()- if t.sensitive { Text("Secret").font(.caption).foregroundStyle(.secondary) }- else if t.bytes > 0 { Text(ByteCountFormatter.string(fromByteCount: Int64(t.bytes), countStyle: .file)).font(.caption).foregroundStyle(.secondary) }- }- .contentShape(Rectangle())- .onTapGesture { teleport.send(.toggleItem(key: t.key)) }- }- }-- private var summary: some View {- VStack(alignment: .leading, spacing: 4) {- ForEach(review.items.filter { $0.kind == .install }, id: \.key) { i in- LabeledContent(i.label) { Text(i.detail).foregroundStyle(.secondary) }- }- ForEach(review.warnings, id: \.self) { Text($0).font(.caption).foregroundStyle(.secondary) }- }- }-}--/// The app's saved Keyvault items, to choose from: grouped by site with-/// checkboxes, search and the names behind Touch ID.-struct SavedItemsChoice: View {- @Bindable var teleport: TeleportModel-- var body: some View {- if let view = teleport.reviewVaultView {- if view.namesHidden {- HStack(spacing: 10) {- Image(systemName: "eye.slash").foregroundStyle(.secondary)- Text(view.hiddenNote ?? "").foregroundStyle(.secondary)- Spacer()- Button(view.showNamesLabel) { Task { await teleport.keyvault?.showItems() } }- }- } else {- HStack(spacing: 8) {- Image(systemName: "magnifyingglass").foregroundStyle(.secondary)- TextField("Search saved items", text: Binding(get: { teleport.reviewVault.query },- set: { teleport.sendVault(.query(text: $0)) }))- .textFieldStyle(.plain)- .lineLimit(1)- Text("\(view.selection.count) of \(view.shown) selected")- .font(.caption).foregroundStyle(.secondary)- Button("All") { teleport.sendVault(.selectAll) }.buttonStyle(.link)- Button("None") { teleport.sendVault(.clear) }.buttonStyle(.link)- }- List {- ForEach(VaultLine.lines(view).filter { line in- if case .app = line { return false }; return true- }, id: \.id) { line in- SavedLine(line: line, teleport: teleport)- }- }- .listStyle(.inset)- .frame(height: 190)- .accessibilityIdentifier("review-vault-list")- }- }- }-}--/// A site or an item of the saved list: a checkbox, no lock.-struct SavedLine: View {- let line: VaultLine- let teleport: TeleportModel-- var body: some View {- switch line {- case .site(_, let site):- row(selected: site.selected, key: site.key, icon: "globe", title: site.site, detail: site.counts,- open: site.open)- case .files(_, let files):- row(selected: files.selected, key: files.key, icon: "folder", title: "Files",- detail: "\(files.count) file\(files.count == 1 ? "" : "s")", open: files.open)- case .item(let item, _):- HStack(spacing: 8) {- TriCheckbox(state: item.selected ? .on : .off, label: "Send \(item.title)") {- teleport.sendVault(.toggle(id: item.id))- }- Image(systemName: item.symbol).foregroundStyle(.secondary).frame(width: 18)- VStack(alignment: .leading, spacing: 0) {- Text(item.title).lineLimit(1).truncationMode(.middle)- if !item.subtitle.isEmpty { Text(item.subtitle).font(.caption).foregroundStyle(.secondary).lineLimit(1) }- }- Spacer()- Text(item.updated).font(.caption).foregroundStyle(.secondary)- }- .padding(.leading, 40)- .contentShape(Rectangle())- .onTapGesture { teleport.sendVault(.toggle(id: item.id)) }- case .app:- EmptyView()- }- }-- private func row(selected: KvTri, key: String, icon: String, title: String, detail: String, open: Bool) -> some View {- HStack(spacing: 8) {- TriCheckbox(state: selected, label: "Send \(title)") { teleport.sendVault(.toggleGroup(key: key)) }- Button { teleport.sendVault(.toggleOpen(key: key)) } label: {- Image(systemName: open ? "chevron.down" : "chevron.right").font(.caption.weight(.semibold))- .foregroundStyle(.secondary).frame(width: 12)- }- .buttonStyle(.plain)- Image(systemName: icon).foregroundStyle(.secondary).frame(width: 18)- Text(title).lineLimit(1)- Text(detail).font(.callout).foregroundStyle(.secondary).lineLimit(1)- Spacer()- }- .contentShape(Rectangle())- .onTapGesture { teleport.sendVault(.toggleOpen(key: key)) }- }-}diff --git a/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Views/ThisMachineView.swift b/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Views/ThisMachineView.swiftdeleted file mode 100644index da5ecc6d4b..0000000000--- a/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Views/ThisMachineView.swift+++ /dev/null@@ -1,511 +0,0 @@-// SPDX-License-Identifier: FSL-1.1-MIT-// Copyright (c) 2026 Cua AI, Inc.--import AppKit-import CuaSDK-import CuaSpacesFFI-import SwiftUI--/// "This machine": how it is shared, who is connected, the permissions-/// left to grant and its buttons; or the host setup form. Everything shown-/// is the core's `appHostPanel` / `appHostFormView`.-struct ThisMachineView: View {- @Bindable var host: HostModel- /// A button waiting for the user's confirmation (the core's `confirm`).- @State private var confirming: AppHostAction?- /// The log open in full ("Show All…").- @State private var fullLog: HostLog?-- var body: some View {- let panel = host.panel- Group {- if host.form != nil {- HostFormView(host: host)- } else {- Form {- if let intro = panel.intro {- // Before setup: what this machine is and why set it- // up, then the form's choices inline.- Section {- Text(intro)- .foregroundStyle(.secondary)- .fixedSize(horizontal: false, vertical: true)- .accessibilityIdentifier("host-summary")- }- Section {- ForEach(panel.setupChoices, id: \.id) { choice in- LabeledContent(choice.label) {- Button(choice.buttonLabel) {- host.openForm()- host.send(.setProfile(profile: choice.id))- }- .disabled(host.busy)- }- .accessibilityIdentifier("host-choice-\(choice.id)")- }- }- } else if let notice = panel.notice {- // Relay sharing paused (signed out, or another- // account): one line in place of the summary, and- // its button.- Section {- HStack(alignment: .firstTextBaseline, spacing: 12) {- Text(notice)- .fixedSize(horizontal: false, vertical: true)- .accessibilityIdentifier("host-notice")- Spacer(minLength: 8)- if let action = panel.noticeAction {- Button(action.label) { Task { await host.run(action.id) } }- .buttonStyle(.borderedProminent)- .disabled(host.busy || !action.enabled)- .accessibilityIdentifier("host-notice-action")- }- }- if let progress = host.progress {- HostSetupProgressView(text: progress)- }- }- } else {- Section {- Text(panel.summary)- .lineLimit(1)- .accessibilityIdentifier("host-summary")- }- }- if !panel.facts.isEmpty {- Section {- ForEach(panel.facts, id: \.label) { fact in- LabeledContent(fact.label) {- Text(fact.value).lineLimit(1).truncationMode(.middle).textSelection(.enabled)- }- }- }- }- if !panel.toggles.isEmpty {- Section {- ForEach(panel.toggles, id: \.id) { toggle in- Toggle(isOn: Binding(- get: { toggle.on },- set: { _ in Task { await host.run(toggle.action) } })) {- Text(toggle.label)- Text(toggle.help).foregroundStyle(.secondary)- }- .disabled(host.busy || !toggle.enabled)- .accessibilityIdentifier("host-toggle-\(toggle.id)")- }- if let limits = panel.limits {- Text(limits).foregroundStyle(.secondary).lineLimit(2)- .accessibilityIdentifier("host-limits")- }- }- }- if let title = panel.providedTitle {- Section(title) {- if let empty = panel.providedEmpty {- Text(empty).foregroundStyle(.secondary)- }- TimedRows(rows: panel.provided)- }- .accessibilityIdentifier("host-provided")- }- if let warning = panel.accessWarning {- Text(warning).foregroundStyle(.red).lineLimit(2)- .accessibilityIdentifier("host-access-warning")- }- if let title = panel.clientsTitle {- Section(title) {- if let empty = panel.clientsEmpty {- Text(empty).foregroundStyle(.secondary)- }- ForEach(panel.clients, id: \.self) { Text($0).lineLimit(1) }- }- }- if let title = panel.recentTitle, !panel.recent.isEmpty {- Section(title) {- // The newest few (repeats collapsed); the rest- // in a sheet, so the page never grows with it.- TimedRows(rows: panel.recent)- if let more = panel.recentMore {- ShowAllButton(label: more) { fullLog = .access }- .accessibilityIdentifier("host-recent-access-more")- }- }- .accessibilityIdentifier("host-recent-access")- }- if let warning = panel.activityWarning {- Text(warning).foregroundStyle(.red).lineLimit(2)- .accessibilityIdentifier("host-activity-warning")- }- if let title = panel.activityTitle, !panel.activity.isEmpty {- Section(title) {- TimedRows(rows: panel.activity)- if let more = panel.activityMore {- ShowAllButton(label: more) { fullLog = .activity }- .accessibilityIdentifier("host-activity-more")- }- }- .accessibilityIdentifier("host-activity")- }- if let title = panel.permissionsTitle {- Section(title) {- PermissionRows(rows: panel.permissions, openLabel: panel.openSettingsLabel)- }- }- if let failure = host.actionFailure {- // A button that failed: what happened in plain- // words, Retry, and the raw error under Details.- HostSetupFailureView(failure: failure, retrying: host.busy) {- Task { await host.retryFailedAction() }- }- } else if let error = host.error {- Text(error).foregroundStyle(.red).lineLimit(1).help(error)- }- }- .formStyle(.grouped)- .safeAreaInset(edge: .bottom, spacing: 0) {- // Pinned under the page: Stop sharing and Remove stay- // in view however long the logs get.- if panel.setupChoices.isEmpty, !panel.actions.isEmpty {- actionBar(panel.actions)- }- }- }- }- .sheet(item: $fullLog) { log in- switch log {- case .access:- HostLogSheet(title: panel.recentTitle ?? "", rows: panel.recentAll,- backgroundRows: panel.recentWithBackground) { fullLog = nil }- case .activity:- HostLogSheet(title: panel.activityTitle ?? "", rows: panel.activityAll,- backgroundRows: nil) { fullLog = nil }- }- }- .navigationTitle(host.form == nil ? panel.title : (host.formView?.title ?? panel.title))- .task {- // Followed while it shows: who is connected now, and a- // permission granted in System Settings (no restart needed).- while !Task.isCancelled {- if host.form == nil { await host.refresh() }- try? await Task.sleep(for: .seconds(5))- }- }- .alert(confirming?.confirm?.title ?? "", isPresented: Binding(- get: { confirming?.confirm != nil },- set: { if !$0 { confirming = nil } })) {- if let action = confirming, let confirm = action.confirm {- Button(confirm.confirmLabel, role: .destructive) {- confirming = nil- Task { await host.run(action.id) }- }- Button(confirm.cancelLabel, role: .cancel) { confirming = nil }- }- } message: {- Text(confirming?.confirm?.message ?? "")- }- }-- /// The page's buttons, primary first, in a bar pinned to the bottom.- private func actionBar(_ actions: [AppHostAction]) -> some View {- VStack(spacing: 0) {- Divider()- HStack {- ForEach(Array(actions.enumerated()), id: \.offset) { index, action in- let button = Button(action.label, role: action.destructive ? .destructive : nil) {- if action.confirm != nil {- confirming = action- } else {- Task { await host.run(action.id) }- }- }- .disabled(host.busy || !action.enabled)- .help(action.help ?? "")- .accessibilityIdentifier("host-action-\(index)")- if index == 0 {- button.buttonStyle(.borderedProminent).tint(action.destructive ? .red : .accentColor)- } else {- button- }- }- Spacer()- }- .padding(.horizontal, 20)- .padding(.vertical, 12)- }- .background(.bar)- .accessibilityIdentifier("host-actions")- }-}--/// A "This machine" log shown in full.-enum HostLog: String, Identifiable {- case access, activity- var id: String { rawValue }-}--/// "Show All…" under a log section.-struct ShowAllButton: View {- let label: String- let action: () -> Void-- var body: some View {- HStack {- Spacer()- Button(label, action: action)- .buttonStyle(.link)- .controlSize(.small)- }- }-}--/// A log in full: every row (repeats collapsed), newest first, and for the-/// access log a switch that adds the background probes.-struct HostLogSheet: View {- let title: String- let rows: [AppHostAccessRow]- /// Every row with background activity too (`nil`: no switch).- let backgroundRows: [AppHostAccessRow]?- let done: () -> Void- @State private var withBackground = false-- var body: some View {- VStack(spacing: 0) {- HStack {- Text(title).font(.headline)- Spacer()- }- .padding(.horizontal, 16)- .padding(.vertical, 12)- Divider()- List {- TimedRows(rows: withBackground ? (backgroundRows ?? rows) : rows)- }- .listStyle(.inset(alternatesRowBackgrounds: true))- .accessibilityIdentifier("host-log-rows")- Divider()- HStack {- if backgroundRows != nil {- Toggle("Include background activity", isOn: $withBackground)- .toggleStyle(.checkbox)- .accessibilityIdentifier("host-log-background")- }- Spacer()- Button("Done", action: done)- .keyboardShortcut(.defaultAction)- .accessibilityIdentifier("host-log-done")- }- .padding(12)- }- .frame(minWidth: 520, idealWidth: 560, minHeight: 360, idealHeight: 460)- .navigationTitle(title)- .accessibilityIdentifier("host-log-sheet")- }-}--/// Rows with a relative time after them (provided Spaces, activity).-struct TimedRows: View {- let rows: [AppHostAccessRow]-- var body: some View {- ForEach(Array(rows.enumerated()), id: \.offset) { _, row in- LabeledContent {- Text(Date(timeIntervalSince1970: Double(row.atMs) / 1000),- format: .relative(presentation: .named))- .foregroundStyle(.secondary)- } label: {- Text(row.text).lineLimit(1).truncationMode(.middle).help(row.text)- }- }- }-}--/// Permission panes to grant: the title, "Open Settings", the-/// instructions as the tooltip. Only System Settings privacy panes open.-struct PermissionRows: View {- let rows: [AppPermissionRow]- let openLabel: String-- var body: some View {- ForEach(rows, id: \.id) { row in- LabeledContent(row.title) {- if let url = row.settingsUrl {- Button(openLabel) { Self.open(url) }- }- }- .help(row.help)- }- }-- static func open(_ url: String) {- guard url.hasPrefix("x-apple.systempreferences:"), let u = URL(string: url) else { return }- NSWorkspace.shared.open(u)- }-}--/// The host setup form (relay by default; a direct `ip:port` under-/// Advanced): the core's fields in order.-struct HostFormView: View {- @Bindable var host: HostModel-- var body: some View {- if let v = host.formView {- Form {- Section {- // Wraps: the lede says what the chosen option does.- Text(v.lede).foregroundStyle(.secondary).fixedSize(horizontal: false, vertical: true)- ForEach(v.fields.filter { !$0.advanced }, id: \.id) { field($0) }- // Self-hosting (Direct, your own relay) opens only from- // Settings → Advanced: no toggle here.- ForEach(v.fields.filter(\.advanced), id: \.id) { field($0) }- if let failure = host.setupFailure {- HostSetupFailureView(failure: failure, retrying: v.busy) {- Task { await host.submit() }- }- }- if let progress = host.progress {- HostSetupProgressView(text: progress)- }- }- Section {- HStack {- Spacer()- Button(v.backLabel) { host.closeForm() }- Button(v.submitLabel) { Task { await host.submit() } }- .buttonStyle(.borderedProminent)- .keyboardShortcut(.defaultAction)- .disabled(!v.canSubmit)- .accessibilityIdentifier("host-setup")- }- }- }- .formStyle(.grouped)- }- }-- @ViewBuilder private func field(_ f: AppHostFormField) -> some View {- if !f.choices.isEmpty {- Picker(f.label, selection: Binding(get: { f.value }, set: { host.send(.setProfile(profile: $0)) })) {- ForEach(f.choices, id: \.id) { Text($0.label).tag($0.id) }- }- .pickerStyle(.radioGroup)- .accessibilityIdentifier("host-\(f.id)")- } else if f.toggle {- Toggle(f.label, isOn: Binding(get: { f.on }, set: { host.send(.setDirect(on: $0)) }))- .accessibilityIdentifier("host-\(f.id)")- } else {- TextField(f.label, text: Binding(get: { f.value }, set: { host.send(Self.action(f.id, $0)) }),- prompt: f.placeholder.map { Text($0) })- .foregroundStyle(f.invalid ? Color.red : Color.primary)- .accessibilityIdentifier("host-\(f.id)")- }- }-- static func action(_ id: String, _ text: String) -> AppHostFormAction {- switch id {- case "allow": return .setAllow(allow: text)- case "listen": return .setListen(listen: text)- case "relay": return .setRelayUrl(url: text)- default: return .setName(name: text)- }- }-}--/// A failed "Set up for access": a small warning symbol and a short title,-/// one secondary line saying what to do, Retry, and the raw error under a-/// collapsed Details (selectable, with Copy).-/// What a running "Set up for access" waits for (the inline sign-in).-struct HostSetupProgressView: View {- let text: String-- var body: some View {- HStack(alignment: .firstTextBaseline, spacing: 6) {- ProgressView().controlSize(.small)- Text(text)- .font(.callout)- .foregroundStyle(.secondary)- .fixedSize(horizontal: false, vertical: true)- }- .accessibilityIdentifier("host-setup-progress")- }-}--struct HostSetupFailureView: View {- let failure: HostSetupFailure- /// The retry is running: Retry shows progress and is disabled.- let retrying: Bool- let retry: () -> Void- @State private var showDetails = false- /// Seconds left before a throttled setup tries again by itself.- @State private var remaining: Int?- /// One automatic retry per setup: a second throttle waits for the user.- @State private var autoRetried = false-- var body: some View {- VStack(alignment: .leading, spacing: 6) {- HStack(alignment: .firstTextBaseline, spacing: 6) {- Image(systemName: "exclamationmark.triangle.fill")- .symbolRenderingMode(.multicolor)- .imageScale(.small)- .accessibilityHidden(true)- Text(failure.title).fontWeight(.medium)- Spacer(minLength: 8)- Button(action: retry) {- HStack(spacing: 6) {- if retrying { ProgressView().controlSize(.small) }- Text(retrying ? HostSetupFailure.retryingLabel : failure.actionLabel)- }- }- .controlSize(.small)- .disabled(retrying)- .accessibilityIdentifier("host-setup-retry")- }- Text(remaining.map { "Trying again in \($0) \($0 == 1 ? "second" : "seconds")." } ?? (autoRetried ? HostSetupFailure.manualWait(failure) : failure.message))- .font(.callout)- .foregroundStyle(.secondary)- .fixedSize(horizontal: false, vertical: true)- .accessibilityIdentifier("host-setup-failure-message")- DisclosureGroup(HostSetupFailure.detailsLabel, isExpanded: $showDetails) {- HStack(alignment: .top, spacing: 8) {- // A long error scrolls instead of pushing the page.- ScrollView {- Text(failure.details)- .font(.system(.caption, design: .monospaced))- .foregroundStyle(.secondary)- .textSelection(.enabled)- .fixedSize(horizontal: false, vertical: true)- .frame(maxWidth: .infinity, alignment: .leading)- }- .frame(maxHeight: 80)- Button(HostSetupFailure.copyLabel) {- NSPasteboard.general.clearContents()- NSPasteboard.general.setString(failure.details, forType: .string)- }- .buttonStyle(.borderless)- .controlSize(.small)- .accessibilityIdentifier("host-setup-copy-details")- }- .padding(.top, 2)- }- .font(.callout)- .foregroundStyle(.secondary)- .accessibilityIdentifier("host-setup-details")- }- .accessibilityElement(children: .contain)- .accessibilityIdentifier("host-setup-failure")- .task(id: failure) {- // A throttled setup counts down, then tries again once.- guard !autoRetried, var left = failure.throttleSeconds else { remaining = nil; return }- while left > 0 {- remaining = left- try? await Task.sleep(for: .seconds(1))- if Task.isCancelled { return }- left -= 1- }- remaining = nil- if !retrying {- autoRetried = true- retry()- }- }- }-}diff --git a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/AgentsPagesTests.swift b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/AgentsPagesTests.swiftindex 7b8e48d601..b0564348a1 100644--- a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/AgentsPagesTests.swift+++ b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/AgentsPagesTests.swift@@ -119,18 +119,4 @@ struct AgentsPagesTests {#expect(tools.calls.suffix(2) == ["routine_add", "routine_remove"])}- @Test func snapshots() async throws {- let tools = FakeAgentsTools()- let m = PersistentModel(tools: tools)- m.now = { Date(timeIntervalSince1970: TimeInterval(tools.now) / 1000) }- m.thisMachine = "relay:0123"- await m.loadAgents()- await m.send(.select(name: "ada"))- let size = CGSize(width: 720, height: 520)- try SnapshotTests().assertSnapshot(AgentsPageView(model: m), "agents-page", size: size)- await m.sendDrive(nil)- try SnapshotTests().assertSnapshot(DrivePageView(model: m), "drive-page", size: size)- await m.pollNotifications()- try SnapshotTests().assertSnapshot(NotificationsPageView(model: m), "notifications-page", size: size)- }}diff --git a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/DetailApprovalTests.swift b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/DetailApprovalTests.swiftdeleted file mode 100644index 9cf2c3c397..0000000000--- a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/DetailApprovalTests.swift+++ /dev/null@@ -1,148 +0,0 @@-// SPDX-License-Identifier: FSL-1.1-MIT-// Copyright (c) 2026 Cua AI, Inc.--import CuaSDK-import CuaSpacesFFI-import CuaSpacesStreaming-@testable import CuaSpacesMacKit-import Foundation-import AppKit-import Testing-import SwiftUI--/// Scripted provider completions; no service, account, or desktop is contacted.-private final class ApprovalBackend: SpacesBackend, @unchecked Sendable {- var result: Result<[AppSpaceRow], Error> = .success(FixtureSpacesBackend.sample)- var failFirst = false- var holdFirst = false- private var held: CheckedContinuation<Void, Never>?- func release() { lock.withLock { held?.resume(); held = nil } }- private let lock = NSLock()- private var ids: [String] = []- var requestedIds: [String] { lock.withLock { ids } }- var isHeld: Bool { lock.withLock { held != nil } }- func rows() async throws -> [AppSpaceRow] { try result.get() }- func create(_ args: AppCreateSpaceArgs, createId: String, progress: @escaping @Sendable (SpaceCreateProgress) -> Void) async throws -> String { fatalError("unexpected create") }- func cancelCreate(createId: String) async throws {}- func add(url: String, token: String?, name: String?) async throws {}- func remove(id: String, removeOnly: Bool) async throws {}- func setPower(id: String, on: Bool) async throws {}- func streamProvider(id: String) async throws -> SpaceStreamSourceProviding {- let attempt = lock.withLock { ids.append(id); return ids.count }- if holdFirst && attempt == 1 {- await withCheckedContinuation { continuation in lock.withLock { held = continuation } }- }- if failFirst && attempt == 1 { throw CuaError.Internal(message: "cancelled provider result") }- return try await FixtureSpacesBackend().streamProvider(id: id)- }- func localBackends() async -> [String]? { nil }- func localStorage() async -> LocalStorage? { nil }- func teleportContext(id: String) async throws -> (CuaSpacesFFI.Teleport, CuaSDK.Space)? { nil }- func teleportHandle() -> CuaSpacesFFI.Teleport? { nil }- func sendFiles(id: String, paths: [String]) async throws -> [AppSentFileInfo] { [] }- func agentRuns(id: String) async throws -> [AppSpaceAgentRun] { [] }-}--@MainActor-@Suite("Detail approval refresh", .serialized)-struct DetailApprovalTests {- @MainActor private struct Fixture {- let backend: ApprovalBackend- let devices: FixtureDevices- let model: AppModel- let space: AppSpace- let window: NSWindow- let directory: URL-- func close() {- backend.release()- window.contentView = nil- window.close()- try? FileManager.default.removeItem(at: directory)- }-- func setApproved(_ approved: Bool) async {- devices.current.devices[0].state = approved ? "enrolled" : "pending"- await model.devices.refresh()- window.contentView?.layoutSubtreeIfNeeded()- }-- func waitForRequests(_ count: Int) async throws {- for _ in 0..<40 where backend.requestedIds.count < count {- try await Task.sleep(for: .milliseconds(50))- }- if count == 1 && backend.holdFirst {- for _ in 0..<40 where !backend.isHeld { try await Task.sleep(for: .milliseconds(50)) }- #expect(backend.isHeld)- }- #expect(backend.requestedIds == Array(repeating: space.id, count: count))- }- }-- private func open(autoConnect: Bool, holdFirst: Bool = false, failFirst: Bool = false) async throws -> Fixture {- let backend = ApprovalBackend()- backend.holdFirst = holdFirst- backend.failFirst = failFirst- var row = FixtureSpacesBackend.sample[0]- row.id = "relay:studio"- row.provider = "relay"- backend.result = .success([row])- var snapshot = FixtureDevices.sample(now: UInt64(Date().timeIntervalSince1970))- snapshot.devices[0].state = "pending"- let devices = FixtureDevices(snapshot: snapshot)- let directory = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString)- let model = AppModel(backend: backend, keyvault: KeyvaultModel(client: nil),- onboarding: OnboardingModel(statePath: nil),- settingsPath: directory.appendingPathComponent("settings.json").path,- telemetry: FixtureTelemetry(), devices: devices, presence: FixturePresence())- model.settings.autoConnect = autoConnect- await model.refresh()- model.devices.signedIn = true- await model.devices.refresh()- let space = try #require(model.spaces.first { $0.id == row.id })- #expect(model.detail(space).access != nil)- let host = NSHostingView(rootView: SpaceDetailView(model: model, space: space)- .frame(width: 800, height: 800))- let window = NSWindow(contentRect: NSRect(x: 0, y: 0, width: 800, height: 800),- styleMask: [.borderless], backing: .buffered, defer: false)- window.isReleasedWhenClosed = false- window.contentView = host- host.layoutSubtreeIfNeeded()- try await Task.sleep(for: .milliseconds(250))- #expect(backend.requestedIds.isEmpty)- return Fixture(backend: backend, devices: devices, model: model, space: space,- window: window, directory: directory)- }-- @Test(arguments: [false, true])- func approvalReevaluatesTheSameDetail(autoConnect: Bool) async throws {- let f = try await open(autoConnect: autoConnect)- defer { f.close() }- await f.setApproved(true)- #expect(f.model.detail(f.space).access == nil)- if autoConnect { try await f.waitForRequests(1) }- // Repeated device snapshots neither force a manual connection nor- // restart a connection that was already created for this exact ID.- await f.setApproved(true)- await f.setApproved(true)- try await Task.sleep(for: .milliseconds(250))- #expect(f.backend.requestedIds == (autoConnect ? [f.space.id] : []))- }-- @Test(arguments: [false, true])- func cancelledProviderCannotBlockLaterApproval(failFirst: Bool) async throws {- let f = try await open(autoConnect: true, holdFirst: true, failFirst: failFirst)- defer { f.close() }- await f.setApproved(true)- try await f.waitForRequests(1)- await f.setApproved(false)- try await Task.sleep(for: .milliseconds(100))- // The backend deliberately returns even though its caller was- // cancelled. Its old provider must not be installed in this view.- f.backend.release()- try await Task.sleep(for: .milliseconds(100))- #expect(f.model.banner == nil)- await f.setApproved(true)- try await f.waitForRequests(2)- }-}diff --git a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/DiscoveryTests.swift b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/DiscoveryTests.swiftindex 21e2534287..a493295e5b 100644--- a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/DiscoveryTests.swift+++ b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/DiscoveryTests.swift@@ -65,53 +65,4 @@ struct DiscoveryTests {#expect(model.rosterError == nil)}- @Test func warmFailureSidebarRetainsRows() async throws {- let snapshots = SnapshotTests()- let backend = DiscoveryBackend()- backend.result = .success(FixtureSpacesBackend.sample)- let model = ViewModelTests().makeModel(backend)- await model.refresh()- backend.result = .failure(CuaError.Internal(message: "fixture failure"))- await model.refresh()- try snapshots.assertSnapshot(Sidebar(model: model).frame(width: 260),- "discovery-warm-sidebar", size: CGSize(width: 260, height: 520))- }- @Test func coldFailureTitleAndWindowNotice() async throws {- let snapshots = SnapshotTests()- let backend = DiscoveryBackend()- backend.result = .failure(CuaError.Internal(message: "fixture"))- let model = ViewModelTests().makeModel(backend)- await model.refresh()- let error = try #require(model.rosterError)- let content = VStack(spacing: 0) {- SpacesDiscoveryNotice(error: error)- EmptySpaces(model: model)- }.frame(width: 560, height: 300).background(Color.white)- let size = CGSize(width: 560, height: 300)- // Native ContentUnavailableView lays out lazily on this offscreen- // surface; settle it before measuring and exporting the same bitmap.- _ = snapshots.render(content, size: size)- _ = snapshots.render(content, size: size)- // Read the actual rendered pixels. A whole-window pixel tolerance- // alone can miss a removed label that occupies only a small area.- let bitmap = snapshots.render(content, size: size)- let request = VNRecognizeTextRequest()- request.recognitionLanguages = ["en-US"]- request.recognitionLevel = .accurate- request.usesLanguageCorrection = false- let image = try #require(bitmap.cgImage)- try VNImageRequestHandler(cgImage: image, options: [:]).perform([request])- let text = (request.results ?? []).compactMap { $0.topCandidates(1).first?.string }.joined(separator: " ")- #expect(text.contains("Could not load Spaces. Try refreshing again."))- #expect(text.contains("Spaces could not be loaded"))- #expect(text.contains("New Space"))- #expect(!text.contains("About 1 minute"))- // Export the exact bitmap OCR checked, not a separate render.- if let directory = ProcessInfo.processInfo.environment["SNAPSHOT_EXPORT_DIR"] {- let url = URL(fileURLWithPath: directory).appendingPathComponent("discovery-cold-content.png")- let png = try #require(bitmap.representation(using: .png, properties: [:]))- try png.write(to: url)- }- }-}diff --git a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/DriveTests.swift b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/DriveTests.swiftindex a1276b4398..a1b61f32fd 100644--- a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/DriveTests.swift+++ b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/DriveTests.swift@@ -223,17 +223,4 @@ struct DriveTests {#expect(v.mountPath == "/Volumes/Cua Volume")}- @Test func snapshots() async throws {- let snap = SnapshotTests()- let tools = FakeDriveTools()- tools.mount = "mounted"- tools.enabled = true- tools.backend = "s3"- tools.hasKeys = true- // The Drive page, mounted and syncing with a conflict.- let p = PersistentModel(tools: tools)- p.now = { Date(timeIntervalSince1970: 1_790_000_000) }- await p.sendDrive(nil)- try snap.assertSnapshot(DrivePageView(model: p), "drive-page-sync", size: CGSize(width: 720, height: 620))- }}diff --git a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/ElasticTests.swift b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/ElasticTests.swiftindex c4bdd575ee..00f94bd0ed 100644--- a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/ElasticTests.swift+++ b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/ElasticTests.swift@@ -149,21 +149,4 @@ struct ElasticTests {#expect(!plain.elastic.visible)}- /// The Machines page with the pool, rendered offscreen for review (only- /// with `ELASTIC_PREVIEW_DIR` set; nothing is launched or shown).- @Test func rendersTheMachinesPageForReview() async throws {- guard let dir = ProcessInfo.processInfo.environment["ELASTIC_PREVIEW_DIR"], !dir.isEmpty else { return }- _ = NSApplication.shared- let backend = FixtureSpacesBackend()- backend.fixtureElastic = true- let app = ViewModelTests().makeModel(backend)- app.onboarding.finish()- await app.refresh()- await app.elastic.refresh(force: true)- let size = CGSize(width: 900, height: 560)- let rep = SnapshotTests().render(MachinesPageView(model: app), size: size)- let out = URL(fileURLWithPath: dir)- try FileManager.default.createDirectory(at: out, withIntermediateDirectories: true)- try rep.representation(using: .png, properties: [:])!.write(to: out.appendingPathComponent("machines-elastic.png"))- }}diff --git a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/KeyvaultReviewTests.swift b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/KeyvaultReviewTests.swiftindex 0255e466af..2dab0332ec 100644--- a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/KeyvaultReviewTests.swift+++ b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/KeyvaultReviewTests.swift@@ -10,24 +10,17 @@ import Testing/// The teleport review as the vault list again: a browser's sites with/// counts and a minimal default, what was picked last time, the Keyvault as-/// the source, and the choices reaching the SDK consent. With-/// `KEYVAULT_EXPORT_DIR` set, the screenshots and GIFs of the redesign are-/// exported too (see KeyvaultSnapshotTests).+/// the source, and the choices reaching the SDK consent.@MainActor@Suite("Keyvault review", .serialized)struct KeyvaultReviewTests {- let snap = SnapshotTests()static let list = CGSize(width: 780, height: 560)- func model(_ overview: KeyvaultOverview = KeyvaultFixtures.overview(),- icons: Bool = false) async -> (AppModel, FakeKeyvault) {- await KeyvaultSnapshotTests().model(overview, icons: icons)- }-- var useRealIcons: Bool { ProcessInfo.processInfo.environment["KEYVAULT_REAL_ICONS"] == "1" }-- func vault(_ m: AppModel) -> some View {- VaultList(keyvault: m.keyvault, page: m.keyvault.page)+ func model(_ overview: KeyvaultOverview = KeyvaultFixtures.overview()) async -> (AppModel, FakeKeyvault) {+ let fake = FakeKeyvault(overview)+ let m = ViewModelTests().makeModel(kv: fake)+ await m.keyvault.refresh()+ return (m, fake)}static let chromePlan = """@@ -47,7 +40,7 @@ struct KeyvaultReviewTests {/// `features`: what the fake Keyvault daemon says it supports (none:/// one that predates the list).func reviewModel(vault: Bool = false, features: [String] = []) async throws -> (TeleportModel, FakeKeyvault) {- let (m, fake) = await model(icons: useRealIcons)+ let (m, fake) = await model()fake.current.status?.features = featureslet t = TeleportModel(spaceName: "aurora", teleport: nil, space: nil)t.keyvault = m.keyvault@@ -81,8 +74,6 @@ struct KeyvaultReviewTests {#expect(review.source == .live)let consent = appPickerConsent(state: t.state)#expect(consent.cookieDomains == review.selectedDomains && consent.fromVault == nil)- try snap.assertSnapshot(TeleportReview(teleport: t, review: review), "keyvault-review-sites",- size: CGSize(width: 640, height: 760))}@Test func cookiesTheBrowserCannotReleaseAreGreyedWithWhyAndNeverSent() async throws {@@ -159,8 +150,6 @@ struct KeyvaultReviewTests {t.sendVault(.toggleGroup(key: "chrome|github.com"))#expect(appPickerConsent(state: t.state).fromVault?.count == 11, "github.com has 5 items a teleport can send")t.sendVault(.toggleGroup(key: "chrome|github.com"))- try snap.assertSnapshot(TeleportReview(teleport: t, review: try #require(t.review)),- "keyvault-review-vault", size: CGSize(width: 640, height: 760))}@Test func aFailedSiteReadFallsBackToThePlanAsListed() async throws {@@ -208,103 +197,4 @@ struct KeyvaultReviewTests {// MARK: - Exported screenshots and GIFs (KEYVAULT_EXPORT_DIR)- @Test func exportScreenshotsAndGifs() async throws {- guard let dir = ProcessInfo.processInfo.environment["KEYVAULT_EXPORT_DIR"], !dir.isEmpty else { return }- let out = URL(fileURLWithPath: dir)- try FileManager.default.createDirectory(at: out, withIntermediateDirectories: true)- let size = Self.list- let recorder = Recorder(snap: snap, size: size, dir: out)-- // Unlock a batch: select a site, Unlock, the prompt, Allow.- do {- let (m, _) = await model(icons: true)- m.keyvault.send(.toggleOpen(key: "chrome|github.com"))- recorder.frame("Vault list: apps, sites, items. Locked by default.", vault(m), delay: 1.4)- m.keyvault.send(.toggleGroup(key: "chrome|github.com"))- recorder.frame("Select a site: its 6 items are selected.", vault(m), delay: 1.4)- let ids = m.keyvault.vaultView.selection.unlockIds- await m.keyvault.requestUnlock(ids: ids)- let prompt = try #require(m.keyvault.unlockPrompt?.prompt)- recorder.frame("Unlock asks first, once for the whole batch.", vault(m), over: UnlockPromptSheet(prompt: prompt) { _ in },- sheetSize: CGSize(width: 440, height: 220), delay: 2.4)- await m.keyvault.answerUnlock(.allow)- recorder.frame("Allow: Touch ID is asked once, then the items are unlocked.", vault(m), delay: 2.0)- try recorder.finish("keyvault-unlock-batch")- }- // Search filters by domain, key, app or type.- do {- let (m, _) = await model(icons: true)- for q in ["", "n", "no", "not", "notion", "cookie github", "slack"] {- m.keyvault.query = q- recorder.frame(q.isEmpty ? "Search by domain, key, app or type." : "Search: \(q)", vault(m), delay: q.isEmpty ? 1.2 : 1.0)- }- try recorder.finish("keyvault-search")- }- // Delete wipes live copies too.- do {- var o = KeyvaultFixtures.overview()- o.deliveries = [KvDelivery(importId: "imp-1", target: "local:aurora", providerId: "chrome",- items: ["c-gh-1", "c-gh-2"], callerFp: "fp", deliveredMs: UInt64(KeyvaultFixtures.now - 600_000),- expiresMs: 0, wiped: false)]- let (m, _) = await model(o, icons: true)- m.keyvault.send(.toggleGroup(key: "arc|figma.com"))- recorder.frame("Select Figma's cookies in Arc.", vault(m), delay: 1.2)- m.keyvault.send(.clear)- m.keyvault.send(.toggleGroup(key: "chrome|github.com"))- recorder.frame("Select github.com in Chrome and delete it.", vault(m), delay: 1.2)- m.keyvault.requestDelete(ids: m.keyvault.vaultView.selection.ids)- let c = try #require(m.keyvault.deleteConfirm?.confirm)- recorder.frame("The confirmation says live copies are wiped too.", vault(m),- over: DeleteConfirmSheet(confirm: c, onDelete: {}, onCancel: {}),- sheetSize: CGSize(width: 420, height: 170), delay: 2.4)- await m.keyvault.confirmDelete()- recorder.frame("Deleted. The copy in Aurora was wiped.", vault(m), delay: 2.0)- try recorder.finish("keyvault-delete")- }- // The review: per-site choice, counts, then the Keyvault as the source.- do {- let rec = Recorder(snap: snap, size: CGSize(width: 640, height: 760), dir: out)- let (t, _) = try await reviewModel()- func review() -> some View { TeleportReview(teleport: t, review: t.review!) }- rec.frame("Review: the sites to send, with counts. Minimal by default.", review(), delay: 2.2)- t.send(.toggleDomain(domain: "amazon.com"))- rec.frame("Pick another site.", review(), delay: 1.4)- t.send(.toggleDomain(domain: "github.com"))- rec.frame("Drop one.", review(), delay: 1.4)- t.send(.domainQuery(text: "n"))- rec.frame("Search the sites.", review(), delay: 1.4)- t.send(.domainQuery(text: ""))- await t.sendFrom(.vault)- t.sendVault(.toggleOpen(key: "chrome|github.com"))- rec.frame("Or send the saved Keyvault items. Nothing is read from this Mac.", review(), delay: 2.6)- try rec.finish("keyvault-review")- }- // Stills.- do {- let (m, _) = await model(icons: true)- m.keyvault.send(.toggleOpen(key: "chrome|github.com"))- m.keyvault.send(.toggleOpen(key: "chrome|\u{1}files"))- try recorder.still("vault-grouped", vault(m))- m.keyvault.send(.toggleGroup(key: "chrome|github.com"))- m.keyvault.send(.toggle(id: "c-no-1"))- try recorder.still("vault-multiselect", vault(m))- m.keyvault.send(.clear)- m.keyvault.query = "notion"- try recorder.still("vault-search", vault(m))- let (h, _) = await model(KeyvaultFixtures.overview(namesVisible: false), icons: true)- try recorder.still("vault-names-hidden", vault(h))- let one = kvUnlockPromptAlways(count: 1, name: "user_session")- try recorder.still("unlock-prompt", UnlockPromptSheet(prompt: one) { _ in }, size: CGSize(width: 440, height: 220))- let batch = kvUnlockPromptAlways(count: 6, name: nil)- try recorder.still("unlock-prompt-batch", UnlockPromptSheet(prompt: batch) { _ in }, size: CGSize(width: 440, height: 220))- try recorder.still("delete-confirm", DeleteConfirmSheet(confirm: kvDeleteConfirm(count: 6, liveCopies: 1), onDelete: {}, onCancel: {}),- size: CGSize(width: 420, height: 170))- let (t, _) = try await reviewModel()- try recorder.still("review-sites", TeleportReview(teleport: t, review: t.review!),- size: CGSize(width: 640, height: 760))- let (v, _) = try await reviewModel(vault: true)- try recorder.still("review-vault", TeleportReview(teleport: v, review: v.review!),- size: CGSize(width: 640, height: 760))- }- }}diff --git a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/KeyvaultSnapshotTests.swift b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/KeyvaultSnapshotTests.swiftdeleted file mode 100644index 0675ce522f..0000000000--- a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/KeyvaultSnapshotTests.swift+++ /dev/null@@ -1,196 +0,0 @@-// SPDX-License-Identifier: FSL-1.1-MIT-// Copyright (c) 2026 Cua AI, Inc.--import AppKit-import CuaSDK-import CuaSpacesFFI-import ImageIO-@testable import CuaSpacesMacKit-import SwiftUI-import Testing-import UniformTypeIdentifiers--/// Snapshots of the vault list (grouped, multi-select, search, names hidden),-/// the unlock prompt and the delete confirmation, on the simulated vault of-/// `KeyvaultFixtures` (no real secret anywhere), rendered offscreen. The-/// `Recorder` collects frames, one real state of the real views each, into-/// the GIFs `KeyvaultReviewTests.exportScreenshotsAndGifs` writes.-@MainActor-@Suite("Keyvault snapshots", .serialized)-struct KeyvaultSnapshotTests {- let snap = SnapshotTests()- static let list = CGSize(width: 780, height: 560)-- func model(_ overview: KeyvaultOverview = KeyvaultFixtures.overview(),- icons: Bool = false) async -> (AppModel, FakeKeyvault) {- let fake = FakeKeyvault(overview)- let m = ViewModelTests().makeModel(kv: fake)- if icons {- m.keyvault.appIcons = AppIconCache(- dir: FileManager.default.temporaryDirectory.appendingPathComponent("cua-snap-icons-\(UUID().uuidString)"),- resolver: { id, name in- var r = AppIconCache.workspace(id, name)- if r == nil, id == "arc", let url = NSWorkspace.shared.urlForApplication(withBundleIdentifier: "company.thebrowser.Browser") {- r = AppIconSource(bundleId: "company.thebrowser.Browser", version: "0") {- AppIconCache.png(NSWorkspace.shared.icon(forFile: url.path), side: 64)- }- }- return r- })- }- await m.keyvault.refresh()- if icons { await m.keyvault.loadIcons() }- return (m, fake)- }-- var useRealIcons: Bool { ProcessInfo.processInfo.environment["KEYVAULT_REAL_ICONS"] == "1" }-- func vault(_ m: AppModel) -> some View {- VaultList(keyvault: m.keyvault, page: m.keyvault.page)- }-- // MARK: - The list-- @Test func vaultGroupedByApp() async throws {- let (m, _) = await model(icons: useRealIcons)- // Open one site and the files of Chrome, the way a user browses.- m.keyvault.send(.toggleOpen(key: "chrome|github.com"))- m.keyvault.send(.toggleOpen(key: "chrome|\u{1}files"))- try snap.assertSnapshot(vault(m), "keyvault-vault-grouped", size: Self.list)- }-- @Test func vaultMultiSelectWithTheBatchBar() async throws {- let (m, _) = await model(icons: useRealIcons)- m.keyvault.send(.toggleOpen(key: "chrome|github.com"))- m.keyvault.send(.toggleGroup(key: "chrome|github.com"))- m.keyvault.send(.toggle(id: "c-no-1"))- #expect(m.keyvault.vaultView.selection.title == "7 selected")- try snap.assertSnapshot(vault(m), "keyvault-vault-multiselect", size: Self.list)- }-- @Test func vaultSearch() async throws {- let (m, _) = await model(icons: useRealIcons)- m.keyvault.query = "notion"- try snap.assertSnapshot(vault(m), "keyvault-vault-search", size: Self.list)- m.keyvault.query = "cookie github"- try snap.assertSnapshot(vault(m), "keyvault-vault-search-type", size: Self.list)- }-- @Test func vaultNamesHidden() async throws {- let (m, _) = await model(KeyvaultFixtures.overview(namesVisible: false), icons: useRealIcons)- try snap.assertSnapshot(vault(m), "keyvault-vault-hidden", size: Self.list)- }-- // MARK: - The prompts-- @Test func unlockPrompt() async throws {- let one = kvUnlockPromptAlways(count: 1, name: "user_session")- try snap.assertSnapshot(UnlockPromptSheet(prompt: one) { _ in }, "keyvault-unlock-prompt",- size: CGSize(width: 440, height: 220))- let batch = kvUnlockPromptAlways(count: 6, name: nil)- try snap.assertSnapshot(UnlockPromptSheet(prompt: batch) { _ in }, "keyvault-unlock-prompt-batch",- size: CGSize(width: 440, height: 220))- }-- @Test func deleteConfirm() async throws {- let c = kvDeleteConfirm(count: 6, liveCopies: 1)- try snap.assertSnapshot(DeleteConfirmSheet(confirm: c, onDelete: {}, onCancel: {}), "keyvault-delete-confirm",- size: CGSize(width: 420, height: 170))- }-}--/// Collects frames (a view and a caption under it) and writes a GIF.-@MainActor-final class Recorder {- let snap: SnapshotTests- let size: CGSize- let dir: URL- private var frames: [(CGImage, Double)] = []-- init(snap: SnapshotTests, size: CGSize, dir: URL) {- self.snap = snap- self.size = size- self.dir = dir- }-- /// One frame: `view`, a sheet over it (the window dimmed behind, the way- /// macOS presents one) and the caption under both. The sheet is rendered- /// on its own and composited as an image, so the text field under it- /// draws as it does without a sheet.- func frame<V: View, O: View>(_ caption: String, _ view: V, over sheet: O, sheetSize: CGSize, delay: Double) {- let base = snap.render(view.frame(width: size.width, height: size.height), size: size)- let top = snap.render(sheet.background(Color(nsColor: .windowBackgroundColor)), size: sheetSize)- let scale: CGFloat = 2- let out = NSBitmapImageRep(bitmapDataPlanes: nil, pixelsWide: Int(size.width * scale), pixelsHigh: Int(size.height * scale),- bitsPerSample: 8, samplesPerPixel: 4, hasAlpha: true, isPlanar: false,- colorSpaceName: .deviceRGB, bytesPerRow: 0, bitsPerPixel: 0)!- out.size = size- NSGraphicsContext.saveGraphicsState()- NSGraphicsContext.current = NSGraphicsContext(bitmapImageRep: out)- NSColor.white.setFill()- CGRect(origin: .zero, size: size).fill()- base.draw(in: CGRect(origin: .zero, size: size))- NSColor.black.withAlphaComponent(0.28).setFill()- CGRect(origin: .zero, size: size).fill()- let rect = CGRect(x: (size.width - sheetSize.width) / 2, y: size.height - sheetSize.height - 96,- width: sheetSize.width, height: sheetSize.height)- let shadow = NSShadow()- shadow.shadowBlurRadius = 24- shadow.shadowColor = NSColor.black.withAlphaComponent(0.35)- shadow.shadowOffset = NSSize(width: 0, height: -6)- NSGraphicsContext.saveGraphicsState()- shadow.set()- NSBezierPath(roundedRect: rect, xRadius: 12, yRadius: 12).addClip()- top.draw(in: rect)- NSGraphicsContext.restoreGraphicsState()- NSGraphicsContext.restoreGraphicsState()- add(caption, Image(nsImage: NSImage(cgImage: out.cgImage!, size: size)).resizable().frame(width: size.width, height: size.height),- delay: delay)- }-- func frame<V: View>(_ caption: String, _ view: V, delay: Double) { add(caption, view, delay: delay) }-- private func add<V: View>(_ caption: String, _ view: V, delay: Double) {- let bar: CGFloat = 34- let composed = VStack(spacing: 0) {- view.frame(width: size.width, height: size.height)- Text(caption)- .font(.system(size: 13, weight: .medium))- .foregroundStyle(.white)- .frame(width: size.width, height: bar)- .background(Color(white: 0.12))- }- let rep = snap.render(composed, size: CGSize(width: size.width, height: size.height + bar))- if let cg = rep.cgImage, let flat = Self.opaque(cg) { frames.append((flat, delay)) }- }-- /// The frame on white, with no alpha: a GIF has none, and what the render- /// left transparent would show black.- static func opaque(_ image: CGImage) -> CGImage? {- guard let ctx = CGContext(data: nil, width: image.width, height: image.height, bitsPerComponent: 8,- bytesPerRow: 0, space: CGColorSpaceCreateDeviceRGB(),- bitmapInfo: CGImageAlphaInfo.noneSkipLast.rawValue) else { return nil }- ctx.setFillColor(CGColor(red: 1, green: 1, blue: 1, alpha: 1))- ctx.fill(CGRect(x: 0, y: 0, width: image.width, height: image.height))- ctx.draw(image, in: CGRect(x: 0, y: 0, width: image.width, height: image.height))- return ctx.makeImage()- }-- func finish(_ name: String) throws {- defer { frames = [] }- guard let dest = CGImageDestinationCreateWithURL(dir.appendingPathComponent("\(name).gif") as CFURL,- UTType.gif.identifier as CFString, frames.count, nil)- else { throw CocoaError(.fileWriteUnknown) }- CGImageDestinationSetProperties(dest, [kCGImagePropertyGIFDictionary: [kCGImagePropertyGIFLoopCount: 0]] as CFDictionary)- for (image, delay) in frames {- CGImageDestinationAddImage(dest, image, [kCGImagePropertyGIFDictionary: [kCGImagePropertyGIFDelayTime: delay]] as CFDictionary)- }- guard CGImageDestinationFinalize(dest) else { throw CocoaError(.fileWriteUnknown) }- }-- func still<V: View>(_ name: String, _ view: V, size: CGSize? = nil) throws {- let s = size ?? self.size- let rep = snap.render(view, size: s)- try rep.representation(using: .png, properties: [:])!.write(to: dir.appendingPathComponent("\(name).png"))- }-}diff --git a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/MachineAccessTests.swift b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/MachineAccessTests.swiftindex efc75a057d..10fe6e590e 100644--- a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/MachineAccessTests.swift+++ b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/MachineAccessTests.swift@@ -215,21 +215,6 @@ struct MachineAccessTests {#expect(LiveSpacesBackend.supportedFeatures(capabilitiesJson: "nope") == nil)}- /// Sharing its desktop lists this Mac on the relay too: it stays- /// "This machine" and is not repeated under My machines, while another- /// Mac of the same name stays.- @Test func thisMacIsNotOneOfMyMachines() async throws {- let m = await MachinesFixture.model(rows: MachinesFixture.rows(includeSelf: true), enrollment: .enrolled,- hostSetUp: true)- #expect(m.sidebar.thisMachine != nil)- let mine = try #require(m.sidebar.sections.first { $0.title.code == "spaces.sidebar.section.my_computers" })- let ids = mine.rows.map(\.id)- #expect(!ids.contains("relay:\(MachinesFixture.thisMacId)"))- #expect(ids.contains("relay:m-dana-2"))- try SnapshotTests().assertSnapshot(Sidebar(model: m).frame(width: 260), "sidebar-without-this-mac",- size: CGSize(width: 260, height: 600))- }-/// The user's Macs after updating to 0.7.0: this Mac (relay/// `b695…`, not sharing) and a spare Mac ("Mac.localdomain", relay/// `9e9d…`: sharing, desktop not shared, Spaces on with none running,@@ -264,63 +249,4 @@ struct MachineAccessTests {#expect(mine.rows.map(\.id) == [other])}}-- // MARK: - Snapshots-- func card(_ cover: AppDesktopCover) -> some View {- Form {- Section { PreviewCard(session: nil) { DesktopCoverView(cover: cover, image: nil) } }- }- .formStyle(.grouped)- }-- /// The machine's card: Connect (enrolled), then greyed out under why- /// and the one action (not enrolled, waiting for approval, expired).- @Test func connectSnapshots() async throws {- let size = CGSize(width: 520, height: 360)- let snap = SnapshotTests()- let enrolled = await MachinesFixture.model(rows: MachinesFixture.rows(), enrollment: .enrolled)- let d = enrolled.detail(try space(enrolled, "relay:m-studio"))- try snap.assertSnapshot(card(enrolled.cover(d, requested: false, stream: .noSession)),- "machine-connect-enrolled", size: size)- for (e, name) in [(MachinesFixture.Enrollment.never, "machine-connect-not-enrolled"),- (.pending, "machine-connect-pending"), (.expired, "machine-connect-expired")] {- let m = await MachinesFixture.model(rows: MachinesFixture.rows(reachable: false), enrollment: e)- let d = m.detail(try space(m, "relay:m-studio"))- try snap.assertSnapshot(card(m.cover(d, requested: false, stream: .noSession)), name, size: size)- }- }-- /// Desktop shared (its live card), not shared with Spaces on (the note- /// and its Spaces), and both off (the note alone).- @Test func desktopSnapshots() async throws {- let size = CGSize(width: 560, height: 440)- let snap = SnapshotTests()- let m = await MachinesFixture.model(rows: MachinesFixture.rows(), enrollment: .enrolled)- let studio = try space(m, "relay:m-studio")- let shared = m.detail(studio)- try snap.assertSnapshot(Form {- Section {- PreviewCard(session: nil) {- DesktopCoverView(cover: m.cover(shared, requested: false, stream: .noSession), image: nil)- }- }- Section("Stream") { Text(appSpaceDetailCopy().streamLoading).foregroundStyle(.secondary) }- }.formStyle(.grouped), "machine-desktop-shared", size: size)- for (id, name) in [("relay:m-mini", "machine-desktop-not-shared"), ("relay:m-ci", "machine-desktop-and-spaces-off")] {- let d = m.detail(try space(m, id))- let note = try #require(d.desktopNote)- try snap.assertSnapshot(Form {- DesktopNotSharedSections(model: m, machineId: id, note: note, newSpace: d.newSpace)- Section { FactRows(facts: d.facts, write: { _ in }, copied: false) }- }.formStyle(.grouped), name, size: size)- }- }-- /// Signed in, not enrolled: My machines still lists every machine.- @Test func sidebarSnapshot() async throws {- let m = await MachinesFixture.model(rows: MachinesFixture.rows(reachable: false), enrollment: .never)- try SnapshotTests().assertSnapshot(Sidebar(model: m).frame(width: 260), "sidebar-my-machines-not-enrolled",- size: CGSize(width: 260, height: 560))- }}diff --git a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/ProviderFailureTests.swift b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/ProviderFailureTests.swiftdeleted file mode 100644index cb7e0ec716..0000000000--- a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/ProviderFailureTests.swift+++ /dev/null@@ -1,204 +0,0 @@-// SPDX-License-Identifier: FSL-1.1-MIT-// Copyright (c) 2026 Cua AI, Inc.--import CuaSDK-import CuaSpacesFFI-import CuaSpacesStreaming-@testable import CuaSpacesMacKit-import Foundation-import AppKit-import Testing-import SwiftUI-import Vision--/// Scripted provider creation and media failures; no host is contacted.-private final class ProviderFailureBackend: SpacesBackend, @unchecked Sendable {- var result: Result<[AppSpaceRow], Error> = .success(FixtureSpacesBackend.sample)- var failures = 2- let provider = RefusingMediaProvider()- private let lock = NSLock()- private var ids: [String] = []- var requestedIds: [String] { lock.withLock { ids } }- func rows() async throws -> [AppSpaceRow] { try result.get() }- func create(_ args: AppCreateSpaceArgs, createId: String, progress: @escaping @Sendable (SpaceCreateProgress) -> Void) async throws -> String { fatalError("unexpected create") }- func cancelCreate(createId: String) async throws {}- func add(url: String, token: String?, name: String?) async throws {}- func remove(id: String, removeOnly: Bool) async throws {}- func setPower(id: String, on: Bool) async throws {}- func streamProvider(id: String) async throws -> SpaceStreamSourceProviding {- let attempt = lock.withLock { ids.append(id); return ids.count }- if attempt <= failures { throw CuaError.Internal(message: "scripted provider failure") }- return provider- }- func localBackends() async -> [String]? { nil }- func localStorage() async -> LocalStorage? { nil }- func teleportContext(id: String) async throws -> (CuaSpacesFFI.Teleport, CuaSDK.Space)? { nil }- func teleportHandle() -> CuaSpacesFFI.Teleport? { nil }- func sendFiles(id: String, paths: [String]) async throws -> [AppSentFileInfo] { [] }- func agentRuns(id: String) async throws -> [AppSpaceAgentRun] { [] }-}--private final class RefusingMediaProvider: SpaceStreamSourceProviding, @unchecked Sendable {- private let lock = NSLock()- private var opens = 0- var attempts: Int { lock.withLock { opens } }- func availableWindows() async throws -> [StreamWindow] { [] }- func openSession(_ source: StreamSource, frames: FrameSink, audio: AudioSink?) async throws -> SpaceStreamSession {- lock.withLock { opens += 1 }- throw StreamError.noStream("scripted media failure")- }- func joinPresence(name: String, color: String?) async throws -> SpacePresence {- throw StreamError.noStream("no presence in fixture")- }-}--@MainActor @Suite("Provider creation recovery", .serialized)-struct ProviderFailureTests {- @MainActor private struct Fixture {- let backend: ProviderFailureBackend- let model: AppModel- let devices: FixtureDevices- let space: AppSpace- let host: NSView- let window: NSWindow- let directory: URL-- func close() {- window.contentView = nil- window.close()- try? FileManager.default.removeItem(at: directory)- }-- func text() throws -> [VNRecognizedTextObservation] {- host.layoutSubtreeIfNeeded()- window.display()- let bitmap = try #require(host.bitmapImageRepForCachingDisplay(in: host.bounds))- host.cacheDisplay(in: host.bounds, to: bitmap)- let request = VNRecognizeTextRequest()- request.recognitionLanguages = ["en-US"]- request.recognitionLevel = .accurate- request.usesLanguageCorrection = false- try VNImageRequestHandler(cgImage: #require(bitmap.cgImage), options: [:]).perform([request])- return request.results ?? []- }-- /// Presses `label` once the detail shows it. The view updates after- /// the model does, so look again (up to 30 s) instead of reading the- /// rendered text once after a fixed wait.- func press(_ label: String) async throws {- let deadline = ContinuousClock.now + .seconds(30)- var found = try text().first { $0.topCandidates(1).first?.string == label }- while found == nil, ContinuousClock.now < deadline {- try await Task.sleep(for: .milliseconds(100))- found = try text().first { $0.topCandidates(1).first?.string == label }- }- let match = try #require(found, "the actual detail renders \(label)")- let box = match.boundingBox- let local = NSPoint(x: box.midX * host.bounds.width,- y: (host.isFlipped ? 1 - box.midY : box.midY) * host.bounds.height)- let point = host.convert(local, to: nil)- let key = NSApp.keyWindow- // AppKit dispatch within this process to this window only: no- // system event posting, Accessibility grant, or real desktop.- for kind in [NSEvent.EventType.leftMouseDown, .leftMouseUp] {- let event = try #require(NSEvent.mouseEvent(with: kind, location: point, modifierFlags: [],- timestamp: ProcessInfo.processInfo.systemUptime, windowNumber: window.windowNumber,- context: nil, eventNumber: 0, clickCount: 1, pressure: 1))- try #require(event.window === window)- NSApp.sendEvent(event)- }- #expect(NSApp.keyWindow === key)- }-- func settle() async throws { try await Task.sleep(for: .milliseconds(350)) }- func expectProviders(_ count: Int) async throws {- for _ in 0..<80 where backend.requestedIds.count < count {- try await Task.sleep(for: .milliseconds(50))- }- try await settle()- #expect(backend.requestedIds == Array(repeating: space.id, count: count))- }- func approve(_ approved: Bool) async throws {- devices.current.devices[0].state = approved ? "enrolled" : "pending"- await model.devices.refresh()- try await settle()- }- }-- private func open(autoConnect: Bool, failures: Int = 2) async throws -> Fixture {- _ = NSApplication.shared- NSApp.finishLaunching()- let backend = ProviderFailureBackend()- backend.failures = failures- var row = FixtureSpacesBackend.sample[0]- row.id = "relay:studio"- row.provider = "relay"- backend.result = .success([row])- let devices = FixtureDevices(snapshot: FixtureDevices.sample(now: UInt64(Date().timeIntervalSince1970)))- let directory = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString)- let model = AppModel(backend: backend, keyvault: KeyvaultModel(client: nil),- onboarding: OnboardingModel(statePath: nil), settingsPath: directory.appendingPathComponent("settings.json").path,- telemetry: FixtureTelemetry(), devices: devices, presence: FixturePresence())- model.settings.autoConnect = autoConnect- await model.refresh()- model.devices.signedIn = true- await model.devices.refresh()- let space = try #require(model.spaces.first { $0.id == row.id })- #expect(model.detail(space).access == nil)- let host = NSHostingView(rootView: SpaceDetailView(model: model, space: space).frame(width: 800, height: 800))- let window = NSWindow(contentRect: NSRect(x: -20000, y: -20000, width: 800, height: 800),- styleMask: [.borderless], backing: .buffered, defer: false)- window.isReleasedWhenClosed = false- window.contentView = host- let key = NSApp.keyWindow- window.orderBack(nil)- #expect(NSApp.keyWindow === key)- try #require(NSScreen.screens.allSatisfy { !$0.frame.intersects(window.frame) })- try #require(window.windowNumber > 0, "requires a WindowServer-backed test window")- host.layoutSubtreeIfNeeded()- return Fixture(backend: backend, model: model, devices: devices, space: space,- host: host, window: window, directory: directory)- }-- @Test(arguments: [false, true])- func retriesProviderCreationThenAttemptsMedia(autoConnect: Bool) async throws {- let f = try await open(autoConnect: autoConnect)- defer { f.close() }- if !autoConnect {- try await f.settle()- #expect(f.backend.requestedIds.isEmpty)- try await f.press("Connect")- }- try await f.expectProviders(1)- #expect(f.model.banner?.contains("scripted provider failure") == true)- await f.model.refresh()- try await f.settle()- #expect(f.backend.requestedIds == [f.space.id], "polling does not retry a failure")- for attempt in 2...3 {- try await f.press("Try again")- try await f.expectProviders(attempt)- }- for _ in 0..<80 where f.backend.provider.attempts < 1 {- try await Task.sleep(for: .milliseconds(50))- }- #expect(f.backend.provider.attempts == 1, "provider creation recovered and attempted to open media")- try await f.settle()- await f.model.refresh()- try await f.settle()- #expect(f.backend.provider.attempts == 1)- #expect(f.backend.requestedIds == Array(repeating: f.space.id, count: 3))- }-- @Test func approvalAndPollingDoNotRetryAnExistingFailure() async throws {- let f = try await open(autoConnect: true, failures: 1)- defer { f.close() }- try await f.expectProviders(1)- try await f.approve(false)- #expect(f.model.detail(f.space).access != nil)- try await f.approve(true)- #expect(f.model.detail(f.space).access == nil)- #expect(f.backend.requestedIds == [f.space.id])- try await f.press("Try again")- try await f.expectProviders(2)- }-}diff --git a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/SnapshotTests.swift b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/SnapshotTests.swiftindex b7f8c84c8f..adeed2b025 100644--- a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/SnapshotTests.swift+++ b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/SnapshotTests.swift@@ -41,161 +41,7 @@ struct SnapshotTests {return m}- @Test func newSpaceWizard() async throws {- let m = try await model()- await m.openNewSpace()- try assertSnapshot(NewSpaceWizardView(wizard: m.wizard, onCreate: { _ in }, onAdd: { _, _, _ in },- onCancel: {}), "new-space", size: CGSize(width: 560, height: 520))- }-- /// Two of your machines that provide Spaces (simulated): one busy, one- /// paused (sharing off), each with its one load line.- static func machineHosts() -> [AppSpaceHost] {- func host(_ id: String, _ name: String, _ load: AppHostLoad) -> AppSpaceHost {- AppSpaceHost(id: id, name: name, via: "relay", online: true, os: "macos", limits: [], load: load)- }- return [- host("m-mini", "Mac mini", AppHostLoad(millicpusTotal: 10_000, millicpusFree: 6_000,- memoryTotalMb: 32_768, memoryFreeMb: 16_384,- spaces: 3, problem: "")),- host("m-studio", "Studio", AppHostLoad(millicpusTotal: 24_000, millicpusFree: 24_000,- memoryTotalMb: 65_536, memoryFreeMb: 65_536,- spaces: 0, problem: "sharing is paused")),- ]- }-- /// New Space with your machines: "Run on" set to Auto (the least-loaded- /// of your machines).- @Test func newSpaceWizardAuto() async throws {- let backend = FixtureSpacesBackend()- backend.fixtureHosts = Self.machineHosts()- let m = ViewModelTests().makeModel(backend, kv: FakeKeyvault(try fixtureOverview()),- host: FixtureHost(), account: FixtureAccount(),- agents: FixtureAgentSetup())- m.onboarding.finish()- await m.refresh()- await m.openNewSpace()- #expect(m.wizard.view.placements.first?.id == "auto")- #expect(m.wizard.view.placementId == "local", "This Mac stays the default")- m.wizard.send(.choosePlacement(on: "auto"))- #expect(m.wizard.view.placementId == "auto")- #expect(appWizardCreateArgs(plan: m.wizard.view.plan).on == "auto")- try assertSnapshot(NewSpaceWizardView(wizard: m.wizard, onCreate: { _ in }, onAdd: { _, _, _ in },- onCancel: {}), "new-space-auto", size: CGSize(width: 560, height: 520))- }-- /// "My machines" in the sidebar: each machine that provides Spaces says- /// how busy it is in one short line.- @Test func mainWindowSidebarMachineLoad() async throws {- func machine(_ id: String, _ name: String) -> AppSpaceRow {- AppSpaceRow(id: "relay:\(id)", name: name, provider: "relay",- spacesdVersion: "0.4.0", features: ["desktop_stream"], addedAt: "2026-09-25T08:00:00Z",- os: .macos, osName: "macOS", osPrettyName: nil, image: nil, imageDigest: nil,- kind: .vm, arch: "arm64", reachable: true,- error: nil, host: nil, hostName: nil, power: nil, powerState: nil,- cloud: nil, cloudPlace: nil, cloudDelete: nil, stopReason: nil)- }- let backend = FixtureSpacesBackend(rows: [machine("m-mini", "Mac mini"), machine("m-studio", "Studio")])- backend.fixtureHosts = Self.machineHosts()- let m = ViewModelTests().makeModel(backend, kv: FakeKeyvault(try fixtureOverview()),- host: FixtureHost(), account: FixtureAccount(),- agents: FixtureAgentSetup())- m.onboarding.finish()- await m.refresh()- await m.refreshHosts()- await m.keyvault.refresh()- #expect(m.hostLoadLine("relay:m-mini") == "3 running \u{b7} 40% CPU")- #expect(m.hostLoadLine("relay:m-studio") == "Paused")- #expect(m.hostLoadLine("local:aurora") == nil)- m.select("relay:m-mini")- try assertSnapshot(Sidebar(model: m).frame(width: 260), "sidebar-machine-load",- size: CGSize(width: 260, height: 520))- }-- /// The Space detail's Stream section: Desktop with the OS mark and the- /// resolution, window rows by title with their app icons (none for- /// xterm), a truncated long title, one panel open.- @Test func streamSection() async throws {- let m = StreamFixture.model()- await m.refresh()- await m.loadIcons()- let open: Set<String> = [StreamSource.window(StreamFixture.windows[2]).pipKey]- let view = Form {- Section("Stream") {- StreamRowList(section: m.section(openKeys: open), image: m.image(for:)) { _ in }- }- }- .formStyle(.grouped)- try assertSnapshot(view, "stream-section", size: CGSize(width: 520, height: 280))- }-- /// The detail's facts from the core with live usage: Image (copy),- /// the full System string, Memory, Identifier (copy), before and right- /// after a copy (never the real pasteboard).- @Test func spaceFacts() async throws {- let backend = FixtureSpacesBackend()- let space = appRowsToSpaces(rows: FixtureSpacesBackend.sample, nowMs: 0)[0]- let usage = await backend.usage(id: space.id)- let facts = appSpaceDetailLive(space: space, usage: usage, hostArch: nil).facts- let size = CGSize(width: 520, height: 300)- func form(_ copied: Bool) -> some View {- Form { Section { FactRows(facts: facts, write: { _ in }, copied: copied) } }.formStyle(.grouped)- }- try assertSnapshot(form(false), "space-facts", size: size)- try assertSnapshot(form(true), "space-facts-copied", size: size)- }-- /// OS-only regression: the real app core, facts view and icon renderer.- @Test func relayOperatingSystemFacts() throws {- for (os, name, expected) in [(Optional<AppSpaceOs>.none, "Unknown", "Unknown"), (.macos, "macOS", "macOS")] {- let row = AppSpaceRow(id: "relay:test-host", name: "Test host", provider: "relay",- spacesdVersion: "0.4.1", features: [], addedAt: nil, os: os,- osName: nil, osPrettyName: nil, image: nil, imageDigest: nil,- kind: nil, arch: nil, reachable: true, error: nil, host: nil, hostName: nil,- power: nil, powerState: nil, cloud: nil, cloudPlace: nil, cloudDelete: nil, stopReason: nil)- let space = appRowsToSpaces(rows: [row], nowMs: 0)[0]- let facts = appSpaceDetail(space: space).facts- #expect(facts.first { $0.label == "System" }?.value == expected)- #expect(space.os.label == expected)- var notch = appNotchInitial()- notch.open = true- // The machine itself is no notch tile (CUA-1619): a Space it- // provides, with the same OS, is.- var providedRow = row- providedRow.id = "relay:test-host/dev"- providedRow.host = "test-host"- let provided = appRowsToSpaces(rows: [providedRow], nowMs: 0)[0]- #expect(appNotchView(state: notch, spaces: [space]).tiles.isEmpty)- let tile = try #require(appNotchView(state: notch, spaces: [space, provided]).tiles.first)- #expect(tile.id == provided.id)- #expect(tile.symbol == (os == nil ? "computer" : "os-macos"))- let view = VStack(alignment: .leading, spacing: 12) {- HStack { OsIconImage(id: tile.symbol, size: 18); Text(space.name) }- Form { Section { FactRows(facts: facts, write: { _ in }, copied: false) } }.formStyle(.grouped)- }.padding().background(Color.white)- try assertSnapshot(view, "relay-os-" + name, size: CGSize(width: 520, height: 300))- }- }-- /// The live desktop's card: its content runs flush to the card's edges- /// (no row inset, no letterbox) at the default desktop's 16:10, with- /// only the card's corner radius, above the facts card.- @Test func spacePreview() async throws {- let space = appRowsToSpaces(rows: FixtureSpacesBackend.sample, nowMs: 0)[0]- let facts = appSpaceDetail(space: space).facts- let view = Form {- Section {- PreviewCard(session: nil) {- LinearGradient(colors: [.indigo, .orange], startPoint: .top, endPoint: .bottom)- }- }- Section { FactRows(facts: facts, write: { _ in }, copied: false) }- }- .formStyle(.grouped)- try assertSnapshot(view, "space-preview", size: CGSize(width: 520, height: 480))- }-- /// The preview card while the stream opens and while it waits for+ /// A Space's window while the stream opens and while it waits for/// Connect: the Space's thumbnail blurred and dimmed with the core's/// words centered, or plain black when there is no thumbnail yet.@Test func desktopCover() async throws {@@ -204,12 +50,7 @@ struct SnapshotTests {let detail = m.detail(space)let preview = DesktopCoverTests.desktop()func card(_ cover: AppDesktopCover, _ image: NSImage?) -> some View {- Form {- Section {- PreviewCard(session: nil) { DesktopCoverView(cover: cover, image: image) }- }- }- .formStyle(.grouped)+ DesktopCoverView(cover: cover, image: image)}let size = CGSize(width: 520, height: 360)let connecting = m.cover(detail, requested: false, stream: .noSession)@@ -228,17 +69,6 @@ struct SnapshotTests {try assertSnapshot(card(stopped, preview), "space-cover-stopped", size: size)}- /// "Teleport an app…" as the core's grid: sections, a tile previewing- /// its app's frontmost window, icons, the app that cannot move dimmed.- @Test func teleportPickerGrid() async throws {- let m = TeleportModel(spaceName: "Aurora", teleport: nil, space: nil, sources: PickerFixture.sources())- m.send(.loaded(entries: try PickerFixture.entries()))- await m.loadWindows()- for tile in m.grid.sections.flatMap(\.tiles) { await m.loadThumbnail(tile) }- try assertSnapshot(TeleportPickerSheet(teleport: m, onClose: {}), "teleport-picker-grid",- size: CGSize(width: 640, height: 540))- }-/// A Keyvault sign-in live in Aurora (auto-wipe off: no expiry).func signedInOverview() throws -> KeyvaultOverview {var o = try fixtureOverview()@@ -249,24 +79,6 @@ struct SnapshotTests {return o}- /// "Signed in" beside the Space a Keyvault sign-in is live in.- @Test func mainWindowSidebarSignedIn() async throws {- let m = try await model(overview: try signedInOverview())- m.select("direct:builder")- try assertSnapshot(Sidebar(model: m).frame(width: 260), "sidebar-signed-in", size: CGSize(width: 260, height: 520))- }-- /// Access from that badge: the Space's copy brought forward, kept until- /// wiped (auto-wipe off), with Dismiss beside Wipe.- @Test func keyvaultAccessFocused() async throws {- let m = try await model(overview: try signedInOverview())- m.showAccess(spaceId: "local:aurora")- m.keyvault.selection = .category(category: .access)- #expect(m.keyvault.focusKey == "d:local:aurora")- try assertSnapshot(CategoryList(keyvault: m.keyvault, page: m.keyvault.page), "keyvault-access",- size: CGSize(width: 640, height: 360))- }-/// Settings, Keyvault (the page's, over this model): its section is there.@Test func settingsKeyvault() async throws {let m = try await model(overview: try signedInOverview())@@ -274,152 +86,6 @@ struct SnapshotTests {#expect(m.settingsPage.sections.contains { $0.id == "keyvault" })}- /// The teleport run says which step it is on: reading the browser's- /// cookies (naming the Keychain prompt), then the upload's bytes.- @Test func teleportRunning() async throws {- let m = TeleportModel(spaceName: "Aurora", teleport: nil, space: nil, sources: PickerFixture.sources())- let flow = try PickerFixture.json("teleport-review")- func json(_ v: Any?) throws -> String {- String(decoding: try JSONSerialization.data(withJSONObject: v!), as: UTF8.self)- }- m.send(.loaded(entries: try appCatalogEntriesFromJson(json: json(flow["entries"]))))- m.send(.select(id: "slack"))- m.send(.choose(id: nil))- m.send(.move(moves: .appWithState))- m.send(.plan)- m.send(.planned(plan: try appTeleportPlanFromJson(json: json(flow["plan"]))))- m.send(.acknowledge(value: true))- m.send(.acknowledgeRelayPlaintext(value: true))- m.send(.confirm)- func ev(_ detail: String, _ done: UInt64 = 0, _ total: UInt64 = 0) -> AppPickerEvent {- .progress(event: AppTeleportRunEvent(step: 1, steps: 3, kind: "state", phase: .progress, detail: detail,- doneBytes: done, totalBytes: total))- }- #expect(m.state.step == .running)- let size = CGSize(width: 640, height: 540)- m.send(ev("Reading Slack cookies (macOS will ask for Keychain access)\u{2026}"))- try assertSnapshot(TeleportPickerSheet(teleport: m, onClose: {}), "teleport-running-reading", size: size)- m.send(ev("Uploading", 12 << 20, 80 << 20))- try assertSnapshot(TeleportPickerSheet(teleport: m, onClose: {}), "teleport-running-upload", size: size)- }-- @Test func mainWindowSidebar() async throws {- let m = try await model()- m.select("local:aurora")- try assertSnapshot(Sidebar(model: m).frame(width: 260), "sidebar", size: CGSize(width: 260, height: 520))- }-- /// The first Linux Space on a Mac with no Docker: the built-in Linux- /// runtime's download shows on the new Space's row, in words, with its- /// bytes (simulated progress).- @Test func mainWindowSidebarSettingUpLinuxRuntime() async throws {- let m = try await model()- let now = Int64(Date().timeIntervalSince1970 * 1000)- m.sendCreate(.start(id: "pending:linux", name: "linux-dev", os: .linux, provider: .local, now: now,- image: "ghcr.io/trycua/linux:24.04", kind: .container, hostArch: "arm64",- gpu: false, host: nil, hostName: nil))- m.sendCreate(.progress(id: "pending:linux", phase: "preparing", fraction: 0.4, now: now,- bytesDone: 192 << 20, bytesTotal: 478 << 20, bytesPerSecond: 24e6))- let space = try #require(m.spaces.first { $0.id == "pending:linux" })- let detail = m.detail(space)- #expect(detail.progressText?.contains("of 478 MB") == true)- let cover = m.cover(detail, requested: false, stream: .noSession)- let view = HStack(spacing: 0) {- Sidebar(model: m).frame(width: 260)- Form {- Section {- PreviewCard(session: nil) {- DesktopCoverView(cover: cover, image: nil, progress: detail.progress,- progressText: detail.progressText)- }- }- }- .formStyle(.grouped)- }- try assertSnapshot(view, "setting-up-linux-runtime", size: CGSize(width: 820, height: 420))- }-- /// The power button next to Delete on the rows: a suspended Space- /// (selected: Resume), a macOS VM turning off (a spinner), and one whose- /// turn-off failed (why, inline).- @Test func mainWindowSidebarPower() async throws {- func row(_ id: String, _ os: AppSpaceOs, _ osName: String, power: String, state: String,- reachable: Bool) -> AppSpaceRow {- AppSpaceRow(id: id, name: String(id.dropFirst("local:".count)), provider: "local",- spacesdVersion: "0.4.0", features: ["desktop_stream"], addedAt: "2026-09-25T08:00:00Z",- os: os, osName: osName, osPrettyName: nil, image: nil, imageDigest: nil,- kind: os == .macos ? .vm : .container, arch: "arm64", reachable: reachable,- error: nil, host: nil, hostName: nil, power: power, powerState: state,- cloud: nil, cloudPlace: nil, cloudDelete: nil, stopReason: nil)- }- let backend = FixtureSpacesBackend(rows: [- row("local:aurora", .linux, "Ubuntu", power: "suspend", state: "suspended", reachable: false),- row("local:mac-studio", .macos, "macOS", power: "stop", state: "running", reachable: true),- row("local:build-box", .linux, "Debian", power: "suspend", state: "running", reachable: true),- ])- let m = ViewModelTests().makeModel(backend, kv: FakeKeyvault(try fixtureOverview()),- host: FixtureHost(), account: FixtureAccount(),- agents: FixtureAgentSetup())- m.onboarding.finish()- await m.refresh()- await m.keyvault.refresh()- m.select("local:aurora")- backend.powerError = "Docker is not running"- m.setPower(try #require(m.spaces.first { $0.id == "local:build-box" }), on: false)- for _ in 0..<200 where m.creates.powering.first?.error == nil {- try await Task.sleep(for: .milliseconds(10))- }- backend.holdPower = true- m.setPower(try #require(m.spaces.first { $0.id == "local:mac-studio" }), on: false)- try assertSnapshot(Sidebar(model: m).frame(width: 260), "sidebar-power", size: CGSize(width: 260, height: 520))- backend.releasePower()- }-- @Test func thisMachine() async throws {- let m = try await model()- await m.host.refresh()- // Before setup: the explainer and both choices inline.- #expect(m.host.panel.intro != nil)- #expect(m.host.panel.setupChoices.map(\.id) == ["desktop", "spare"])- try assertSnapshot(ThisMachineView(host: m.host), "this-machine-unset", size: CGSize(width: 640, height: 420))- m.host.computerName = { "Ada’s MacBook Pro" }- m.host.openForm()- try assertSnapshot(ThisMachineView(host: m.host), "host-setup", size: CGSize(width: 640, height: 420))- m.host.send(.setName(name: "Studio"))- await m.host.submit()- try assertSnapshot(ThisMachineView(host: m.host), "this-machine", size: CGSize(width: 640, height: 520))- }-- /// Relay sharing and the sign-in: shared with your account; paused- /// while signed out (one line and Sign In); both settings off (Resume- /// sharing disabled).- @Test func thisMachineAndTheSignIn() async throws {- let account = FakeAccountTokens()- account.token = "tok-ada"- let who = HostSignInSharingTests.Box(HostSignInSharingTests.ada)- let h = HostModel(host: FixtureHost())- account.wire(h)- h.currentAccount = { who.value }- h.openForm()- h.send(.setName(name: "Studio"))- await h.submit()- await h.reconcileAccount()- try assertSnapshot(ThisMachineView(host: h), "this-machine-shared-with-account", size: CGSize(width: 640, height: 520))- account.token = nil- who.value = nil- await h.reconcileAccount()- #expect(h.panel.notice != nil)- try assertSnapshot(ThisMachineView(host: h), "this-machine-signed-out", size: CGSize(width: 640, height: 520))-- let off = HostModel(host: FixtureHost())- off.openForm()- off.send(.setName(name: "Studio"))- await off.submit()- await off.run(.hideDesktop)- #expect(off.panel.actions.first?.enabled == false)- try assertSnapshot(ThisMachineView(host: off), "this-machine-nothing-shared", size: CGSize(width: 640, height: 520))- }-/// Launch at login waiting for approval in System Settings (a fake/// login item; the Mac's own is never touched).@Test func settingsLoginItemApproval() async throws {@@ -429,37 +95,6 @@ struct SnapshotTests {#expect(item.calls == ["register"], "the first run's Done registered it")}- @Test func keyvaultAll() async throws {- let m = try await model()- let sel = KvSelection.category(category: .all)- m.keyvault.selection = sel- try assertSnapshot(VaultList(keyvault: m.keyvault, page: m.keyvault.page), "keyvault-all",- size: CGSize(width: 640, height: 520))- }-- @Test func approvalSheet() async throws {- let m = try await model()- m.keyvault.openApproval("req-1")- m.keyvault.sendApproval(.toggle(key: "chrome|example.test"))- try assertSnapshot(ApprovalSheet(keyvault: m.keyvault), "approval", size: CGSize(width: 480, height: 360))- }-- /// A new device asking: its name and the code it shows, Approve (after- /// Touch ID) and Deny; then this Mac waiting with its own code.- @Test func deviceSheets() async throws {- let d = DevicesTests().model()- await d.refresh()- d.setCode("k7qxm2rp")- try assertSnapshot(DeviceApprovalSheet(devices: d), "device-approval", size: CGSize(width: 420, height: 250))- var snap = FixtureDevices.sample(now: DevicesTests.now)- snap.devices[0].state = "pending"- let waiting = DevicesTests().model(FixtureDevices(snapshot: snap))- waiting.pollLimit = 1- waiting.startEnroll(in: .main)- await waiting.chooseEnroll(.approve)- try assertSnapshot(EnrollSheet(devices: waiting), "device-enroll-code", size: CGSize(width: 440, height: 300))- }-/// The notch panel in each state, settled, at its stage size (the/// 14-inch MacBook Pro layout; the view draws on a clear panel).func assertNotch(_ name: String, _ setup: (NotchModel) -> Void) async throws {diff --git a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/agents-page.png b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/agents-page.pngdeleted file mode 100644index 7da13de562..0000000000Binary files a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/agents-page.png and /dev/null differdiff --git a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/approval.png b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/approval.pngdeleted file mode 100644index 093b35dce4..0000000000Binary files a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/approval.png and /dev/null differdiff --git a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/device-approval.png b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/device-approval.pngdeleted file mode 100644index 2c460bf0c8..0000000000Binary files a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/device-approval.png and /dev/null differdiff --git a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/device-enroll-code.png b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/device-enroll-code.pngdeleted file mode 100644index a295041672..0000000000Binary files a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/device-enroll-code.png and /dev/null differdiff --git a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/discovery-warm-sidebar.png b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/discovery-warm-sidebar.pngdeleted file mode 100644index c86f24e8fe..0000000000Binary files a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/discovery-warm-sidebar.png and /dev/null differdiff --git a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/drive-page-sync.png b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/drive-page-sync.pngdeleted file mode 100644index 08356ec1dc..0000000000Binary files a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/drive-page-sync.png and /dev/null differdiff --git a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/drive-page.png b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/drive-page.pngdeleted file mode 100644index 223d33e5f0..0000000000Binary files a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/drive-page.png and /dev/null differdiff --git a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/host-setup.png b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/host-setup.pngdeleted file mode 100644index d7d268d711..0000000000Binary files a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/host-setup.png and /dev/null differdiff --git a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/keyvault-access.png b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/keyvault-access.pngdeleted file mode 100644index a9797878a0..0000000000Binary files a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/keyvault-access.png and /dev/null differdiff --git a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/keyvault-all.png b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/keyvault-all.pngdeleted file mode 100644index bdcfe63fe2..0000000000Binary files a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/keyvault-all.png and /dev/null differdiff --git a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/keyvault-delete-confirm.png b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/keyvault-delete-confirm.pngdeleted file mode 100644index 5eed4dbc17..0000000000Binary files a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/keyvault-delete-confirm.png and /dev/null differdiff --git a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/keyvault-review-sites.png b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/keyvault-review-sites.pngdeleted file mode 100644index 09079a74ce..0000000000Binary files a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/keyvault-review-sites.png and /dev/null differdiff --git a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/keyvault-review-vault.png b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/keyvault-review-vault.pngdeleted file mode 100644index d1f7d10672..0000000000Binary files a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/keyvault-review-vault.png and /dev/null differdiff --git a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/keyvault-unlock-prompt-batch.png b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/keyvault-unlock-prompt-batch.pngdeleted file mode 100644index 34daedb090..0000000000Binary files a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/keyvault-unlock-prompt-batch.png and /dev/null differdiff --git a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/keyvault-unlock-prompt.png b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/keyvault-unlock-prompt.pngdeleted file mode 100644index 93e91c2ede..0000000000Binary files a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/keyvault-unlock-prompt.png and /dev/null differdiff --git a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/keyvault-vault-grouped.png b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/keyvault-vault-grouped.pngdeleted file mode 100644index c41456f234..0000000000Binary files a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/keyvault-vault-grouped.png and /dev/null differdiff --git a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/keyvault-vault-hidden.png b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/keyvault-vault-hidden.pngdeleted file mode 100644index f2cce9b3ce..0000000000Binary files a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/keyvault-vault-hidden.png and /dev/null differdiff --git a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/keyvault-vault-multiselect.png b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/keyvault-vault-multiselect.pngdeleted file mode 100644index 3ffabfcbb9..0000000000Binary files a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/keyvault-vault-multiselect.png and /dev/null differdiff --git a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/keyvault-vault-search-type.png b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/keyvault-vault-search-type.pngdeleted file mode 100644index e0497a7bf3..0000000000Binary files a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/keyvault-vault-search-type.png and /dev/null differdiff --git a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/keyvault-vault-search.png b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/keyvault-vault-search.pngdeleted file mode 100644index 6fc6f8d716..0000000000Binary files a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/keyvault-vault-search.png and /dev/null differdiff --git a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/machine-connect-enrolled.png b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/machine-connect-enrolled.pngdeleted file mode 100644index e82c8dfbef..0000000000Binary files a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/machine-connect-enrolled.png and /dev/null differdiff --git a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/machine-connect-expired.png b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/machine-connect-expired.pngdeleted file mode 100644index 649debd993..0000000000Binary files a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/machine-connect-expired.png and /dev/null differdiff --git a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/machine-connect-not-enrolled.png b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/machine-connect-not-enrolled.pngdeleted file mode 100644index 4d7aeb28c3..0000000000Binary files a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/machine-connect-not-enrolled.png and /dev/null differdiff --git a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/machine-connect-pending.png b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/machine-connect-pending.pngdeleted file mode 100644index 6b664e3549..0000000000Binary files a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/machine-connect-pending.png and /dev/null differdiff --git a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/machine-desktop-and-spaces-off.png b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/machine-desktop-and-spaces-off.pngdeleted file mode 100644index 42242406a8..0000000000Binary files a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/machine-desktop-and-spaces-off.png and /dev/null differdiff --git a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/machine-desktop-not-shared.png b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/machine-desktop-not-shared.pngdeleted file mode 100644index f381f81d77..0000000000Binary files a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/machine-desktop-not-shared.png and /dev/null differdiff --git a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/machine-desktop-shared.png b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/machine-desktop-shared.pngdeleted file mode 100644index e507cf5494..0000000000Binary files a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/machine-desktop-shared.png and /dev/null differdiff --git a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/new-space-auto.png b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/new-space-auto.pngdeleted file mode 100644index 7d35ddb739..0000000000Binary files a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/new-space-auto.png and /dev/null differdiff --git a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/new-space.png b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/new-space.pngdeleted file mode 100644index 7ed3651338..0000000000Binary files a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/new-space.png and /dev/null differdiff --git a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/notifications-page.png b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/notifications-page.pngdeleted file mode 100644index c4a2840c91..0000000000Binary files a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/notifications-page.png and /dev/null differdiff --git a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/relay-os-Unknown.png b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/relay-os-Unknown.pngdeleted file mode 100644index ac1cf426d7..0000000000Binary files a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/relay-os-Unknown.png and /dev/null differdiff --git a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/relay-os-macOS.png b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/relay-os-macOS.pngdeleted file mode 100644index 42e5652811..0000000000Binary files a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/relay-os-macOS.png and /dev/null differdiff --git a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/setting-up-linux-runtime.png b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/setting-up-linux-runtime.pngdeleted file mode 100644index 1923ddb0f0..0000000000Binary files a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/setting-up-linux-runtime.png and /dev/null differdiff --git a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/sidebar-machine-load.png b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/sidebar-machine-load.pngdeleted file mode 100644index 9b76f3bb59..0000000000Binary files a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/sidebar-machine-load.png and /dev/null differdiff --git a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/sidebar-my-machines-not-enrolled.png b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/sidebar-my-machines-not-enrolled.pngdeleted file mode 100644index 6d6a8dc702..0000000000Binary files a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/sidebar-my-machines-not-enrolled.png and /dev/null differdiff --git a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/sidebar-power.png b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/sidebar-power.pngdeleted file mode 100644index b886fe0c1f..0000000000Binary files a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/sidebar-power.png and /dev/null differdiff --git a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/sidebar-signed-in.png b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/sidebar-signed-in.pngdeleted file mode 100644index 9c7a20d9a6..0000000000Binary files a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/sidebar-signed-in.png and /dev/null differdiff --git a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/sidebar-without-this-mac.png b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/sidebar-without-this-mac.pngdeleted file mode 100644index 6d5746cdf6..0000000000Binary files a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/sidebar-without-this-mac.png and /dev/null differdiff --git a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/sidebar.png b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/sidebar.pngdeleted file mode 100644index 03b9d04bf0..0000000000Binary files a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/sidebar.png and /dev/null differdiff --git a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/space-cover-connect-black.png b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/space-cover-connect-black.pngindex e82c8dfbef..97f3afaaa1 100644Binary files a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/space-cover-connect-black.png and b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/space-cover-connect-black.png differdiff --git a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/space-cover-connect.png b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/space-cover-connect.pngindex ff72039e1b..2c88fd800d 100644Binary files a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/space-cover-connect.png and b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/space-cover-connect.png differdiff --git a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/space-cover-connecting-black.png b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/space-cover-connecting-black.pngindex ecc323064f..88b13be54a 100644Binary files a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/space-cover-connecting-black.png and b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/space-cover-connecting-black.png differdiff --git a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/space-cover-connecting.png b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/space-cover-connecting.pngindex 1d0802be17..bffd3e5ca6 100644Binary files a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/space-cover-connecting.png and b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/space-cover-connecting.png differdiff --git a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/space-cover-stopped.png b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/space-cover-stopped.pngindex 2e972c4c85..385e27c0c1 100644Binary files a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/space-cover-stopped.png and b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/space-cover-stopped.png differdiff --git a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/space-facts-copied.png b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/space-facts-copied.pngdeleted file mode 100644index f2b6f6a246..0000000000Binary files a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/space-facts-copied.png and /dev/null differdiff --git a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/space-facts.png b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/space-facts.pngdeleted file mode 100644index f287d367f0..0000000000Binary files a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/space-facts.png and /dev/null differdiff --git a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/space-preview.png b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/space-preview.pngdeleted file mode 100644index eb3ceb962b..0000000000Binary files a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/space-preview.png and /dev/null differdiff --git a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/stream-section.png b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/stream-section.pngdeleted file mode 100644index 32ec4f9ecd..0000000000Binary files a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/stream-section.png and /dev/null differdiff --git a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/teleport-picker-grid.png b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/teleport-picker-grid.pngdeleted file mode 100644index 32528bc1da..0000000000Binary files a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/teleport-picker-grid.png and /dev/null differdiff --git a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/teleport-running-reading.png b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/teleport-running-reading.pngdeleted file mode 100644index 216fd66e47..0000000000Binary files a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/teleport-running-reading.png and /dev/null differdiff --git a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/teleport-running-upload.png b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/teleport-running-upload.pngdeleted file mode 100644index 48096483d9..0000000000Binary files a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/teleport-running-upload.png and /dev/null differdiff --git a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/this-machine-nothing-shared.png b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/this-machine-nothing-shared.pngdeleted file mode 100644index 5b6f8e56cf..0000000000Binary files a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/this-machine-nothing-shared.png and /dev/null differdiff --git a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/this-machine-shared-with-account.png b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/this-machine-shared-with-account.pngdeleted file mode 100644index 43f40f1213..0000000000Binary files a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/this-machine-shared-with-account.png and /dev/null differdiff --git a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/this-machine-signed-out.png b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/this-machine-signed-out.pngdeleted file mode 100644index 3cd1aa8415..0000000000Binary files a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/this-machine-signed-out.png and /dev/null differdiff --git a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/this-machine-unset.png b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/this-machine-unset.pngdeleted file mode 100644index 2db7205b40..0000000000Binary files a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/this-machine-unset.png and /dev/null differdiff --git a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/this-machine.png b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/this-machine.pngdeleted file mode 100644index aedf309ab8..0000000000Binary files a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/Snapshots/this-machine.png and /dev/null differdiff --git a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/WizardRunOnTooltipTests.swift b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/WizardRunOnTooltipTests.swiftdeleted file mode 100644index 01e0cba579..0000000000--- a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/WizardRunOnTooltipTests.swift+++ /dev/null@@ -1,36 +0,0 @@-// SPDX-License-Identifier: FSL-1.1-MIT-// Copyright (c) 2026 Cua AI, Inc.--@testable import CuaSpacesMacKit-import CuaSpacesFFI-import Testing--/// New Space's "Run on" tooltip says what This Mac runs the Space on, for-/// every system (in 0.7.2 for Linux and Windows too; it regressed to macOS-/// only). The menu itself now carries the chosen place's line-/// (`NewSpaceWizardView.runOnHelp`), so it no longer depends on which item-/// SwiftUI's menu kept the tooltip of.-@Suite("New Space Run on tooltip")-@MainActor-struct WizardRunOnTooltipTests {- @Test func theTooltipFollowsTheSystem() async throws {- let m = ViewModelTests().makeModel(FixtureSpacesBackend(), kv: nil, host: FixtureHost(),- account: FixtureAccount(), agents: FixtureAgentSetup(),- loginItem: FixtureLoginItem())- m.onboarding.finish()- await m.refresh()- await m.openNewSpace()- var seen: [AppSpaceOs: String] = [:]- // macOS first, then the others: each one's own line, never the last one's.- for os in [AppSpaceOs.macos, .linux, .windows, .macos] {- m.wizard.send(.chooseOs(os: os))- m.wizard.send(.choosePlacement(on: "local"))- let v = m.wizard.view- #expect(v.placementId == "local")- seen[os] = NewSpaceWizardView.runOnHelp(v)- }- #expect(seen[.linux] == "Linux, on this Mac")- #expect(seen[.windows] == "QEMU virtual machine on this Mac")- #expect(seen[.macos] == "Lume virtual machine (Apple silicon)")- }-}