// SETTINGS' FIRST TWO CARDS (owner, 1 Nov 2026): Backup and Cotton server,// shell screens over the personal object's session (`PersonalObject`), never// definitions — they hold the way to a credential. The settings board lists// them only where the manifest names a personal object (`needs:// personal_object`), so Rigby's never shows them and nothing here asks which// flavour this is.//// - Backup, before sign-in: what backing up does, one act (Back up: the// number-and-code sheet), and the line for a person who already has a// Cotton. Signed in with rows made on this phone: how many have gone up// (`personal.adopt`), polled once a second while the card is up, then// Backed up — or the object's line and Try again. Connected: this phone's device card// (the sync status Home's first card used to carry), Stop backing up, and// Remove from this phone last, red, asked first.// - Cotton server, before sign-in: what the server adds, and that it needs// backup. Connected: the server's address, and that MCP keys are made from// the assistants' side for now (making them on the phone is a later job;// nothing untrue is said).//// A tool whose rows only the server brings says so on its empty deck before// backup (`ToolServerLine`), with Back up opening this card.importCottonKitimportSwiftUI/// `/backup` — Settings › Backup.structBackupRoute: View { @Environment(PersonalObject.self) privatevar personal: PersonalObject?var body: someView {iflet personal {BackupScreen(personal: personal) } else {// An app whose manifest names no personal object lists no Backup// card; a link here draws nothing.PaperScreen { EmptyView() } } }}structBackupScreen: View {let personal: PersonalObjectvar body: someView {PaperScreen(title: ShellLines.line("board", "object.backup.title"), clearsFan: true) {OpenedCardContent {if personal.stand == .connected { ThisDeviceCard() } } acts: { VStack(alignment: .leading, spacing: BackupCardKnobs.gap) {switch personal.stand {case .local:Text(ShellLines.line("board", "object.backup.body")).paperBody(BackupCardKnobs.body)TypedRow(symbol: "phone", label: ShellLines.line("board", "object.backup.act")) {Task { await personal.backUp() } } .accessibilityIdentifier("backup-act")Text(ShellLines.line("board", "object.backup.again")).paperBody(BackupCardKnobs.small, ink: .pencil)case .connecting:Text(ShellLines.line("board", "object.backup.connecting")).paperBody(BackupCardKnobs.body, ink: .pencil)case .backingUp:Text(personal.backupLine).paperBody(BackupCardKnobs.body) .accessibilityIdentifier("backup-progress")case .backupFailed:Text(personal.backupLine).paperBody(BackupCardKnobs.body) .accessibilityIdentifier("backup-failed")TypedRow(symbol: "arrow.clockwise", label: ShellLines.line("board", "object.backup.try_again")) {Task { await personal.backUp() } } .accessibilityIdentifier("backup-try-again")TypedRow(label: ShellLines.line("board", "object.backup.stop"), chevron: false) {Task { await personal.stopBackingUp() } } .accessibilityIdentifier("backup-stop")case .connected:if personal.backedUp {Text(ShellLines.line("board", "object.backup.backed_up")).paperBody(BackupCardKnobs.body) .accessibilityIdentifier("backup-done") }TypedRow(label: ShellLines.line("board", "object.backup.stop"), chevron: false) {Task { await personal.stopBackingUp() } } .accessibilityIdentifier("backup-stop") }if personal.stand == .local || personal.stand == .connected {TypedRow(label: ShellLines.line("board", "object.backup.remove"), chevron: false, destructive: true) { personal.asksRemoval = .remove } .accessibilityIdentifier("backup-remove") }if personal.isLocal, !personal.asking, let refusal = personal.refusal ?? personal.home?.notices.first(where: { $0.id == "signed_out" })?.words {CustomerRefusalLine(refusal: refusal) } } } }// While the rows go up, the card asks where they stand once a second. .task { await personal.refresh() } .task(id: personal.isBackingUp) {while personal.isBackingUp, !Task.isCancelled {await personal.followAdopt()try? awaitTask.sleep(for: .seconds(1)) } }// The sign-in sheet and the ask before Remove are the root's// (`PersonalSheets`), raised from here and from Home's card alike. .accessibilityIdentifier("backup-page") }}/// `/server` — Settings › Cotton server.structServerRoute: View { @Environment(PersonalObject.self) privatevar personal: PersonalObject?var body: someView {PaperScreen(title: ShellLines.line("board", "object.server.title"), clearsFan: true) { VStack(alignment: .leading, spacing: BackupCardKnobs.gap) {iflet personal, personal.stand == .connected { HStack {Text(ShellLines.line("board", "object.server.address")).paperBody(BackupCardKnobs.body, ink: .pencil)Spacer()Text(personal.server).paperBody(BackupCardKnobs.body) .textSelection(.enabled) }Text(ShellLines.line("board", "object.server.keys")).paperBody(BackupCardKnobs.small, ink: .pencil) } else {Text(ShellLines.line("board", "object.server.body")).paperBody(BackupCardKnobs.body)Text(ShellLines.line("board", "object.server.needs")).paperBody(BackupCardKnobs.small, ink: .pencil) .accessibilityIdentifier("server-needs") } } } .accessibilityIdentifier("server-page") }}/// This phone's own device card — the device tool's card with its sync rows,/// as Home's `device` part drew it — for the record `read.devices` names this/// device.structThisDeviceCard: View { @Environment(\.cottonCore) privatevar core @State privatevar id: String?var body: someView {// A stack, not a Group: a Group with nothing in it is no view, so its// task would never run and the card never be read (walk, 1 Nov 2026). VStack(alignment: .leading, spacing: 0) {iflet id { BoardDevicePart(id: id) } } .task {guard id == nil, let core else { return } id = (try? await core.callJSON(CottonMethod.readDevices))?.untrimmed("thisDevice") } }}/// The sizes the two cards draw with: Swift's own, beside their reader.enumBackupCardKnobs {staticlet gap: CGFloat = 18staticlet body: CGFloat = 16staticlet small: CGFloat = 14}/// What a tool's empty deck says before backup: the line of the tool that/// owns `table` and whose rows only the server brings (`server.needs`) —/// the table's own built-in tool (Calls) or a package tool whose tables or/// views read it — from the tool's definition alone. Nil where no such tool/// owns the table.enumToolServerLine {staticfunc of(_ table: TableDefinition, tools: [ToolDefinition]) -> String? {iflet server = table.tool?.server, server.needs { return server.line }let owning = tools.first { tool inguardlet server = tool.server, server.needs else { returnfalse }return tool.tables.contains(table.id) || tool.views.contains { $0.read["table"] == .string(table.id) } }return owning?.server?.line }}