// WHICH LIST a route was picked from, and the whole path a host that draws // columns opens for a link. // // `RouteTier` says what SHAPE a route is. This says what a route is picked // FROM, and it exists because a tier alone cannot open a link into a record on // a host with more than one column: `tinmen-cotton://…/notes/note/` names // the note and nothing else, so a host that only pushed it put the record // beside whichever list happened to be open — on the Mac, the Todos the launch // selects — and lit the sidebar on a row nobody clicked. That is what the Mac // walk found (walk-07, walk-11): a record with the wrong list beside it, and // on the built app no page column at all. // // **It lives here, beside `Route`, for `RouteTier`'s reason**: which list a // record belongs to is a fact about the SCREEN, not about a window. The phone // has one column and never asks; the Mac asks on every link. A second table in // the Mac's host would be a second opinion about where a record lives, and it // would go quiet rather than red the day a record moved lists. // // **The switch is TOTAL and carries no `default`**, exactly as `Route.path`, // `Route.tier` and `Boot/RouteScreen.swift` do. A new route does not compile // until somebody says which list it is picked from. A `default` would quietly // answer "todos" for a screen nobody looked at, which is the very defect this // file is here to remove. import Foundation extension Route { /// **The list column's root for this route** — the list it is picked from. /// /// A list is its own root. A page names the list it belongs to, so a link /// straight into a record opens that list beside it and the sidebar lights /// on the row a person would have clicked to get there. `nil` is the two /// tiers that are never in a path: the launcher IS the sidebar, and an /// action is an instruction rather than a screen. public var listRoot: Route? { switch self { case .raised(let page, _): return page.listRoot // ── never in a path ─────────────────────────────────────────────── case .root, .home, .capture, .take, .keyboardTake: return nil // ── a list is its own root ──────────────────────────────────────── case .money, .activity, .alarms, .bin, .tools, .calendar, .calendarMonth, .callsHistory, .code, .devices, .documents, .email, .goals, .storage, .deviceStorage, .journal, .tableList, .toolBoard, .locations, .meetings, // The meetings list with the recorder up: a list, never a page. .meetingsRecord, .memoryDropped, .messages, .messagesStarred, .mood, .news, .notes, .passwords, .people, // The People list with the import up: a list, never a page. .peopleImport, .peoplePersonSection, .photos, .photosAlbums, .photosDuplicates, .photosPeople, .projects, .projectsCode, .projectsFeedback, .projectsFeedbackReport, .projectsMemory, .projectsSlug, .projectsSlugSection, .projectsTodos, .reader, .rejected, .members, .voiceWords, .database, .device, .backup, .server, .bringIn, .export, .search, .thoughts, .todos, .todosDone, .todosDropped, .videos: return self // ── a page, and the list it was picked from ─────────────────────── // A Money record opens beside its accounts list. case .moneyAccount, .moneyStatement, .moneyTransaction: return .money // The briefing is the day's own reading, and the day is the timeline. case .briefing: return .todos(new: false) // An event belongs to the DAY it is on, so the list beside it is the // calendar showing that day rather than today. case .calendarEvent(_, let date, _), .calendarEventEdit(_, let date, _): return .calendar(date: date) case .callsCall: return .callsHistory(person: nil) case .documentsDocument, .documentsDocumentViewer, .documentsImport: return .documents(status: nil) case .emailId: return .email case .goalsGoal: return .goals // A journal day and today's page are both the journal's. case .journalDate, .notesJournalToday: return .journal // A capture is picked from the thoughts list — every one, newest // first. Asked of you holds only what someone asked the owner. case .thoughtsThought: return .thoughts // The legal pages are reached from About and nowhere else; one device // asking to join is a row on the Devices waiting list even when the // push is what opened it. case .legalPrivacy, .legalTerms: return .tools case .settingsJoinRequest: return .devices case .locationsLocation: return .locations case .meetingsMeeting: return .meetings(importing: false) // A memory is a project's, always: there is no global layer, so the // list a sentence is picked from is the projects list. case .memory: return .projects case .messagesImport, .messagesInfo, .messagesMedia, .messagesNew, .messagesThread: return .messages // `/news` IS the News tool — today's edition and every past one under // it — so an older edition, the settings page and the topic form all // come off it. There is no Editions index and no Topics list any more // (2026-09-21). case .newsEdition, .newsSettings, .newsTopic, .newsTopicNew: return .news case .notesNote: return .notes case .passwordsSecret: return .passwords // Me is the owner's own People row. case .peoplePerson, .me: return .people case .photosAlbum, .photosAlbumAdd: return .photosAlbums // A shot lands in the library, so the camera is the photos' too. case .photosPhoto, .camera: return .photos(show: nil) // A project has no page of its own (it is the database page), so the // list beside its brand sheet is the projects index. case .projectsBrand: return .projects case .readerPage: return .reader // Every session card lives on the Code screen now — there is no // sessions list — so the page a session's own page was picked from is // `/code`. case .sessionsId, .sessionsTerminal, .codeNew: return .code // The defaults are one page, opened from the Code list itself. case .codeDefaults: return .code // One machine is picked from the list of machines, and from nowhere // else: the Devices tool is the only surface that holds them now. // This device's host-drawn pages are opened from its own record // page, which is picked from the same list. case .devicesId, .hostPage: return .devices case .membersId, .membersAdmit: return .members // A word is picked from the Voice words list and nowhere else. case .voiceWordsId: return .voiceWords case .about, .aboutWhatsNew, .aboutHelp: return .tools // A record no named route addresses is picked from its table's list: // the NAMED list that draws that table when there is one (an // assistant's placement lists are `/placements`), else the generic // `/lists/[table]`. The generic list over a Settings-backed table reads // the database's store rather than the table's own source, so a link // to a placement list opened a list beside it that held nothing. case .tableRecord(let table, _): return Route.namedList(ofTable: table) ?? .tableList(table: table, filter: nil, title: nil, query: nil) // A line of Storage is picked from the Storage list and nowhere else. case .storageId: return .storage case .todosTodo: return .todos(new: false) case .videosVideo: return .videos } } /// **The whole path a host that draws COLUMNS opens for a route that came /// from outside** — a deep link, a notification, a held tap /// replayed at launch. /// /// A list is one route: it REPLACES whatever the columns were showing, /// because a person following a link to Notes has chosen what they are /// looking at and the Todos the launch selected is not it. A record is a /// PAIR — its list, then itself — so column 2 shows what it was picked /// from and column 3 shows the record. The two tiers that are never in a /// path answer with an empty path: the launcher is the sidebar's own, and /// an action raises capture and moves nothing. public var columnPath: [Route] { guard let root = listRoot else { return [] } return root == self ? [root] : [root, self] } /// **The named list route that draws a table's whole list**, by table id — /// the ONE answer to "which list is `/lists/[table]/[id]` picked from" /// when that table has a list of its own address. /// /// A named list (`/notes`, `/assistants`) is the screen a /// person actually opens; `/lists/[table]` is the generic narrowed list. /// Without this a record of a named list's table — pushed from that list, /// or arriving as a link — named the generic list as its parent, which is /// not the list standing in the column. `RouteColumnsTests` holds every /// entry to be a list that is its own root. public static let namedTableLists: [String: Route] = [ "album": .photosAlbums, "alarm": .alarms, "bin": .bin, "device": .devices, "duplicate": .photosDuplicates, "goal": .goals, "journal": .journal, "location": .locations, "member": .members, "money_account": .money, "mood": .mood, "news_edition": .news, "note": .notes, "page": .reader, "person": .people, "storage": .storage, "thought": .thoughts, "thread": .messages, "voice_word": .voiceWords, ] /// The named list that draws `table`'s whole list, or `nil` when the table /// has none and is listed at `/lists/[table]`. public static func namedList(ofTable table: String) -> Route? { namedTableLists[table] } }