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.
Arc parity: Archive Little Windows after (1, 6, 12 hours) and Profiles ▸ Your Data and Settings
Victord4e9705a57ca
diff --git a/Packages/CraCore/Sources/CraCore/LittleWindowArchive.swift b/Packages/CraCore/Sources/CraCore/LittleWindowArchive.swiftnew file mode 100644index 0000000..0825288--- /dev/null+++ b/Packages/CraCore/Sources/CraCore/LittleWindowArchive.swift@@ -0,0 +1,29 @@+import Foundation++/// Arc's Settings ▸ Links ▸ "Archive Little Arcs after:" (Arc 1.172.1): a Little Arc left alone+/// that long is closed, its page kept in the archive. Arc offers 1 hour, 6 hours (its default)+/// and 12 hours.+public enum LittleWindowArchive: String, Codable, CaseIterable, Sendable {+ case oneHour, sixHours, twelveHours++ public var seconds: TimeInterval {+ switch self {+ case .oneHour: 3600+ case .sixHours: 6 * 3600+ case .twelveHours: 12 * 3600+ }+ }++ public var label: String {+ switch self {+ case .oneHour: "1 hour"+ case .sixHours: "6 hours (default)"+ case .twelveHours: "12 hours"+ }+ }++ /// Whether a Little Window last in use at `lastUsed` is archived now. The key one is in use.+ public func expired(lastUsed: Date, now: Date, isKey: Bool) -> Bool {+ !isKey && now.timeIntervalSince(lastUsed) >= seconds+ }+}diff --git a/Packages/CraCore/Sources/CraCore/SidebarModel.swift b/Packages/CraCore/Sources/CraCore/SidebarModel.swiftindex 2c9b70b..86d8a85 100644--- a/Packages/CraCore/Sources/CraCore/SidebarModel.swift+++ b/Packages/CraCore/Sources/CraCore/SidebarModel.swift@@ -517,6 +517,8 @@ public struct AppSettings: Codable, Equatable {/// asks macOS for access), then the folders the Library button's "Show media" menu ticks.public var mediaLibraryEnabled: Bool = falsepublic var mediaFolders: [MediaLibrary.Folder] = MediaLibrary.Folder.allCases+ /// Arc's Settings ▸ Links ▸ "Archive Little Arcs after:".+ public var littleWindowArchiveAfter: LittleWindowArchive = .sixHours/// Arc's searchSuggestEnabled: the command bar asks the search engine for suggestions/// as you type and fills its rows with them.public var searchSuggestions: Bool = true@@ -724,6 +726,7 @@ extension AppSettings {soundEffects = try c.decodeIfPresent(Bool.self, forKey: .soundEffects) ?? truemediaLibraryEnabled = try c.decodeIfPresent(Bool.self, forKey: .mediaLibraryEnabled) ?? falsemediaFolders = (try? c.decodeIfPresent([MediaLibrary.Folder].self, forKey: .mediaFolders)) ?? MediaLibrary.Folder.allCases+ littleWindowArchiveAfter = (try? c.decodeIfPresent(LittleWindowArchive.self, forKey: .littleWindowArchiveAfter)) ?? .sixHourssearchSuggestions = try c.decodeIfPresent(Bool.self, forKey: .searchSuggestions) ?? trueshowSpaceHeaderOnSingleSpace = try c.decodeIfPresent(Bool.self, forKey: .showSpaceHeaderOnSingleSpace) ?? truesharedFavorites = try c.decodeIfPresent(Bool.self, forKey: .sharedFavorites) ?? falsediff --git a/Packages/CraCore/Tests/CraCoreTests/LittleWindowArchiveTests.swift b/Packages/CraCore/Tests/CraCoreTests/LittleWindowArchiveTests.swiftnew file mode 100644index 0000000..a7980b8--- /dev/null+++ b/Packages/CraCore/Tests/CraCoreTests/LittleWindowArchiveTests.swift@@ -0,0 +1,23 @@+import CraCore+import Foundation+import Testing++/// Arc's "Archive Little Arcs after:" (Settings ▸ Links, Arc 1.172.1): 1 hour, 6 hours (default), 12 hours.+struct LittleWindowArchiveTests {+ let start = Date(timeIntervalSince1970: 1_800_000_000)++ @Test func archivesOnceTheTimeIsUp() {+ let a = LittleWindowArchive.sixHours+ #expect(!a.expired(lastUsed: start, now: start.addingTimeInterval(6 * 3600 - 1), isKey: false))+ #expect(a.expired(lastUsed: start, now: start.addingTimeInterval(6 * 3600), isKey: false))+ }++ @Test func neverTheOneInUse() {+ #expect(!LittleWindowArchive.oneHour.expired(lastUsed: start, now: start.addingTimeInterval(86400), isKey: true))+ }++ @Test func arcsChoicesAndDefault() throws {+ #expect(LittleWindowArchive.allCases.map(\.label) == ["1 hour", "6 hours (default)", "12 hours"])+ #expect(try JSONDecoder().decode(AppSettings.self, from: Data("{}".utf8)).littleWindowArchiveAfter == .sixHours)+ }+}diff --git a/Sources/Cra/App/AppDelegate.swift b/Sources/Cra/App/AppDelegate.swiftindex e8cc3e8..cb191d4 100644--- a/Sources/Cra/App/AppDelegate.swift+++ b/Sources/Cra/App/AppDelegate.swift@@ -26,6 +26,9 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSMenuItemValidation {private lazy var extensionsMenu = ExtensionsMenu(app: self)/// Arc's Little Arc windows: small, sidebar-less, disposable (see LittleWindowController).private(set) var littleWindows: [LittleWindowController] = []+ /// When each Little Window was last the key window, for Arc's "Archive Little Arcs after:".+ private var littleWindowLastUsed: [ObjectIdentifier: Date] = [:]+ private var littleWindowArchiveCheck: ScheduledWork?/// Shortcuts the app takes before the web page sees them (Chrome calls/// these reserved). Everything else goes to the page first. Copy URL is reserved like Arc:@@ -180,6 +183,8 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSMenuItemValidation {}observeContentBlocking()observeHttpsOnly()+ // Arc's "Archive Little Arcs after:": a Little Window left alone that long closes, its page archived.+ littleWindowArchiveCheck = composition.clock.every(60) { [weak self] in self?.archiveIdleLittleWindows() }observeChanges(of: { [store] in store.settings.websiteAppearance }) { CraCEFRuntime.setWebsiteAppearance($0.chromiumMode) }observeChanges(of: { [store] in store.settings.soundEffects }) { CaptureSound.enabled = $0 }observeLinkMenu()@@ -605,6 +610,21 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSMenuItemValidation {if let parent = w.peekParent, !littleWindows.contains(where: { $0.peekParent === parent }) { parent.sidebarUI.peekBadge = nil }}+ private func archiveIdleLittleWindows() {+ let now = Date(), rule = store.settings.littleWindowArchiveAfter+ let open = Set(littleWindows.map(ObjectIdentifier.init))+ littleWindowLastUsed = littleWindowLastUsed.filter { open.contains($0.key) }+ // A Peek belongs to its tab; only Little Windows of their own are archived (Arc).+ for w in littleWindows where !w.isPeek {+ let id = ObjectIdentifier(w), isKey = w.window?.isKeyWindow == true+ if isKey || littleWindowLastUsed[id] == nil { littleWindowLastUsed[id] = now; continue }+ if rule.expired(lastUsed: littleWindowLastUsed[id]!, now: now, isKey: isKey) {+ CraLog.note("archiving a Little Window left alone for \(rule.label)")+ w.closeWindow()+ }+ }+ }+func closeLittleWindows() {for w in littleWindows { w.closeWindow() }}diff --git a/Sources/Cra/UI/Settings/ProfilesPane.swift b/Sources/Cra/UI/Settings/ProfilesPane.swiftindex 34cf3d1..f83a686 100644--- a/Sources/Cra/UI/Settings/ProfilesPane.swift+++ b/Sources/Cra/UI/Settings/ProfilesPane.swift@@ -57,6 +57,39 @@ struct ProfilesPane: View {}.id(nav.shown) // read again each time Settings comes up: Chromium's page may have changed themSettingsFootnote("The languages websites show their pages in for each Profile, most wanted first. Change opens Chromium’s language settings for that Profile. Cra itself stays in English.")+ // Arc's Profiles ▸ "Your Data and Settings": Chromium's pages for the profile.+ SettingsHeader("Your Data and Settings").padding(.top, 20)+ SettingsCard {+ ForEach(Array(Self.dataPages.enumerated()), id: \.offset) { i, page in+ if i > 0 { SettingsCardDivider() }+ dataRow(page)+ }+ }+ }+ }++ /// Arc's four rows, in its order, with the Chromium page each opens.+ static let dataPages: [(title: String, symbol: String, url: String)] = [+ ("Privacy and Security", "lock.fill", "chrome://settings/privacy"),+ ("Passwords", "key.fill", "chrome://password-manager/passwords"),+ ("Credit Cards", "creditcard.and.123", "chrome://settings/payments"),+ ("Notifications", "bell.fill", "chrome://settings/content/notifications"),+ ]++ private func dataRow(_ page: (title: String, symbol: String, url: String)) -> some View {+ SettingsCardRow {+ Label(page.title, systemImage: page.symbol).font(.system(size: 13))+ } trailing: {+ if store.profiles.isEmpty {+ Button("Open") { actions.openProfilePage(page.url, nil) }+ } else {+ // One set of pages per Profile: pick whose.+ Menu("Open") {+ Button("Default") { actions.openProfilePage(page.url, nil) }+ ForEach(store.profiles) { p in Button(p.name) { actions.openProfilePage(page.url, p.id) } }+ }+ .fixedSize()+ }}}diff --git a/Sources/Cra/UI/Settings/TabsPane.swift b/Sources/Cra/UI/Settings/TabsPane.swiftindex bdb9b0c..6a1c457 100644--- a/Sources/Cra/UI/Settings/TabsPane.swift+++ b/Sources/Cra/UI/Settings/TabsPane.swift@@ -38,6 +38,15 @@ struct TabsPane: View {// Arc's "Open Little Arc when I press ⌥⌘N" (#195): New Little Window's shortcut from any app.SettingsCheckbox(title: "Open a Little Window when I press \(KeyBindingRegistry.shared.action("newLittleWindow")?.primary?.display ?? "⌥⌘N") in any app",isOn: $store.settings.littleWindowShortcutEverywhere)+ // Arc: "Archive Little Arcs after:" 1 hour, 6 hours (default), 12 hours.+ HStack(spacing: 6) {+ Text("Archive Little Windows after:")+ Picker("", selection: $store.settings.littleWindowArchiveAfter) {+ ForEach(LittleWindowArchive.allCases, id: \.self) { Text($0.label).tag($0) }+ }+ .labelsHidden()+ .fixedSize()+ }SettingsCheckbox(title: "Open a Peek window when clicking on links to other sites", isOn: $store.settings.peekLinksToOtherSites)SettingsCheckbox(title: "In every tab, not only Favorites and Pinned tabs", isOn: $store.settings.peekInEveryTab).disabled(!store.settings.peekLinksToOtherSites)diff --git a/docs/arc-parity.md b/docs/arc-parity.mdindex 2a88cc2..f3ad604 100644--- a/docs/arc-parity.md+++ b/docs/arc-parity.md@@ -33,7 +33,7 @@ or Arc-only service), per CONTRIBUTING.md.| Window dragging from the top of webpages | Settings ▸ Advanced | missing | || Restore windows from previous session | Settings ▸ Advanced | partial | Cra has "Quit and Keep Windows" only. || Block Cookie Banners | Settings ▸ General | missing | Cra blocks ads and trackers only. |-| Archive Little Arcs after | Settings ▸ Links (6 hours default) | missing | |+| Archive Little Arcs after | Settings ▸ Links (6 hours default) | done | Settings ▸ Tabs ▸ Links; a Little Window left alone that long closes into the archive. || Previews (Gmail, Calendar on Favorites) | Settings ▸ General ▸ Previews Settings… | missing | Fetches through the browser session; nothing leaves the Mac. || Join Meeting ⌃⌘J | Shortcuts | missing | Needs calendar previews first. || Troubleshooting menu | Help ▸ Troubleshooting: Record Trace, Open Task Manager, Reveal Arc Data, Copy Arc Info | partial | Cra has Export Diagnostics… |@@ -84,8 +84,8 @@ gains "New Profile".| Arc tab | Rows Cra lacks ||---|---|| General | Previews Settings…, Block Cookie Banners |-| Profiles | Passwords / Credit Cards / Notifications / Privacy and Security shortcuts to Chromium's pages, "New documents" app |-| Links | "Open Little Arc when clicking on links with ⌥⌘ held", "Archive Little Arcs after" |+| Profiles | "New documents" app (Arc's Notes/Easels); Privacy, Passwords, Credit Cards and Notifications done |+| Links | "Open Little Arc when clicking on links with ⌥⌘ held"; Archive Little Windows after done || Advanced | Play sound effects, restore windows from previous session, window dragging from the top of webpages, Shared Quotes, websites get theme data, Enable Boosts || Icon | Cra has its own icon picker |@@ -112,3 +112,14 @@ in this sweep (Essential Shortcuts window, Library pages).- Settings ▸ Advanced ▸ Play Cra sound effects.- Library ▸ Media and Window ▸ View Media…; File ▸ Capture in Portrait Mode; the toolbar addressmenu's Capture…, Capture Full Page, Manage Extensions… and Hide Toolbar.+- Settings ▸ Tabs ▸ Archive Little Windows after (1 hour, 6 hours, 12 hours); Settings ▸ Profiles ▸+ Your Data and Settings (Chromium's privacy, passwords, cards and notifications pages per profile).++## Left for later, and why++- Boosts: the offline Arc has no network and a local server is blocked in this session, so its Boost+ editor couldn't be put on screen to copy. Needs a site in Arc (Victor's OK to run the real Arc, or+ a localhost server).+- Easels and Notes: whole document types with their own editors; same approach once Boosts is in.+- AppleScript dictionary, Cast, Find and Replace, cookie banner blocking, theme data for websites,+ window dragging from the top of pages, Previews and Join Meeting: not started.