Skip to content

armgit / cra

Public Imported from GitHub
0

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, first batch: Stay On Top, Save Page As, Copy URL as Quote, tracker-free Copy URL, Reveal Tab, Archive Tabs Below, folder and pinned collapse actions

Victord110dc619c25
diff --git a/Packages/CraCore/Sources/CraCore/CleanURL.swift b/Packages/CraCore/Sources/CraCore/CleanURL.swift
new file mode 100644
index 0000000..a788ab8
--- /dev/null
+++ b/Packages/CraCore/Sources/CraCore/CleanURL.swift
@@ -0,0 +1,50 @@
+import Foundation
+
+/// What Cra puts on the clipboard for a page's address.
+public enum CleanURL {
+ /// Query keys that only tell a site where a click came from. Arc's Copy URL leaves them out
+ /// ("Copy the current tab's URL without trackers", Arc 1.172's Essential Keyboard Shortcuts).
+ static let trackerKeys: Set<String> = [
+ "fbclid", "gclid", "gclsrc", "dclid", "gbraid", "wbraid", "msclkid", "yclid", "twclid", "ttclid", "li_fat_id",
+ "mc_cid", "mc_eid", "igshid", "_hsenc", "_hsmi", "__hssc", "__hstc", "__hsfp", "hsctatracking", "mkt_tok",
+ "oly_anon_id", "oly_enc_id", "vero_id", "vero_conv", "_ga", "_gl", "s_cid", "wickedid", "rb_clickid",
+ "ref_src", "ref_url",
+ ]
+
+ /// The address without tracking parameters (utm_* and the click ids above). Anything that isn't
+ /// an http(s) URL with such a parameter comes back unchanged, byte for byte.
+ public static func withoutTrackers(_ url: String) -> String {
+ guard let q = url.firstIndex(of: "?"), url.hasPrefix("http://") || url.hasPrefix("https://") else { return url }
+ let hash = url[q...].firstIndex(of: "#") ?? url.endIndex
+ let pairs = url[url.index(after: q)..<hash].split(separator: "&", omittingEmptySubsequences: false)
+ let kept = pairs.filter { pair in
+ let key = pair.split(separator: "=", maxSplits: 1, omittingEmptySubsequences: false).first.map(String.init) ?? ""
+ let lower = key.lowercased()
+ return !(lower.hasPrefix("utm_") || trackerKeys.contains(lower))
+ }
+ guard kept.count != pairs.count else { return url }
+ return String(url[..<q]) + (kept.isEmpty ? "" : "?" + kept.joined(separator: "&")) + String(url[hash...])
+ }
+
+ /// Copy URL as Quote: the selection in curly quotes, then a link that scrolls to it and marks it
+ /// (a text fragment, `#:~:text=`). Arc links to a quote card on arc.net; nothing leaves the Mac
+ /// here, so the link is the page's own. Longer quotes link by their first and last five words.
+ public static func quote(_ selection: String, url: String) -> String? {
+ let words = selection.split(whereSeparator: { $0.isWhitespace || $0.isNewline })
+ guard !words.isEmpty else { return nil }
+ let text = words.joined(separator: " ")
+ let base = withoutTrackers(String(url[..<(url.firstIndex(of: "#") ?? url.endIndex)]))
+ let directive = words.count > 10
+ ? escape(words.prefix(5).joined(separator: " ")) + "," + escape(words.suffix(5).joined(separator: " "))
+ : escape(text)
+ return "“\(text)”\n\(base)#:~:text=\(directive)"
+ }
+
+ /// Text-fragment escaping: percent-encode everything but unreserved characters, and `-`, `,`
+ /// and `&` too, which are the directive's own syntax.
+ private static func escape(_ s: String) -> String {
+ var allowed = CharacterSet.alphanumerics
+ allowed.insert(charactersIn: "._~")
+ return s.addingPercentEncoding(withAllowedCharacters: allowed) ?? s
+ }
+}
diff --git a/Packages/CraCore/Sources/CraCore/KeyChord.swift b/Packages/CraCore/Sources/CraCore/KeyChord.swift
index 4fcb92a..b178d8b 100644
--- a/Packages/CraCore/Sources/CraCore/KeyChord.swift
+++ b/Packages/CraCore/Sources/CraCore/KeyChord.swift
@@ -53,6 +53,11 @@ public struct KeyChord: Codable, Hashable {
}
}
+ /// The digit row's virtual key codes (the same on ANSI and ISO keyboards).
+ static let digitKeyCode: [UInt16: String] = [
+ 18: "1", 19: "2", 20: "3", 21: "4", 23: "5", 22: "6", 26: "7", 28: "8", 25: "9", 29: "0",
+ ]
+
static let unshift: [String: String] = [
"\u{19}": tab, "\u{7F}": delete, "{": "[", "}": "]", "<": ",", ">": ".", "?": "/", "+": "=", "_": "-",
"~": "`", ":": ";", "\"": "'", "|": "\\",
@@ -77,6 +82,9 @@ public struct KeyChord: Codable, Hashable {
// Turkish Q types "-" on the ANSI "=" key, and "=" itself as ⇧0: matching "=" by place
// turned ⌘- into Zoom In (GitHub #212).
if let code = Self.ansiKeyCode[key], press.keyCode == code, !typable(key) { return .position }
+ // ⇧ on the digit row types "!", "@", "\"" and so on, which differ by layout: a chord of
+ // ⇧ and a digit (Arc's ⌃⇧1, Switch to Split View 1) takes the key in that digit's place.
+ if keys.contains(.shift), Self.digitKeyCode[press.keyCode] == key { return .position }
return nil
}
@@ -104,6 +112,10 @@ public struct KeyChord: Codable, Hashable {
/// The Delete key as a menu's key equivalent wants it (NSBackspaceCharacter), shown ⌫.
/// Its key events carry U+007F, which the app reads as this.
public static let delete = "\u{8}"
+ /// F12 (NSF12FunctionKey): Arc's second Developer Tools key.
+ public static let f12 = "\u{F70F}"
+ /// The space bar: Arc's Reveal Current Tab is ⌃Space, shown ⌃⎵.
+ public static let space = " "
/// How menus and the command bar show it: ⌃⌥⇧⌘ in Apple's order, then the key.
public var display: String { caps.joined() }
@@ -122,6 +134,8 @@ public struct KeyChord: Codable, Hashable {
case Self.up: s.append("↑")
case Self.down: s.append("↓")
case Self.delete: s.append("⌫")
+ case Self.f12: s.append("F12")
+ case Self.space: s.append("⎵")
default: s.append(key.uppercased())
}
return s
diff --git a/Packages/CraCore/Tests/CraCoreTests/CleanURLTests.swift b/Packages/CraCore/Tests/CraCoreTests/CleanURLTests.swift
new file mode 100644
index 0000000..89d21ef
--- /dev/null
+++ b/Packages/CraCore/Tests/CraCoreTests/CleanURLTests.swift
@@ -0,0 +1,44 @@
+import CraCore
+import Testing
+
+/// Arc's Copy URL (⇧⌘C) copies "the current tab's URL without trackers" (Help ▸ Essential
+/// Keyboard Shortcuts, Arc 1.172); Copy URL as Quote (⌃⇧⌘C) copies the selection with a link to it.
+struct CleanURLTests {
+ @Test func dropsTrackingParameters() {
+ #expect(CleanURL.withoutTrackers("https://example.com/a?utm_source=x&utm_medium=y&id=4&fbclid=abc")
+ == "https://example.com/a?id=4")
+ #expect(CleanURL.withoutTrackers("https://shop.example/p?gclid=1&msclkid=2&mc_eid=3&_hsenc=4&igshid=5")
+ == "https://shop.example/p")
+ }
+
+ @Test func keepsTheFragmentAndOrder() {
+ #expect(CleanURL.withoutTrackers("https://example.com/?b=2&utm_campaign=z&a=1#top")
+ == "https://example.com/?b=2&a=1#top")
+ }
+
+ @Test(arguments: ["https://example.com/", "https://example.com/?q=utm_source", "https://www.google.com/search?q=cra+browser",
+ "file:///Users/me/a.html", "chrome://settings", "not a url", "https://example.com/?utm=1"])
+ func leavesEverythingElseAlone(url: String) {
+ #expect(CleanURL.withoutTrackers(url) == url)
+ }
+
+ @Test func quotesTheSelectionWithALinkToIt() {
+ #expect(CleanURL.quote("Hello, world", url: "https://example.com/post?utm_source=x")
+ == "“Hello, world”\nhttps://example.com/post#:~:text=Hello%2C%20world")
+ }
+
+ @Test func longQuotesLinkByTheirEnds() {
+ let text = "one two three four five six seven eight nine ten eleven twelve thirteen fourteen fifteen"
+ #expect(CleanURL.quote(text, url: "https://example.com/#old")
+ == "“\(text)”\nhttps://example.com/#:~:text=one%20two%20three%20four%20five,eleven%20twelve%20thirteen%20fourteen%20fifteen")
+ }
+
+ @Test func squeezesWhitespaceAndEscapesFragmentSyntax() {
+ #expect(CleanURL.quote(" a-b &\n c ", url: "https://example.com/")
+ == "“a-b & c”\nhttps://example.com/#:~:text=a%2Db%20%26%20c")
+ }
+
+ @Test func nothingSelectedIsNoQuote() {
+ #expect(CleanURL.quote(" \n ", url: "https://example.com/") == nil)
+ }
+}
diff --git a/Packages/CraCore/Tests/CraCoreTests/KeyChordTests.swift b/Packages/CraCore/Tests/CraCoreTests/KeyChordTests.swift
index 48c67b9..66fa216 100644
--- a/Packages/CraCore/Tests/CraCoreTests/KeyChordTests.swift
+++ b/Packages/CraCore/Tests/CraCoreTests/KeyChordTests.swift
@@ -124,4 +124,24 @@ struct KeyChordTests {
#expect(KeyChord.Press(characters: "\u{19}", keyCode: 48, modifiers: 0).key == KeyChord.tab)
#expect(KeyChord.Press(characters: "T", keyCode: 17, modifiers: 0).key == "t")
}
+
+ /// Arc's Shortcuts list shows Developer Tools F12 and Reveal Current Tab ⌃⎵.
+ @Test func showsFunctionKeysAndSpace() {
+ #expect(KeyChord(key: KeyChord.f12, modifiers: 0).display == "F12")
+ #expect(KeyChord(key: KeyChord.space, modifiers: KeyChord.Modifiers.control.rawValue).display == "⌃⎵")
+ let press = KeyChord.Press(characters: "\u{F70F}", keyCode: 111, modifiers: 1 << 23)
+ #expect(KeyChord(key: KeyChord.f12, modifiers: 0).match(press, typable: { _ in true }) == .character,
+ "the function-key bit a press carries doesn't count")
+ }
+
+ /// Arc's Switch to Split View 1 is ⌃⇧1: ⇧1 types "!" (US) or "!" and ⇧2 types "\"" (Danish).
+ @Test(arguments: [("!", UInt16(18), "1"), ("\"", UInt16(19), "2"), ("@", UInt16(19), "2"), ("¤", UInt16(21), "4")])
+ func shiftedDigitsAreTheirDigit(chars: String, code: UInt16, digit: String) {
+ let mods = KeyChord.Modifiers([.control, .shift]).rawValue
+ let press = KeyChord.Press(characters: chars, keyCode: code, modifiers: mods)
+ #expect(KeyChord(key: digit, modifiers: mods).match(press, typable: { _ in true }) == .position)
+ let ctrl = KeyChord.Modifiers.control.rawValue
+ #expect(KeyChord(key: digit, modifiers: ctrl).match(KeyChord.Press(characters: chars, keyCode: code, modifiers: ctrl),
+ typable: { _ in true }) == nil, "without ⇧ in the chord, the character counts")
+ }
}
diff --git a/Sources/Cra/App/AppDelegate.swift b/Sources/Cra/App/AppDelegate.swift
index e8bccf7..7062c67 100644
--- a/Sources/Cra/App/AppDelegate.swift
+++ b/Sources/Cra/App/AppDelegate.swift
@@ -966,11 +966,13 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSMenuItemValidation {
let space = m.focusedSpace
let tabs = (store.tabs(under: space.pinnedContainerID) + store.tabs(under: space.todayContainerID)).compactMap { $0.tab?.url }
let open = store.selectedTabID(window: m.windowID).flatMap { store.item($0)?.tab?.url } ?? "-"
- NSLog("Cra browser windows %@: kind=%@ space=%@ listed=%d tabs=[%@] open=%@ page=%d frame=%@", label,
+ let folders = (store.children(of: space.pinnedContainerID) + store.children(of: space.todayContainerID)).filter { $0.isFolder && !$0.isTabGroup }
+ NSLog("Cra browser windows %@: kind=%@ space=%@ listed=%d tabs=[%@] open=%@ page=%d frame=%@ onTop=%d pinnedCollapsed=%d openFolders=%d/%d", label,
m.isBlank ? "blank" : m.isIncognito ? "incognito" : "normal", space.title,
store.orderedSpaces.contains { $0.id == space.id } ? 1 : 0, tabs.joined(separator: " "), open,
store.selectedTabID(window: m.windowID).flatMap { m.browsers.runtime(for: $0) } != nil ? 1 : 0,
- m.window.map { NSStringFromRect($0.frame) } ?? "-")
+ m.window.map { NSStringFromRect($0.frame) } ?? "-", m.staysOnTop ? 1 : 0,
+ store.isPinnedCollapsed(space.id) ? 1 : 0, folders.filter { store.isExpanded($0.id) }.count, folders.count)
// cra.log (which a relaunch keeps) gets no addresses or names: kinds and counts.
CraLog.note("browser windows \(label): kind=\(m.isBlank ? "blank" : m.isIncognito ? "incognito" : "normal") "
+ "listed=\(store.orderedSpaces.contains { $0.id == space.id } ? 1 : 0) tabs=\(tabs.count) open=\(open == "-" ? 0 : 1)")
@@ -1064,6 +1066,13 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSMenuItemValidation {
switch item.representedObject as? String {
case "toggleSidebar": item.title = main.sidebarVisible ? "Hide Sidebar" : "Show Sidebar"
case "toggleToolbar": item.title = store.settings.showToolbar ? "Hide Toolbar" : "Show Toolbar"
+ case "collapsePinned":
+ item.title = store.isPinnedCollapsed(main.focusedSpaceID) ? "Expand Pinned Tabs" : "Collapse Pinned Tabs"
+ return !main.isStandalone
+ case "stayOnTop": item.state = main.staysOnTop ? .on : .off
+ case "copyURLQuote", "savePageAs", "captureFullPage", "revealTab": return store.selectedTabID != nil
+ case "clearArchive": return !store.archive.isEmpty
+ case "resetSpaceTabs": return !main.isStandalone
case "toggleDeveloperMode":
let on = store.selectedTab?.tab.map { store.settings.isDeveloperMode(url: $0.url) } ?? false
item.title = on ? "Turn off Developer Mode for this Site" : "Turn on Developer Mode for this Site"
@@ -1241,15 +1250,30 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSMenuItemValidation {
store.reopenLastArchived()
}
case "copyURL":
- if let url = current.flatMap({ store.item($0)?.tab?.url }) {
+ // Arc: "Copy the current tab's URL without trackers".
+ if let url = current.flatMap({ store.item($0)?.tab?.url }).map(CleanURL.withoutTrackers) {
copy(url)
main.showToast("Copied Current URL", action: .share(url))
}
case "copyURLMarkdown":
if let c = current, let it = store.item(c), let url = it.tab?.url {
- copy("[\(it.displayTitle)](\(url))")
+ copy("[\(it.displayTitle)](\(CleanURL.withoutTrackers(url)))")
main.showToast("Copied URL as Markdown")
}
+ case "copyURLQuote": main.copyURLAsQuote()
+ case "savePageAs": main.savePageAs()
+ case "captureFullPage": main.captureFullPage()
+ case "collapsePinned": if !main.isStandalone { store.togglePinnedCollapsed(main.focusedSpaceID) }
+ case "revealTab": main.revealSelectedTab()
+ case "resetSpaceTabs": main.resetAllPinnedTabs()
+ case "collapseAllFolders": store.setAllFoldersExpanded(false, inSpace: main.focusedSpaceID)
+ case "expandAllFolders": store.setAllFoldersExpanded(true, inSpace: main.focusedSpaceID)
+ case "openExtensions": main.showSiteControlsFromTheirButton()
+ case "showArchive": main.showLibrary(.archive)
+ case "clearArchive": store.clearArchive()
+ case "stayOnTop": main.toggleStayOnTop()
+ case "revealData": NSWorkspace.shared.activateFileViewerSelecting([AppPaths.supportDir])
+ case "copyAppInfo": copy(appInfo())
case "print": main.currentBrowser?.print()
case "capturePage": main.capturePage()
case "find": main.showFindBar()
@@ -1323,7 +1347,10 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSMenuItemValidation {
default:
if id.hasPrefix("item"), let n = Int(id.dropFirst(4)) {
let tabs = store.visibleTabs(in: store.focusedSpaceID)
- if n - 1 < tabs.count { store.selectTab(tabs[n - 1].id) }
+ // ⌘9 is the last one (Arc's "Go to last Sidebar Item").
+ if n == 9, let last = tabs.last { store.selectTab(last.id) } else if n - 1 < tabs.count { store.selectTab(tabs[n - 1].id) }
+ } else if id.hasPrefix("splitPane"), let n = Int(id.dropFirst(9)) {
+ main.selectSplitPane(n)
} else if id.hasPrefix("space"), let n = Int(id.dropFirst(5)) {
if n - 1 < store.spaceOrder.count { store.focusSpace(store.spaceOrder[n - 1]) }
} else if id.hasPrefix("moveTabToSpace"), let n = Int(id.dropFirst(14)) {
@@ -1332,6 +1359,17 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSMenuItemValidation {
}
}
+ /// Help ▸ Troubleshooting ▸ Copy Cra Info: what a bug report needs about this copy.
+ private func appInfo() -> String {
+ let info = Bundle.main.infoDictionary
+ let os = ProcessInfo.processInfo.operatingSystemVersion
+ return """
+ Cra \(info?["CFBundleShortVersionString"] as? String ?? "") (\(info?["CFBundleVersion"] as? String ?? ""))
+ Chromium \(CraCEFRuntime.chromiumVersion()) · CEF \(CraCEFRuntime.cefVersion())
+ macOS \(os.majorVersion).\(os.minorVersion).\(os.patchVersion)
+ """
+ }
+
private func copy(_ s: String) {
NSPasteboard.general.clearContents()
NSPasteboard.general.setString(s, forType: .string)
@@ -1432,7 +1470,8 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSMenuItemValidation {
file.addItem(.separator())
file.addItem(item("closeWindow")); file.addItem(item("closeTab"))
file.addItem(.separator())
- file.addItem(item("capturePage")); file.addItem(item("print"))
+ // Arc: Capture…, Capture Full Page, Save Page As, Print.
+ for id in ["capturePage", "captureFullPage", "savePageAs", "print"] { file.addItem(item(id)) }
menubar.addItem(submenu: file, title: "File")
let edit = NSMenu(title: "Edit")
@@ -1441,7 +1480,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSMenuItemValidation {
edit.addItem(.separator())
edit.addItem(std("Cut", #selector(NSText.cut(_:)), "x"))
edit.addItem(std("Copy", #selector(NSText.copy(_:)), "c"))
- edit.addItem(item("copyURL")); edit.addItem(item("copyURLMarkdown"))
+ edit.addItem(item("copyURL")); edit.addItem(item("copyURLMarkdown")); edit.addItem(item("copyURLQuote"))
edit.addItem(std("Paste", #selector(NSText.paste(_:)), "v"))
edit.addItem(std("Paste and Match Style", #selector(pasteAsPlainText(_:)), "v", [.command, .shift]))
edit.addItem(std("Delete", #selector(NSText.delete(_:))))
@@ -1453,7 +1492,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSMenuItemValidation {
menubar.addItem(submenu: edit, title: "Edit")
let view = NSMenu(title: "View")
- view.addItem(item("toggleSidebar")); view.addItem(item("toggleToolbar"))
+ view.addItem(item("toggleSidebar")); view.addItem(item("toggleToolbar")); view.addItem(item("collapsePinned"))
view.addItem(.separator())
view.addItem(item("stop")); view.addItem(item("reload")); view.addItem(item("hardReload"))
// Arc's View menu order: cookies, then cache.
@@ -1485,7 +1524,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSMenuItemValidation {
menubar.addItem(submenu: spaces, title: "Spaces")
let tabs = NSMenu(title: "Tabs")
- for id in ["newTab", "pinTab", "nextTab", "previousTab", "recentTab", "clearToday"] { tabs.addItem(item(id)) }
+ for id in ["newTab", "pinTab", "nextTab", "previousTab", "revealTab", "recentTab", "clearToday", "resetSpaceTabs"] { tabs.addItem(item(id)) }
tabs.addItem(.separator())
for id in ["favoriteTab", "renameTab", "duplicateTab", "resetTab", "muteTab"] { tabs.addItem(item(id)) }
tabs.addItem(.separator())
@@ -1493,13 +1532,16 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSMenuItemValidation {
menubar.addItem(submenu: tabs, title: "Tabs")
let archive = NSMenu(title: "Archive")
- archive.addItem(item("goBack")); archive.addItem(item("goForward")); archive.addItem(item("viewArchive"))
+ archive.addItem(item("goBack")); archive.addItem(item("goForward"))
+ archive.addItem(.separator())
+ for id in ["viewArchive", "showArchive", "clearArchive"] { archive.addItem(item(id)) }
menubar.addItem(submenu: archive, title: "Archive")
// Dia: Extensions sits just before Window.
menubar.addItem(submenu: extensionsMenu.makeMenu(), title: "Extensions")
let window = NSMenu(title: "Window")
+ window.addItem(item("stayOnTop"))
window.addItem(std("Minimize Window", #selector(NSWindow.performMiniaturize(_:)), "m"))
window.addItem(std("Zoom", #selector(NSWindow.performZoom(_:))))
window.addItem(.separator())
@@ -1522,7 +1564,12 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSMenuItemValidation {
help.addItem(link)
}
help.addItem(.separator())
- help.addItem(withTitle: "Export Diagnostics…", action: #selector(exportDiagnostics), keyEquivalent: "").target = self
+ // Arc: Help ▸ Troubleshooting.
+ let trouble = NSMenu(title: "Troubleshooting")
+ trouble.addItem(withTitle: "Export Diagnostics…", action: #selector(exportDiagnostics), keyEquivalent: "").target = self
+ trouble.addItem(.separator())
+ trouble.addItem(item("revealData")); trouble.addItem(item("copyAppInfo"))
+ help.addItem(submenu: trouble, title: "Troubleshooting")
menubar.addItem(submenu: help, title: "Help")
NSApp.helpMenu = help
diff --git a/Sources/Cra/App/KeyBindings.swift b/Sources/Cra/App/KeyBindings.swift
index 341ef4e..a2fa3ba 100644
--- a/Sources/Cra/App/KeyBindings.swift
+++ b/Sources/Cra/App/KeyBindings.swift
@@ -142,16 +142,23 @@ final class KeyBindingRegistry {
KeyAction(id: "closeWindow", name: "Close Window", section: .file, shortcuts: [Shortcut("w", cmdShift)], inCommandBar: false),
KeyAction(id: "closeTab", name: "Close Tab", section: .file, shortcuts: [Shortcut("w", cmd)], triggers: ["close", "archive tab"]),
KeyAction(id: "capturePage", name: "Capture…", section: .file, shortcuts: [Shortcut("2", cmdShift)], triggers: ["capture", "screenshot"]),
+ // Arc: File ▸ Capture Full Page, Save Page As ⇧⌘S.
+ KeyAction(id: "captureFullPage", name: "Capture Full Page", section: .file, shortcuts: [], triggers: ["full page", "screenshot"]),
+ KeyAction(id: "savePageAs", name: "Save Page As…", section: .file, shortcuts: [Shortcut("s", cmdShift)], triggers: ["save page", "download page"]),
KeyAction(id: "print", name: "Print", section: .file, shortcuts: [Shortcut("p", cmd)]),
// Edit
KeyAction(id: "copyURL", name: "Copy URL", section: .edit, shortcuts: [Shortcut("c", cmdShift)], triggers: ["copy link"]),
KeyAction(id: "copyURLMarkdown", name: "Copy URL as Markdown", section: .edit, shortcuts: [Shortcut("c", cmdOptShift)], triggers: ["markdown"]),
+ // Arc: Edit ▸ Copy URL as Quote ⌃⇧⌘C, the selection with a link to it.
+ KeyAction(id: "copyURLQuote", name: "Copy URL as Quote", section: .edit, shortcuts: [Shortcut("c", [.command, .shift, .control])], triggers: ["quote", "highlight"]),
KeyAction(id: "find", name: "Find…", section: .edit, shortcuts: [Shortcut("f", cmd)], triggers: ["find", "search page"]),
KeyAction(id: "findNext", name: "Find Next", section: .edit, shortcuts: [Shortcut("g", cmd)], inCommandBar: false),
KeyAction(id: "findPrevious", name: "Find Previous", section: .edit, shortcuts: [Shortcut("g", cmdShift)], inCommandBar: false),
// View
KeyAction(id: "toggleSidebar", name: "Hide Sidebar", section: .view, shortcuts: [Shortcut("s", cmd)], triggers: ["sidebar", "hide sidebar", "show sidebar"]),
KeyAction(id: "toggleToolbar", name: "Hide Toolbar", section: .view, shortcuts: [Shortcut("d", cmdShift)], triggers: ["toolbar"]),
+ // Arc: View ▸ Collapse Pinned Tabs / Expand Pinned Tabs.
+ KeyAction(id: "collapsePinned", name: "Collapse Pinned Tabs", section: .view, shortcuts: [], triggers: ["collapse pinned", "expand pinned"]),
KeyAction(id: "stop", name: "Stop Loading", section: .view, shortcuts: [Shortcut(".", cmd)], inCommandBar: false),
KeyAction(id: "reload", name: "Refresh the Page", section: .view, shortcuts: [Shortcut("r", cmd)], triggers: ["refresh", "reload"]),
KeyAction(id: "hardReload", name: "Force Refresh the Page", section: .view, shortcuts: [Shortcut("r", cmdShift)]),
@@ -164,7 +171,7 @@ final class KeyBindingRegistry {
KeyAction(id: "zoomIn", name: "Zoom In", section: .view, shortcuts: [Shortcut("=", cmd), Shortcut("=", cmdShift)]),
KeyAction(id: "zoomOut", name: "Zoom Out", section: .view, shortcuts: [Shortcut("-", cmd)]),
KeyAction(id: "viewSource", name: "View Source", section: .view, shortcuts: [Shortcut("u", cmdOpt)]),
- KeyAction(id: "devTools", name: "Developer Tools", section: .view, shortcuts: [Shortcut("i", cmdOpt)], triggers: ["devtools", "inspect", "console"]),
+ KeyAction(id: "devTools", name: "Developer Tools", section: .view, shortcuts: [Shortcut("i", cmdOpt), Shortcut(Shortcut.f12, [])], triggers: ["devtools", "inspect", "console"]),
KeyAction(id: "inspectElement", name: "Inspect Elements", section: .view, shortcuts: [Shortcut("c", cmdOpt)], inCommandBar: false),
KeyAction(id: "jsConsole", name: "JavaScript Console", section: .view, shortcuts: [Shortcut("j", cmdOpt)], inCommandBar: false),
// Arc: Extensions ▸ Picture in Picture (no shortcut); "Open Picture in Picture" in the command bar.
@@ -185,8 +192,11 @@ final class KeyBindingRegistry {
KeyAction(id: "manageSpaces", name: "Manage Spaces…", section: .spaces, shortcuts: [], triggers: ["manage spaces", "reorder spaces"]),
// Tabs
KeyAction(id: "pinTab", name: "Pin/Unpin Tab", section: .tabs, shortcuts: [Shortcut("d", cmd)], triggers: ["pin", "unpin"]),
- KeyAction(id: "nextTab", name: "Next Tab", section: .tabs, shortcuts: [Shortcut(Shortcut.down, cmdOpt)], inCommandBar: false),
- KeyAction(id: "previousTab", name: "Previous Tab", section: .tabs, shortcuts: [Shortcut(Shortcut.up, cmdOpt)], inCommandBar: false),
+ // Arc: Next Tab ⌥⌘↓ and ⌘}, Previous Tab ⌥⌘↑ and ⌘{ (Settings ▸ Shortcuts).
+ KeyAction(id: "nextTab", name: "Next Tab", section: .tabs, shortcuts: [Shortcut(Shortcut.down, cmdOpt), Shortcut("]", cmdShift)], inCommandBar: false),
+ KeyAction(id: "previousTab", name: "Previous Tab", section: .tabs, shortcuts: [Shortcut(Shortcut.up, cmdOpt), Shortcut("[", cmdShift)], inCommandBar: false),
+ // Arc: Tabs ▸ Reveal Tab in Sidebar; Reveal Current Tab ⌃Space.
+ KeyAction(id: "revealTab", name: "Reveal Tab in Sidebar", section: .tabs, shortcuts: [Shortcut(Shortcut.space, .control)], triggers: ["reveal", "find tab"]),
KeyAction(id: "recentTab", name: "Next Recent Tab", section: .tabs, shortcuts: [Shortcut(Shortcut.tab, .control)], inCommandBar: false),
KeyAction(id: "recentTabBackward", name: "Previous Recent Tab", section: .tabs, shortcuts: [Shortcut(Shortcut.tab, [.control, .shift])], inCommandBar: false),
KeyAction(id: "clearToday", name: "Clear Today", section: .tabs, shortcuts: [Shortcut("k", cmdShift)], triggers: ["clear", "tidy"]),
@@ -195,13 +205,23 @@ final class KeyBindingRegistry {
KeyAction(id: "duplicateTab", name: "Duplicate Tab", section: .tabs, shortcuts: [], triggers: ["duplicate"]),
KeyAction(id: "resetTab", name: "Reset Pinned Tab", section: .tabs, shortcuts: [], triggers: ["reset", "home"]),
KeyAction(id: "muteTab", name: "Mute / Unmute Tab", section: .tabs, shortcuts: [], triggers: ["mute"]),
+ KeyAction(id: "resetSpaceTabs", name: "Reset all tabs in this Space", section: .tabs, shortcuts: [], triggers: ["reset all", "reset pinned"]),
+ // Arc lists these in Settings ▸ Shortcuts and the command bar only.
+ KeyAction(id: "collapseAllFolders", name: "Collapse All Folders", section: .none, shortcuts: [], triggers: ["collapse folders", "close folders"]),
+ KeyAction(id: "expandAllFolders", name: "Expand All Folders", section: .none, shortcuts: [], triggers: ["expand folders", "open folders"]),
+ KeyAction(id: "openExtensions", name: "Open Extensions", section: .none, shortcuts: [Shortcut("e", cmd)], triggers: ["extensions", "site controls"]),
// Archive
KeyAction(id: "goBack", name: "Go Back", section: .archive, shortcuts: [Shortcut("[", cmd), Shortcut(Shortcut.left, cmd)]),
KeyAction(id: "goForward", name: "Go Forward", section: .archive, shortcuts: [Shortcut("]", cmd), Shortcut(Shortcut.right, cmd)]),
KeyAction(id: "viewArchive", name: "View History", section: .archive, shortcuts: [Shortcut("y", cmd)], triggers: ["archive", "history", "closed tabs"]),
+ // Arc: Archive ▸ View Archive…, Clear Archive.
+ KeyAction(id: "showArchive", name: "View Archive…", section: .archive, shortcuts: [], triggers: ["archive", "archived tabs"]),
+ KeyAction(id: "clearArchive", name: "Clear Archive", section: .archive, shortcuts: [], triggers: ["clear archive"], symbol: "trash"),
// Window
KeyAction(id: "openLibrary", name: "Open Library…", section: .window, shortcuts: [Shortcut("l", cmdShift)], triggers: ["library"]),
KeyAction(id: "viewDownloads", name: "View Downloads…", section: .window, shortcuts: [Shortcut("j", cmdShift)], triggers: ["downloads"]),
+ // Arc: Window ▸ Stay On Top.
+ KeyAction(id: "stayOnTop", name: "Stay On Top", section: .window, shortcuts: [], triggers: ["stay on top", "float", "always on top", "pin window"]),
// Arc's Little Arc "Open in Space" button (LittleBrowserMoveButton) and "Close Little Arc Windows".
KeyAction(id: "promoteLittleWindow", name: "Open Little Window in Space", section: .window, shortcuts: [Shortcut("o", cmd)], inCommandBar: false),
KeyAction(id: "closeLittleWindows", name: "Close Little Windows", section: .window, shortcuts: [], triggers: ["close little"]),
@@ -219,9 +239,18 @@ final class KeyBindingRegistry {
triggers: ["language", "languages", "preferred language", "accept language"], symbol: "globe"),
KeyAction(id: "checkForUpdates", name: "Check for Updates…", section: .app, shortcuts: [],
triggers: ["update", "upgrade", "new version"], symbol: "arrow.down.circle"),
+ // Arc: Help ▸ Troubleshooting ▸ Reveal Arc Data, Copy Arc Info.
+ KeyAction(id: "revealData", name: "Reveal Cra Data", section: .help, shortcuts: [], triggers: ["data folder", "reveal data"]),
+ KeyAction(id: "copyAppInfo", name: "Copy Cra Info", section: .help, shortcuts: [], triggers: ["version", "copy info"]),
]
+ // Arc: Switch to Split View 1–4 (⌃⇧1…4), the panes of the open split.
+ for n in 1...4 {
+ list.append(KeyAction(id: "splitPane\(n)", name: "Switch to Split View \(n)", section: .none,
+ shortcuts: [Shortcut("\(n)", [.control, .shift])], inCommandBar: false))
+ }
for n in 1...9 {
- list.append(KeyAction(id: "item\(n)", name: "Go to Tab \(n)", section: .tabs,
+ // Arc: ⌘9 is "Go to last Sidebar Item", as in Chrome.
+ list.append(KeyAction(id: "item\(n)", name: n == 9 ? "Go to Last Tab" : "Go to Tab \(n)", section: .tabs,
shortcuts: [Shortcut("\(n)", cmd)], triggers: ["\(n). tab", "\(n). item"], inCommandBar: false))
list.append(KeyAction(id: "space\(n)", name: "Go to Space \(n)", section: .spaces,
shortcuts: [Shortcut("\(n)", .control)], inCommandBar: false))
diff --git a/Sources/Cra/Services/SidebarStore.swift b/Sources/Cra/Services/SidebarStore.swift
index d0504a7..553475f 100644
--- a/Sources/Cra/Services/SidebarStore.swift
+++ b/Sources/Cra/Services/SidebarStore.swift
@@ -1533,6 +1533,25 @@ final class SidebarStore {
if p != prefs { prefs = p }
}
+ /// Arc's Collapse All Folders / Expand All Folders: every folder in the space, nested ones too.
+ func setAllFoldersExpanded(_ expanded: Bool, inSpace sid: UUID) {
+ guard let space = spaces[sid] else { return }
+ var folders: [UUID] = []
+ func walk(_ id: UUID) {
+ for c in children(of: id) where c.isFolder && !c.isTabGroup { folders.append(c.id); walk(c.id) }
+ }
+ walk(space.pinnedContainerID)
+ walk(space.todayContainerID)
+ for f in folders { setExpanded(f, expanded) }
+ }
+
+ /// Arc's Reveal Tab in Sidebar (⌃Space): open the folders the tab sits in, and its space's
+ /// pinned section when that is collapsed and the tab is in it.
+ func revealInSidebar(_ id: UUID) {
+ for f in folderChain(of: id) where !isExpanded(f) { setExpanded(f, true) }
+ if isPinned(id), let sid = spaceID(ofItem: id), isPinnedCollapsed(sid) { togglePinnedCollapsed(sid) }
+ }
+
/// Arc's spacesWithCollapsedPinnedSections: clicking the space name hides its pinned tabs.
func isPinnedCollapsed(_ spaceID: UUID) -> Bool {
items.observe(spaceID)
@@ -2010,6 +2029,18 @@ final class SidebarStore {
}
}
+ /// Arc's Today tab menu "Archive Tabs Below": every Today row under this one (splits and
+ /// groups with all their tabs). Pinned and favorite tabs don't offer it.
+ func archiveTabsBelow(_ id: UUID) {
+ guard let item = items[id], let parent = item.parentID, let sid = spaceID(ofItem: id),
+ spaces[sid]?.todayContainerID == parent,
+ let rows = items[parent]?.children, let i = rows.firstIndex(of: id) else { return }
+ for row in rows[(i + 1)...] {
+ guard let r = items[row] else { continue }
+ for t in r.isTab ? [r] : tabs(under: row) { archiveTab(t.id, reason: .manual) }
+ }
+ }
+
func clearToday(_ sid: UUID? = nil) {
guard let space = spaces[sid ?? focusedSpaceID] else { return }
for t in tabs(under: space.todayContainerID) { archiveTab(t.id, reason: .clear) }
diff --git a/Sources/Cra/UI/Sidebar/List/SidebarMenus.swift b/Sources/Cra/UI/Sidebar/List/SidebarMenus.swift
index 2041528..d5c0510 100644
--- a/Sources/Cra/UI/Sidebar/List/SidebarMenus.swift
+++ b/Sources/Cra/UI/Sidebar/List/SidebarMenus.swift
@@ -79,7 +79,7 @@ enum SidebarMenus {
if item.title != nil { add(menu, "Use Page Title") { store.rename(id, to: nil) } }
if m.pinned, tab.liveItemURL == nil { pinnedURLItems(menu, id, navigatedAway: m.navigatedAway, store: store, actions: actions) }
add(menu, action: "duplicateTab", "Duplicate") { _ = store.duplicateTab(id) }
- add(menu, action: "copyURL", "Copy Link") { copy(tab.url) }
+ add(menu, action: "copyURL", "Copy Link") { copy(CleanURL.withoutTrackers(tab.url)) }
add(menu, action: "muteTab", tab.muted ? "Unmute" : "Mute") {
store.setMuted(id, !tab.muted)
actions.performAction("muteTab:\(id)")
@@ -102,6 +102,11 @@ enum SidebarMenus {
add(menu, "Archive Tab") { store.archiveTab(id, reason: .manual) }
} else {
add(menu, action: "closeTab", "Archive") { actions.closeTab(id) }
+ // Arc's Today tab menu: Archive Tab, Archive Tabs Below.
+ if let parent = item.parentID, let rows = store.item(parent)?.children, rows.last != id,
+ store.spaceID(ofItem: id).flatMap(store.space)?.todayContainerID == parent {
+ add(menu, "Archive Tabs Below") { store.archiveTabsBelow(id) }
+ }
}
return menu
}
diff --git a/Sources/Cra/UI/Windows/MainWindowController.swift b/Sources/Cra/UI/Windows/MainWindowController.swift
index 7790f31..ac39cd2 100644
--- a/Sources/Cra/UI/Windows/MainWindowController.swift
+++ b/Sources/Cra/UI/Windows/MainWindowController.swift
@@ -2530,7 +2530,7 @@ final class MainWindowController: NSWindowController, NSWindowDelegate, BrowserM
/// The Site Control Center as if its sliders button was clicked, wherever the request came from
/// (the protected media toast's Why?): under the toolbar's button, else under the sidebar's URL
/// field at its right end, where that button sits. The arrow shows where to find it next time.
- private func showSiteControlsFromTheirButton() {
+ func showSiteControlsFromTheirButton() {
if let button = (shell.focusedCard?.toolbarHost as? PaneToolbarView)?.siteControlsButtonFrameOnScreen() {
return showToolbarExtensionsMenu(from: button, inToolbar: true)
}
@@ -2665,6 +2665,90 @@ final class MainWindowController: NSWindowController, NSWindowDelegate, BrowserM
}
/// Arc's "Capture the full page": the whole document, beyond the viewport, as a PNG.
+ // MARK: Arc parity (docs/arc-parity.md)
+
+ /// Arc's Window ▸ Stay On Top: the window floats over other apps' windows.
+ var staysOnTop: Bool { window?.level == .floating }
+ func toggleStayOnTop() { window?.level = staysOnTop ? .normal : .floating }
+
+ /// Arc's Reveal Tab in Sidebar / Reveal Current Tab (⌃Space): the sidebar comes out with the
+ /// open tab's folders and pinned section open, and scrolls to it.
+ func revealSelectedTab() {
+ guard let id = selectedTabID else { return }
+ store.revealInSidebar(store.splitContaining(id)?.id ?? id)
+ if sidebarUI.libraryPage != nil { closeLibrary() }
+ if !sidebarVisible { toggleSidebar() }
+ let ui = sidebarUI, space = focusedSpaceID
+ DispatchQueue.main.async { SpaceListView.jumpToSelected(for: ui, space: space) }
+ }
+
+ /// Arc's Switch to Split View 1–4 (⌃⇧1…4): the n-th pane of the open split.
+ func selectSplitPane(_ n: Int) {
+ guard let current = selectedTabID else { return }
+ let panes = store.paneTabIDs(for: current)
+ guard panes.count > 1, n >= 1, n <= panes.count else { return }
+ store.selectTab(panes[n - 1], window: windowID)
+ }
+
+ /// Arc's Open Extensions (⌘E): the Site Control Center, as if its sliders were clicked.
+ func openSiteControls() { showSiteControlsFromTheirButton() }
+
+ /// Arc's Tabs ▸ Reset all tabs in this Space: every pinned tab away from its page goes back.
+ func resetAllPinnedTabs() {
+ guard !isStandalone else { return }
+ let space = store.focusedSpace(window: windowID)
+ for t in store.tabs(under: space.pinnedContainerID) where t.tab.map({ $0.url != $0.savedURL }) == true {
+ resetPinnedTab(t.id)
+ }
+ }
+
+ /// Arc's Edit ▸ Copy URL as Quote (⌃⇧⌘C): the page's selection in quotes with a link that
+ /// scrolls to it (CleanURL.quote; Arc's own link goes through arc.net).
+ func copyURLAsQuote() {
+ guard let b = currentBrowser, let url = selectedTabID.flatMap({ store.item($0)?.tab?.url }) else { return }
+ b.sendDevToolsMethod("Runtime.evaluate", params: #"{"expression":"getSelection().toString()","returnByValue":true}"#) { [weak self] result, _ in
+ MainActor.assumeIsolated {
+ let value = result.flatMap { try? JSONSerialization.jsonObject(with: Data($0.utf8)) as? [String: Any] }
+ let text = (value?["result"] as? [String: Any])?["value"] as? String ?? ""
+ guard let quote = CleanURL.quote(text, url: url) else { self?.showToast("Select Text to Copy as a Quote"); return }
+ NSPasteboard.general.clearContents()
+ NSPasteboard.general.setString(quote, forType: .string)
+ self?.showToast("Copied URL as Quote")
+ }
+ }
+ }
+
+ /// Arc's File ▸ Save Page As (⇧⌘S): Chrome's two formats, a single-file web archive or the
+ /// page's HTML.
+ func savePageAs() {
+ guard let b = currentBrowser, let window, let tab = selectedTabID.flatMap({ store.item($0) }) else { return }
+ let panel = NSSavePanel()
+ let format = SavePageFormat(panel: panel)
+ panel.accessoryView = format.view
+ let base = tab.displayTitle.replacingOccurrences(of: "/", with: "-").replacingOccurrences(of: ":", with: "-")
+ panel.nameFieldStringValue = (base.isEmpty ? "Page" : base) + ".mhtml"
+ panel.canCreateDirectories = true
+ panel.beginSheetModal(for: window) { [weak self] response in
+ guard response == .OK, let dest = panel.url else { return }
+ let single = format.singleFile
+ let (method, params) = single
+ ? ("Page.captureSnapshot", #"{"format":"mhtml"}"#)
+ : ("Runtime.evaluate", #"{"expression":"'<!DOCTYPE html>\n'+document.documentElement.outerHTML","returnByValue":true}"#)
+ b.sendDevToolsMethod(method, params: params) { result, error in
+ MainActor.assumeIsolated {
+ let o = result.flatMap { try? JSONSerialization.jsonObject(with: Data($0.utf8)) as? [String: Any] }
+ let text = single ? o?["data"] as? String : (o?["result"] as? [String: Any])?["value"] as? String
+ guard let text, (try? Data(text.utf8).write(to: dest, options: .atomic)) != nil else {
+ NSLog("Cra: save page failed: %@", error ?? "no data")
+ self?.showToast("Couldn’t Save the Page")
+ return
+ }
+ self?.showToast("Page Saved")
+ }
+ }
+ }
+ }
+
func captureFullPage() {
captureOverlay?.close()
guard let b = currentBrowser else { return }
@@ -3379,3 +3463,31 @@ final class CraWindow: NSWindow {
}
}
}
+
+/// Save Page As's Format pop-up (Chrome's "Web Page, Single File" and "Web Page, HTML Only");
+/// switching it swaps the name's extension.
+@MainActor
+private final class SavePageFormat: NSObject {
+ let view: NSView
+ private let popup = NSPopUpButton(frame: .zero, pullsDown: false)
+ private weak var panel: NSSavePanel?
+ var singleFile: Bool { popup.indexOfSelectedItem == 0 }
+
+ init(panel: NSSavePanel) {
+ self.panel = panel
+ let label = NSTextField(labelWithString: "Format:")
+ popup.addItems(withTitles: ["Web Page, Single File", "Web Page, HTML Only"])
+ let row = NSStackView(views: [label, popup])
+ row.edgeInsets = NSEdgeInsets(top: 10, left: 20, bottom: 10, right: 20)
+ view = row
+ super.init()
+ popup.target = self
+ popup.action = #selector(changed)
+ }
+
+ @objc private func changed() {
+ guard let panel else { return }
+ let name = (panel.nameFieldStringValue as NSString).deletingPathExtension
+ panel.nameFieldStringValue = name + (singleFile ? ".mhtml" : ".html")
+ }
+}
diff --git a/Tests/Scenarios/arc-parity-actions.scenario b/Tests/Scenarios/arc-parity-actions.scenario
new file mode 100644
index 0000000..9680f31
--- /dev/null
+++ b/Tests/Scenarios/arc-parity-actions.scenario
@@ -0,0 +1,33 @@
+# Arc parity sweep (docs/arc-parity.md, Arc 1.172.1): Window ▸ Stay On Top floats the window and
+# turns off again; Collapse All Folders / Expand All Folders close and open every folder in the
+# space; View ▸ Collapse Pinned Tabs collapses the section and Tabs ▸ Reveal Tab in Sidebar (⌃Space)
+# opens it again for the pinned tab that is open.
+budget rss=700 stalls50=10
+cra://open?url=${PAGE}?n=one
+expect-log loaded 127\.0\.0\.1 \(HTTP 200\)
+cra://action/stayOnTop
+cra://debug?browserWindows=top
+expect-log Cra browser windows top: kind=normal .* onTop=1
+cra://action/stayOnTop
+cra://debug?browserWindows=down
+expect-log Cra browser windows down: kind=normal .* onTop=0
+cra://action/pinTab
+cra://action/newFolder
+cra://action/newFolder
+wait 1
+cra://action/collapseAllFolders
+cra://debug?browserWindows=closed
+expect-log Cra browser windows closed: .* openFolders=0/2
+cra://action/expandAllFolders
+cra://debug?browserWindows=opened
+expect-log Cra browser windows opened: .* openFolders=2/2
+cra://action/collapsePinned
+cra://debug?browserWindows=collapsed
+expect-log Cra browser windows collapsed: .* pinnedCollapsed=1
+cra://action/revealTab
+cra://debug?browserWindows=revealed
+expect-log Cra browser windows revealed: .* pinnedCollapsed=0
+cra://action/resetSpaceTabs
+cra://action/showArchive
+cra://action/openExtensions
+wait 1
diff --git a/Tests/StoreTests.swift b/Tests/StoreTests.swift
index 620cfba..2cc1233 100644
--- a/Tests/StoreTests.swift
+++ b/Tests/StoreTests.swift
@@ -58,6 +58,9 @@ enum StoreTests {
blankWindows()
blankWindowWithoutItsWindow()
tornOffTabMovesToABlankWindow()
+ archiveTabsBelow()
+ allFoldersExpanded()
+ revealInSidebar()
print("Store: \(checks) checks passed")
}
@@ -1586,6 +1589,67 @@ enum StoreTests {
store.saveAll()
}
+ /// Arc's Today tab menu: "Archive Tabs Below" archives every Today row under the one clicked.
+ @MainActor
+ private static func archiveTabsBelow() {
+ let store = AppComposition(clock: ManualScheduler()).store
+ let sid = store.createSpace(title: "Below", emoji: "⬇️").id
+ let today = store.space(sid)!.todayContainerID
+ let a = store.createTab(url: "https://a.example/", in: sid, select: false, parent: today, index: 0)
+ let b = store.createTab(url: "https://b.example/", in: sid, select: false, parent: today, index: 1)
+ let c = store.createTab(url: "https://c.example/", in: sid, select: false, parent: today, index: 2)
+ let d = store.createTab(url: "https://d.example/", in: sid, select: false, parent: today, index: 3)
+ let split = store.createSplit(with: [c.id, d.id])!
+ let pinned = store.createTab(url: "https://p.example/", in: sid, pinned: true, select: false)
+ expect(store.children(of: today).map(\.id) == [a.id, b.id, split.id], "set up: two tabs and a split in Today")
+ store.archiveTabsBelow(a.id)
+ expect(store.children(of: today).map(\.id) == [a.id], "the tabs and the split below it are archived")
+ expect(Set(store.archive.prefix(3).compactMap(\.item.tab?.url)) == ["https://b.example/", "https://c.example/", "https://d.example/"],
+ "and land in the archive")
+ store.archiveTabsBelow(pinned.id)
+ expect(store.item(pinned.id) != nil, "a pinned tab archives nothing below it (Arc offers it on Today tabs only)")
+ expect(store.integrityProblems().isEmpty, "the sidebar stays sound")
+ }
+
+ /// Arc's Shortcuts list: Collapse All Folders / Expand All Folders, nested folders included.
+ @MainActor
+ private static func allFoldersExpanded() {
+ let store = AppComposition(clock: ManualScheduler()).store
+ let sid = store.createSpace(title: "Folders", emoji: "📁").id
+ let pinned = store.space(sid)!.pinnedContainerID
+ let outer = store.createFolder(named: "Outer", in: pinned)
+ let inner = store.createFolder(named: "Inner", in: outer.id)
+ let other = store.createSpace(title: "Other", emoji: "🗂️", focus: false).id
+ let elsewhere = store.createFolder(named: "Elsewhere", in: store.space(other)!.pinnedContainerID)
+ store.setExpanded(elsewhere.id, false)
+ store.setAllFoldersExpanded(false, inSpace: sid)
+ expect(!store.isExpanded(outer.id) && !store.isExpanded(inner.id), "every folder in the space closes, nested ones too")
+ store.setAllFoldersExpanded(true, inSpace: sid)
+ expect(store.isExpanded(outer.id) && store.isExpanded(inner.id), "and they all open again")
+ expect(!store.isExpanded(elsewhere.id), "another space's folders stay as they were")
+ }
+
+ /// Arc's Reveal Tab in Sidebar (⌃Space): the folders around the tab open, and a collapsed
+ /// pinned section opens when the tab is in it.
+ @MainActor
+ private static func revealInSidebar() {
+ let store = AppComposition(clock: ManualScheduler()).store
+ let sid = store.createSpace(title: "Reveal", emoji: "🔦").id
+ let pinned = store.space(sid)!.pinnedContainerID
+ let outer = store.createFolder(named: "Outer", in: pinned)
+ let inner = store.createFolder(named: "Inner", in: outer.id)
+ let tab = store.createTab(url: "https://deep.example/", in: sid, pinned: true, select: false, parent: inner.id)
+ store.setAllFoldersExpanded(false, inSpace: sid)
+ store.togglePinnedCollapsed(sid)
+ store.revealInSidebar(tab.id)
+ expect(store.isExpanded(outer.id) && store.isExpanded(inner.id), "both folders around the tab open")
+ expect(!store.isPinnedCollapsed(sid), "and the collapsed pinned section opens")
+ let today = store.createTab(url: "https://today.example/", in: sid, select: false)
+ store.togglePinnedCollapsed(sid)
+ store.revealInSidebar(today.id)
+ expect(store.isPinnedCollapsed(sid), "a Today tab leaves the pinned section as it is")
+ }
+
private static func expect(_ condition: @autoclosure () -> Bool, _ message: String) {
guard condition() else {
FileHandle.standardError.write(Data("FAIL: \(message)\n".utf8))
diff --git a/docs/arc-parity.md b/docs/arc-parity.md
new file mode 100644
index 0000000..4ba900b
--- /dev/null
+++ b/docs/arc-parity.md
@@ -0,0 +1,101 @@
+# Arc parity sweep (Arc 1.172.1, 7 Nov 2026)
+
+A full pass over Arc's menu bar, Settings window, Shortcuts list, right-click menus and Library,
+compared item by item with Cra on main (8dbd6d1). Arc was an offline copy on a fake home
+(docs/arc-reverse-engineering.md, "One space"), read through Accessibility and window captures.
+Arc's source file list (paths left in its binary) was used to find feature modules Cra has no
+counterpart for.
+
+Status: **missing** = Cra has nothing; **partial** = Cra has some of it; **done** = built in this
+sweep (commit noted). Items marked *skip* are left out on purpose (cloud, account, AI partner,
+or Arc-only service), per CONTRIBUTING.md.
+
+## 1. Whole features
+
+| Arc feature | Where in Arc | Cra | Notes |
+|---|---|---|---|
+| Boosts (per-site CSS/JS, colours, fonts, Zap) | URL bar ✎, Library ▸ Boosts, Settings ▸ Advanced "Enable Boosts" | missing | Biggest local feature still absent. |
+| Easels | File ▸ New Easel ⌃⇧E, Library ▸ Easels | missing | Canvas of captures, text and live page clips. |
+| Notes | File ▸ New Note ⌃⇧N, ⌃⌥N in split, Help ▸ Export Arc Notes | missing | Rich-text documents as sidebar items. |
+| Library ▸ Media | Window ▸ View Media…, Library rail | missing | Images/videos from Documents, Desktop, Screenshots, Arc Captures, Downloads; right-click "Show media" picks folders. |
+| Essential Keyboard Shortcuts window | Help ▸ Essential Keyboard Shortcuts, Settings ▸ Shortcuts | missing | 475×462 floating dark panel, five rows of key caps, "View All ↗". |
+| Website appearance | View ▸ Appearance ▸ Automatic / Light / Dark ("Websites, Easels, and Notes will use:") | missing | Forces prefers-color-scheme for pages. |
+| Stay On Top | Window ▸ Stay On Top | missing | Floats the window above other apps. |
+| Save Page As | File ▸ Save Page As ⇧⌘S | missing | |
+| Capture Full Page / Portrait Mode | File, URL-bar menu | partial | Cra has Capture… only. |
+| Copy URL without trackers | Copy URL ⇧⌘C ("Copy the current tab's URL without trackers") | missing | Cra copies the URL as is. |
+| Copy URL as Quote | Edit ▸ ⌃⇧⌘C, "Enable Shared Quotes when highlighting text" | missing | Arc links to arc.net (cloud); Cra can use a text-fragment link instead. |
+| AppleScript dictionary | Arc.sdef, View ▸ Developer ▸ Allow JavaScript from Apple Events | missing | Raycast and other launchers script Arc through it. |
+| Cast | View ▸ Cast | missing | Chromium's media router. |
+| Find and Replace, Use Selection to Find, Jump to Selection | Edit ▸ Find | missing | |
+| Sound effects | Settings ▸ Advanced "Play Arc sound effects" | partial | Cra plays the capture shutter only, with no setting. |
+| Theme data for websites | Settings ▸ Advanced "Allow websites to get your theme data" | missing | Arc exposes the space's palette to pages. |
+| 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 | |
+| 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… |
+| Help menu | Getting Started, Release Notes, Contact the Team, Visit Help Center, Restore Data | partial | |
+| Ad blocker upsell card, Sync, Account, Membership card, Share Arc, Sign Out, Send to Dia, Share Space | | *skip* | Account/cloud. |
+| Max: Instant Links, 5-Second Previews, ChatGPT in the Command Bar, New ChatGPT Message ⌥⌘G | Settings ▸ Max | *skip* | AI partner (cloud). Tidy Tabs/Titles/Downloads already on-device. |
+
+## 2. Menu bar and shortcuts
+
+Arc's actions (Settings ▸ Shortcuts, 106 rows) that Cra has no action for:
+
+| Arc action | Arc shortcut | Cra |
+|---|---|---|
+| Collapse Pinned Tabs (View) | — | missing |
+| Reveal Tab in Sidebar (Tabs) / Reveal Current Tab | ⌃Space | missing |
+| Reset all tabs in this Space (Tabs) | — | missing |
+| View Archive… / Clear Archive (Archive menu) | — | partial (Library only) |
+| Collapse All Folders / Expand All Folders | — | missing |
+| Next Tab / Previous Tab, second binding | ⌘} / ⌘{ | missing |
+| Go Back / Go Forward, second binding | ⌘← / ⌘→ | missing |
+| Developer Tools, second binding | F12 | missing |
+| Go to last Sidebar Item | ⌘9 | check (Cra: Go to Tab 9) |
+| Switch to Split View 1–4 | ⌃⇧1…4 | missing |
+| Expand Current Split | — | missing (Cra has Flip orientation) |
+| Open Extensions | ⌘E | missing |
+| Show Little Arc "Open In" Menu | ⇧⌘O | missing |
+| Open Little Arc or Peek in… | ⌘O | partial (Window menu) |
+| Network Inspector | — | *skip* (DevTools has it) |
+| Exit | ⎋ | n/a |
+
+Naming differences (Cra → Arc): "Close Tab" → "Archive Tab" for ⌘W in Shortcuts; "Go to Space N" →
+the space's name ("Victor ⌃1"); "Hide Sidebar" → "Show/Hide Sidebar" in Shortcuts; Spaces menu
+"Edit Space…" → "Edit Theme…" and "Rename Space"; Tabs menu "New Folder" → "New Folder…"; File
+gains "New Profile".
+
+## 3. Right-click menus
+
+| Where | Arc items Cra lacks |
+|---|---|
+| Today tab | Share ▸, Change Icon…, Open in Split View, Archive Tabs Below |
+| Pinned tab | Share ▸, Change Icon…, Edit Pinned Page ▸ (submenu), Add Split View, Remove Pin |
+| Space header / empty sidebar | Share Space… (*skip*), New Folder, Manage Spaces…, Delete Space (check order) |
+| Toolbar address | Share ▸, Capture…, Capture Full Page, Manage Extensions…, Hide Toolbar, Disable Shared Quotes |
+| Library button | Show media ▸ Documents, Desktop, Screenshots, Arc Captures, Downloads |
+
+## 4. Settings
+
+| 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" |
+| 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 |
+
+## 5. Animations and styling
+
+Not re-measured in this sweep: earlier sessions measured the sidebar, command bar, split view,
+Peek, Little Arc, PiP, folders, space dock, Library swipe, dialogs, toasts and toolbar against Arc
+(docs/arc-reverse-engineering.md). New surfaces built from this list are matched to captures taken
+in this sweep (Essential Shortcuts window, Library pages).
+
+## Built in this sweep
+
+(filled in as items land)