// Routing and filters over the shared list/page; ingestion, sync and mailbox// writes stay in Rust. EmailRecords adapts the current boundary until the// generic engine-backed Records seam can serve the same envelope columns.importCottonKitimportSwiftUIstructEmailArchiveSurface: View {/// What the Email tool shows: its ONE list of mail, newest first, with its/// groups drawn as stacks above it (owner, 11 Oct 2026: the seven-way/// folder menu felt infinite). The people who write and the blocked ones/// are the list's link tiles (email_thread.json's `links` and `link_tiles`), and a/// sender's page lists their mail — nothing here draws a way to them.let id: String?/// The message a Find hit matched: the conversation opens on it rather/// than at the newest (mailsearch). The page fetches it when it is older/// than the first page, and only when it is in this conversation.var at: String? = nil @Environment(\.cottonCore) privatevar core @State privatevar archive: EmailRecords? @Environment(\.tableDefinitions) privatevar definitions @Environment(Navigator.self) privatevar navigator @Environment(ToolViews.self) privatevar views: ToolViews?var body: someView {Group {if archive != nil { content }elseif core == nil {QuietState(title: ShellLines.line("email", "archive.unread_title"), message: ShellLines.line("email", "archive.unread_body")) } else { SkeletonPage(rows: 3) } } .environment(\.records, archive) .task {if archive == nil, let core { archive = EmailRecords(core: core, definitions: definitions.all) } } } @ViewBuilder privatevar content: someView {iflet definition = definitions["email_thread"] {iflet id {// A mail conversation opens on its own (`ConversationRoute`),// at the message a search found.ConversationRoute(table: definition.id, id: id, anchor: at) } else {// ONE list: the view the ring over the fan chose (Today, Records,// People, Junk, All — email_thread.json's `tool.views`), read// exactly as it says; no stacks, the ring moves between them.let view = views?.current(of: "email")ifDeckSwitch.draws(definition, view: view?.read, plain: true) {// No scrolling lists: the mail is its deck, the ring's// views rolling one into the next.DeckSurface(definition: definition, filter: view?.read.filter ?? [:], view: view?.read, rollover: { forward inguardlet views,let next = views.neighbour(of: "email", step: forward ? 1 : -1)else { returnnil } views.choose(next.id, of: "email")return next.label }) } else {RecordListSurface(definition: definition, where: view?.read.filter ?? [:], view: view?.read) { record in navigator.push(.emailId(id: record.id)) } .id(view?.id) } } } }}