The open-source Arc replacement for macOS. Spaces, pinned tabs, split view, Little Windows and Arc's shortcuts on Chromium, with your Arc sidebar imported in one go.
Keep the core free of AppKit, with fixtures recorded from current behaviour (#51) (#72)
Victor Kildahl3770bdca4946
diff --git a/CLAUDE.md b/CLAUDE.mdnew file mode 100644index 0000000..df7367d--- /dev/null+++ b/CLAUDE.md@@ -0,0 +1,55 @@+# Cra: notes for coding agents++[CONTRIBUTING.md](CONTRIBUTING.md) says what fits (Arc parity one to one, no built-in AI,+nothing leaves the Mac) and how to send a change. [docs/development.md](docs/development.md)+has the layout and the tests, and [docs/testing.md](docs/testing.md) has the test rules. This+file holds the layer rules.++## Layers++| Layer | Where | Imports |+|---|---|---|+| Core | `Packages/CraCore` | Foundation, CoreGraphics, Observation |+| App | `Sources/Cra` | CraCore, AppKit, SwiftUI, CraCEF |+| Bridge | `Sources/CraCEF` | CEF (Objective-C++, seen by Swift through `include/`) |+| Helper | `Sources/CraHelper` | CEF (the Chromium subprocess) |++CraCore never imports AppKit, Cocoa, SwiftUI, UIKit or CraCEF. `scripts/lint.py`+(`core-platform-import`) fails the build when it does. CraCore is a package of its own, so+`swift test --package-path Packages/CraCore` runs without `vendor/cef`. Every app file sees it+through `Sources/Cra/App/CraCoreExports.swift`.++1. **Decisions go in CraCore.** Code that decides something without a window or a page (a+ model, a file format, a layout rule, a policy) goes in CraCore, with a test. Its API is+ `public` because the app is another package.+2. **Split a type that needs AppKit for part of its job.** The value goes in CraCore and the+ AppKit side becomes an extension in the app: `KeyChord` and `Shortcut`, `FaviconKey` and+ `FaviconCache`.+3. **A decoder reads only its own file.** A one-time migration that needs anything else+ (another app's preferences, the disk) takes it as an argument and runs where the file is+ loaded. Example: `AppSettings.migrateToolbarDefault(arcShowsToolbar:)`, called by+ `SidebarStore`.+4. **Data-folder formats don't change by accident.**+ `Packages/CraCore/Tests/CraCoreTests/Fixtures/Model` holds current and older+ `sidebar.json`, `settings.json`, `windows.json`, `keybindings.json` and the others. Each+ comes with what Cra saved after loading it. If a change makes a file load differently,+ record the new expectation and say why in the PR.+5. **Run `scripts/test.sh` before a PR.** CI runs it as well, with the coverage gates in+ docs/testing.md.++## Known exceptions++This logic is pure enough for CraCore but still lives in the app. Move a piece when a change+touches it anyway, not as a side errand.++- `Services/SuggestionEngine.swift`: the command bar's ranking. It holds `SidebarStore`,+ `KeyBindingRegistry` and `SearchSuggestions`.+- `Services/SidebarStore.swift` and `SidebarIntegrity.swift`: tree edits and repair, on+ `JSONStore` files, the app's clock and `ArcImporter`. Tested by `scripts/test-store.sh`.+- `App/KeyBindings.swift`: `KeyAction`, `MenuSection` and the default bindings, in a file that+ imports AppKit for `Shortcut`'s event matching.+- `Services/Import/`: the parsers for other browsers' files. Tested on `Tests/Fixtures` by+ `scripts/test-store.sh`.+- `UI/ToolbarComposition.swift`, `UI/Windows/ExtensionLaunch.swift`,+ `Services/DevToolsToggle.swift` and `UI/Windows/FloatingSidebarGeometry.swift`: policies,+ tested by `scripts/test-policies.sh` and `scripts/test-floating-sidebar.sh`.diff --git a/Packages/CraCore/Sources/CraCore/FaviconKey.swift b/Packages/CraCore/Sources/CraCore/FaviconKey.swiftnew file mode 100644index 0000000..25097dd--- /dev/null+++ b/Packages/CraCore/Sources/CraCore/FaviconKey.swift@@ -0,0 +1,9 @@+import Foundation++/// What favicons are cached under: the page's host, lowercased (Arc: SidebarItemsFaviconCache).+public enum FaviconKey {+ public static func key(for urlString: String) -> String? {+ guard let host = URL(string: urlString)?.host, !host.isEmpty else { return nil }+ return host.lowercased()+ }+}diff --git a/Sources/Cra/Services/ItemTable.swift b/Packages/CraCore/Sources/CraCore/ItemTable.swiftsimilarity index 78%rename from Sources/Cra/Services/ItemTable.swiftrename to Packages/CraCore/Sources/CraCore/ItemTable.swiftindex b651bff..fb65fa1 100644--- a/Sources/Cra/Services/ItemTable.swift+++ b/Packages/CraCore/Sources/CraCore/ItemTable.swift@@ -4,8 +4,10 @@ import Observation/// One sidebar item's change counter. A view that read the item depends on this, not on/// every item.@MainActor @Observable-final class ItemSignal {- var version = 0+public final class ItemSignal {+ public var version = 0++ public init() {}}/// The sidebar's items, observed one by one. As a single `[UUID: SidebarItem]` property, any@@ -13,13 +15,15 @@ final class ItemSignal {/// and row in every space. Now a view re-renders when an item it read changed; a walk over/// all items (`all`, `values`) still depends on every change.@MainActor @Observable-final class ItemTable {+public final class ItemTable {@ObservationIgnored private var storage: [UUID: SidebarItem] = [:]@ObservationIgnored private var signals: [UUID: ItemSignal] = [:]/// Bumped on every change: what a walk over all items observes.private var version = 0- subscript(id: UUID) -> SidebarItem? {+ public init() {}++ public subscript(id: UUID) -> SidebarItem? {get {observe(id)return storage[id]@@ -31,19 +35,19 @@ final class ItemTable {}}- var all: [UUID: SidebarItem] {+ public var all: [UUID: SidebarItem] {_ = versionreturn storage}- var values: Dictionary<UUID, SidebarItem>.Values { all.values }+ public var values: Dictionary<UUID, SidebarItem>.Values { all.values }/// Depend on `id` without reading it (state kept elsewhere, keyed by the item: expansion,/// selection).- func observe(_ id: UUID) { _ = signal(id).version }+ public func observe(_ id: UUID) { _ = signal(id).version }/// What reads `id` is out of date.- func notify(_ id: UUID) {+ public func notify(_ id: UUID) {signal(id).version &+= 1version &+= 1}diff --git a/Packages/CraCore/Sources/CraCore/KeyChord.swift b/Packages/CraCore/Sources/CraCore/KeyChord.swiftnew file mode 100644index 0000000..263f68c--- /dev/null+++ b/Packages/CraCore/Sources/CraCore/KeyChord.swift@@ -0,0 +1,49 @@+/// A keyboard shortcut as keybindings.json stores it: `key` is the lowercase character or a+/// special key (`tab`, `left`...), `modifiers` the device-independent modifier bits of+/// AppKit's NSEvent.ModifierFlags. The app reads events into it (Shortcut in KeyBindings.swift).+public struct KeyChord: Codable, Hashable {+ public var key: String+ public var modifiers: UInt++ public init(key: String, modifiers: UInt) {+ self.key = key+ self.modifiers = modifiers+ }++ /// NSEvent.ModifierFlags' bits for the four keys a shortcut can hold.+ public struct Modifiers: OptionSet, Hashable {+ public let rawValue: UInt+ public init(rawValue: UInt) { self.rawValue = rawValue }+ public static let shift = Modifiers(rawValue: 1 << 17)+ public static let control = Modifiers(rawValue: 1 << 18)+ public static let option = Modifiers(rawValue: 1 << 19)+ public static let command = Modifiers(rawValue: 1 << 20)+ }++ public var keys: Modifiers { Modifiers(rawValue: modifiers) }++ public static let tab = "\t"+ // AppKit's function-key characters (NSLeftArrowFunctionKey...).+ public static let left = "\u{F702}"+ public static let right = "\u{F703}"+ public static let up = "\u{F700}"+ public static let down = "\u{F701}"++ /// How menus and the command bar show it: ⌃⌥⇧⌘ in Apple's order, then the key.+ public var display: String {+ var s = ""+ if keys.contains(.control) { s += "⌃" }+ if keys.contains(.option) { s += "⌥" }+ if keys.contains(.shift) { s += "⇧" }+ if keys.contains(.command) { s += "⌘" }+ switch key {+ case Self.tab: s += "⇥"+ case Self.left: s += "←"+ case Self.right: s += "→"+ case Self.up: s += "↑"+ case Self.down: s += "↓"+ default: s += key.uppercased()+ }+ return s+ }+}diff --git a/Sources/Cra/Model/LinkRouting.swift b/Packages/CraCore/Sources/CraCore/LinkRouting.swiftsimilarity index 77%rename from Sources/Cra/Model/LinkRouting.swiftrename to Packages/CraCore/Sources/CraCore/LinkRouting.swiftindex f19b4df..ccf0ba7 100644--- a/Sources/Cra/Model/LinkRouting.swift+++ b/Packages/CraCore/Sources/CraCore/LinkRouting.swift@@ -6,10 +6,10 @@ import Foundation// and anything else goes to the default destination./// Arc's LinkSourceTextMatchingStyle (`matches` / `contains`).-enum LinkMatchStyle: String, Codable, CaseIterable, Identifiable {+public enum LinkMatchStyle: String, Codable, CaseIterable, Identifiable {case equals, contains- var id: String { rawValue }- var label: String { self == .equals ? "Is equal to" : "Contains" }+ public var id: String { rawValue }+ public var label: String { self == .equals ? "Is equal to" : "Contains" }}/// Arc's LinkDestination is `space(ProfileDestination)` or `littleArc(ProfileDestination)`@@ -18,24 +18,31 @@ enum LinkMatchStyle: String, Codable, CaseIterable, Identifiable {/// opened with "Open in <most recent space>", so Cra has no profiles and no space here./// A space destination opens a new foreground tab in that space's Today list (also when/// the URL is already open) and switches the window to the space.-enum LinkDestination: Codable, Hashable {+public enum LinkDestination: Codable, Hashable {case mostRecentSpacecase space(UUID)case littleWindow}-struct LinkRoute: Codable, Identifiable, Equatable {- var id = UUID()- var match: LinkMatchStyle = .contains- var text = ""- var destination: LinkDestination = .mostRecentSpace+public struct LinkRoute: Codable, Identifiable, Equatable {+ public var id = UUID()+ public var match: LinkMatchStyle = .contains+ public var text = ""+ public var destination: LinkDestination = .mostRecentSpace++ public init(id: UUID = UUID(), match: LinkMatchStyle = .contains, text: String = "", destination: LinkDestination = .mostRecentSpace) {+ self.id = id+ self.match = match+ self.text = text+ self.destination = destination+ }/// Matches like Arc 1.170 (observed by handing it links, see docs/arc-reverse-engineering.md):/// both sides lose case, the scheme and a leading `www.`; "Contains" then searches the/// rest including query and fragment, while "Is equal to" also drops the query, the/// fragment and trailing slashes, so `example.com/a` equals `http://www.example.com/a/?x#y`/// but not `example.com/a/b`. An empty route matches nothing.- func matches(_ url: String) -> Bool {+ public func matches(_ url: String) -> Bool {let want = Self.normalized(text.trimmingCharacters(in: .whitespacesAndNewlines))guard !want.isEmpty else { return false }let have = Self.normalized(url)@@ -61,12 +68,12 @@ struct LinkRoute: Codable, Identifiable, Equatable {/// Arc seeds this route once (AppState+DefaultLinkRoutes, `didSetDefaultGoogleMeetRoute`)/// so calls open in a full window rather than in Little Arc.- static let googleMeet = LinkRoute(match: .contains, text: "meet.google.com", destination: .mostRecentSpace)+ public static let googleMeet = LinkRoute(match: .contains, text: "meet.google.com", destination: .mostRecentSpace)}extension AppSettings {/// Where a link from another app opens: the first matching route, else the default.- func destination(forExternalURL url: String) -> LinkDestination {+ public func destination(forExternalURL url: String) -> LinkDestination {linkRoutes.first { $0.matches(url) }?.destination ?? defaultLinkDestination}}@@ -74,10 +81,10 @@ extension AppSettings {/// Arc's Peek opens links "to other sites": the registrable domain differs, so a link from/// mail.google.com to accounts.google.com stays in the tab. Cra has no public suffix list;/// a generic second-level label under a country code (co.uk, com.au) counts as suffix.-enum SiteKey {+public enum SiteKey {private static let secondLevel: Set<Substring> = ["co", "com", "net", "org", "gov", "edu", "ac", "ne", "or", "go", "gv"]- static func site(of url: String) -> String? {+ public static func site(of url: String) -> String? {guard let u = URL(string: url), let scheme = u.scheme?.lowercased(), scheme == "http" || scheme == "https",let host = u.host?.lowercased(), !host.isEmpty else { return nil }let labels = host.split(separator: ".")diff --git a/Packages/CraCore/Sources/CraCore/LiveFolderModel.swift b/Packages/CraCore/Sources/CraCore/LiveFolderModel.swiftnew file mode 100644index 0000000..6f662f4--- /dev/null+++ b/Packages/CraCore/Sources/CraCore/LiveFolderModel.swift@@ -0,0 +1,107 @@+import Foundation++// Live folders: folders that fill themselves from a service and empty as items close.+// Shape follows Arc's AutomaticLiveFolderData (StorableSidebar.json `list.automaticLiveFolderData`:+// dataSource github, filter.github {attributes, hiddenRepositories}, hiddenItems, lastFetch) and the+// cached LiveItem.github.pullRequest in StorableLiveData.json. Dia 1.54 keeps the same GitHub client+// (ARCClients/GitHubClient). Findings and what was verified: docs/live-folders.md.++/// What a live folder is filled from. Arc and Dia also have Bitbucket, Notion, Drive and calendar sources.+public enum LiveFolderSource: String, Codable {+ case github+}++/// Which pull requests a GitHub live folder shows. Arc saves `attributes` as a bit mask (7 = all three).+public struct GitHubLiveFilter: Codable, Equatable {+ public struct Attributes: OptionSet, Codable, Hashable {+ public let rawValue: Int+ public init(rawValue: Int) { self.rawValue = rawValue }+ /// author:@me+ public static let authored = Attributes(rawValue: 1)+ /// user-review-requested:@me (asked of you by name)+ public static let reviewRequests = Attributes(rawValue: 2)+ /// review-requested:@me, which also covers teams you are on (Arc: "Team Review Requests")+ public static let teamReviewRequests = Attributes(rawValue: 4)+ public static let all: Attributes = [.authored, .reviewRequests, .teamReviewRequests]+ }++ public var attributes: Attributes = .all+ /// "owner/name" of repositories switched off in the folder's menu.+ public var hiddenRepositories: [String] = []++ public init(attributes: Attributes = .all, hiddenRepositories: [String] = []) {+ self.attributes = attributes+ self.hiddenRepositories = hiddenRepositories+ }+}++public enum LiveFolderError: String, Codable, Equatable {+ case notSignedIn, rateLimited, unexpectedPage, network+}++public struct LiveFolderData: Codable, Equatable {+ public var source: LiveFolderSource = .github+ public var filter = GitHubLiveFilter()+ /// Items closed out of the folder; they don't come back (Arc: hiddenItems).+ public var hiddenItems: [String] = []+ public var lastFetch: Date?+ /// Why the last refresh failed; nil once one succeeds.+ public var lastError: LiveFolderError?+ /// Organizations that want a SAML sign-in before their pull requests show up (Arc: needsSSO).+ public var ssoOrganizations: [String] = []+ /// The enterprise whose single sign-on GitHub sent a tab to (Enterprise Managed Users sign in+ /// there, not at github.com/login): the folder's sign-in button goes there too.+ public var enterprise: String?++ /// Where to sign in again.+ public var signInURL: String {+ if let enterprise { return "https://github.com/enterprises/\(enterprise)/sso" }+ return "https://github.com/login?return_to=%2Fpulls"+ }++ public init() {}+ public init(from decoder: Decoder) throws {+ let c = try decoder.container(keyedBy: CodingKeys.self)+ source = try c.decodeIfPresent(LiveFolderSource.self, forKey: .source) ?? .github+ filter = try c.decodeIfPresent(GitHubLiveFilter.self, forKey: .filter) ?? GitHubLiveFilter()+ hiddenItems = try c.decodeIfPresent([String].self, forKey: .hiddenItems) ?? []+ lastFetch = try c.decodeIfPresent(Date.self, forKey: .lastFetch)+ lastError = try? c.decodeIfPresent(LiveFolderError.self, forKey: .lastError)+ ssoOrganizations = try c.decodeIfPresent([String].self, forKey: .ssoOrganizations) ?? []+ enterprise = try c.decodeIfPresent(String.self, forKey: .enterprise)+ }+}++/// One pull request as the GitHub client reads it (Arc: LiveItem.Data.github.pullRequest).+public struct LivePullRequest: Codable, Equatable, Identifiable {+ public enum State: String, Codable { case open, draft, merged, closed }++ public var owner: String+ public var repo: String+ public var number: Int+ public var title: String+ public var author: String?+ public var state: State = .open+ public var createdByMe = false+ public var isAwaitingMyReview = false+ public var createdAt: Date?+ public var updatedAt: Date?++ public init(owner: String, repo: String, number: Int, title: String, author: String? = nil, state: State = .open,+ createdByMe: Bool = false, isAwaitingMyReview: Bool = false, createdAt: Date? = nil, updatedAt: Date? = nil) {+ self.owner = owner+ self.repo = repo+ self.number = number+ self.title = title+ self.author = author+ self.state = state+ self.createdByMe = createdByMe+ self.isAwaitingMyReview = isAwaitingMyReview+ self.createdAt = createdAt+ self.updatedAt = updatedAt+ }++ public var id: String { url }+ public var url: String { "https://github.com/\(owner)/\(repo)/pull/\(number)" }+ public var repository: String { "\(owner)/\(repo)" }+}diff --git a/Sources/Cra/Model/SidebarModel.swift b/Packages/CraCore/Sources/CraCore/SidebarModel.swiftsimilarity index 64%rename from Sources/Cra/Model/SidebarModel.swiftrename to Packages/CraCore/Sources/CraCore/SidebarModel.swiftindex 0ce0aa3..88c7c1f 100644--- a/Sources/Cra/Model/SidebarModel.swift+++ b/Packages/CraCore/Sources/CraCore/SidebarModel.swift@@ -5,14 +5,14 @@ import Foundation// "today" container, tabs/folders are items in a tree keyed by id with explicit// child ordering. Unlike Arc, favorites are not shared between spaces.-typealias ItemID = UUID+public typealias ItemID = UUID-enum ContainerKind: Codable, Equatable, Hashable {+public enum ContainerKind: Codable, Equatable, Hashable {case favorites(spaceID: UUID)case pinned(spaceID: UUID)case today(spaceID: UUID)- var spaceID: UUID {+ public var spaceID: UUID {switch self {case .favorites(let id), .pinned(let id), .today(let id): return id}@@ -20,12 +20,12 @@ enum ContainerKind: Codable, Equatable, Hashable {/// Stands in for the space of the favorites container every space shared/// before favorites became per space; SidebarStore splits it up on load.- static let sharedFavoritesSpaceID = UUID(uuid: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0))+ public static let sharedFavoritesSpaceID = UUID(uuid: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0))private enum CodingKeys: String, CodingKey { case favorites, pinned, today }private enum SpaceKeys: String, CodingKey { case spaceID }- init(from decoder: Decoder) throws {+ public init(from decoder: Decoder) throws {let c = try decoder.container(keyedBy: CodingKeys.self)guard let key = c.allKeys.first else {throw DecodingError.dataCorrupted(.init(codingPath: c.codingPath, debugDescription: "No container kind"))@@ -38,7 +38,7 @@ enum ContainerKind: Codable, Equatable, Hashable {}}- func encode(to encoder: Encoder) throws {+ public func encode(to encoder: Encoder) throws {var c = encoder.container(keyedBy: CodingKeys.self)let key: CodingKeysswitch self {@@ -51,36 +51,36 @@ enum ContainerKind: Codable, Equatable, Hashable {}}-struct TabData: Codable, Equatable {+public struct TabData: Codable, Equatable {/// Where the tab currently is. Restored on relaunch.- var url: String+ public var url: String/// The "home" of the tab. For pinned tabs this is what reset returns to;/// for today tabs it is just the URL the tab was created with.- var savedURL: String+ public var savedURL: String/// Last known page title.- var savedTitle: String- var muted: Bool = false- var timeLastActiveAt: Date?- var activeTabBeforeCreationID: UUID?+ public var savedTitle: String+ public var muted: Bool = false+ public var timeLastActiveAt: Date?+ public var activeTabBeforeCreationID: UUID?/// Host used as favicon cache key.- var faviconKey: String?- /// FaviconCache key of an image the user picked; wins over the site's favicon.- var customIconKey: String?+ public var faviconKey: String?+ /// Favicon cache key of an image the user picked; wins over the site's favicon.+ public var customIconKey: String?/// Favorite tile background as "#RRGGBB". nil is the theme's tile fill.- var tileColor: String?+ public var tileColor: String?/// The live folder item this tab shows (Arc: liveItemID.url), e.g. a pull request URL.- var liveItemURL: String?+ public var liveItemURL: String?/// Line under the title that the live folder writes (a pull request's author).- var liveSubtitle: String?+ public var liveSubtitle: String?/// When its pull request left the live folder's results; the tab goes after a grace period.- var liveGoneAt: Date?+ public var liveGoneAt: Date?/// The page's toolbar colour as last reported (TabRuntime.themeColor). A slept or restored/// tab's toolbar keeps it while the page loads again, as Arc's does.- var themeColor: String?+ public var themeColor: String?- var iconKey: String? { customIconKey ?? faviconKey }+ public var iconKey: String? { customIconKey ?? faviconKey }- init(url: String, title: String = "") {+ public init(url: String, title: String = "") {self.url = urlself.savedURL = urlself.savedTitle = title@@ -90,15 +90,15 @@ struct TabData: Codable, Equatable {/// Arc's SidebarSplitViewData: a split is a sidebar item whose children are/// the pane tabs (in pane order). Widths are stored as factors per child.-struct SplitData: Codable, Equatable {- var widthFactors: [UUID: Double] = [:]- var orientation: SplitOrientation = .horizontal+public struct SplitData: Codable, Equatable {+ public var widthFactors: [UUID: Double] = [:]+ public var orientation: SplitOrientation = .horizontal/// The pane that has keyboard focus (Arc: focusItemID).- var focusTabID: UUID?- var timeLastActiveAt: Date?+ public var focusTabID: UUID?+ public var timeLastActiveAt: Date?- init() {}- init(from decoder: Decoder) throws {+ public init() {}+ public init(from decoder: Decoder) throws {let c = try decoder.container(keyedBy: CodingKeys.self)widthFactors = try c.decodeIfPresent([UUID: Double].self, forKey: .widthFactors) ?? [:]orientation = try c.decodeIfPresent(SplitOrientation.self, forKey: .orientation) ?? .horizontal@@ -107,7 +107,7 @@ struct SplitData: Codable, Equatable {}}-enum SplitOrientation: String, Codable {+public enum SplitOrientation: String, Codable {/// Panes side by side (Arc's default).case horizontal/// Panes stacked top to bottom.@@ -115,53 +115,66 @@ enum SplitOrientation: String, Codable {}/// A fixed folder glyph colour, for when the theme's own doesn't read well.-enum FolderIconStyle: String, Codable, CaseIterable {+public enum FolderIconStyle: String, Codable, CaseIterable {case white, black}-enum ItemData: Codable, Equatable {+public enum ItemData: Codable, Equatable {case tab(TabData)case foldercase container(ContainerKind)case split(SplitData)}-struct SidebarItem: Identifiable, Codable, Equatable {- var id: UUID- var parentID: UUID?+public struct SidebarItem: Identifiable, Codable, Equatable {+ public var id: UUID+ public var parentID: UUID?/// Custom title set by renaming. nil means "use the page title".- var title: String?- var children: [UUID]- var isUnread: Bool- var createdAt: Date- var data: ItemData+ public var title: String?+ public var children: [UUID]+ public var isUnread: Bool+ public var createdAt: Date+ public var data: ItemData/// A folder's glyph colour; nil is Auto (it follows the theme).- var folderIcon: FolderIconStyle? = nil+ public var folderIcon: FolderIconStyle? = nil/// Set on a folder that fills itself (Arc: list.automaticLiveFolderData).- var liveFolder: LiveFolderData? = nil+ public var liveFolder: LiveFolderData? = nil++ public init(id: UUID, parentID: UUID?, title: String?, children: [UUID], isUnread: Bool, createdAt: Date, data: ItemData,+ folderIcon: FolderIconStyle? = nil, liveFolder: LiveFolderData? = nil) {+ self.id = id+ self.parentID = parentID+ self.title = title+ self.children = children+ self.isUnread = isUnread+ self.createdAt = createdAt+ self.data = data+ self.folderIcon = folderIcon+ self.liveFolder = liveFolder+ }- var tab: TabData? {+ public var tab: TabData? {if case .tab(let t) = data { return t }return nil}- var isTab: Bool { tab != nil }- var isFolder: Bool { if case .folder = data { return true }; return false }- var isLiveFolder: Bool { isFolder && liveFolder != nil }- var split: SplitData? {+ public var isTab: Bool { tab != nil }+ public var isFolder: Bool { if case .folder = data { return true }; return false }+ public var isLiveFolder: Bool { isFolder && liveFolder != nil }+ public var split: SplitData? {if case .split(let s) = data { return s }return nil}- var isSplit: Bool { split != nil }+ public var isSplit: Bool { split != nil }/// A tab with no page yet: Arc's empty split pane ("Search or Enter URL…").- var isEmptyTab: Bool { tab.map { $0.url.isEmpty || $0.url == "about:blank" } ?? false }- var container: ContainerKind? {+ public var isEmptyTab: Bool { tab.map { $0.url.isEmpty || $0.url == "about:blank" } ?? false }+ public var container: ContainerKind? {if case .container(let c) = data { return c }return nil}/// What the sidebar shows: the custom name wins over the page title,/// which wins over the host.- var displayTitle: String {+ public var displayTitle: String {if let t = title, !t.isEmpty { return t }if let tab {if isEmptyTab { return "New Tab" }@@ -173,64 +186,93 @@ struct SidebarItem: Identifiable, Codable, Equatable {return "Untitled"}- static func split(parent: UUID?) -> SidebarItem {+ public static func split(parent: UUID?) -> SidebarItem {SidebarItem(id: UUID(), parentID: parent, title: nil, children: [], isUnread: false,createdAt: Date(), data: .split(SplitData()))}- static func tab(_ url: String, title: String = "", parent: UUID?) -> SidebarItem {+ public static func tab(_ url: String, title: String = "", parent: UUID?) -> SidebarItem {SidebarItem(id: UUID(), parentID: parent, title: nil, children: [], isUnread: false,createdAt: Date(), data: .tab(TabData(url: url, title: title)))}- static func folder(_ name: String, parent: UUID?) -> SidebarItem {+ public static func folder(_ name: String, parent: UUID?) -> SidebarItem {SidebarItem(id: UUID(), parentID: parent, title: name, children: [], isUnread: false,createdAt: Date(), data: .folder)}- static func container(_ kind: ContainerKind, id: UUID = UUID()) -> SidebarItem {+ public static func container(_ kind: ContainerKind, id: UUID = UUID()) -> SidebarItem {SidebarItem(id: id, parentID: nil, title: nil, children: [], isUnread: false,createdAt: Date(), data: .container(kind))}}-struct Space: Identifiable, Codable, Equatable {- var id: UUID- var title: String- var emoji: String- var theme: SpaceTheme- var favoritesContainerID: UUID- var pinnedContainerID: UUID- var todayContainerID: UUID- var createdAt: Date+public struct Space: Identifiable, Codable, Equatable {+ public var id: UUID+ public var title: String+ public var emoji: String+ public var theme: SpaceTheme+ public var favoritesContainerID: UUID+ public var pinnedContainerID: UUID+ public var todayContainerID: UUID+ public var createdAt: Date/// The profile its pages load in (Arc: SpaceModel.profile); nil is the Default profile.- var profileID: UUID?+ public var profileID: UUID?/// An SF Symbol from the Icon tab of Arc's icon picker, shown instead of `emoji` (then empty).- var symbol: String? = nil+ public var symbol: String? = nil++ public init(id: UUID, title: String, emoji: String, theme: SpaceTheme, favoritesContainerID: UUID, pinnedContainerID: UUID,+ todayContainerID: UUID, createdAt: Date, profileID: UUID? = nil, symbol: String? = nil) {+ self.id = id+ self.title = title+ self.emoji = emoji+ self.theme = theme+ self.favoritesContainerID = favoritesContainerID+ self.pinnedContainerID = pinnedContainerID+ self.todayContainerID = todayContainerID+ self.createdAt = createdAt+ self.profileID = profileID+ self.symbol = symbol+ }}/// Arc's Profiles: logins, cookies, site storage and Chromium's own data kept apart/// from the Default profile. Any number of spaces can use one.-struct BrowserProfile: Identifiable, Codable, Equatable {- var id: UUID- var name: String+public struct BrowserProfile: Identifiable, Codable, Equatable {+ public var id: UUID+ public var name: String++ public init(id: UUID, name: String) {+ self.id = id+ self.name = name+ }/// Chromium's folder for it, next to Default under AppPaths.chromiumCache.- var directoryName: String { "Profile \(id.uuidString)" }+ public var directoryName: String { "Profile \(id.uuidString)" }}-struct SidebarDocument: Codable {- var version: Int = 1- var spaceOrder: [UUID]- var spaces: [Space]+public struct SidebarDocument: Codable, Equatable {+ public var version: Int = 1+ public var spaceOrder: [UUID]+ public var spaces: [Space]/// The favorites container all spaces shared in older files. Only read, to/// split it up between the spaces; new files leave it out.- var favoritesContainerID: UUID?- var items: [SidebarItem]+ public var favoritesContainerID: UUID?+ public var items: [SidebarItem]/// Profiles besides Default (missing in files from before profiles).- var profiles: [BrowserProfile]?+ public var profiles: [BrowserProfile]?++ public init(version: Int = 1, spaceOrder: [UUID], spaces: [Space], favoritesContainerID: UUID? = nil, items: [SidebarItem],+ profiles: [BrowserProfile]? = nil) {+ self.version = version+ self.spaceOrder = spaceOrder+ self.spaces = spaces+ self.favoritesContainerID = favoritesContainerID+ self.items = items+ self.profiles = profiles+ }- static func fresh() -> SidebarDocument {+ public static func fresh() -> SidebarDocument {let spaceID = UUID()let fav = SidebarItem.container(.favorites(spaceID: spaceID))let pinned = SidebarItem.container(.pinned(spaceID: spaceID))@@ -241,30 +283,42 @@ struct SidebarDocument: Codable {}}-enum ArchiveReason: String, Codable {+public enum ArchiveReason: String, Codable {case manual, auto, clear, spaceDeleted}-struct ArchivedItem: Codable, Identifiable, Equatable {- var id: UUID { item.id }- var archivedAt: Date- var reason: ArchiveReason- var sourceSpaceID: UUID?- var wasPinned: Bool- var item: SidebarItem+public struct ArchivedItem: Codable, Identifiable, Equatable {+ public var id: UUID { item.id }+ public var archivedAt: Date+ public var reason: ArchiveReason+ public var sourceSpaceID: UUID?+ public var wasPinned: Bool+ public var item: SidebarItem/// Closed from a Little Window (Arc: archive source `littleArc`); never/// had a place in the sidebar, so restoring puts it in the focused space.- var fromLittleWindow: Bool? = nil+ public var fromLittleWindow: Bool? = nil/// The folder it was closed out of (live folders too) and its place there:/// restoring puts it back while that folder is still in the space.- var sourceFolderID: UUID? = nil- var sourceIndex: Int? = nil+ public var sourceFolderID: UUID? = nil+ public var sourceIndex: Int? = nil++ public init(archivedAt: Date, reason: ArchiveReason, sourceSpaceID: UUID?, wasPinned: Bool, item: SidebarItem,+ fromLittleWindow: Bool? = nil, sourceFolderID: UUID? = nil, sourceIndex: Int? = nil) {+ self.archivedAt = archivedAt+ self.reason = reason+ self.sourceSpaceID = sourceSpaceID+ self.wasPinned = wasPinned+ self.item = item+ self.fromLittleWindow = fromLittleWindow+ self.sourceFolderID = sourceFolderID+ self.sourceIndex = sourceIndex+ }}-enum AutoArchiveThreshold: String, Codable, CaseIterable, Identifiable {+public enum AutoArchiveThreshold: String, Codable, CaseIterable, Identifiable {case twelveHours, twentyFourHours, sevenDays, thirtyDays- var id: String { rawValue }- var seconds: TimeInterval {+ public var id: String { rawValue }+ public var seconds: TimeInterval {switch self {case .twelveHours: return 12 * 3600case .twentyFourHours: return 24 * 3600@@ -272,7 +326,7 @@ enum AutoArchiveThreshold: String, Codable, CaseIterable, Identifiable {case .thirtyDays: return 30 * 86400}}- var label: String {+ public var label: String {switch self {case .twelveHours: return "12 hours"case .twentyFourHours: return "24 hours"@@ -282,10 +336,10 @@ enum AutoArchiveThreshold: String, Codable, CaseIterable, Identifiable {}}-enum TabSleepThreshold: String, Codable, CaseIterable, Identifiable {+public enum TabSleepThreshold: String, Codable, CaseIterable, Identifiable {case fifteenMinutes, oneHour, fourHours, twelveHours- var id: String { rawValue }- var seconds: TimeInterval {+ public var id: String { rawValue }+ public var seconds: TimeInterval {switch self {case .fifteenMinutes: return 15 * 60case .oneHour: return 3600@@ -293,7 +347,7 @@ enum TabSleepThreshold: String, Codable, CaseIterable, Identifiable {case .twelveHours: return 12 * 3600}}- var label: String {+ public var label: String {switch self {case .fifteenMinutes: return "15 minutes"case .oneHour: return "1 hour"@@ -303,10 +357,10 @@ enum TabSleepThreshold: String, Codable, CaseIterable, Identifiable {}}-enum SearchEngine: String, Codable, CaseIterable, Identifiable {+public enum SearchEngine: String, Codable, CaseIterable, Identifiable {case google, duckduckgo, bing, kagi- var id: String { rawValue }- var label: String {+ public var id: String { rawValue }+ public var label: String {switch self {case .google: return "Google"case .duckduckgo: return "DuckDuckGo"@@ -314,7 +368,7 @@ enum SearchEngine: String, Codable, CaseIterable, Identifiable {case .kagi: return "Kagi"}}- func searchURL(_ query: String) -> String {+ public func searchURL(_ query: String) -> String {let q = query.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)?.replacingOccurrences(of: "&", with: "%26") ?? queryswitch self {@@ -325,7 +379,7 @@ enum SearchEngine: String, Codable, CaseIterable, Identifiable {}}/// Each engine's OpenSearch suggest endpoint, for the command bar's search suggestions.- func suggestURL(_ query: String) -> URL? {+ public func suggestURL(_ query: String) -> URL? {guard let q = query.addingPercentEncoding(withAllowedCharacters: .alphanumerics) else { return nil }switch self {case .google: return URL(string: "https://www.google.com/complete/search?client=chrome&ie=utf-8&oe=utf-8&q=\(q)")@@ -336,138 +390,177 @@ enum SearchEngine: String, Codable, CaseIterable, Identifiable {}}-struct AppSettings: Codable, Equatable {- var autoArchive: AutoArchiveThreshold = .twelveHours- var searchEngine: SearchEngine = .google- var newTabsAtTop: Bool = true+public struct AppSettings: Codable, Equatable {+ public var autoArchive: AutoArchiveThreshold = .twelveHours+ public var searchEngine: SearchEngine = .google+ public var newTabsAtTop: Bool = true/// Tabs ▸ "Show the New Tab button above tabs": the + New Tab row leads Today/// instead of following its last tab. On like Arc, which keeps it under the divider.- var newTabButtonAtTop: Bool = true+ public var newTabButtonAtTop: Bool = true/// Cra 0.1.15–0.1.23 saved the New Tab row below Today for everyone; settings without/// this mark move it back above, where Arc has it, once.- var newTabButtonDefaultMigrated: Bool = true- var showStatusBar: Bool = true+ public var newTabButtonDefaultMigrated: Bool = true+ public var showStatusBar: Bool = true/// Arc's toolbar above the page (URL, copy link, DevTools). ⇧⌘D toggles. Off by/// default like Arc, which keeps the URL at the top of the sidebar.- var showToolbar: Bool = false+ public var showToolbar: Bool = false/// Cra 0.1.0 saved `showToolbar` as on for everyone; settings without this mark/// take the toolbar from Arc's own preference once (off without Arc).- var toolbarDefaultMigrated: Bool = true- var hasSeenImportPrompt: Bool = false+ public var toolbarDefaultMigrated: Bool = true+ public var hasSeenImportPrompt: Bool = false/// Arc's per-site Developer Mode (⌃D): the toolbar shows the full URL in/// monospace with the developer icons, and the nav buttons move to the sidebar.- var developerHosts: Set<String> = []+ public var developerHosts: Set<String> = []/// Host pages in Chrome-style windows: Chrome extensions and Chrome's own/// DevTools docking. Needs a restart to change.- var chromeEngine: Bool = true+ public var chromeEngine: Bool = true/// Air Traffic Control's "Default": where links from other apps open when no route/// matches. Arc's "Links from other apps open in Little Arc" switch is this set to/// Little Arc (on) or the most recent space (off).- var defaultLinkDestination: LinkDestination = .littleWindow+ public var defaultLinkDestination: LinkDestination = .littleWindow/// Air Traffic Control routes, checked in order (LinkRouting.swift). Starts with Arc's/// Google Meet route.- var linkRoutes: [LinkRoute] = [.googleMeet]+ public var linkRoutes: [LinkRoute] = [.googleMeet]/// Arc's "Open a Peek window when clicking on links to other sites" (modalEnabled): only/// links clicked in favorites and pinned tabs.- var peekLinksToOtherSites: Bool = true+ public var peekLinksToOtherSites: Bool = true/// Cra's addition (issue #12): links to other sites peek from every tab, not only/// favorites and pinned tabs.- var peekInEveryTab: Bool = false+ public var peekInEveryTab: Bool = false/// Arc's "Open a Peek window when clicking on links with Shift held"/// (shiftClickModalEntryPointEnabled).- var peekOnShiftClick: Bool = true+ public var peekOnShiftClick: Bool = true/// Arc's Previews ▸ Folders (folderPreviewEnabled): resting the pointer on a closed folder/// lists its tabs, most recent first, with a search field.- var folderPreviews: Bool = true+ public var folderPreviews: Bool = true/// Arc: "Enable Picture in Picture when you leave a video tab".- var autoPictureInPicture: Bool = true+ public var autoPictureInPicture: Bool = true/// Dia's onboarding privacy choice "Block third-party ads and trackers": requests/// to listed ad and tracker domains are cancelled unless they are first-party.- var blockAdsAndTrackers: Bool = true+ public var blockAdsAndTrackers: Bool = true/// Dia's Tabs ▸ "Haptic feedback when reordering tabs" (tabReorderingHapticsEnabled).- var hapticFeedbackOnReorder: Bool = true+ public var hapticFeedbackOnReorder: Bool = true/// Dia's Advanced ▸ "Warn before quitting" (shouldWarnBeforeQuitting, off by default).- var warnBeforeQuitting: Bool = false+ public var warnBeforeQuitting: Bool = false/// Dia's Tabs ▸ "Clean up tabs I haven't used in:" checkbox; `autoArchive` keeps the/// threshold while this is off.- var autoArchiveEnabled: Bool = true+ public var autoArchiveEnabled: Bool = true/// Tabs ▸ "Sleep tabs I haven't looked at in:": a page hidden that long closes and/// loads again when shown (BrowserManager.sleepIdleTabs). Off by default.- var tabSleepEnabled: Bool = false- var tabSleep: TabSleepThreshold = .oneHour+ public var tabSleepEnabled: Bool = false+ public var tabSleep: TabSleepThreshold = .oneHour/// Privacy ▸ "Always use secure connections": Chrome's HTTPS-Only Mode.- var httpsOnly: Bool = false+ public var httpsOnly: Bool = false/// Arc's searchSuggestEnabled: the command bar asks the search engine for suggestions/// as you type and fills its rows with them.- var searchSuggestions: Bool = true+ public var searchSuggestions: Bool = true/// Arc's showSpaceHeaderOnSingleUnnamedSpaces: with only one space, its header (and the/// dock's lone space icon) can be hidden, for people who don't use spaces.- var showSpaceHeaderOnSingleSpace: Bool = true+ public var showSpaceHeaderOnSingleSpace: Bool = true/// GitHub #24, not in Arc: the page fills the window with no margin and no rounded/// card, like a traditional browser. Off by default.- var edgeToEdgeContent: Bool = false+ public var edgeToEdgeContent: Bool = false- init() {}+ public init() {}- static func siteKey(for url: String) -> String? {+ public static func siteKey(for url: String) -> String? {URL(string: url)?.host?.lowercased().replacingOccurrences(of: "www.", with: "")}/// Arc's "Links from other apps open in Little Arc" (URLs handed over by other apps/// open in a small disposable window instead of a sidebar tab).- var openExternalLinksInLittleWindow: Bool {+ public var openExternalLinksInLittleWindow: Bool {get { defaultLinkDestination == .littleWindow }set { defaultLinkDestination = newValue ? .littleWindow : .mostRecentSpace }}- func isDeveloperMode(url: String) -> Bool { AppSettings.siteKey(for: url).map(developerHosts.contains) ?? false }- mutating func toggleDeveloperMode(url: String) {+ public func isDeveloperMode(url: String) -> Bool { AppSettings.siteKey(for: url).map(developerHosts.contains) ?? false }+ public mutating func toggleDeveloperMode(url: String) {guard let k = AppSettings.siteKey(for: url) else { return }if developerHosts.contains(k) { developerHosts.remove(k) } else { developerHosts.insert(k) }}+ /// Settings saved without `toolbarDefaultMigrated` take the toolbar from Arc's View ▸+ /// Show Toolbar (nil without Arc: off), once. Arc's preference is read only then.+ public mutating func migrateToolbarDefault(arcShowsToolbar: @autoclosure () -> Bool?) {+ guard !toolbarDefaultMigrated else { return }+ showToolbar = arcShowsToolbar() ?? false+ toolbarDefaultMigrated = true+ }}/// One browser window. Each window shows its own space and remembers its own/// open tab per space; spaces and tabs themselves are shared (Arc).-struct WindowSession: Codable, Equatable, Identifiable {- var id = UUID()- var focusedSpaceID: UUID?- var selectedTabPerSpace: [UUID: UUID] = [:]- var frame: String?- var sidebarVisible = true+public struct WindowSession: Codable, Equatable, Identifiable {+ public var id = UUID()+ public var focusedSpaceID: UUID?+ public var selectedTabPerSpace: [UUID: UUID] = [:]+ public var frame: String?+ public var sidebarVisible = true/// Incognito windows show a space of their own, never saved (SidebarStore.addIncognitoWindow).- var isIncognito = false+ public var isIncognito = false++ public init(id: UUID = UUID(), focusedSpaceID: UUID? = nil, selectedTabPerSpace: [UUID: UUID] = [:], frame: String? = nil,+ sidebarVisible: Bool = true, isIncognito: Bool = false) {+ self.id = id+ self.focusedSpaceID = focusedSpaceID+ self.selectedTabPerSpace = selectedTabPerSpace+ self.frame = frame+ self.sidebarVisible = sidebarVisible+ self.isIncognito = isIncognito+ }}-struct WindowPrefs: Codable, Equatable {- var sidebarWidth: Double = 328- var expandedFolders: Set<UUID> = []- var collapsedPinnedSpaces: Set<UUID> = []+public struct WindowPrefs: Codable, Equatable {+ public var sidebarWidth: Double = 328+ public var expandedFolders: Set<UUID> = []+ public var collapsedPinnedSpaces: Set<UUID> = []/// Open browser windows, restored at launch. Never empty.- var windows: [WindowSession] = [WindowSession()]+ public var windows: [WindowSession] = [WindowSession()]/// What is written to windows.json: incognito windows are never restored.- var withoutIncognito: WindowPrefs {+ public var withoutIncognito: WindowPrefs {var p = selfp.windows.removeAll { $0.isIncognito }return p}/// Last Little Window size (Arc: LittleBrowserWindow_size).- var littleWindowSize: String?+ public var littleWindowSize: String?++ public init(sidebarWidth: Double = 328, expandedFolders: Set<UUID> = [], collapsedPinnedSpaces: Set<UUID> = [],+ windows: [WindowSession] = [WindowSession()], littleWindowSize: String? = nil) {+ self.sidebarWidth = sidebarWidth+ self.expandedFolders = expandedFolders+ self.collapsedPinnedSpaces = collapsedPinnedSpaces+ self.windows = windows+ self.littleWindowSize = littleWindowSize+ }}-struct HistoryEntry: Codable, Equatable {- var url: String- var title: String- var lastVisit: Date- var visitCount: Int+public struct HistoryEntry: Codable, Equatable {+ public var url: String+ public var title: String+ public var lastVisit: Date+ public var visitCount: Int++ public init(url: String, title: String, lastVisit: Date, visitCount: Int) {+ self.url = url+ self.title = title+ self.lastVisit = lastVisit+ self.visitCount = visitCount+ }}/// Signals the command bar learns from, mirroring Arc's/// StorableCommandBarAdditionalRanking.json (recentlySwitchedToTabs,/// queriesToSelectedArchetype, typeTravelUsage).-struct RankingData: Codable, Equatable {- var recentlySwitchedToTabs: [UUID: [Date]] = [:]- var queriesToSelected: [String: String] = [:]- var commandUsage: [String: Int] = [:]+public struct RankingData: Codable, Equatable {+ public var recentlySwitchedToTabs: [UUID: [Date]] = [:]+ public var queriesToSelected: [String: String] = [:]+ public var commandUsage: [String: Int] = [:]++ public init(recentlySwitchedToTabs: [UUID: [Date]] = [:], queriesToSelected: [String: String] = [:], commandUsage: [String: Int] = [:]) {+ self.recentlySwitchedToTabs = recentlySwitchedToTabs+ self.queriesToSelected = queriesToSelected+ self.commandUsage = commandUsage+ }}@@ -476,7 +569,7 @@ extension AppSettings {/// Keys earlier versions wrote; read once and replaced.private enum LegacyKeys: String, CodingKey { case openExternalLinksInLittleWindow }- init(from decoder: Decoder) throws {+ public init(from decoder: Decoder) throws {let c = try decoder.container(keyedBy: CodingKeys.self)autoArchive = try c.decodeIfPresent(AutoArchiveThreshold.self, forKey: .autoArchive) ?? .twelveHourssearchEngine = try c.decodeIfPresent(SearchEngine.self, forKey: .searchEngine) ?? .google@@ -485,10 +578,10 @@ extension AppSettings {newTabButtonAtTop = try c.decodeIfPresent(Bool.self, forKey: .newTabButtonAtTop) ?? true}showStatusBar = try c.decodeIfPresent(Bool.self, forKey: .showStatusBar) ?? true- if try c.decodeIfPresent(Bool.self, forKey: .toolbarDefaultMigrated) == true {+ // Without the mark, `showToolbar` waits for migrateToolbarDefault(arcShowsToolbar:).+ toolbarDefaultMigrated = try c.decodeIfPresent(Bool.self, forKey: .toolbarDefaultMigrated) == true+ if toolbarDefaultMigrated {showToolbar = try c.decodeIfPresent(Bool.self, forKey: .showToolbar) ?? false- } else {- showToolbar = ArcImporter.showsToolbar ?? false}hasSeenImportPrompt = try c.decodeIfPresent(Bool.self, forKey: .hasSeenImportPrompt) ?? falsedeveloperHosts = try c.decodeIfPresent(Set<String>.self, forKey: .developerHosts) ?? []@@ -523,7 +616,7 @@ extension WindowPrefs {/// Single-window builds kept the window's state at the top level.private enum LegacyKeys: String, CodingKey { case sidebarVisible, focusedSpaceID, selectedTabPerSpace, windowFrame }- init(from decoder: Decoder) throws {+ public init(from decoder: Decoder) throws {let c = try decoder.container(keyedBy: CodingKeys.self)sidebarWidth = try c.decodeIfPresent(Double.self, forKey: .sidebarWidth) ?? 328expandedFolders = try c.decodeIfPresent(Set<UUID>.self, forKey: .expandedFolders) ?? []@@ -542,7 +635,7 @@ extension WindowPrefs {}extension WindowSession {- init(from decoder: Decoder) throws {+ public init(from decoder: Decoder) throws {let c = try decoder.container(keyedBy: CodingKeys.self)id = try c.decodeIfPresent(UUID.self, forKey: .id) ?? UUID()focusedSpaceID = try c.decodeIfPresent(UUID.self, forKey: .focusedSpaceID)@@ -553,7 +646,7 @@ extension WindowSession {}extension Space {- init(from decoder: Decoder) throws {+ public init(from decoder: Decoder) throws {let c = try decoder.container(keyedBy: CodingKeys.self)id = try c.decode(UUID.self, forKey: .id)title = try c.decode(String.self, forKey: .title)@@ -570,7 +663,7 @@ extension Space {}extension TabData {- init(from decoder: Decoder) throws {+ public init(from decoder: Decoder) throws {let c = try decoder.container(keyedBy: CodingKeys.self)url = try c.decodeIfPresent(String.self, forKey: .url) ?? ""savedURL = try c.decodeIfPresent(String.self, forKey: .savedURL) ?? urldiff --git a/Packages/CraCore/Tests/CraCoreTests/FaviconKeyTests.swift b/Packages/CraCore/Tests/CraCoreTests/FaviconKeyTests.swiftnew file mode 100644index 0000000..2e59cca--- /dev/null+++ b/Packages/CraCore/Tests/CraCoreTests/FaviconKeyTests.swift@@ -0,0 +1,16 @@+import CraCore+import Testing++struct FaviconKeyTests {+ @Test(arguments: [+ ("https://Mail.Example.com/inbox?x=1", "mail.example.com" as String?),+ ("http://localhost:3000/", "localhost"),+ ("https://www.example.com/", "www.example.com"),+ ("notes", nil),+ ("about:blank", nil),+ ("file:///tmp/a.html", nil),+ ])+ func keyIsTheLowercasedHost(url: String, key: String?) {+ #expect(FaviconKey.key(for: url) == key)+ }+}diff --git a/Packages/CraCore/Tests/CraCoreTests/Fixtures/Model/input/archive.json b/Packages/CraCore/Tests/CraCoreTests/Fixtures/Model/input/archive.jsonnew file mode 100644index 0000000..eb512a1--- /dev/null+++ b/Packages/CraCore/Tests/CraCoreTests/Fixtures/Model/input/archive.json@@ -0,0 +1,9 @@+[+ {"archivedAt": "2026-10-31T08:00:00Z", "reason": "auto", "sourceSpaceID": "A0000000-0000-0000-0000-000000000001", "wasPinned": false,+ "sourceFolderID": "D0000000-0000-0000-0000-000000000002", "sourceIndex": 1,+ "item": {"id": "D0000000-0000-0000-0000-0000000000A1", "children": [], "isUnread": false, "createdAt": "2026-10-20T08:00:00Z",+ "data": {"tab": {"_0": {"url": "https://news.example.com/", "savedURL": "https://news.example.com/", "savedTitle": "News", "faviconKey": "news.example.com"}}}}},+ {"archivedAt": "2026-10-30T08:00:00Z", "reason": "manual", "wasPinned": true, "fromLittleWindow": true,+ "item": {"id": "D0000000-0000-0000-0000-0000000000A2", "title": "Renamed", "children": [], "isUnread": false, "createdAt": "2026-10-29T08:00:00Z",+ "data": {"tab": {"_0": {"url": "https://example.net/x", "savedURL": "https://example.net/", "savedTitle": "X"}}}}}+]diff --git a/Packages/CraCore/Tests/CraCoreTests/Fixtures/Model/input/commandbar.json b/Packages/CraCore/Tests/CraCoreTests/Fixtures/Model/input/commandbar.jsonnew file mode 100644index 0000000..faccd14--- /dev/null+++ b/Packages/CraCore/Tests/CraCoreTests/Fixtures/Model/input/commandbar.json@@ -0,0 +1,2 @@+{"recentlySwitchedToTabs": ["D0000000-0000-0000-0000-000000000001", ["2026-10-31T09:00:00Z", "2026-10-31T09:05:00Z"]],+ "queriesToSelected": {"gh": "tab:D0000000-0000-0000-0000-000000000004"}, "commandUsage": {"newTab": 4}}diff --git a/Packages/CraCore/Tests/CraCoreTests/Fixtures/Model/input/history.json b/Packages/CraCore/Tests/CraCoreTests/Fixtures/Model/input/history.jsonnew file mode 100644index 0000000..967558e--- /dev/null+++ b/Packages/CraCore/Tests/CraCoreTests/Fixtures/Model/input/history.json@@ -0,0 +1 @@+[{"url": "https://example.com/", "title": "Example", "lastVisit": "2026-10-31T09:30:00Z", "visitCount": 12}]diff --git a/Packages/CraCore/Tests/CraCoreTests/Fixtures/Model/input/keybindings.json b/Packages/CraCore/Tests/CraCoreTests/Fixtures/Model/input/keybindings.jsonnew file mode 100644index 0000000..1d59989--- /dev/null+++ b/Packages/CraCore/Tests/CraCoreTests/Fixtures/Model/input/keybindings.json@@ -0,0 +1,24 @@+{+ "newTab" : [+ {+ "key" : "t",+ "modifiers" : 1048576+ }+ ],+ "nextTab" : [+ {+ "key" : "\t",+ "modifiers" : 262144+ },+ {+ "key" : "",+ "modifiers" : 1572864+ }+ ],+ "toggleSidebar" : [+ {+ "key" : "s",+ "modifiers" : 1179648+ }+ ]+}\ No newline at end of filediff --git a/Packages/CraCore/Tests/CraCoreTests/Fixtures/Model/input/settings-bad-routes.json b/Packages/CraCore/Tests/CraCoreTests/Fixtures/Model/input/settings-bad-routes.jsonnew file mode 100644index 0000000..b750b39--- /dev/null+++ b/Packages/CraCore/Tests/CraCoreTests/Fixtures/Model/input/settings-bad-routes.json@@ -0,0 +1 @@+{"toolbarDefaultMigrated": true, "defaultLinkDestination": {"teleport": {}}, "linkRoutes": [{"match": "fuzzy"}]}diff --git a/Packages/CraCore/Tests/CraCoreTests/Fixtures/Model/input/settings-empty.json b/Packages/CraCore/Tests/CraCoreTests/Fixtures/Model/input/settings-empty.jsonnew file mode 100644index 0000000..0967ef4--- /dev/null+++ b/Packages/CraCore/Tests/CraCoreTests/Fixtures/Model/input/settings-empty.json@@ -0,0 +1 @@+{}diff --git a/Packages/CraCore/Tests/CraCoreTests/Fixtures/Model/input/settings-legacy.json b/Packages/CraCore/Tests/CraCoreTests/Fixtures/Model/input/settings-legacy.jsonnew file mode 100644index 0000000..167a4c7--- /dev/null+++ b/Packages/CraCore/Tests/CraCoreTests/Fixtures/Model/input/settings-legacy.json@@ -0,0 +1,4 @@+{+ "autoArchive": "thirtyDays", "searchEngine": "duckduckgo", "openExternalLinksInLittleWindow": false,+ "showToolbar": false, "newTabButtonAtTop": false, "tabSleep": "everyFortnight", "hasSeenImportPrompt": true+}diff --git a/Packages/CraCore/Tests/CraCoreTests/Fixtures/Model/input/settings.json b/Packages/CraCore/Tests/CraCoreTests/Fixtures/Model/input/settings.jsonnew file mode 100644index 0000000..9b67b35--- /dev/null+++ b/Packages/CraCore/Tests/CraCoreTests/Fixtures/Model/input/settings.json@@ -0,0 +1,14 @@+{+ "autoArchive": "sevenDays", "autoArchiveEnabled": false, "autoPictureInPicture": false, "blockAdsAndTrackers": false,+ "chromeEngine": false, "defaultLinkDestination": {"space": {"_0": "A0000000-0000-0000-0000-000000000002"}},+ "developerHosts": ["localhost"], "edgeToEdgeContent": true, "folderPreviews": false, "hapticFeedbackOnReorder": false,+ "hasSeenImportPrompt": true, "httpsOnly": true,+ "linkRoutes": [+ {"id": "E0000000-0000-0000-0000-000000000001", "match": "contains", "text": "meet.google.com", "destination": {"mostRecentSpace": {}}},+ {"id": "E0000000-0000-0000-0000-000000000002", "match": "equals", "text": "example.com/standup", "destination": {"littleWindow": {}}}+ ],+ "newTabButtonAtTop": false, "newTabButtonDefaultMigrated": true, "newTabsAtTop": false,+ "peekInEveryTab": true, "peekLinksToOtherSites": false, "peekOnShiftClick": false,+ "searchEngine": "kagi", "searchSuggestions": false, "showSpaceHeaderOnSingleSpace": false, "showStatusBar": false,+ "showToolbar": true, "tabSleep": "fourHours", "tabSleepEnabled": true, "toolbarDefaultMigrated": true, "warnBeforeQuitting": true+}diff --git a/Packages/CraCore/Tests/CraCoreTests/Fixtures/Model/input/sidebar-legacy.json b/Packages/CraCore/Tests/CraCoreTests/Fixtures/Model/input/sidebar-legacy.jsonnew file mode 100644index 0000000..486c5f0--- /dev/null+++ b/Packages/CraCore/Tests/CraCoreTests/Fixtures/Model/input/sidebar-legacy.json@@ -0,0 +1,29 @@+{+ "version": 1,+ "spaceOrder": ["A0000000-0000-0000-0000-000000000001", "A0000000-0000-0000-0000-0000000000FF"],+ "favoritesContainerID": "C0000000-0000-0000-0000-0000000000F0",+ "spaces": [+ {+ "id": "A0000000-0000-0000-0000-000000000001", "title": "Home", "emoji": "🌱",+ "theme": {"colors": ["#1C242B", "#3A3660"]},+ "favoritesContainerID": "C0000000-0000-0000-0000-000000000001",+ "pinnedContainerID": "C0000000-0000-0000-0000-000000000002",+ "todayContainerID": "C0000000-0000-0000-0000-000000000003",+ "createdAt": "2025-05-01T08:00:00Z"+ }+ ],+ "items": [+ {"id": "C0000000-0000-0000-0000-0000000000F0", "children": ["D0000000-0000-0000-0000-000000000001"], "isUnread": false, "createdAt": "2025-05-01T08:00:00Z",+ "data": {"container": {"_0": {"favorites": {}}}}},+ {"id": "C0000000-0000-0000-0000-000000000002", "children": ["D0000000-0000-0000-0000-000000000002"], "isUnread": false, "createdAt": "2025-05-01T08:00:00Z",+ "data": {"container": {"_0": {"pinned": {"spaceID": "A0000000-0000-0000-0000-000000000001"}}}}},+ {"id": "C0000000-0000-0000-0000-000000000003", "children": ["D0000000-0000-0000-0000-000000000003"], "isUnread": false, "createdAt": "2025-05-01T08:00:00Z",+ "data": {"container": {"_0": {"today": {"spaceID": "A0000000-0000-0000-0000-000000000001"}}}}},+ {"id": "D0000000-0000-0000-0000-000000000001", "parentID": "C0000000-0000-0000-0000-0000000000F0", "children": [], "isUnread": false, "createdAt": "2025-05-02T08:00:00Z",+ "data": {"tab": {"_0": {"url": "https://Calendar.Example.com/week"}}}},+ {"id": "D0000000-0000-0000-0000-000000000002", "parentID": "C0000000-0000-0000-0000-000000000002", "title": "Live", "children": [], "isUnread": false, "createdAt": "2025-05-02T08:00:00Z",+ "data": {"folder": {}}, "liveFolder": {"lastError": "somethingNew", "filter": {"attributes": 2, "hiddenRepositories": []}}},+ {"id": "D0000000-0000-0000-0000-000000000003", "parentID": "C0000000-0000-0000-0000-000000000003", "children": [], "isUnread": false, "createdAt": "2025-05-02T08:00:00Z",+ "data": {"split": {"_0": {}}}}+ ]+}diff --git a/Packages/CraCore/Tests/CraCoreTests/Fixtures/Model/input/sidebar.json b/Packages/CraCore/Tests/CraCoreTests/Fixtures/Model/input/sidebar.jsonnew file mode 100644index 0000000..427a241--- /dev/null+++ b/Packages/CraCore/Tests/CraCoreTests/Fixtures/Model/input/sidebar.json@@ -0,0 +1,61 @@+{+ "version": 1,+ "spaceOrder": ["A0000000-0000-0000-0000-000000000001", "A0000000-0000-0000-0000-000000000002"],+ "spaces": [+ {+ "id": "A0000000-0000-0000-0000-000000000001", "title": "Home", "emoji": "🏠",+ "theme": {"colors": ["#F4F1EA", "#29283D"], "intensity": 0.6, "noise": 0.15, "appearance": "light", "vibrant": false, "solid": false},+ "favoritesContainerID": "C0000000-0000-0000-0000-000000000001",+ "pinnedContainerID": "C0000000-0000-0000-0000-000000000002",+ "todayContainerID": "C0000000-0000-0000-0000-000000000003",+ "createdAt": "2026-10-01T08:00:00Z"+ },+ {+ "id": "A0000000-0000-0000-0000-000000000002", "title": "Work", "emoji": "", "symbol": "briefcase",+ "theme": {"colors": ["#2861B3", "#2861B3"], "intensity": 1, "noise": 0, "appearance": "dark", "vibrant": true, "accent": "#2861B3", "solid": true},+ "favoritesContainerID": "C0000000-0000-0000-0000-000000000004",+ "pinnedContainerID": "C0000000-0000-0000-0000-000000000005",+ "todayContainerID": "C0000000-0000-0000-0000-000000000006",+ "createdAt": "2026-10-02T08:00:00Z",+ "profileID": "B0000000-0000-0000-0000-000000000001"+ }+ ],+ "profiles": [{"id": "B0000000-0000-0000-0000-000000000001", "name": "Work"}],+ "items": [+ {"id": "C0000000-0000-0000-0000-000000000001", "children": ["D0000000-0000-0000-0000-000000000001"], "isUnread": false, "createdAt": "2026-10-01T08:00:00Z",+ "data": {"container": {"_0": {"favorites": {"spaceID": "A0000000-0000-0000-0000-000000000001"}}}}},+ {"id": "C0000000-0000-0000-0000-000000000002", "children": ["D0000000-0000-0000-0000-000000000002", "D0000000-0000-0000-0000-000000000005"], "isUnread": false, "createdAt": "2026-10-01T08:00:00Z",+ "data": {"container": {"_0": {"pinned": {"spaceID": "A0000000-0000-0000-0000-000000000001"}}}}},+ {"id": "C0000000-0000-0000-0000-000000000003", "children": ["D0000000-0000-0000-0000-000000000006", "D0000000-0000-0000-0000-000000000009"], "isUnread": false, "createdAt": "2026-10-01T08:00:00Z",+ "data": {"container": {"_0": {"today": {"spaceID": "A0000000-0000-0000-0000-000000000001"}}}}},+ {"id": "C0000000-0000-0000-0000-000000000004", "children": [], "isUnread": false, "createdAt": "2026-10-02T08:00:00Z",+ "data": {"container": {"_0": {"favorites": {"spaceID": "A0000000-0000-0000-0000-000000000002"}}}}},+ {"id": "C0000000-0000-0000-0000-000000000005", "children": [], "isUnread": false, "createdAt": "2026-10-02T08:00:00Z",+ "data": {"container": {"_0": {"pinned": {"spaceID": "A0000000-0000-0000-0000-000000000002"}}}}},+ {"id": "C0000000-0000-0000-0000-000000000006", "children": [], "isUnread": false, "createdAt": "2026-10-02T08:00:00Z",+ "data": {"container": {"_0": {"today": {"spaceID": "A0000000-0000-0000-0000-000000000002"}}}}},+ {"id": "D0000000-0000-0000-0000-000000000001", "parentID": "C0000000-0000-0000-0000-000000000001", "children": [], "isUnread": false, "createdAt": "2026-10-03T08:00:00Z",+ "data": {"tab": {"_0": {"url": "https://mail.example.com/inbox", "savedURL": "https://mail.example.com/", "savedTitle": "Inbox (3)", "muted": true,+ "timeLastActiveAt": "2026-10-30T09:00:00Z", "faviconKey": "mail.example.com", "customIconKey": "custom-mail", "tileColor": "#E63333"}}}},+ {"id": "D0000000-0000-0000-0000-000000000002", "parentID": "C0000000-0000-0000-0000-000000000002", "title": "Reading", "children": ["D0000000-0000-0000-0000-000000000003"], "isUnread": false, "createdAt": "2026-10-03T08:00:00Z",+ "data": {"folder": {}}, "folderIcon": "white"},+ {"id": "D0000000-0000-0000-0000-000000000003", "parentID": "D0000000-0000-0000-0000-000000000002", "title": "My blog", "children": [], "isUnread": true, "createdAt": "2026-10-03T08:00:00Z",+ "data": {"tab": {"_0": {"url": "https://blog.example.org/post/1", "savedURL": "https://blog.example.org/", "savedTitle": "Post one",+ "activeTabBeforeCreationID": "D0000000-0000-0000-0000-000000000001", "faviconKey": "blog.example.org"}}}},+ {"id": "D0000000-0000-0000-0000-000000000005", "parentID": "C0000000-0000-0000-0000-000000000002", "title": "Reviews", "children": ["D0000000-0000-0000-0000-000000000004"], "isUnread": false, "createdAt": "2026-10-04T08:00:00Z",+ "data": {"folder": {}},+ "liveFolder": {"source": "github", "filter": {"attributes": 5, "hiddenRepositories": ["example/old"]}, "hiddenItems": ["https://github.com/example/app/pull/7"],+ "lastFetch": "2026-10-31T10:00:00Z", "lastError": "rateLimited", "ssoOrganizations": ["example-org"], "enterprise": "example-ent"}},+ {"id": "D0000000-0000-0000-0000-000000000004", "parentID": "D0000000-0000-0000-0000-000000000005", "children": [], "isUnread": false, "createdAt": "2026-10-31T10:00:00Z",+ "data": {"tab": {"_0": {"url": "https://github.com/example/app/pull/9", "savedURL": "https://github.com/example/app/pull/9", "savedTitle": "Fix the thing",+ "faviconKey": "github.com", "liveItemURL": "https://github.com/example/app/pull/9", "liveSubtitle": "someone", "liveGoneAt": "2026-10-31T12:00:00Z"}}}},+ {"id": "D0000000-0000-0000-0000-000000000006", "parentID": "C0000000-0000-0000-0000-000000000003", "children": ["D0000000-0000-0000-0000-000000000007", "D0000000-0000-0000-0000-000000000008"], "isUnread": false, "createdAt": "2026-10-05T08:00:00Z",+ "data": {"split": {"_0": {"widthFactors": ["D0000000-0000-0000-0000-000000000007", 0.6], "orientation": "vertical", "focusTabID": "D0000000-0000-0000-0000-000000000008", "timeLastActiveAt": "2026-10-30T10:00:00Z"}}}},+ {"id": "D0000000-0000-0000-0000-000000000007", "parentID": "D0000000-0000-0000-0000-000000000006", "children": [], "isUnread": false, "createdAt": "2026-10-05T08:00:00Z",+ "data": {"tab": {"_0": {"url": "https://docs.example.com/a", "savedURL": "https://docs.example.com/a", "savedTitle": "", "faviconKey": "docs.example.com"}}}},+ {"id": "D0000000-0000-0000-0000-000000000008", "parentID": "D0000000-0000-0000-0000-000000000006", "children": [], "isUnread": false, "createdAt": "2026-10-05T08:00:00Z",+ "data": {"tab": {"_0": {"url": "about:blank", "savedURL": "about:blank", "savedTitle": ""}}}},+ {"id": "D0000000-0000-0000-0000-000000000009", "parentID": "C0000000-0000-0000-0000-000000000003", "children": [], "isUnread": false, "createdAt": "2026-10-06T08:00:00Z",+ "data": {"tab": {"_0": {"url": "https://Shop.Example.co.uk/basket?x=1", "savedURL": "https://Shop.Example.co.uk/basket?x=1", "savedTitle": "", "faviconKey": "Shop.Example.co.uk"}}}}+ ]+}diff --git a/Packages/CraCore/Tests/CraCoreTests/Fixtures/Model/input/windows-legacy.json b/Packages/CraCore/Tests/CraCoreTests/Fixtures/Model/input/windows-legacy.jsonnew file mode 100644index 0000000..8cd5d54--- /dev/null+++ b/Packages/CraCore/Tests/CraCoreTests/Fixtures/Model/input/windows-legacy.json@@ -0,0 +1,5 @@+{+ "sidebarWidth": 300, "sidebarVisible": false, "focusedSpaceID": "A0000000-0000-0000-0000-000000000001",+ "selectedTabPerSpace": ["A0000000-0000-0000-0000-000000000001", "D0000000-0000-0000-0000-000000000003"],+ "windowFrame": "{{0, 0}, {1200, 800}}"+}diff --git a/Packages/CraCore/Tests/CraCoreTests/Fixtures/Model/input/windows.json b/Packages/CraCore/Tests/CraCoreTests/Fixtures/Model/input/windows.jsonnew file mode 100644index 0000000..e314bcd--- /dev/null+++ b/Packages/CraCore/Tests/CraCoreTests/Fixtures/Model/input/windows.json@@ -0,0 +1,10 @@+{+ "sidebarWidth": 280, "expandedFolders": ["D0000000-0000-0000-0000-000000000002"], "collapsedPinnedSpaces": ["A0000000-0000-0000-0000-000000000002"],+ "littleWindowSize": "{480, 640}",+ "windows": [+ {"id": "F0000000-0000-0000-0000-000000000001", "focusedSpaceID": "A0000000-0000-0000-0000-000000000001",+ "selectedTabPerSpace": ["A0000000-0000-0000-0000-000000000001", "D0000000-0000-0000-0000-000000000009"],+ "frame": "{{100, 100}, {1400, 880}}", "sidebarVisible": false},+ {"id": "F0000000-0000-0000-0000-000000000002", "focusedSpaceID": "A0000000-0000-0000-0000-000000000002"}+ ]+}diff --git a/Packages/CraCore/Tests/CraCoreTests/Fixtures/Model/recorded/archive.json b/Packages/CraCore/Tests/CraCoreTests/Fixtures/Model/recorded/archive.jsonnew file mode 100644index 0000000..694e64e--- /dev/null+++ b/Packages/CraCore/Tests/CraCoreTests/Fixtures/Model/recorded/archive.json@@ -0,0 +1,55 @@+[+ {+ "archivedAt" : "2026-10-31T08:00:00Z",+ "item" : {+ "children" : [++ ],+ "createdAt" : "2026-10-20T08:00:00Z",+ "data" : {+ "tab" : {+ "_0" : {+ "faviconKey" : "news.example.com",+ "muted" : false,+ "savedTitle" : "News",+ "savedURL" : "https:\/\/news.example.com\/",+ "url" : "https:\/\/news.example.com\/"+ }+ }+ },+ "id" : "D0000000-0000-0000-0000-0000000000A1",+ "isUnread" : false+ },+ "reason" : "auto",+ "sourceFolderID" : "D0000000-0000-0000-0000-000000000002",+ "sourceIndex" : 1,+ "sourceSpaceID" : "A0000000-0000-0000-0000-000000000001",+ "wasPinned" : false+ },+ {+ "archivedAt" : "2026-10-30T08:00:00Z",+ "fromLittleWindow" : true,+ "item" : {+ "children" : [++ ],+ "createdAt" : "2026-10-29T08:00:00Z",+ "data" : {+ "tab" : {+ "_0" : {+ "faviconKey" : "example.net",+ "muted" : false,+ "savedTitle" : "X",+ "savedURL" : "https:\/\/example.net\/",+ "url" : "https:\/\/example.net\/x"+ }+ }+ },+ "id" : "D0000000-0000-0000-0000-0000000000A2",+ "isUnread" : false,+ "title" : "Renamed"+ },+ "reason" : "manual",+ "wasPinned" : true+ }+]\ No newline at end of filediff --git a/Packages/CraCore/Tests/CraCoreTests/Fixtures/Model/recorded/commandbar.json b/Packages/CraCore/Tests/CraCoreTests/Fixtures/Model/recorded/commandbar.jsonnew file mode 100644index 0000000..e6c0a8b--- /dev/null+++ b/Packages/CraCore/Tests/CraCoreTests/Fixtures/Model/recorded/commandbar.json@@ -0,0 +1,15 @@+{+ "commandUsage" : {+ "newTab" : 4+ },+ "queriesToSelected" : {+ "gh" : "tab:D0000000-0000-0000-0000-000000000004"+ },+ "recentlySwitchedToTabs" : [+ "D0000000-0000-0000-0000-000000000001",+ [+ "2026-10-31T09:00:00Z",+ "2026-10-31T09:05:00Z"+ ]+ ]+}\ No newline at end of filediff --git a/Packages/CraCore/Tests/CraCoreTests/Fixtures/Model/recorded/history.json b/Packages/CraCore/Tests/CraCoreTests/Fixtures/Model/recorded/history.jsonnew file mode 100644index 0000000..6999a15--- /dev/null+++ b/Packages/CraCore/Tests/CraCoreTests/Fixtures/Model/recorded/history.json@@ -0,0 +1,8 @@+[+ {+ "lastVisit" : "2026-10-31T09:30:00Z",+ "title" : "Example",+ "url" : "https:\/\/example.com\/",+ "visitCount" : 12+ }+]\ No newline at end of filediff --git a/Packages/CraCore/Tests/CraCoreTests/Fixtures/Model/recorded/keybindings.json b/Packages/CraCore/Tests/CraCoreTests/Fixtures/Model/recorded/keybindings.jsonnew file mode 100644index 0000000..1d59989--- /dev/null+++ b/Packages/CraCore/Tests/CraCoreTests/Fixtures/Model/recorded/keybindings.json@@ -0,0 +1,24 @@+{+ "newTab" : [+ {+ "key" : "t",+ "modifiers" : 1048576+ }+ ],+ "nextTab" : [+ {+ "key" : "\t",+ "modifiers" : 262144+ },+ {+ "key" : "",+ "modifiers" : 1572864+ }+ ],+ "toggleSidebar" : [+ {+ "key" : "s",+ "modifiers" : 1179648+ }+ ]+}\ No newline at end of filediff --git a/Packages/CraCore/Tests/CraCoreTests/Fixtures/Model/recorded/settings-bad-routes.json b/Packages/CraCore/Tests/CraCoreTests/Fixtures/Model/recorded/settings-bad-routes.jsonnew file mode 100644index 0000000..c5d062c--- /dev/null+++ b/Packages/CraCore/Tests/CraCoreTests/Fixtures/Model/recorded/settings-bad-routes.json@@ -0,0 +1,38 @@+{+ "autoArchive" : "twelveHours",+ "autoArchiveEnabled" : true,+ "autoPictureInPicture" : true,+ "blockAdsAndTrackers" : true,+ "chromeEngine" : true,+ "defaultLinkDestination" : {+ "littleWindow" : {++ }+ },+ "developerHosts" : [++ ],+ "edgeToEdgeContent" : false,+ "folderPreviews" : true,+ "hapticFeedbackOnReorder" : true,+ "hasSeenImportPrompt" : false,+ "httpsOnly" : false,+ "linkRoutes" : [++ ],+ "newTabButtonAtTop" : true,+ "newTabButtonDefaultMigrated" : true,+ "newTabsAtTop" : true,+ "peekInEveryTab" : false,+ "peekLinksToOtherSites" : true,+ "peekOnShiftClick" : true,+ "searchEngine" : "google",+ "searchSuggestions" : true,+ "showSpaceHeaderOnSingleSpace" : true,+ "showStatusBar" : true,+ "showToolbar" : false,+ "tabSleep" : "oneHour",+ "tabSleepEnabled" : false,+ "toolbarDefaultMigrated" : true,+ "warnBeforeQuitting" : false+}\ No newline at end of filediff --git a/Packages/CraCore/Tests/CraCoreTests/Fixtures/Model/recorded/settings-empty.json b/Packages/CraCore/Tests/CraCoreTests/Fixtures/Model/recorded/settings-empty.jsonnew file mode 100644index 0000000..637a6ec--- /dev/null+++ b/Packages/CraCore/Tests/CraCoreTests/Fixtures/Model/recorded/settings-empty.json@@ -0,0 +1,47 @@+{+ "autoArchive" : "twelveHours",+ "autoArchiveEnabled" : true,+ "autoPictureInPicture" : true,+ "blockAdsAndTrackers" : true,+ "chromeEngine" : true,+ "defaultLinkDestination" : {+ "littleWindow" : {++ }+ },+ "developerHosts" : [++ ],+ "edgeToEdgeContent" : false,+ "folderPreviews" : true,+ "hapticFeedbackOnReorder" : true,+ "hasSeenImportPrompt" : false,+ "httpsOnly" : false,+ "linkRoutes" : [+ {+ "destination" : {+ "mostRecentSpace" : {++ }+ },+ "id" : "00000000-0000-0000-0000-000000000000",+ "match" : "contains",+ "text" : "meet.google.com"+ }+ ],+ "newTabButtonAtTop" : true,+ "newTabButtonDefaultMigrated" : true,+ "newTabsAtTop" : true,+ "peekInEveryTab" : false,+ "peekLinksToOtherSites" : true,+ "peekOnShiftClick" : true,+ "searchEngine" : "google",+ "searchSuggestions" : true,+ "showSpaceHeaderOnSingleSpace" : true,+ "showStatusBar" : true,+ "showToolbar" : true,+ "tabSleep" : "oneHour",+ "tabSleepEnabled" : false,+ "toolbarDefaultMigrated" : true,+ "warnBeforeQuitting" : false+}\ No newline at end of filediff --git a/Packages/CraCore/Tests/CraCoreTests/Fixtures/Model/recorded/settings-legacy.json b/Packages/CraCore/Tests/CraCoreTests/Fixtures/Model/recorded/settings-legacy.jsonnew file mode 100644index 0000000..d397d38--- /dev/null+++ b/Packages/CraCore/Tests/CraCoreTests/Fixtures/Model/recorded/settings-legacy.json@@ -0,0 +1,47 @@+{+ "autoArchive" : "thirtyDays",+ "autoArchiveEnabled" : true,+ "autoPictureInPicture" : true,+ "blockAdsAndTrackers" : true,+ "chromeEngine" : true,+ "defaultLinkDestination" : {+ "mostRecentSpace" : {++ }+ },+ "developerHosts" : [++ ],+ "edgeToEdgeContent" : false,+ "folderPreviews" : true,+ "hapticFeedbackOnReorder" : true,+ "hasSeenImportPrompt" : true,+ "httpsOnly" : false,+ "linkRoutes" : [+ {+ "destination" : {+ "mostRecentSpace" : {++ }+ },+ "id" : "00000000-0000-0000-0000-000000000000",+ "match" : "contains",+ "text" : "meet.google.com"+ }+ ],+ "newTabButtonAtTop" : true,+ "newTabButtonDefaultMigrated" : true,+ "newTabsAtTop" : true,+ "peekInEveryTab" : false,+ "peekLinksToOtherSites" : true,+ "peekOnShiftClick" : true,+ "searchEngine" : "duckduckgo",+ "searchSuggestions" : true,+ "showSpaceHeaderOnSingleSpace" : true,+ "showStatusBar" : true,+ "showToolbar" : true,+ "tabSleep" : "oneHour",+ "tabSleepEnabled" : false,+ "toolbarDefaultMigrated" : true,+ "warnBeforeQuitting" : false+}\ No newline at end of filediff --git a/Packages/CraCore/Tests/CraCoreTests/Fixtures/Model/recorded/settings.json b/Packages/CraCore/Tests/CraCoreTests/Fixtures/Model/recorded/settings.jsonnew file mode 100644index 0000000..0cda852--- /dev/null+++ b/Packages/CraCore/Tests/CraCoreTests/Fixtures/Model/recorded/settings.json@@ -0,0 +1,57 @@+{+ "autoArchive" : "sevenDays",+ "autoArchiveEnabled" : false,+ "autoPictureInPicture" : false,+ "blockAdsAndTrackers" : false,+ "chromeEngine" : false,+ "defaultLinkDestination" : {+ "space" : {+ "_0" : "A0000000-0000-0000-0000-000000000002"+ }+ },+ "developerHosts" : [+ "localhost"+ ],+ "edgeToEdgeContent" : true,+ "folderPreviews" : false,+ "hapticFeedbackOnReorder" : false,+ "hasSeenImportPrompt" : true,+ "httpsOnly" : true,+ "linkRoutes" : [+ {+ "destination" : {+ "mostRecentSpace" : {++ }+ },+ "id" : "E0000000-0000-0000-0000-000000000001",+ "match" : "contains",+ "text" : "meet.google.com"+ },+ {+ "destination" : {+ "littleWindow" : {++ }+ },+ "id" : "E0000000-0000-0000-0000-000000000002",+ "match" : "equals",+ "text" : "example.com\/standup"+ }+ ],+ "newTabButtonAtTop" : false,+ "newTabButtonDefaultMigrated" : true,+ "newTabsAtTop" : false,+ "peekInEveryTab" : true,+ "peekLinksToOtherSites" : false,+ "peekOnShiftClick" : false,+ "searchEngine" : "kagi",+ "searchSuggestions" : false,+ "showSpaceHeaderOnSingleSpace" : false,+ "showStatusBar" : false,+ "showToolbar" : true,+ "tabSleep" : "fourHours",+ "tabSleepEnabled" : true,+ "toolbarDefaultMigrated" : true,+ "warnBeforeQuitting" : true+}\ No newline at end of filediff --git a/Packages/CraCore/Tests/CraCoreTests/Fixtures/Model/recorded/sidebar-legacy.json b/Packages/CraCore/Tests/CraCoreTests/Fixtures/Model/recorded/sidebar-legacy.jsonnew file mode 100644index 0000000..a7e3836--- /dev/null+++ b/Packages/CraCore/Tests/CraCoreTests/Fixtures/Model/recorded/sidebar-legacy.json@@ -0,0 +1,152 @@+{+ "favoritesContainerID" : "C0000000-0000-0000-0000-0000000000F0",+ "items" : [+ {+ "children" : [+ "D0000000-0000-0000-0000-000000000001"+ ],+ "createdAt" : "2025-05-01T08:00:00Z",+ "data" : {+ "container" : {+ "_0" : {+ "favorites" : {+ "spaceID" : "00000000-0000-0000-0000-000000000000"+ }+ }+ }+ },+ "id" : "C0000000-0000-0000-0000-0000000000F0",+ "isUnread" : false+ },+ {+ "children" : [+ "D0000000-0000-0000-0000-000000000002"+ ],+ "createdAt" : "2025-05-01T08:00:00Z",+ "data" : {+ "container" : {+ "_0" : {+ "pinned" : {+ "spaceID" : "A0000000-0000-0000-0000-000000000001"+ }+ }+ }+ },+ "id" : "C0000000-0000-0000-0000-000000000002",+ "isUnread" : false+ },+ {+ "children" : [+ "D0000000-0000-0000-0000-000000000003"+ ],+ "createdAt" : "2025-05-01T08:00:00Z",+ "data" : {+ "container" : {+ "_0" : {+ "today" : {+ "spaceID" : "A0000000-0000-0000-0000-000000000001"+ }+ }+ }+ },+ "id" : "C0000000-0000-0000-0000-000000000003",+ "isUnread" : false+ },+ {+ "children" : [++ ],+ "createdAt" : "2025-05-02T08:00:00Z",+ "data" : {+ "tab" : {+ "_0" : {+ "faviconKey" : "Calendar.Example.com",+ "muted" : false,+ "savedTitle" : "",+ "savedURL" : "https:\/\/Calendar.Example.com\/week",+ "url" : "https:\/\/Calendar.Example.com\/week"+ }+ }+ },+ "id" : "D0000000-0000-0000-0000-000000000001",+ "isUnread" : false,+ "parentID" : "C0000000-0000-0000-0000-0000000000F0"+ },+ {+ "children" : [++ ],+ "createdAt" : "2025-05-02T08:00:00Z",+ "data" : {+ "folder" : {++ }+ },+ "id" : "D0000000-0000-0000-0000-000000000002",+ "isUnread" : false,+ "liveFolder" : {+ "filter" : {+ "attributes" : 2,+ "hiddenRepositories" : [++ ]+ },+ "hiddenItems" : [++ ],+ "source" : "github",+ "ssoOrganizations" : [++ ]+ },+ "parentID" : "C0000000-0000-0000-0000-000000000002",+ "title" : "Live"+ },+ {+ "children" : [++ ],+ "createdAt" : "2025-05-02T08:00:00Z",+ "data" : {+ "split" : {+ "_0" : {+ "orientation" : "horizontal",+ "widthFactors" : [++ ]+ }+ }+ },+ "id" : "D0000000-0000-0000-0000-000000000003",+ "isUnread" : false,+ "parentID" : "C0000000-0000-0000-0000-000000000003"+ }+ ],+ "spaceOrder" : [+ "A0000000-0000-0000-0000-000000000001",+ "A0000000-0000-0000-0000-0000000000FF"+ ],+ "spaces" : [+ {+ "createdAt" : "2025-05-01T08:00:00Z",+ "emoji" : "🌱",+ "favoritesContainerID" : "C0000000-0000-0000-0000-000000000001",+ "id" : "A0000000-0000-0000-0000-000000000001",+ "pinnedContainerID" : "C0000000-0000-0000-0000-000000000002",+ "theme" : {+ "appearance" : "auto",+ "colors" : [+ "#1C242B",+ "#3A3660"+ ],+ "intensity" : 0.8,+ "noise" : 0.15,+ "solid" : false,+ "vibrant" : false+ },+ "title" : "Home",+ "todayContainerID" : "C0000000-0000-0000-0000-000000000003"+ }+ ],+ "version" : 1+}\ No newline at end of filediff --git a/Packages/CraCore/Tests/CraCoreTests/Fixtures/Model/recorded/sidebar.json b/Packages/CraCore/Tests/CraCoreTests/Fixtures/Model/recorded/sidebar.jsonnew file mode 100644index 0000000..25158ef--- /dev/null+++ b/Packages/CraCore/Tests/CraCoreTests/Fixtures/Model/recorded/sidebar.json@@ -0,0 +1,363 @@+{+ "items" : [+ {+ "children" : [+ "D0000000-0000-0000-0000-000000000001"+ ],+ "createdAt" : "2026-10-01T08:00:00Z",+ "data" : {+ "container" : {+ "_0" : {+ "favorites" : {+ "spaceID" : "A0000000-0000-0000-0000-000000000001"+ }+ }+ }+ },+ "id" : "C0000000-0000-0000-0000-000000000001",+ "isUnread" : false+ },+ {+ "children" : [+ "D0000000-0000-0000-0000-000000000002",+ "D0000000-0000-0000-0000-000000000005"+ ],+ "createdAt" : "2026-10-01T08:00:00Z",+ "data" : {+ "container" : {+ "_0" : {+ "pinned" : {+ "spaceID" : "A0000000-0000-0000-0000-000000000001"+ }+ }+ }+ },+ "id" : "C0000000-0000-0000-0000-000000000002",+ "isUnread" : false+ },+ {+ "children" : [+ "D0000000-0000-0000-0000-000000000006",+ "D0000000-0000-0000-0000-000000000009"+ ],+ "createdAt" : "2026-10-01T08:00:00Z",+ "data" : {+ "container" : {+ "_0" : {+ "today" : {+ "spaceID" : "A0000000-0000-0000-0000-000000000001"+ }+ }+ }+ },+ "id" : "C0000000-0000-0000-0000-000000000003",+ "isUnread" : false+ },+ {+ "children" : [++ ],+ "createdAt" : "2026-10-02T08:00:00Z",+ "data" : {+ "container" : {+ "_0" : {+ "favorites" : {+ "spaceID" : "A0000000-0000-0000-0000-000000000002"+ }+ }+ }+ },+ "id" : "C0000000-0000-0000-0000-000000000004",+ "isUnread" : false+ },+ {+ "children" : [++ ],+ "createdAt" : "2026-10-02T08:00:00Z",+ "data" : {+ "container" : {+ "_0" : {+ "pinned" : {+ "spaceID" : "A0000000-0000-0000-0000-000000000002"+ }+ }+ }+ },+ "id" : "C0000000-0000-0000-0000-000000000005",+ "isUnread" : false+ },+ {+ "children" : [++ ],+ "createdAt" : "2026-10-02T08:00:00Z",+ "data" : {+ "container" : {+ "_0" : {+ "today" : {+ "spaceID" : "A0000000-0000-0000-0000-000000000002"+ }+ }+ }+ },+ "id" : "C0000000-0000-0000-0000-000000000006",+ "isUnread" : false+ },+ {+ "children" : [++ ],+ "createdAt" : "2026-10-03T08:00:00Z",+ "data" : {+ "tab" : {+ "_0" : {+ "customIconKey" : "custom-mail",+ "faviconKey" : "mail.example.com",+ "muted" : true,+ "savedTitle" : "Inbox (3)",+ "savedURL" : "https:\/\/mail.example.com\/",+ "tileColor" : "#E63333",+ "timeLastActiveAt" : "2026-10-30T09:00:00Z",+ "url" : "https:\/\/mail.example.com\/inbox"+ }+ }+ },+ "id" : "D0000000-0000-0000-0000-000000000001",+ "isUnread" : false,+ "parentID" : "C0000000-0000-0000-0000-000000000001"+ },+ {+ "children" : [+ "D0000000-0000-0000-0000-000000000003"+ ],+ "createdAt" : "2026-10-03T08:00:00Z",+ "data" : {+ "folder" : {++ }+ },+ "folderIcon" : "white",+ "id" : "D0000000-0000-0000-0000-000000000002",+ "isUnread" : false,+ "parentID" : "C0000000-0000-0000-0000-000000000002",+ "title" : "Reading"+ },+ {+ "children" : [++ ],+ "createdAt" : "2026-10-03T08:00:00Z",+ "data" : {+ "tab" : {+ "_0" : {+ "activeTabBeforeCreationID" : "D0000000-0000-0000-0000-000000000001",+ "faviconKey" : "blog.example.org",+ "muted" : false,+ "savedTitle" : "Post one",+ "savedURL" : "https:\/\/blog.example.org\/",+ "url" : "https:\/\/blog.example.org\/post\/1"+ }+ }+ },+ "id" : "D0000000-0000-0000-0000-000000000003",+ "isUnread" : true,+ "parentID" : "D0000000-0000-0000-0000-000000000002",+ "title" : "My blog"+ },+ {+ "children" : [+ "D0000000-0000-0000-0000-000000000004"+ ],+ "createdAt" : "2026-10-04T08:00:00Z",+ "data" : {+ "folder" : {++ }+ },+ "id" : "D0000000-0000-0000-0000-000000000005",+ "isUnread" : false,+ "liveFolder" : {+ "enterprise" : "example-ent",+ "filter" : {+ "attributes" : 5,+ "hiddenRepositories" : [+ "example\/old"+ ]+ },+ "hiddenItems" : [+ "https:\/\/github.com\/example\/app\/pull\/7"+ ],+ "lastError" : "rateLimited",+ "lastFetch" : "2026-10-31T10:00:00Z",+ "source" : "github",+ "ssoOrganizations" : [+ "example-org"+ ]+ },+ "parentID" : "C0000000-0000-0000-0000-000000000002",+ "title" : "Reviews"+ },+ {+ "children" : [++ ],+ "createdAt" : "2026-10-31T10:00:00Z",+ "data" : {+ "tab" : {+ "_0" : {+ "faviconKey" : "github.com",+ "liveGoneAt" : "2026-10-31T12:00:00Z",+ "liveItemURL" : "https:\/\/github.com\/example\/app\/pull\/9",+ "liveSubtitle" : "someone",+ "muted" : false,+ "savedTitle" : "Fix the thing",+ "savedURL" : "https:\/\/github.com\/example\/app\/pull\/9",+ "url" : "https:\/\/github.com\/example\/app\/pull\/9"+ }+ }+ },+ "id" : "D0000000-0000-0000-0000-000000000004",+ "isUnread" : false,+ "parentID" : "D0000000-0000-0000-0000-000000000005"+ },+ {+ "children" : [+ "D0000000-0000-0000-0000-000000000007",+ "D0000000-0000-0000-0000-000000000008"+ ],+ "createdAt" : "2026-10-05T08:00:00Z",+ "data" : {+ "split" : {+ "_0" : {+ "focusTabID" : "D0000000-0000-0000-0000-000000000008",+ "orientation" : "vertical",+ "timeLastActiveAt" : "2026-10-30T10:00:00Z",+ "widthFactors" : [+ "D0000000-0000-0000-0000-000000000007",+ 0.6+ ]+ }+ }+ },+ "id" : "D0000000-0000-0000-0000-000000000006",+ "isUnread" : false,+ "parentID" : "C0000000-0000-0000-0000-000000000003"+ },+ {+ "children" : [++ ],+ "createdAt" : "2026-10-05T08:00:00Z",+ "data" : {+ "tab" : {+ "_0" : {+ "faviconKey" : "docs.example.com",+ "muted" : false,+ "savedTitle" : "",+ "savedURL" : "https:\/\/docs.example.com\/a",+ "url" : "https:\/\/docs.example.com\/a"+ }+ }+ },+ "id" : "D0000000-0000-0000-0000-000000000007",+ "isUnread" : false,+ "parentID" : "D0000000-0000-0000-0000-000000000006"+ },+ {+ "children" : [++ ],+ "createdAt" : "2026-10-05T08:00:00Z",+ "data" : {+ "tab" : {+ "_0" : {+ "muted" : false,+ "savedTitle" : "",+ "savedURL" : "about:blank",+ "url" : "about:blank"+ }+ }+ },+ "id" : "D0000000-0000-0000-0000-000000000008",+ "isUnread" : false,+ "parentID" : "D0000000-0000-0000-0000-000000000006"+ },+ {+ "children" : [++ ],+ "createdAt" : "2026-10-06T08:00:00Z",+ "data" : {+ "tab" : {+ "_0" : {+ "faviconKey" : "Shop.Example.co.uk",+ "muted" : false,+ "savedTitle" : "",+ "savedURL" : "https:\/\/Shop.Example.co.uk\/basket?x=1",+ "url" : "https:\/\/Shop.Example.co.uk\/basket?x=1"+ }+ }+ },+ "id" : "D0000000-0000-0000-0000-000000000009",+ "isUnread" : false,+ "parentID" : "C0000000-0000-0000-0000-000000000003"+ }+ ],+ "profiles" : [+ {+ "id" : "B0000000-0000-0000-0000-000000000001",+ "name" : "Work"+ }+ ],+ "spaceOrder" : [+ "A0000000-0000-0000-0000-000000000001",+ "A0000000-0000-0000-0000-000000000002"+ ],+ "spaces" : [+ {+ "createdAt" : "2026-10-01T08:00:00Z",+ "emoji" : "🏠",+ "favoritesContainerID" : "C0000000-0000-0000-0000-000000000001",+ "id" : "A0000000-0000-0000-0000-000000000001",+ "pinnedContainerID" : "C0000000-0000-0000-0000-000000000002",+ "theme" : {+ "appearance" : "light",+ "colors" : [+ "#F4F1EA",+ "#29283D"+ ],+ "intensity" : 0.6,+ "noise" : 0.15,+ "solid" : false,+ "vibrant" : false+ },+ "title" : "Home",+ "todayContainerID" : "C0000000-0000-0000-0000-000000000003"+ },+ {+ "createdAt" : "2026-10-02T08:00:00Z",+ "emoji" : "",+ "favoritesContainerID" : "C0000000-0000-0000-0000-000000000004",+ "id" : "A0000000-0000-0000-0000-000000000002",+ "pinnedContainerID" : "C0000000-0000-0000-0000-000000000005",+ "profileID" : "B0000000-0000-0000-0000-000000000001",+ "symbol" : "briefcase",+ "theme" : {+ "accent" : "#2861B3",+ "appearance" : "dark",+ "colors" : [+ "#2861B3",+ "#2861B3"+ ],+ "intensity" : 1,+ "noise" : 0,+ "solid" : true,+ "vibrant" : true+ },+ "title" : "Work",+ "todayContainerID" : "C0000000-0000-0000-0000-000000000006"+ }+ ],+ "version" : 1+}\ No newline at end of filediff --git a/Packages/CraCore/Tests/CraCoreTests/Fixtures/Model/recorded/windows-legacy.json b/Packages/CraCore/Tests/CraCoreTests/Fixtures/Model/recorded/windows-legacy.jsonnew file mode 100644index 0000000..6b9c874--- /dev/null+++ b/Packages/CraCore/Tests/CraCoreTests/Fixtures/Model/recorded/windows-legacy.json@@ -0,0 +1,22 @@+{+ "collapsedPinnedSpaces" : [++ ],+ "expandedFolders" : [++ ],+ "sidebarWidth" : 300,+ "windows" : [+ {+ "focusedSpaceID" : "A0000000-0000-0000-0000-000000000001",+ "frame" : "{{0, 0}, {1200, 800}}",+ "id" : "00000000-0000-0000-0000-000000000000",+ "isIncognito" : false,+ "selectedTabPerSpace" : [+ "A0000000-0000-0000-0000-000000000001",+ "D0000000-0000-0000-0000-000000000003"+ ],+ "sidebarVisible" : false+ }+ ]+}\ No newline at end of filediff --git a/Packages/CraCore/Tests/CraCoreTests/Fixtures/Model/recorded/windows.json b/Packages/CraCore/Tests/CraCoreTests/Fixtures/Model/recorded/windows.jsonnew file mode 100644index 0000000..75e6d6d--- /dev/null+++ b/Packages/CraCore/Tests/CraCoreTests/Fixtures/Model/recorded/windows.json@@ -0,0 +1,32 @@+{+ "collapsedPinnedSpaces" : [+ "A0000000-0000-0000-0000-000000000002"+ ],+ "expandedFolders" : [+ "D0000000-0000-0000-0000-000000000002"+ ],+ "littleWindowSize" : "{480, 640}",+ "sidebarWidth" : 280,+ "windows" : [+ {+ "focusedSpaceID" : "A0000000-0000-0000-0000-000000000001",+ "frame" : "{{100, 100}, {1400, 880}}",+ "id" : "F0000000-0000-0000-0000-000000000001",+ "isIncognito" : false,+ "selectedTabPerSpace" : [+ "A0000000-0000-0000-0000-000000000001",+ "D0000000-0000-0000-0000-000000000009"+ ],+ "sidebarVisible" : false+ },+ {+ "focusedSpaceID" : "A0000000-0000-0000-0000-000000000002",+ "id" : "F0000000-0000-0000-0000-000000000002",+ "isIncognito" : false,+ "selectedTabPerSpace" : [++ ],+ "sidebarVisible" : true+ }+ ]+}\ No newline at end of filediff --git a/Packages/CraCore/Tests/CraCoreTests/ItemTableTests.swift b/Packages/CraCore/Tests/CraCoreTests/ItemTableTests.swiftnew file mode 100644index 0000000..aa137cd--- /dev/null+++ b/Packages/CraCore/Tests/CraCoreTests/ItemTableTests.swift@@ -0,0 +1,60 @@+import CraCore+import Foundation+import Observation+import Testing++@MainActor+struct ItemTableTests {+ final class Fired: @unchecked Sendable { var value = false }++ /// Why ItemTable exists: a row that read one item doesn't redraw when another changes.+ @Test func readersOfOneItemIgnoreOthers() {+ let table = ItemTable()+ let a = SidebarItem.tab("https://a.test", parent: nil), b = SidebarItem.tab("https://b.test", parent: nil)+ table[a.id] = a+ table[b.id] = b+ let fired = Fired()+ _ = withObservationTracking { table[a.id] } onChange: { fired.value = true }+ var changed = b+ changed.title = "B"+ table[b.id] = changed+ #expect(!fired.value)+ var changedA = a+ changedA.title = "A"+ table[a.id] = changedA+ #expect(fired.value)+ }++ @Test func walksSeeEveryChange() {+ let table = ItemTable()+ let a = SidebarItem.folder("A", parent: nil)+ let fired = Fired()+ _ = withObservationTracking { table.values.count } onChange: { fired.value = true }+ table[a.id] = a+ #expect(fired.value && table.all.count == 1 && table[a.id] == a)+ }++ @Test func writingTheSameItemNotifiesNobody() {+ let table = ItemTable()+ let a = SidebarItem.folder("A", parent: nil)+ table[a.id] = a+ let fired = Fired()+ _ = withObservationTracking { table[a.id] } onChange: { fired.value = true }+ table[a.id] = a+ #expect(!fired.value)+ table[a.id] = nil+ #expect(fired.value && table[a.id] == nil)+ }++ /// State kept beside the item (expansion, selection) invalidates its readers through notify.+ @Test func observeAndNotify() {+ let table = ItemTable()+ let id = UUID(), fired = Fired()+ _ = withObservationTracking { table.observe(id) } onChange: { fired.value = true }+ table.notify(UUID())+ #expect(!fired.value)+ table.notify(id)+ #expect(fired.value)+ #expect(ItemSignal().version == 0)+ }+}diff --git a/Packages/CraCore/Tests/CraCoreTests/KeyChordTests.swift b/Packages/CraCore/Tests/CraCoreTests/KeyChordTests.swiftnew file mode 100644index 0000000..5022ca7--- /dev/null+++ b/Packages/CraCore/Tests/CraCoreTests/KeyChordTests.swift@@ -0,0 +1,36 @@+import CraCore+import Testing++struct KeyChordTests {+ static let command = KeyChord.Modifiers.command.rawValue++ /// NSEvent.ModifierFlags' raw values, which keybindings.json has always stored.+ @Test func modifierBitsAreAppKits() {+ #expect(KeyChord.Modifiers.shift.rawValue == 0x20000)+ #expect(KeyChord.Modifiers.control.rawValue == 0x40000)+ #expect(KeyChord.Modifiers.option.rawValue == 0x80000)+ #expect(KeyChord.Modifiers.command.rawValue == 0x100000)+ #expect(KeyChord.left.unicodeScalars.map(\.value) == [0xF702] && KeyChord.right.unicodeScalars.map(\.value) == [0xF703])+ #expect(KeyChord.up.unicodeScalars.map(\.value) == [0xF700] && KeyChord.down.unicodeScalars.map(\.value) == [0xF701])+ }++ @Test(arguments: [+ (KeyChord(key: "t", modifiers: command), "⌘T"),+ (KeyChord(key: "[", modifiers: command | KeyChord.Modifiers.shift.rawValue), "⇧⌘["),+ (KeyChord(key: KeyChord.tab, modifiers: KeyChord.Modifiers.control.rawValue), "⌃⇥"),+ (KeyChord(key: KeyChord.left, modifiers: command | KeyChord.Modifiers.option.rawValue), "⌥⌘←"),+ (KeyChord(key: KeyChord.right, modifiers: command), "⌘→"),+ (KeyChord(key: KeyChord.up, modifiers: KeyChord.Modifiers([.control, .option, .shift, .command]).rawValue), "⌃⌥⇧⌘↑"),+ (KeyChord(key: KeyChord.down, modifiers: 0), "↓"),+ // Caps Lock and the function-key bit are kept in the file but never shown.+ (KeyChord(key: "d", modifiers: command | 0x10000 | 0x800000), "⌘D"),+ ])+ func display(chord: KeyChord, shown: String) {+ #expect(chord.display == shown)+ }++ @Test func keysReadsTheStoredBits() {+ let chord = KeyChord(key: "s", modifiers: Self.command | KeyChord.Modifiers.shift.rawValue)+ #expect(chord.keys == KeyChord.Modifiers([.command, .shift]))+ }+}diff --git a/Packages/CraCore/Tests/CraCoreTests/LinkRoutingTests.swift b/Packages/CraCore/Tests/CraCoreTests/LinkRoutingTests.swiftnew file mode 100644index 0000000..ee02cb6--- /dev/null+++ b/Packages/CraCore/Tests/CraCoreTests/LinkRoutingTests.swift@@ -0,0 +1,69 @@+import CraCore+import Foundation+import Testing++/// Air Traffic Control against what Arc 1.170 did with the same routes (26 Oct 2026, links handed+/// over with `open -g -a Arc`; docs/arc-reverse-engineering.md, "Air Traffic Control").+struct LinkRoutingTests {+ @Test(arguments: [+ // Case, scheme and a leading www. go on both sides.+ (LinkMatchStyle.contains, "https://example.com/atc-scheme", "http://example.com/atc-scheme", true),+ (.contains, "https://example.com/atc-scheme", "https://www.example.com/atc-scheme", true),+ (.contains, "ATC-CASE", "https://example.com/atc-case", true),+ // Contains also sees the query and the fragment.+ (.contains, "atc-order", "https://example.com/?x=atc-order", true),+ (.contains, "atc-recent", "https://example.com/#atc-recent", true),+ (.contains, "atc-missing", "https://example.com/other", false),+ // Is equal to: host and path only, trailing slashes dropped.+ (.equals, "example.com/atc-eq", "https://example.com/atc-eq?x=1", true),+ (.equals, "example.com/atc-eq", "https://example.com/atc-eq#frag", true),+ (.equals, "example.com/atc-eq", "http://www.EXAMPLE.com/atc-eq/", true),+ (.equals, "example.com/atc-eq", "https://example.com/atc-eq/more", false),+ // An empty route matches nothing.+ (.contains, " ", "https://example.com/", false),+ (.equals, "", "https://example.com/", false),+ ])+ func matchesLikeArc(style: LinkMatchStyle, text: String, url: String, matches: Bool) {+ #expect(LinkRoute(match: style, text: text).matches(url) == matches)+ }++ @Test func firstMatchWinsElseTheDefault() {+ let work = UUID()+ var settings = AppSettings()+ settings.linkRoutes = [+ LinkRoute(match: .contains, text: "example.com", destination: .space(work)),+ LinkRoute(match: .contains, text: "example.com/call", destination: .littleWindow),+ .googleMeet,+ ]+ #expect(settings.destination(forExternalURL: "https://example.com/call") == .space(work))+ #expect(settings.destination(forExternalURL: "https://meet.google.com/abc") == .mostRecentSpace)+ #expect(settings.destination(forExternalURL: "https://other.test/") == .littleWindow, "no match: the default")+ }++ @Test func styles() {+ #expect(LinkMatchStyle.allCases.map(\.label) == ["Is equal to", "Contains"])+ #expect(LinkMatchStyle.allCases.map(\.id) == ["equals", "contains"])+ let route = LinkRoute()+ #expect(route.match == .contains && route.text.isEmpty && route.destination == .mostRecentSpace)+ }++ /// Peek's "other site": the registrable domain, with co.uk-style suffixes kept together.+ @Test(arguments: [+ ("https://mail.google.com/a", "google.com"),+ ("https://accounts.google.com/", "google.com"),+ ("https://Shop.Example.co.uk/basket", "example.co.uk"),+ ("https://a.b.example.com.au/", "example.com.au"),+ ("https://news.bbc.uk/", "bbc.uk"),+ ("https://example.com/", "example.com"),+ ("http://192.168.0.10:8080/", "192.168.0.10"),+ ("http://localhost:3000/", "localhost"),+ ])+ func siteOf(url: String, site: String) {+ #expect(SiteKey.site(of: url) == site)+ }++ @Test(arguments: ["file:///tmp/a.html", "about:blank", "chrome://extensions", "notes", "https:///path"])+ func noSiteOutsideTheWeb(url: String) {+ #expect(SiteKey.site(of: url) == nil)+ }+}diff --git a/Packages/CraCore/Tests/CraCoreTests/LiveFolderModelTests.swift b/Packages/CraCore/Tests/CraCoreTests/LiveFolderModelTests.swiftnew file mode 100644index 0000000..0fc1b66--- /dev/null+++ b/Packages/CraCore/Tests/CraCoreTests/LiveFolderModelTests.swift@@ -0,0 +1,24 @@+import CraCore+import Testing++struct LiveFolderModelTests {+ @Test func signInGoesToTheEnterpriseWhenThereIsOne() {+ var folder = LiveFolderData()+ #expect(folder.signInURL == "https://github.com/login?return_to=%2Fpulls")+ folder.enterprise = "example-ent"+ #expect(folder.signInURL == "https://github.com/enterprises/example-ent/sso")+ }++ @Test func defaultsShowEveryPullRequest() {+ let folder = LiveFolderData()+ #expect(folder.source == .github && folder.filter == GitHubLiveFilter() && folder.filter.attributes == .all)+ #expect(GitHubLiveFilter.Attributes.all.rawValue == 7, "Arc's bit mask for all three")+ #expect(GitHubLiveFilter(attributes: [.authored, .teamReviewRequests]).attributes.rawValue == 5)+ }++ @Test func pullRequestIsKnownByItsURL() {+ let pr = LivePullRequest(owner: "example", repo: "app", number: 9, title: "Fix", author: "someone", state: .draft)+ #expect(pr.url == "https://github.com/example/app/pull/9" && pr.id == pr.url && pr.repository == "example/app")+ #expect(!pr.createdByMe && !pr.isAwaitingMyReview && pr.createdAt == nil && pr.updatedAt == nil)+ }+}diff --git a/Packages/CraCore/Tests/CraCoreTests/ModelFixtureTests.swift b/Packages/CraCore/Tests/CraCoreTests/ModelFixtureTests.swiftnew file mode 100644index 0000000..5aab87e--- /dev/null+++ b/Packages/CraCore/Tests/CraCoreTests/ModelFixtureTests.swift@@ -0,0 +1,155 @@+import CraCore+import Foundation+import Testing++/// Fixtures/Model/input holds made-up data-folder files: current ones and the shapes older Cra+/// versions wrote. Fixtures/Model/recorded is what Cra saved after loading each of them, recorded+/// from the model code on main (c02cffa) before it moved into CraCore (#51), with JSONStore's+/// encoder and Arc's View ▸ Show Toolbar stubbed on. A file that loads differently from its+/// recording changes what people's settings or sidebars turn into on update.+struct ModelFixtureTests {+ static let decoder: JSONDecoder = {+ let d = JSONDecoder()+ d.dateDecodingStrategy = .iso8601+ return d+ }()++ /// JSONStore's encoder.+ static let encoder: JSONEncoder = {+ let e = JSONEncoder()+ e.outputFormatting = [.prettyPrinted, .sortedKeys]+ e.dateEncodingStrategy = .iso8601+ return e+ }()++ static func data(_ folder: String, _ name: String) throws -> Data {+ let url = try #require(Bundle.module.url(forResource: name, withExtension: nil, subdirectory: "Fixtures/Model/\(folder)"))+ return try Data(contentsOf: url)+ }++ /// The input as Cra loads it, and the recording, each decoded.+ static func load<T: Codable>(_ name: String, as type: T.Type) throws -> (loaded: T, recorded: T) {+ (try decoder.decode(T.self, from: data("input", name)), try decoder.decode(T.self, from: data("recorded", name)))+ }++ /// Ids the decoder makes up are random per process; the recordings have them zeroed.+ static let zero = UUID(uuid: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0))++ /// What SidebarStore does with settings.json: decode, then the one-time toolbar migration.+ static func loadSettings(_ name: String, arcShowsToolbar: Bool? = true) throws -> (loaded: AppSettings, recorded: AppSettings) {+ var (loaded, recorded) = try load(name, as: AppSettings.self)+ loaded.migrateToolbarDefault(arcShowsToolbar: arcShowsToolbar)+ for i in loaded.linkRoutes.indices where loaded.linkRoutes[i].id == LinkRoute.googleMeet.id { loaded.linkRoutes[i].id = zero }+ return (loaded, recorded)+ }++ /// Saving what was loaded and loading it again changes nothing.+ static func roundTrips<T: Codable & Equatable>(_ value: T) throws -> Bool {+ try decoder.decode(T.self, from: encoder.encode(value)) == value+ }++ @Test(arguments: ["sidebar.json", "sidebar-legacy.json"])+ func sidebarLoadsAsRecorded(name: String) throws {+ let (loaded, recorded) = try Self.load(name, as: SidebarDocument.self)+ #expect(loaded == recorded)+ #expect(try Self.roundTrips(loaded))+ }++ @Test(arguments: ["settings.json", "settings-legacy.json", "settings-empty.json", "settings-bad-routes.json"])+ func settingsLoadAsRecorded(name: String) throws {+ let (loaded, recorded) = try Self.loadSettings(name)+ #expect(loaded == recorded)+ #expect(try Self.roundTrips(loaded))+ }++ @Test func windowsLoadAsRecorded() throws {+ let (loaded, recorded) = try Self.load("windows.json", as: WindowPrefs.self)+ #expect(loaded == recorded)+ #expect(try Self.roundTrips(loaded))++ var (legacy, legacyRecorded) = try Self.load("windows-legacy.json", as: WindowPrefs.self)+ legacy.windows[0].id = Self.zero+ #expect(legacy == legacyRecorded)+ }++ @Test func archiveHistoryAndRankingLoadAsRecorded() throws {+ let archive = try Self.load("archive.json", as: [ArchivedItem].self)+ #expect(archive.loaded == archive.recorded)+ let history = try Self.load("history.json", as: [HistoryEntry].self)+ #expect(history.loaded == history.recorded)+ let ranking = try Self.load("commandbar.json", as: RankingData.self)+ #expect(ranking.loaded == ranking.recorded)+ #expect(try Self.roundTrips(archive.loaded) && Self.roundTrips(history.loaded) && Self.roundTrips(ranking.loaded))+ }++ /// keybindings.json keeps its bytes: KeyChord encodes exactly as the AppKit Shortcut did.+ @Test func keybindingsSaveByteForByte() throws {+ let loaded = try Self.decoder.decode([String: [KeyChord]].self, from: Self.data("input", "keybindings.json"))+ #expect(try Self.encoder.encode(loaded) == Self.data("recorded", "keybindings.json"))+ #expect(loaded["nextTab"] == [KeyChord(key: KeyChord.tab, modifiers: 1 << 18), KeyChord(key: KeyChord.right, modifiers: 1 << 20 | 1 << 19)])+ }++ // MARK: What the old shapes turn into++ @Test func legacySidebarGetsWhatTheStoreRepairsFrom() throws {+ let doc = try Self.load("sidebar-legacy.json", as: SidebarDocument.self).loaded+ #expect(doc.favoritesContainerID != nil && doc.profiles == nil)+ let shared = try #require(doc.items.first { $0.id == doc.favoritesContainerID })+ #expect(shared.container == .favorites(spaceID: ContainerKind.sharedFavoritesSpaceID),+ "favorites without a space stand for the container every space shared")+ let tab = try #require(doc.items.first { $0.isTab }?.tab)+ #expect(tab.savedURL == tab.url && tab.savedTitle.isEmpty && !tab.muted)+ #expect(tab.faviconKey == "Calendar.Example.com", "a missing favicon key is the host as written")+ let live = try #require(doc.items.first { $0.isLiveFolder }?.liveFolder)+ #expect(live.lastError == nil, "an error this version doesn't know is dropped, not fatal")+ #expect(live.filter.attributes == .reviewRequests && live.hiddenItems.isEmpty && live.ssoOrganizations.isEmpty)+ let split = try #require(doc.items.first { $0.isSplit }?.split)+ #expect(split == SplitData())+ }++ @Test func legacySettingsMigrate() throws {+ let legacy = try Self.loadSettings("settings-legacy.json").loaded+ #expect(legacy.defaultLinkDestination == .mostRecentSpace && !legacy.openExternalLinksInLittleWindow,+ "Links from other apps → Little Window off becomes the most recent space")+ #expect(legacy.linkRoutes.map(\.text) == ["meet.google.com"], "settings from before Air Traffic Control get Arc's Meet route")+ #expect(legacy.newTabButtonAtTop, "the New Tab row goes back above Today once")+ #expect(legacy.tabSleep == .oneHour, "a sleep threshold this version doesn't know falls back")+ #expect(legacy.showToolbar, "Arc's toolbar preference wins over the 0.1.0 value")++ let bad = try Self.loadSettings("settings-bad-routes.json").loaded+ #expect(bad.defaultLinkDestination == .littleWindow && bad.linkRoutes.isEmpty)+ }++ @Test func legacyWindowsBecomeOneWindow() throws {+ let prefs = try Self.load("windows-legacy.json", as: WindowPrefs.self).loaded+ #expect(prefs.windows.count == 1 && prefs.sidebarWidth == 300 && prefs.littleWindowSize == nil)+ let w = prefs.windows[0]+ #expect(!w.sidebarVisible && w.frame == "{{0, 0}, {1200, 800}}" && !w.isIncognito)+ #expect(w.selectedTabPerSpace[try #require(w.focusedSpaceID)] != nil)+ }++ // MARK: The toolbar migration, moved out of the decoder++ @Test func decodingNeverReadsArc() throws {+ let settings = try Self.decoder.decode(AppSettings.self, from: Self.data("input", "settings-empty.json"))+ #expect(!settings.toolbarDefaultMigrated && !settings.showToolbar, "the decoder leaves the toolbar for the migration")+ }++ @Test(arguments: [(true as Bool?, true), (false, false), (nil, false)])+ func unmarkedSettingsTakeArcsToolbarOnce(arc: Bool?, shown: Bool) throws {+ var settings = try Self.decoder.decode(AppSettings.self, from: Self.data("input", "settings-legacy.json"))+ settings.migrateToolbarDefault(arcShowsToolbar: arc)+ #expect(settings.showToolbar == shown && settings.toolbarDefaultMigrated)+ settings.migrateToolbarDefault(arcShowsToolbar: !shown)+ #expect(settings.showToolbar == shown, "a second launch keeps the migrated value")+ }++ @Test func markedSettingsNeverAskArc() throws {+ var settings = try Self.decoder.decode(AppSettings.self, from: Self.data("input", "settings.json"))+ settings.migrateToolbarDefault(arcShowsToolbar: { Issue.record("Arc's preference was read"); return false }())+ #expect(settings.showToolbar)+ var fresh = AppSettings()+ fresh.migrateToolbarDefault(arcShowsToolbar: { Issue.record("Arc's preference was read"); return true }())+ #expect(!fresh.showToolbar, "a first launch (no settings.json) starts with the toolbar off")+ }+}diff --git a/Packages/CraCore/Tests/CraCoreTests/SidebarModelTests.swift b/Packages/CraCore/Tests/CraCoreTests/SidebarModelTests.swiftnew file mode 100644index 0000000..c576e88--- /dev/null+++ b/Packages/CraCore/Tests/CraCoreTests/SidebarModelTests.swift@@ -0,0 +1,140 @@+import CraCore+import Foundation+import Testing++struct SidebarModelTests {+ static let space = UUID()++ /// The sidebar row's title: the user's name, then the page title, then the host.+ @Test func displayTitle() {+ var tab = SidebarItem.tab("https://example.com/a", title: "Page", parent: nil)+ #expect(tab.displayTitle == "Page")+ tab.title = "Renamed"+ #expect(tab.displayTitle == "Renamed")+ tab.title = ""+ #expect(tab.displayTitle == "Page", "an empty name is no name")+ #expect(SidebarItem.tab("https://example.com/a", parent: nil).displayTitle == "example.com")+ #expect(SidebarItem.tab("notes", parent: nil).displayTitle == "notes", "no host: the URL as typed")+ #expect(SidebarItem.tab("about:blank", parent: nil).displayTitle == "New Tab")+ #expect(SidebarItem.tab("", parent: nil).displayTitle == "New Tab")+ #expect(SidebarItem.split(parent: nil).displayTitle == "Split View")+ #expect(SidebarItem.folder("Reading", parent: nil).displayTitle == "Reading")+ #expect(SidebarItem.container(.today(spaceID: Self.space)).displayTitle == "Untitled")+ }++ @Test func kinds() {+ let parent = UUID()+ let tab = SidebarItem.tab("https://example.com", parent: parent)+ #expect(tab.isTab && !tab.isFolder && !tab.isSplit && tab.split == nil && tab.container == nil && tab.parentID == parent)+ #expect(tab.tab?.faviconKey == "example.com" && tab.tab?.savedURL == "https://example.com")+ var folder = SidebarItem.folder("F", parent: nil)+ #expect(folder.isFolder && !folder.isLiveFolder && folder.tab == nil && !folder.isEmptyTab)+ folder.liveFolder = LiveFolderData()+ #expect(folder.isLiveFolder)+ let split = SidebarItem.split(parent: nil)+ #expect(split.isSplit && split.split == SplitData())+ let id = UUID()+ let container = SidebarItem.container(.pinned(spaceID: Self.space), id: id)+ #expect(container.id == id && container.container?.spaceID == Self.space)+ }++ @Test func iconKeyPrefersTheUsersPick() {+ var tab = TabData(url: "https://example.com", title: "E")+ #expect(tab.iconKey == "example.com")+ tab.customIconKey = "picked"+ #expect(tab.iconKey == "picked")+ }++ @Test func containerKindsRoundTripAndNeedAKind() throws {+ for kind in [ContainerKind.favorites(spaceID: Self.space), .pinned(spaceID: Self.space), .today(spaceID: Self.space)] {+ #expect(try JSONDecoder().decode(ContainerKind.self, from: JSONEncoder().encode(kind)) == kind)+ #expect(kind.spaceID == Self.space)+ }+ #expect(throws: DecodingError.self) { try JSONDecoder().decode(ContainerKind.self, from: Data("{}".utf8)) }+ #expect(throws: DecodingError.self) { try JSONDecoder().decode(ContainerKind.self, from: Data(#"{"pinned": {}}"#.utf8)) }+ }++ @Test func freshSidebarHasOneSpaceWithItsContainers() throws {+ let doc = SidebarDocument.fresh()+ let space = try #require(doc.spaces.first)+ #expect(doc.spaces.count == 1 && doc.spaceOrder == [space.id] && space.title == "Personal" && space.emoji == "🌱")+ #expect(Set(doc.items.map(\.id)) == [space.favoritesContainerID, space.pinnedContainerID, space.todayContainerID])+ #expect(doc.items.allSatisfy { $0.container?.spaceID == space.id })+ #expect(doc.version == 1 && doc.favoritesContainerID == nil && doc.profiles == nil)+ }++ @Test func profileFolderName() {+ let id = UUID()+ #expect(BrowserProfile(id: id, name: "Work").directoryName == "Profile \(id.uuidString)")+ }++ @Test func thresholds() {+ #expect(AutoArchiveThreshold.allCases.map(\.seconds) == [43_200, 86_400, 604_800, 2_592_000])+ #expect(AutoArchiveThreshold.allCases.map(\.label) == ["12 hours", "24 hours", "7 days", "30 days"])+ #expect(AutoArchiveThreshold.allCases.map(\.id) == AutoArchiveThreshold.allCases.map(\.rawValue))+ #expect(TabSleepThreshold.allCases.map(\.seconds) == [900, 3600, 14_400, 43_200])+ #expect(TabSleepThreshold.allCases.map(\.label) == ["15 minutes", "1 hour", "4 hours", "12 hours"])+ #expect(TabSleepThreshold.allCases.map(\.id) == TabSleepThreshold.allCases.map(\.rawValue))+ }++ @Test(arguments: [+ (SearchEngine.google, "Google", "https://www.google.com/search?q=a%20b%26c", "https://www.google.com/complete/search?client=chrome&ie=utf-8&oe=utf-8&q=a%20b%26c"),+ (.duckduckgo, "DuckDuckGo", "https://duckduckgo.com/?q=a%20b%26c", "https://duckduckgo.com/ac/?type=list&q=a%20b%26c"),+ (.bing, "Bing", "https://www.bing.com/search?q=a%20b%26c", "https://api.bing.com/osjson.aspx?query=a%20b%26c"),+ (.kagi, "Kagi", "https://kagi.com/search?q=a%20b%26c", "https://kagi.com/api/autosuggest?q=a%20b%26c"),+ ])+ func searchEngines(engine: SearchEngine, label: String, search: String, suggest: String) {+ #expect(engine.label == label && engine.id == engine.rawValue)+ #expect(engine.searchURL("a b&c") == search, "& is escaped so it stays in the query")+ #expect(engine.suggestURL("a b&c")?.absoluteString == suggest)+ }++ @Test func developerModeIsPerSite() {+ var settings = AppSettings()+ #expect(AppSettings.siteKey(for: "https://www.Example.com/a") == "example.com")+ #expect(AppSettings.siteKey(for: "notes") == nil)+ settings.toggleDeveloperMode(url: "http://localhost:3000/")+ #expect(settings.isDeveloperMode(url: "http://localhost:8080/other"))+ #expect(!settings.isDeveloperMode(url: "https://example.com"))+ #expect(!settings.isDeveloperMode(url: "notes"))+ settings.toggleDeveloperMode(url: "http://localhost/")+ #expect(settings.developerHosts.isEmpty)+ settings.toggleDeveloperMode(url: "notes")+ #expect(settings.developerHosts.isEmpty, "no host, nothing to toggle")+ }++ @Test func littleWindowSwitchIsTheDefaultDestination() {+ var settings = AppSettings()+ #expect(settings.openExternalLinksInLittleWindow)+ settings.openExternalLinksInLittleWindow = false+ #expect(settings.defaultLinkDestination == .mostRecentSpace)+ settings.openExternalLinksInLittleWindow = true+ #expect(settings.defaultLinkDestination == .littleWindow)+ }++ @Test func incognitoWindowsAreNeverSaved() {+ let normal = WindowSession(focusedSpaceID: Self.space)+ let prefs = WindowPrefs(sidebarWidth: 300, windows: [normal, WindowSession(isIncognito: true)])+ #expect(prefs.withoutIncognito.windows == [normal] && prefs.withoutIncognito.sidebarWidth == 300)+ }++ @Test func archivedItemIsKnownByItsItem() {+ let item = SidebarItem.tab("https://example.com", parent: nil)+ let archived = ArchivedItem(archivedAt: Date(), reason: .manual, sourceSpaceID: nil, wasPinned: false, item: item)+ #expect(archived.id == item.id && archived.fromLittleWindow == nil && archived.sourceFolderID == nil && archived.sourceIndex == nil)+ }++ @Test func memberwiseValues() {+ let date = Date(timeIntervalSince1970: 0)+ let entry = HistoryEntry(url: "https://example.com", title: "E", lastVisit: date, visitCount: 2)+ #expect(entry.visitCount == 2 && entry.lastVisit == date)+ let ranking = RankingData(commandUsage: ["newTab": 1])+ #expect(ranking.commandUsage["newTab"] == 1 && ranking.recentlySwitchedToTabs.isEmpty && ranking.queriesToSelected.isEmpty)+ let doc = SidebarDocument(spaceOrder: [], spaces: [], items: [])+ #expect(doc.version == 1)+ let theme = SpaceTheme.presets[0]+ let space = Space(id: Self.space, title: "S", emoji: "", theme: theme, favoritesContainerID: UUID(), pinnedContainerID: UUID(),+ todayContainerID: UUID(), createdAt: date, symbol: "star")+ #expect(space.symbol == "star" && space.profileID == nil)+ }+}diff --git a/Sources/Cra/App/KeyBindings.swift b/Sources/Cra/App/KeyBindings.swiftindex 5a198aa..cd0602c 100644--- a/Sources/Cra/App/KeyBindings.swift+++ b/Sources/Cra/App/KeyBindings.swift@@ -1,23 +1,15 @@import AppKitimport Observation-/// A keyboard shortcut. `key` is the lowercase character or a special key-/// (see `Shortcut.tab`, `.left`...), `modifiers` the device-independent flags.-struct Shortcut: Codable, Hashable {- var key: String- var modifiers: UInt+/// A keyboard shortcut: CraCore's KeyChord (the keybindings.json format), read from and+/// matched against AppKit key events here.+typealias Shortcut = KeyChord+extension Shortcut {init(_ key: String, _ mods: NSEvent.ModifierFlags) {- self.key = key- self.modifiers = mods.intersection(.deviceIndependentFlagsMask).rawValue+ self.init(key: key, modifiers: mods.intersection(.deviceIndependentFlagsMask).rawValue)}- static let tab = "\t"- static let left = String(UnicodeScalar(NSLeftArrowFunctionKey)!)- static let right = String(UnicodeScalar(NSRightArrowFunctionKey)!)- static let up = String(UnicodeScalar(NSUpArrowFunctionKey)!)- static let down = String(UnicodeScalar(NSDownArrowFunctionKey)!)-var flags: NSEvent.ModifierFlags { NSEvent.ModifierFlags(rawValue: modifiers) }/// Shift turns "[" into "{" in charactersIgnoringModifiers; undo that.@@ -52,23 +44,6 @@ struct Shortcut: Codable, Hashable {guard special || !flags.intersection([.command, .control, .option]).isEmpty else { return nil }return Shortcut(chars, flags)}-- var display: String {- var s = ""- if flags.contains(.control) { s += "⌃" }- if flags.contains(.option) { s += "⌥" }- if flags.contains(.shift) { s += "⇧" }- if flags.contains(.command) { s += "⌘" }- switch key {- case Shortcut.tab: s += "⇥"- case Shortcut.left: s += "←"- case Shortcut.right: s += "→"- case Shortcut.up: s += "↑"- case Shortcut.down: s += "↓"- default: s += key.uppercased()- }- return s- }}enum MenuSection: String, Codable {diff --git a/Sources/Cra/Model/LiveFolderModel.swift b/Sources/Cra/Model/LiveFolderModel.swiftdeleted file mode 100644index bd78bfe..0000000--- a/Sources/Cra/Model/LiveFolderModel.swift+++ /dev/null@@ -1,87 +0,0 @@-import Foundation--// Live folders: folders that fill themselves from a service and empty as items close.-// Shape follows Arc's AutomaticLiveFolderData (StorableSidebar.json `list.automaticLiveFolderData`:-// dataSource github, filter.github {attributes, hiddenRepositories}, hiddenItems, lastFetch) and the-// cached LiveItem.github.pullRequest in StorableLiveData.json. Dia 1.54 keeps the same GitHub client-// (ARCClients/GitHubClient). Findings and what was verified: docs/live-folders.md.--/// What a live folder is filled from. Arc and Dia also have Bitbucket, Notion, Drive and calendar sources.-enum LiveFolderSource: String, Codable {- case github-}--/// Which pull requests a GitHub live folder shows. Arc saves `attributes` as a bit mask (7 = all three).-struct GitHubLiveFilter: Codable, Equatable {- struct Attributes: OptionSet, Codable, Hashable {- let rawValue: Int- /// author:@me- static let authored = Attributes(rawValue: 1)- /// user-review-requested:@me (asked of you by name)- static let reviewRequests = Attributes(rawValue: 2)- /// review-requested:@me, which also covers teams you are on (Arc: "Team Review Requests")- static let teamReviewRequests = Attributes(rawValue: 4)- static let all: Attributes = [.authored, .reviewRequests, .teamReviewRequests]- }-- var attributes: Attributes = .all- /// "owner/name" of repositories switched off in the folder's menu.- var hiddenRepositories: [String] = []-}--enum LiveFolderError: String, Codable, Equatable {- case notSignedIn, rateLimited, unexpectedPage, network-}--struct LiveFolderData: Codable, Equatable {- var source: LiveFolderSource = .github- var filter = GitHubLiveFilter()- /// Items closed out of the folder; they don't come back (Arc: hiddenItems).- var hiddenItems: [String] = []- var lastFetch: Date?- /// Why the last refresh failed; nil once one succeeds.- var lastError: LiveFolderError?- /// Organizations that want a SAML sign-in before their pull requests show up (Arc: needsSSO).- var ssoOrganizations: [String] = []- /// The enterprise whose single sign-on GitHub sent a tab to (Enterprise Managed Users sign in- /// there, not at github.com/login): the folder's sign-in button goes there too.- var enterprise: String?-- /// Where to sign in again.- var signInURL: String {- if let enterprise { return "https://github.com/enterprises/\(enterprise)/sso" }- return "https://github.com/login?return_to=%2Fpulls"- }-- init() {}- init(from decoder: Decoder) throws {- let c = try decoder.container(keyedBy: CodingKeys.self)- source = try c.decodeIfPresent(LiveFolderSource.self, forKey: .source) ?? .github- filter = try c.decodeIfPresent(GitHubLiveFilter.self, forKey: .filter) ?? GitHubLiveFilter()- hiddenItems = try c.decodeIfPresent([String].self, forKey: .hiddenItems) ?? []- lastFetch = try c.decodeIfPresent(Date.self, forKey: .lastFetch)- lastError = try? c.decodeIfPresent(LiveFolderError.self, forKey: .lastError)- ssoOrganizations = try c.decodeIfPresent([String].self, forKey: .ssoOrganizations) ?? []- enterprise = try c.decodeIfPresent(String.self, forKey: .enterprise)- }-}--/// One pull request as the GitHub client reads it (Arc: LiveItem.Data.github.pullRequest).-struct LivePullRequest: Codable, Equatable, Identifiable {- enum State: String, Codable { case open, draft, merged, closed }-- var owner: String- var repo: String- var number: Int- var title: String- var author: String?- var state: State = .open- var createdByMe = false- var isAwaitingMyReview = false- var createdAt: Date?- var updatedAt: Date?-- var id: String { url }- var url: String { "https://github.com/\(owner)/\(repo)/pull/\(number)" }- var repository: String { "\(owner)/\(repo)" }-}diff --git a/Sources/Cra/Services/BrowserManager.swift b/Sources/Cra/Services/BrowserManager.swiftindex 938cdd8..27f8747 100644--- a/Sources/Cra/Services/BrowserManager.swift+++ b/Sources/Cra/Services/BrowserManager.swift@@ -659,7 +659,7 @@ final class BrowserManager: NSObject, @preconcurrency CraBrowserDelegate {func browser(_ browser: CraBrowser, didLoadFavicon image: NSImage, forURL iconURL: String) {guard let id = tabID(of: browser), let tab = store.item(id)?.tab else { return }- let key = FaviconCache.key(for: tab.url) ?? tab.faviconKey+ let key = FaviconKey.key(for: tab.url) ?? tab.faviconKeyguard let key else { return }favicons.store(image, forKey: key, persist: !browser.isIncognito)if tab.faviconKey != key { store.updateTab(id, url: tab.url) }diff --git a/Sources/Cra/Services/FaviconCache.swift b/Sources/Cra/Services/FaviconCache.swiftindex b745e16..6bfb372 100644--- a/Sources/Cra/Services/FaviconCache.swift+++ b/Sources/Cra/Services/FaviconCache.swift@@ -1,7 +1,7 @@import AppKitimport Observation-/// Favicons keyed by host. Chromium hands us PNG bytes through the bridge;+/// Favicons keyed by host (FaviconKey). Chromium hands us PNG bytes through the bridge;/// we keep them in memory and on disk so the sidebar is populated on launch/// before any tab has loaded (Arc: SidebarItemsFaviconCache).@MainActor@@ -10,10 +10,8 @@ final class FaviconCache {private(set) var images: [String: NSImage] = [:]private var attemptedDiskLoad: Set<String> = []- static func key(for urlString: String) -> String? {- guard let host = URL(string: urlString)?.host, !host.isEmpty else { return nil }- return host.lowercased()- }+ /// FaviconKey.key(for:), for code written before it moved to CraCore (#51).+ static func key(for urlString: String) -> String? { FaviconKey.key(for: urlString) }func image(forKey key: String?) -> NSImage? {guard let key else { return nil }@@ -29,7 +27,7 @@ final class FaviconCache {return nil}- func image(for urlString: String) -> NSImage? { image(forKey: Self.key(for: urlString)) }+ func image(for urlString: String) -> NSImage? { image(forKey: FaviconKey.key(for: urlString)) }private var dominant: [String: String] = [:]diff --git a/Sources/Cra/Services/Import/Importers.swift b/Sources/Cra/Services/Import/Importers.swiftindex 73d1aad..a564d6a 100644--- a/Sources/Cra/Services/Import/Importers.swift+++ b/Sources/Cra/Services/Import/Importers.swift@@ -379,7 +379,7 @@ extension SidebarStore {func copyFavicons(_ items: [ImportedItem]) {for it in items {if it.isFolder { copyFavicons(it.children); continue }- guard let src = it.faviconPath, let url = it.url, let key = FaviconCache.key(for: url) else { continue }+ guard let src = it.faviconPath, let url = it.url, let key = FaviconKey.key(for: url) else { continue }let dst = AppPaths.favicons.appendingPathComponent(FaviconCache.fileName(key))if !FileManager.default.fileExists(atPath: dst.path) {try? FileManager.default.copyItem(atPath: src, toPath: dst.path)diff --git a/Sources/Cra/Services/SidebarStore.swift b/Sources/Cra/Services/SidebarStore.swiftindex fa06766..400e78b 100644--- a/Sources/Cra/Services/SidebarStore.swift+++ b/Sources/Cra/Services/SidebarStore.swift@@ -62,7 +62,9 @@ final class SidebarStore {archive = archiveFile.load(or: { [] })archiveChanged = falseprefs = prefsStore.load(or: { WindowPrefs() })- settings = settingsStore.load(or: { AppSettings() })+ var loaded = settingsStore.load(or: { AppSettings() })+ loaded.migrateToolbarDefault(arcShowsToolbar: ArcImporter.showsToolbar)+ settings = loadedfor h in historyFile.load(or: { [] }) { history[h.url] = h }ranking = rankingFile.load(or: { RankingData() })repair()@@ -440,7 +442,7 @@ final class SidebarStore {t.url = url// A pinned tab that never had a page (a new pane of a pinned split) takes its first one as home.if !isPinned(id) || t.savedURL.isEmpty || t.savedURL == "about:blank" { t.savedURL = url }- if let key = FaviconCache.key(for: url) { t.faviconKey = key }+ if let key = FaviconKey.key(for: url) { t.faviconKey = key }}// A live folder's tab keeps the pull request's title (Arc shows that, not the page's).if let title, !(t.liveItemURL.map { t.url.hasPrefix($0) } ?? false) { t.savedTitle = title }diff --git a/Sources/Cra/Services/SuggestionEngine.swift b/Sources/Cra/Services/SuggestionEngine.swiftindex 57ec578..6064e6e 100644--- a/Sources/Cra/Services/SuggestionEngine.swift+++ b/Sources/Cra/Services/SuggestionEngine.swift@@ -224,7 +224,7 @@ final class SuggestionEngine {}guard !urls.contains(url) else { return nil }return Suggestion(id: "sugg:\(url)", kind: .history, title: r.text, subtitle: "", url: url,- faviconKey: FaviconCache.key(for: url), symbol: "globe", trailing: nil, score: 0)+ faviconKey: FaviconKey.key(for: url), symbol: "globe", trailing: nil, score: 0)}}@@ -253,7 +253,7 @@ final class SuggestionEngine {if Self.looksLikeURL(query) {let url = Self.urlFromInput(query)return Suggestion(id: "typed", kind: .navigate, title: query, subtitle: "Open URL", url: url,- faviconKey: FaviconCache.key(for: url), symbol: "globe", trailing: nil, score: 1000)+ faviconKey: FaviconKey.key(for: url), symbol: "globe", trailing: nil, score: 1000)}let engine = store.settings.searchEnginereturn Suggestion(id: "typed", kind: .search, title: query, subtitle: "Search \(engine.label)",@@ -314,7 +314,7 @@ final class SuggestionEngine {if score < 30 { continue }score += min(Double(h.visitCount), 20) * 1.5 + recencyBoost(h.lastVisit) * 0.6out.append(Suggestion(id: "hist:\(h.url)", kind: .history, title: h.title.isEmpty ? Self.humanURL(h.url) : h.title,- subtitle: Self.humanURL(h.url), url: h.url, faviconKey: FaviconCache.key(for: h.url),+ subtitle: Self.humanURL(h.url), url: h.url, faviconKey: FaviconKey.key(for: h.url),symbol: "clock", trailing: nil, score: score, loose: text < Self.looseBelow))}return out@@ -328,7 +328,7 @@ final class SuggestionEngine {guard bare.hasPrefix(q) || d.hasPrefix(q) else { continue }let url = "https://\(d)/"out.append(Suggestion(id: "top:\(d)", kind: .topDomain, title: bare, subtitle: "Open URL", url: url,- faviconKey: FaviconCache.key(for: url), symbol: "globe", trailing: nil,+ faviconKey: FaviconKey.key(for: url), symbol: "globe", trailing: nil,score: 72 - Double(i) * 0.1))}return outdiff --git a/Sources/Cra/UI/CommandBar/CommandBarView.swift b/Sources/Cra/UI/CommandBar/CommandBarView.swiftindex 9eb0e3e..487dde0 100644--- a/Sources/Cra/UI/CommandBar/CommandBarView.swift+++ b/Sources/Cra/UI/CommandBar/CommandBarView.swift@@ -134,7 +134,7 @@ final class CommandBarView: NSView {let typed = c.query.trimmingCharacters(in: .whitespaces)let glyph = CommandBarGlyph.resolve(editingURL: c.mode == .editURL, untouched: !previewing && (typed.isEmpty || typed == c.openedPrefill),- scoped: scope != nil, pageFaviconKey: c.openedPrefill.flatMap(FaviconCache.key(for:)),+ scoped: scope != nil, pageFaviconKey: c.openedPrefill.flatMap(FaviconKey.key(for:)),row: row.map { ($0.faviconKey, $0.symbol) }, hasFavicon: { [favicons] in favicons.image(forKey: $0) != nil })if case .favicon(let key) = glyph, let img = favicons.image(forKey: key) {leadingIcon.imageScaling = .scaleProportionallyUpOrDowndiff --git a/Sources/Cra/UI/Onboarding/ImportFlow.swift b/Sources/Cra/UI/Onboarding/ImportFlow.swiftindex 6dee06a..756310a 100644--- a/Sources/Cra/UI/Onboarding/ImportFlow.swift+++ b/Sources/Cra/UI/Onboarding/ImportFlow.swift@@ -516,7 +516,7 @@ final class ImportFlowModel {pinsLoaded = truelet source = self.source?.kind == .safari ? nil : (self.source ?? sources.first { $0.kind != .safari })let fromExport = exportTopSites- let existing = Set(store.tabs(under: store.focusedSpace.favoritesContainerID).compactMap { $0.tab.flatMap { FaviconCache.key(for: $0.url) } })+ let existing = Set(store.tabs(under: store.focusedSpace.favoritesContainerID).compactMap { $0.tab.flatMap { FaviconKey.key(for: $0.url) } })pinCandidates = Self.presetPinsTask { @MainActor inlet (sites, icons) = await Task.detached(priority: .userInitiated) { () -> ([TopSite], [String: NSImage]) in@@ -556,7 +556,7 @@ final class ImportFlowModel {var plan = ImportPlan(source: "Onboarding")plan.favorites = picked.map { ImportedItem(customTitle: $0.name, pageTitle: $0.name, url: $0.url) }store.apply(plan, includeArchive: false, includeSettings: false)- for p in picked { if let icon = pinIcons[p.host], let key = FaviconCache.key(for: p.url) { favicons.store(icon, forKey: key) } }+ for p in picked { if let icon = pinIcons[p.host], let key = FaviconKey.key(for: p.url) { favicons.store(icon, forKey: key) } }}go(.personalization)}diff --git a/Sources/Cra/UI/Windows/LittleWindowController.swift b/Sources/Cra/UI/Windows/LittleWindowController.swiftindex e57c24a..d56f61e 100644--- a/Sources/Cra/UI/Windows/LittleWindowController.swift+++ b/Sources/Cra/UI/Windows/LittleWindowController.swift@@ -544,7 +544,7 @@ final class LittleWindowController: NSWindowController, NSWindowDelegate, @precolet sid = (spaceID ?? state.targetSpaceID).flatMap { store.space($0) != nil && !store.isIncognito(space: $0) ? $0 : nil }?? store.focusedSpaceIDlet tab = store.createTab(url: b.currentURL, title: b.currentTitle, in: sid, select: true)- if let favicon, let key = FaviconCache.key(for: b.currentURL) { app.favicons.store(favicon, forKey: key) }+ if let favicon, let key = FaviconKey.key(for: b.currentURL) { app.favicons.store(favicon, forKey: key) }promoted = truebrowser = nilapp.main.browsers.adopt(b, for: tab.id)@@ -559,7 +559,7 @@ final class LittleWindowController: NSWindowController, NSWindowDelegate, @preco// A Peek is a look at a link, not a page to keep.guard hasPage, !promoted, !isPeek else { return }store.archiveLittleWindowPage(url: currentURL, title: browser?.currentTitle ?? state.title)- if let favicon, let key = FaviconCache.key(for: currentURL) { app.favicons.store(favicon, forKey: key) }+ if let favicon, let key = FaviconKey.key(for: currentURL) { app.favicons.store(favicon, forKey: key) }promoted = true // archived once; a later close must not archive again}@@ -706,7 +706,7 @@ final class LittleWindowController: NSWindowController, NSWindowDelegate, @precofunc browser(_ browser: CraBrowser, didLoadFavicon image: NSImage, forURL iconURL: String) {favicon = image- if let key = FaviconCache.key(for: browser.currentURL) { app.favicons.store(image, forKey: key) }+ if let key = FaviconKey.key(for: browser.currentURL) { app.favicons.store(image, forKey: key) }}func browser(_ browser: CraBrowser, didReportThemeColor hex: String) { state.themeColor = hex }diff --git a/Tests/BrowserManagerSupport/AppServices.swift b/Tests/BrowserManagerSupport/AppServices.swiftindex 042bac7..bd68052 100644--- a/Tests/BrowserManagerSupport/AppServices.swift+++ b/Tests/BrowserManagerSupport/AppServices.swift@@ -38,8 +38,8 @@ enum TestRoot { case today }return item}}+enum FaviconKey { static func key(for url: String) -> String? { url } }final class FaviconCache {- static func key(for url: String) -> String? { url }func store(_ image: NSImage, forKey: String, persist: Bool) {}}enum TabSwitcherMetrics { static let thumbnail = NSSize(width: 320, height: 200) }diff --git a/docs/arc-reverse-engineering.md b/docs/arc-reverse-engineering.mdindex 706aa31..536431c 100644--- a/docs/arc-reverse-engineering.md+++ b/docs/arc-reverse-engineering.md@@ -1454,7 +1454,7 @@ the arm64 slice. [O] = observed, [I] = inferred.editor shows that destination blank. The payload only picks a profile.- [U] what several conditions in one rule mean (any vs all; the UI never creates them), the ⓘ help article URL(built at run time, `featuresForLinkRouting`), the empty-list state.-- Cra: `Model/LinkRouting.swift` (Arc's matching above, checked against every observed case; first match wins; the+- Cra: `Packages/CraCore/Sources/CraCore/LinkRouting.swift` (Arc's matching above, checked against every observed case; first match wins; theGoogle Meet route is seeded once), `AppSettings.linkRoutes` / `defaultLinkDestination` (the Little Window checkbox is a view of thedefault; old `openExternalLinksInLittleWindow` values migrate), `AppDelegate.openExternalURL`, Settings ▸ Tabs ▸Links ▸ "Air Traffic Control…" (`UI/Settings/AirTrafficControlView.swift`, Arc's geometry within 1 pt, 440 tall todiff --git a/docs/development.md b/docs/development.mdindex 82fa618..58269f8 100644--- a/docs/development.md+++ b/docs/development.md@@ -22,13 +22,15 @@ issue when a newer stable CEF is out; `scripts/update-cef.sh` moves the pin.## Layout-- `Sources/Cra` — the app: `App` (delegate, key bindings), `Model`, `Services` (sidebar- store, persistence, import, updates, extensions, live folders), `UI` (sidebar, command- bar, split view, windows, settings, onboarding)+- `Sources/Cra` — the app: `App` (delegate, key bindings), `Services` (sidebar store,+ persistence, import, updates, extensions, live folders), `UI` (sidebar, command bar, split+ view, windows, settings, onboarding)- `Sources/CraCEF` — Objective-C++ bridge between Swift and CEF- `Sources/CraHelper` — Chromium subprocess executable-- `Packages/CraCore` — models and decisions with no AppKit or Chromium (space themes, Arc- theme import, the favorites grid), visible in every `Sources/Cra` file+- `Packages/CraCore` — models and decisions with no AppKit or Chromium (the sidebar model,+ settings and the other data-folder files, Air Traffic Control, live folder data, key chords,+ space themes, Arc theme import, the favorites grid), visible in every `Sources/Cra` file.+ The layer rules are in [CLAUDE.md](../CLAUDE.md)- `Tests/` — the harnesses that compile production files against fakes, and the smoke test- `resources/` — app icon, brand PNGs, the ad and tracker blocklist with its licence notices- `scripts/` — build, release, CEF and test tooling; `scripts/clips` records release clips@@ -70,6 +72,8 @@ app it builds.page belongs here, with a test: a layout rule, a mapping from Arc's or Chromium's files,a policy. Expected values for anything copied from Arc come from Arc's measurements in`docs/arc-reverse-engineering.md`; fixtures hold Arc's own JSON, trimmed to what is read.+ `Fixtures/Model` holds data-folder files, current and older shapes, each with what Cra+ saved after loading it (recorded before the model moved here, #51).- `Tests/test-browser-manager.sh`, `scripts/test-floating-sidebar.sh`,`scripts/test-extension-popup-candidate.sh`, `scripts/test-extension-state.sh`: compile afew production files with `swiftc` against fakes (`Tests/BrowserManagerSupport` stands indiff --git a/docs/testing.md b/docs/testing.mdindex 3c17537..696d45f 100644--- a/docs/testing.md+++ b/docs/testing.md@@ -70,11 +70,13 @@ a finding fails, and when one loses a finding the baseline comes down- `layer-colour-outside-transaction`: a colour or opacity set on a `CALayer` Cra made itself,outside a `CATransaction` with actions disabled, animates for 0.25 s.-- `timer-outside-scheduler`: `Timer.scheduledTimer` in `App/`, `Services/` or `Model/`.+- `timer-outside-scheduler`: `Timer.scheduledTimer` in `App/` or `Services/`.- `wall-clock-in-decision`: `Date()` in the store, tab sleep or live folders.- `raw-observation-tracking`: `withObservationTracking` outside CraCore's`observeChanges(of:apply:)`. A struct copied out before the closure is never tracked.- `importer-without-fixture`: an `…Importer` with no profile under `Tests/Fixtures`.+- `core-platform-import`: `Packages/CraCore` importing AppKit, Cocoa, SwiftUI, UIKit or CraCEF+ ([CLAUDE.md](../CLAUDE.md) has the layers).## Faultsdiff --git a/scripts/fuzz.sh b/scripts/fuzz.shindex 1cd615e..50c6ef5 100755--- a/scripts/fuzz.sh+++ b/scripts/fuzz.sh@@ -8,9 +8,9 @@ TEST_DIR="$(mktemp -d /tmp/cra-fuzz.XXXXXX)"trap 'rm -rf "$TEST_DIR"' EXITmkdir -p build/fuzzxcrun swiftc -swift-version 5 -parse-as-library -sanitize=address -g \- Packages/CraCore/Sources/CraCore/*.swift Sources/Cra/Model/*.swift Sources/Cra/Services/Import/*.swift \+ Packages/CraCore/Sources/CraCore/*.swift Sources/Cra/Services/Import/*.swift \Sources/Cra/Services/SidebarStore.swift Sources/Cra/Services/SidebarIntegrity.swift Sources/Cra/Services/Persistence.swift \- Sources/Cra/Services/ItemTable.swift Sources/Cra/Services/GitHubLiveClient.swift Sources/Cra/Services/FaviconCache.swift \+ Sources/Cra/Services/GitHubLiveClient.swift Sources/Cra/Services/FaviconCache.swift \Sources/Cra/Services/SafeStorage.swift Sources/Cra/Services/CraLog.swift Sources/Cra/Services/Scheduler.swift \Tests/FuzzTests.swift -o "$TEST_DIR/fuzz"CRA_FUZZ_OUT="$PWD/build/fuzz" "$TEST_DIR/fuzz"diff --git a/scripts/lint.py b/scripts/lint.pyindex 7221974..53b556c 100755--- a/scripts/lint.py+++ b/scripts/lint.py@@ -1,5 +1,5 @@#!/usr/bin/env python3 -I-"""Cra's own lint: the bug classes that kept shipping, as rules over Sources/Cra.+"""Cra's own lint: the bug classes that kept shipping, as rules over Sources/Cra and CraCore.Existing code is grandfathered in Tests/lint-baseline.txt (rule, file, count); a file thatgains a finding fails, one that loses one is reported so the baseline can come down@@ -11,7 +11,7 @@ gains a finding fails, one that loses one is reported so the baseline can come da flash on every theme or window-activation change. Inits are exempt (not on screen), andso is a layer whose `actions` map the property to NSNull().timer-outside-scheduler- Timer.scheduledTimer in App/, Services/ or Model/: decisions taken from time run on the+ Timer.scheduledTimer in App/ or Services/: decisions taken from time run on theinjectable clock (Scheduler), or no test can reach them. UI animation timers are exempt.wall-clock-in-decisionDate() in a file whose decisions run on the clock (store, tab sleep, live folders).@@ -23,6 +23,10 @@ gains a finding fails, one that loses one is reported so the baseline can come dimporter-without-fixtureAn importer (enum …Importer) without a checked-in profile under Tests/Fixtures/<Name>:parsers are tested against files in the source browser's format, not dictionaries.+ core-platform-import+ Packages/CraCore importing AppKit, Cocoa, SwiftUI, UIKit or CraCEF. The core is models and+ decisions that build and test without a window or Chromium (#51); what needs one stays in+ the app, with the pure part in CraCore (Shortcut over KeyChord, FaviconCache over FaviconKey)."""import collectionsimport os@@ -31,10 +35,12 @@ import sysROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))SOURCES = os.path.join(ROOT, "Sources", "Cra")+CORE = os.path.join(ROOT, "Packages", "CraCore", "Sources")BASELINE = os.path.join(ROOT, "Tests", "lint-baseline.txt")LAYER_SET = re.compile(r"\b(?!layer\b)(\w*[Ll]ayer)\.(backgroundColor|borderColor|colors|opacity|shadowColor|fillColor|strokeColor)\s*=")FUNC_START = re.compile(r"^\s*(?:@\w+\s+)*(?:(?:private|fileprivate|internal|public|override|static|final|class|nonisolated|convenience|required|@objc)\s+)*(func\s|init[(?!])")+CORE_IMPORT = re.compile(r"^\s*(?:@\w+\s+)*import\s+(?:(?:struct|class|enum|protocol|func|var|let|typealias)\s+)?(AppKit|Cocoa|SwiftUI|UIKit|CraCEF)\b")CLOCK_FILES = {"Services/SidebarStore.swift", "Services/BrowserManager.swift", "Services/LiveFolderManager.swift","Services/SidebarIntegrity.swift", "App/AppComposition.swift"}@@ -77,7 +83,7 @@ def findings():for m in LAYER_SET.finditer(line):if depth <= 0 and not in_init and "setDisableActions" not in line and (m.group(1), m.group(2)) not in quiet:hit("layer-colour-outside-transaction", rel, i)- if "Timer.scheduledTimer" in line and top in ("App", "Services", "Model") and rel != "Services/Scheduler.swift":+ if "Timer.scheduledTimer" in line and top in ("App", "Services") and rel != "Services/Scheduler.swift":hit("timer-outside-scheduler", rel, i)if rel in CLOCK_FILES and re.search(r"\bDate\(\)", line):hit("wall-clock-in-decision", rel, i)@@ -86,6 +92,14 @@ def findings():for name in re.findall(r"\benum (\w+)Importer\b", line):if not os.path.isdir(os.path.join(ROOT, "Tests", "Fixtures", name)):hit("importer-without-fixture", f"{rel}:{name}", i)+ for dirpath, _, names in os.walk(CORE):+ for n in sorted(names):+ if n.endswith(".swift"):+ full = os.path.join(dirpath, n)+ with open(full, encoding="utf-8") as f:+ for i, line in enumerate(f, 1):+ if CORE_IMPORT.match(code(line)):+ hit("core-platform-import", os.path.relpath(full, ROOT), i)return out, where@@ -116,7 +130,8 @@ def main():failed = Truerule, rel = keylines = ", ".join(map(str, where[key]))- print(f"Sources/Cra/{rel.split(':')[0]}: {rule}: {n} (baseline {base.get(key, 0)}), lines {lines}")+ path = rel.split(":")[0]+ print(f"{path if path.startswith('Packages/') else 'Sources/Cra/' + path}: {rule}: {n} (baseline {base.get(key, 0)}), lines {lines}")lower = [(k, base[k], found.get(k, 0)) for k in sorted(base) if found.get(k, 0) < base[k]]for (rule, rel), was, now in lower:print(f"note: {rel}: {rule} down from {was} to {now}; run scripts/lint.py --update-baseline")diff --git a/scripts/test-store.sh b/scripts/test-store.shindex 05b2140..f62c63b 100755--- a/scripts/test-store.sh+++ b/scripts/test-store.sh@@ -5,8 +5,8 @@ cd "$(dirname "$0")/.."TEST_DIR="$(mktemp -d /tmp/cra-store-tests.XXXXXX)"trap 'rm -rf "$TEST_DIR"' EXITxcrun swiftc -swift-version 5 -parse-as-library ${CRA_TEST_SWIFTC_FLAGS:-} \- Packages/CraCore/Sources/CraCore/*.swift Sources/Cra/Model/*.swift Sources/Cra/Services/Import/*.swift \- Sources/Cra/Services/SidebarStore.swift Sources/Cra/Services/SidebarIntegrity.swift Sources/Cra/Services/Persistence.swift Sources/Cra/Services/ItemTable.swift \+ Packages/CraCore/Sources/CraCore/*.swift Sources/Cra/Services/Import/*.swift \+ Sources/Cra/Services/SidebarStore.swift Sources/Cra/Services/SidebarIntegrity.swift Sources/Cra/Services/Persistence.swift \Sources/Cra/Services/GitHubLiveClient.swift Sources/Cra/Services/FaviconCache.swift Sources/Cra/Services/SafeStorage.swift \Sources/Cra/Services/CraLog.swift Sources/Cra/Services/Scheduler.swift \Sources/Cra/App/AppComposition.swift Sources/Cra/App/FeatureFlags.swift \