// The board parts that read their own source (design note 26203e21)://// • `list` — one table's records as one section, drawn by the same// `BoardSection` a tool's section is, under the part's heading;// • `facts` — the record of the table `source` for the database this window// shows (the `database` source's row: its name, colour, what is kept),// drawn as that record's page face, read only. A tap opens its whole page,// where a column is edited — the board never edits in place;// • `device` — this device's own record, the one the core served the board// naming, drawn by the device tool's card over its live sync columns// (`shell.today`'s device card). On the phone's deck it is Home's first card// (`HomeToday`); a page of parts draws it here. A tap opens This device.//// Each is a part on its own: none draws another part.importCottonKitimportCottonValuesimportSwiftUI/// The `list` part: the rows the core answered, as one section.structBoardListPart: View {let entry: BoardEntrylet onOpen: (GridTile) -> Voidlet onOpenRecord: (TableRecord, BoardSectionItem) -> Voidlet onToggle: (TableRecord, TableDefinition) -> Void @Environment(\.tableDefinitions) privatevar definitionsvar body: someView {iflet table = entry.table, let definition = definitions[table] {let records = entry.recordslet section = BoardSectionItem( tile: GridTile(key: "list-\(table)", name: entry.heading ?? "", picture: nil, opens: .route(BoardLayout.route(forTable: definition))), definition: definition, read: ToolTileRead(records: records, count: entry.count ?? records.count, linkTitles: LinkTitles(), next: nil), whole: true)BoardSection( section: section, onOpen: { onOpen(section.tile) }, onToggle: { onToggle($0, section.definition) }, onOpenRecord: { onOpenRecord($0, section) }) } }}/// The `facts` part: the shown database's record of the table `source`, as/// its page face, each column in the words the core answered.structBoardFactsPart: View {let entry: BoardEntry/// Opens the record on its deck.let onOpen: () -> Void @Environment(\.tableDefinitions) privatevar definitionsvar body: someView {iflet source = entry.source, let id = entry.record, let definition = definitions[source] {RecordCardFace(definition: definition, record: TableRecord(id: id, values: Dictionary(uniqueKeysWithValues: entry.facts.map { ($0.key, RecordValue.text($0.value)) }))) .contentShape(Rectangle()) .onTapGesture(perform: onOpen) .accessibilityIdentifier("board-facts-\(source)") } }}/// The `device` part on a page of parts: this device's own record (`id`, the/// one the core served the board naming) as the device tool's card, as Home's/// page answers it (`shell.today`) and read again alone on each sync revision/// and every few seconds, so its sync rows are the phone's as they move. A/// tap opens This device.structBoardDevicePart: View {let id: String @Environment(\.cottonCore) privatevar core @Environment(\.cottonSync) privatevar sync @Environment(\.tableDefinitions) privatevar definitions @Environment(Navigator.self) privatevar navigator: Navigator?/// This device's card, as the core dealt it (`shell.today {only: device}`). @State privatevar card: TodayAnswer.Card?privatestructAsked: Hashable {var id: Stringvar revision: Intvar pulled: String? }privatestructDeviceAsk: Encodable, Sendable { let only = "device" }privatestructDeviceRead: Decodable, Sendable { let cards: [TodayAnswer.Card] }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(spacing: 0) {iflet card, let definition = definitions[card.table ?? "device"] {RecordCardFace(definition: definition, record: card.deck.record.record) .contentShape(Rectangle()) .onTapGesture { navigator?.open(.device) } .accessibilityIdentifier("board-device") } }// It moves with every sync pass: read again on each, and every few// seconds. A read that fails keeps the card it has. .task(id: Asked(id: id, revision: sync?.revision ?? 0, pulled: sync?.lastPullAt)) {while !Task.isCancelled {iflet core, let read = try? await core.call(CottonMethod.shellToday, DeviceAsk(), as: DeviceRead.self),let next = read.cards.first, next != card { card = next }try? awaitTask.sleep(for: .seconds(HomeSyncKnobs.every)) } } }}