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.

Cra 0.1.21: pinned split views, Clear Cookies/Cache commands, hide space header

Victor76b00813a310
diff --git a/Sources/Cra/App/AppDelegate.swift b/Sources/Cra/App/AppDelegate.swift
index bb553f2..d1d842a 100644
--- a/Sources/Cra/App/AppDelegate.swift
+++ b/Sources/Cra/App/AppDelegate.swift
@@ -757,6 +757,8 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSMenuItemValidation {
case "toggleDeveloperMode": if let url = store.selectedTab?.tab?.url { store.settings.toggleDeveloperMode(url: url) }
case "reload": main.currentBrowser?.reload()
case "hardReload": main.currentBrowser?.reloadIgnoringCache()
+ case "clearCache": main.currentBrowser?.clearSiteDataAndReload(cookies: false)
+ case "clearCookies": main.currentBrowser?.clearSiteDataAndReload(cookies: true)
case "stop": main.currentBrowser?.stopLoading()
case "zoomIn": main.zoom(by: 0.5)
case "zoomOut": main.zoom(by: -0.5)
@@ -923,6 +925,8 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSMenuItemValidation {
view.addItem(item("toggleSidebar")); view.addItem(item("toggleToolbar"))
view.addItem(.separator())
view.addItem(item("stop")); view.addItem(item("reload")); view.addItem(item("hardReload"))
+ // Arc's View menu order: cookies, then cache.
+ view.addItem(item("clearCookies")); view.addItem(item("clearCache"))
view.addItem(.separator())
view.addItem(item("resetZoom")); view.addItem(item("zoomIn")); view.addItem(item("zoomOut"))
view.addItem(.separator())
diff --git a/Sources/Cra/App/KeyBindings.swift b/Sources/Cra/App/KeyBindings.swift
index f20e855..e54fb6f 100644
--- a/Sources/Cra/App/KeyBindings.swift
+++ b/Sources/Cra/App/KeyBindings.swift
@@ -84,6 +84,8 @@ struct KeyAction: Identifiable, Hashable {
var shortcuts: [Shortcut]
var triggers: [String] = []
var inCommandBar: Bool = true
+ /// The command bar row's glyph, where Arc gives the command its own (else ⌘).
+ var symbol: String? = nil
var primary: Shortcut? { shortcuts.first }
}
@@ -181,6 +183,9 @@ final class KeyBindingRegistry {
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)]),
+ // Arc's command bar (1.171): "clear" lists both, cache first, with a trash glyph.
+ KeyAction(id: "clearCache", name: "Clear Cache and Refresh", section: .view, shortcuts: [], symbol: "trash"),
+ KeyAction(id: "clearCookies", name: "Clear Cookies and Refresh", section: .view, shortcuts: [], symbol: "trash"),
// Arc: View ▸ Developer ▸ "Turn on/off Developer Mode for this site" (⌃D).
KeyAction(id: "toggleDeveloperMode", name: "Toggle Developer Mode for this Site", section: .view, shortcuts: [Shortcut("d", .control)], triggers: ["developer mode", "dev mode"]),
KeyAction(id: "resetZoom", name: "Zoom to Actual Size", section: .view, shortcuts: [Shortcut("0", cmd)], triggers: ["reset zoom"]),
diff --git a/Sources/Cra/Model/SidebarModel.swift b/Sources/Cra/Model/SidebarModel.swift
index 67a5b04..3acf609 100644
--- a/Sources/Cra/Model/SidebarModel.swift
+++ b/Sources/Cra/Model/SidebarModel.swift
@@ -460,6 +460,9 @@ struct AppSettings: Codable, Equatable {
/// 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
+ /// 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
init() {}
@@ -564,6 +567,7 @@ extension AppSettings {
tabSleep = (try? c.decodeIfPresent(TabSleepThreshold.self, forKey: .tabSleep)) ?? .oneHour
httpsOnly = try c.decodeIfPresent(Bool.self, forKey: .httpsOnly) ?? false
searchSuggestions = try c.decodeIfPresent(Bool.self, forKey: .searchSuggestions) ?? true
+ showSpaceHeaderOnSingleSpace = try c.decodeIfPresent(Bool.self, forKey: .showSpaceHeaderOnSingleSpace) ?? true
}
}
diff --git a/Sources/Cra/Services/SearchSuggestions.swift b/Sources/Cra/Services/SearchSuggestions.swift
index d2aaea0..6bdf666 100644
--- a/Sources/Cra/Services/SearchSuggestions.swift
+++ b/Sources/Cra/Services/SearchSuggestions.swift
@@ -12,9 +12,11 @@ final class SearchSuggestions {
}
private var cache: [String: [Item]] = [:]
- /// The newest answer, narrowed to the query while the query's own answer loads, so rows
- /// don't empty and refill on every keystroke.
+ /// The newest answer, kept on screen while the query's own answer loads (Chrome's omnibox
+ /// does the same), so rows don't empty and refill on every keystroke.
private var last: (query: String, items: [Item])?
+ /// The query whose answer is loading.
+ private var pending: String?
private var task: Task<Void, Never>?
/// No cookies: the request says nothing about who is typing beyond the text itself.
@@ -33,18 +35,30 @@ final class SearchSuggestions {
func items(for query: String, engine: SearchEngine) -> [Item] {
let q = query.lowercased()
if let hit = cache["\(engine.rawValue)|\(q)"] { return hit }
- guard let last, q.hasPrefix(last.query) else { return [] }
- return last.items.filter { $0.url == nil && $0.text.lowercased().hasPrefix(q) && $0.text.lowercased() != q }
+ guard let last, pending == q else { return [] }
+ // What still starts the typed text first; the rest only holds the bar's height, since
+ // the engine often corrects the spelling ("ramayyana mov" → "ramayana movie").
+ let rest = last.items.filter { $0.text.lowercased() != q }
+ let narrowed = rest.filter { $0.url == nil && $0.text.lowercased().hasPrefix(q) }
+ return narrowed + rest.filter { !narrowed.contains($0) }
}
func fetch(_ query: String, engine: SearchEngine, done: @escaping @MainActor () -> Void) {
task?.cancel()
+ pending = nil
let q = query.lowercased()
let key = "\(engine.rawValue)|\(q)"
guard cache[key] == nil, let url = engine.suggestURL(query) else { return }
+ pending = q
task = Task { [session, weak self] in
- guard let (data, response) = try? await session.data(from: url),
- (response as? HTTPURLResponse)?.statusCode == 200, !Task.isCancelled, let self else { return }
+ let answer = try? await session.data(from: url)
+ guard !Task.isCancelled, let self else { return }
+ self.pending = nil
+ guard let (data, response) = answer, (response as? HTTPURLResponse)?.statusCode == 200 else {
+ // No answer: stop holding the previous one on screen.
+ done()
+ return
+ }
let items = Self.parse(data)
self.cache[key] = items
self.last = (q, items)
@@ -56,6 +70,7 @@ final class SearchSuggestions {
func reset() {
task?.cancel()
task = nil
+ pending = nil
cache = [:]
last = nil
}
diff --git a/Sources/Cra/Services/SidebarStore.swift b/Sources/Cra/Services/SidebarStore.swift
index b1e2bc1..8fb8508 100644
--- a/Sources/Cra/Services/SidebarStore.swift
+++ b/Sources/Cra/Services/SidebarStore.swift
@@ -262,6 +262,10 @@ final class SidebarStore {
// MARK: Lookup
var orderedSpaces: [Space] { spaceOrder.compactMap { spaces[$0] } }
+ /// Arc's single-space mode: one space and the header turned off. Incognito windows keep theirs.
+ func hidesSpaceHeader(_ id: UUID) -> Bool {
+ !settings.showSpaceHeaderOnSingleSpace && spaceOrder.count == 1 && !isIncognito(space: id)
+ }
func focusedSpaceID(window id: UUID?) -> UUID {
window(id).focusedSpaceID.flatMap { spaces[$0] != nil ? $0 : nil } ?? spaceOrder.first!
}
@@ -419,7 +423,8 @@ final class SidebarStore {
guard var it = items[id], var t = it.tab else { return }
if let url, !url.isEmpty, url != "about:blank" {
t.url = url
- if !isPinned(id) { t.savedURL = 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 }
}
// A live folder's tab keeps the pull request's title (Arc shows that, not the page's).
@@ -602,6 +607,15 @@ final class SidebarStore {
it.data = .tab(t)
}
items[id] = it
+ if it.isSplit, isPinned(newParent) {
+ // A pinned split keeps each pane's page as that pane's home.
+ for c in it.children {
+ guard var pane = items[c], var t = pane.tab else { continue }
+ t.savedURL = t.url
+ pane.data = .tab(t)
+ items[c] = pane
+ }
+ }
if let from = fromParent, from != newParent { collapseSplitIfNeeded(from) }
touch()
}
@@ -836,12 +850,16 @@ final class SidebarStore {
moveItem(id, to: space.todayContainerID, index: 0)
}
+ /// A pane pins and unpins its whole split.
func togglePinned(_ id: UUID) {
+ let id = splitContaining(id)?.id ?? id
if isPinned(id) { unpinTab(id) } else { pinTab(id) }
}
/// Favorites belong to one space: the tab's own unless another is given.
func addToFavorites(_ id: UUID, in spaceID: UUID? = nil) {
+ // A favorite is one page's tile; a split can be pinned but not a favorite.
+ guard items[id]?.isSplit != true else { return }
guard let space = spaces[spaceID ?? self.spaceID(ofItem: id) ?? focusedSpaceID] else { return }
// A new favorite takes the tile color when every existing one shares it.
let colors = Set(tabs(under: space.favoritesContainerID).map { $0.tab?.tileColor })
diff --git a/Sources/Cra/Services/SiteData.swift b/Sources/Cra/Services/SiteData.swift
new file mode 100644
index 0000000..936d43f
--- /dev/null
+++ b/Sources/Cra/Services/SiteData.swift
@@ -0,0 +1,21 @@
+import CraCEF
+import Foundation
+
+extension CraBrowser {
+ /// Arc's "Clear Cookies and Refresh" and "Clear Cache and Refresh": this site's cookies, or
+ /// the HTTP cache, then a reload.
+ func clearSiteDataAndReload(cookies: Bool) {
+ guard let u = URL(string: currentURL), let host = u.host, let scheme = u.scheme else { return }
+ let done: (String?, String?) -> Void = { [weak self] _, error in
+ if let error { NSLog("Cra: clearing site data failed: %@", error) }
+ DispatchQueue.main.async { self?.reload() }
+ }
+ if cookies {
+ let params = ["origin": "\(scheme)://\(host)\(u.port.map { ":\($0)" } ?? "")", "storageTypes": "cookies"]
+ let json = String(decoding: (try? JSONSerialization.data(withJSONObject: params)) ?? Data("{}".utf8), as: UTF8.self)
+ sendDevToolsMethod("Storage.clearDataForOrigin", params: json, completion: done)
+ } else {
+ sendDevToolsMethod("Network.clearBrowserCache", params: "{}", completion: done)
+ }
+ }
+}
diff --git a/Sources/Cra/Services/SuggestionEngine.swift b/Sources/Cra/Services/SuggestionEngine.swift
index 77f2465..dd983fd 100644
--- a/Sources/Cra/Services/SuggestionEngine.swift
+++ b/Sources/Cra/Services/SuggestionEngine.swift
@@ -94,7 +94,11 @@ final class SuggestionEngine {
}
items = dedupe(items)
- items.sort { $0.score > $1.score }
+ // Stable: equal scores keep their order (tabs, archive, history, domains, then commands
+ // in menu order), so "clear" lists Clear Cache before Clear Cookies, as Arc does.
+ items = items.enumerated().sorted { a, b in
+ a.element.score != b.element.score ? a.element.score > b.element.score : a.offset < b.offset
+ }.map(\.element)
// Arc's order: the row that supplies the inline completion comes first,
// then what you typed, then everything else.
@@ -103,6 +107,10 @@ final class SuggestionEngine {
let c = items.remove(at: idx)
items.insert(c, at: 0)
items.insert(typed, at: 1)
+ } else if let top = items.first, case .command = top.kind, top.score >= 68 {
+ // Arc 1.171 lists a command the text names above it too: "sett" → Settings,
+ // "clear" → Clear Cache and Refresh, "clear cook" → Clear Cookies and Refresh.
+ items.insert(typed, at: 1)
} else {
items.insert(typed, at: 0)
}
@@ -323,7 +331,7 @@ final class SuggestionEngine {
guard s > 0 else { continue }
s += Double(min(store.ranking.commandUsage[a.id] ?? 0, 10)) * 2
out.append(Suggestion(id: "cmd:\(a.id)", kind: .command(a.id), title: a.name, subtitle: "Command",
- url: nil, faviconKey: nil, symbol: "command", trailing: a.primary?.display, score: s))
+ url: nil, faviconKey: nil, symbol: a.symbol ?? "command", trailing: a.primary?.display, score: s))
}
for space in incognito ? [] : store.orderedSpaces {
let s = nameScore("Switch to \(space.title)", triggers: [space.title.lowercased()])
diff --git a/Sources/Cra/UI/CommandBar/CommandBarController.swift b/Sources/Cra/UI/CommandBar/CommandBarController.swift
index 10e42d5..75400e7 100644
--- a/Sources/Cra/UI/CommandBar/CommandBarController.swift
+++ b/Sources/Cra/UI/CommandBar/CommandBarController.swift
@@ -86,15 +86,16 @@ final class CommandBarController {
previewText = nil
return
}
- result = engine.suggestions(for: newQuery, mode: mode, currentTabID: store.selectedTabID)
- if !allowCompletion { result.inlineCompletion = nil }
- selectedIndex = 0
- previewText = nil
+ // Asked first: while the answer loads, the previous one keeps its rows.
let typed = newQuery
engine.fetchSearchSuggestions(for: typed) { [weak self] in
guard let self, self.isOpen, self.query == typed else { return }
self.relist()
}
+ result = engine.suggestions(for: newQuery, mode: mode, currentTabID: store.selectedTabID)
+ if !allowCompletion { result.inlineCompletion = nil }
+ selectedIndex = 0
+ previewText = nil
}
/// The search engine answered: list again, keeping the selected row where it still is.
diff --git a/Sources/Cra/UI/Settings/ShortcutsPane.swift b/Sources/Cra/UI/Settings/ShortcutsPane.swift
index 01d53b2..7443f0a 100644
--- a/Sources/Cra/UI/Settings/ShortcutsPane.swift
+++ b/Sources/Cra/UI/Settings/ShortcutsPane.swift
@@ -267,6 +267,8 @@ enum ShortcutDescriptions {
"stop": "Stop loading the page.",
"reload": "Reload the page.",
"hardReload": "Reload the page, ignoring cached content.",
+ "clearCache": "Clear the browser cache and reload the page.",
+ "clearCookies": "Clear this site’s cookies and reload the page.",
"toggleDeveloperMode": "Show the full URL and developer tools for this site.",
"resetZoom": "Return the page to its actual size.",
"zoomIn": "Make the page larger.",
diff --git a/Sources/Cra/UI/Settings/TabsPane.swift b/Sources/Cra/UI/Settings/TabsPane.swift
index 733c92a..b0ef53f 100644
--- a/Sources/Cra/UI/Settings/TabsPane.swift
+++ b/Sources/Cra/UI/Settings/TabsPane.swift
@@ -16,6 +16,13 @@ struct TabsPane: View {
SettingsCheckbox(title: "Show toolbar above the page", isOn: $store.settings.showToolbar)
SettingsCheckbox(title: "Enable Picture in Picture when you leave a video tab", isOn: $store.settings.autoPictureInPicture)
}
+ // Arc's single-space mode ("Hide Space Header" on the space's menu), for people who
+ // don't use spaces.
+ SettingsFormRow(label: "Spaces:") {
+ SettingsCheckbox(title: "Show the space header with only one space", isOn: $store.settings.showSpaceHeaderOnSingleSpace)
+ Text("Off hides the space’s name and its icon at the bottom of the sidebar while you have one space.")
+ .font(.system(size: 11)).foregroundStyle(.secondary)
+ }
// Arc's Links pane: the Little Arc switch and "Choose where links open inside
// Arc." with an "Air Traffic Control…" button.
SettingsFormRow(label: "Links:") {
diff --git a/Sources/Cra/UI/Sidebar/List/SidebarMenus.swift b/Sources/Cra/UI/Sidebar/List/SidebarMenus.swift
index 611120c..45ba27e 100644
--- a/Sources/Cra/UI/Sidebar/List/SidebarMenus.swift
+++ b/Sources/Cra/UI/Sidebar/List/SidebarMenus.swift
@@ -224,36 +224,56 @@ enum SidebarMenus {
// MARK: Splits
+ /// Arc 1.171's split menu, item for item where Cra has the feature (no Share or Change Icon).
+ /// It is pinned by dragging it into Pinned or with Pin Tab (⌘D), not from here.
static func split(_ m: SplitRowModel, list: SpaceListView) -> NSMenu {
let store = list.store, ui = list.ui, actions = list.actions
let id = m.id
let menu = menu()
let children = m.cells.map(\.id)
add(menu, "Separate All Tabs") { store.separateAll(id) }
- add(menu, store.item(id)?.split?.orientation == .vertical ? "Convert to Horizontal Split View" : "Convert to Vertical Split View") {
- store.flipSplitOrientation(id)
- }
- add(menu, "Add Pane") {
+ // Arc greys it out while the split is closed (no pane to add next to).
+ add(menu, "Add Tab…", enabled: m.selected && children.count < 4) {
if let first = children.first {
actions.focusPane(first)
actions.performAction("addSplitView")
}
}
+ add(menu, store.item(id)?.split?.orientation == .vertical ? "Convert to Horizontal Split View" : "Convert to Vertical Split View") {
+ store.flipSplitOrientation(id)
+ }
+ menu.addItem(.separator())
+ note(menu, "Tab Options")
+ for c in m.cells {
+ paneItems(submenu(menu, c.title), c.id, list: list)
+ }
menu.addItem(.separator())
add(menu, "Rename…") { ui.renamingID = id }
menu.addItem(.separator())
- add(menu, m.today ? "Archive All" : "Close All") { for c in children { actions.closeTab(c) } }
+ let spaces = submenu(menu, "Move to")
+ let current = store.spaceID(ofItem: id)
+ for s in store.orderedSpaces {
+ add(spaces, "\(s.emoji) \(s.title)", on: s.id == current) { if s.id != current { store.moveTab(id, toSpace: s.id) } }
+ }
+ menu.addItem(.separator())
+ add(menu, "Archive Item") { for c in children { store.archiveTab(c, reason: .manual) } }
return menu
}
- static func splitCell(_ id: UUID, list: SpaceListView) -> NSMenu {
+ /// One pane's submenu under "Tab Options" (Arc: childItem(id, …)).
+ private static func paneItems(_ menu: NSMenu, _ id: UUID, list: SpaceListView) {
let store = list.store, actions = list.actions
- let menu = menu()
- add(menu, "Separate Tab from Split") { store.separateFromSplit(id) }
- add(menu, "Copy Link") { copy(store.item(id)?.tab?.url ?? "") }
+ guard let tab = store.item(id)?.tab else { return }
+ add(menu, "Separate from Split View") { store.separateFromSplit(id) }
menu.addItem(.separator())
- add(menu, "Close") { actions.closeTab(id) }
- return menu
+ add(menu, tab.muted ? "Unmute" : "Mute") {
+ store.setMuted(id, !tab.muted)
+ actions.performAction("muteTab:\(id)")
+ }
+ add(menu, "Copy Link") { copy(tab.url) }
+ add(menu, "Copy Link as Markdown") { copy("[\(store.item(id)?.displayTitle ?? tab.savedTitle)](\(tab.url))") }
+ menu.addItem(.separator())
+ add(menu, "Archive Item") { store.archiveTab(id, reason: .manual) }
}
// MARK: The list
@@ -274,6 +294,10 @@ enum SidebarMenus {
if let s = store.space(space) {
add(menu, "Edit Space…") { actions.editSpace(s) }
}
+ // With the header hidden (one space), its menu items live here.
+ if store.hidesSpaceHeader(space) {
+ add(menu, "Show Space Header") { store.settings.showSpaceHeaderOnSingleSpace = true }
+ }
return menu
}
}
diff --git a/Sources/Cra/UI/Sidebar/List/SidebarRowViews.swift b/Sources/Cra/UI/Sidebar/List/SidebarRowViews.swift
index 5272138..3d684cd 100644
--- a/Sources/Cra/UI/Sidebar/List/SidebarRowViews.swift
+++ b/Sources/Cra/UI/Sidebar/List/SidebarRowViews.swift
@@ -1049,7 +1049,9 @@ final class SplitRowView: SidebarRowView {
func apply(_ m: SplitRowModel) {
guard m != model else { return }
+ let closeChanged = m.selected != model?.selected || m.today != model?.today
model = m
+ defer { if closeChanged { for c in cells where c.hovering { c.refreshClose() } } }
if cells.map(\.cellID) != m.cells.map(\.id) {
cells.forEach { $0.removeFromSuperview() }
separators.forEach { $0.removeFromSuperview() }
@@ -1131,16 +1133,18 @@ final class SplitRowView: SidebarRowView {
private func cell(at point: NSPoint) -> SplitCellView? { cells.first { $0.frame.contains(point) } }
- override func dragItemID(at point: NSPoint) -> UUID? { cell(at: point)?.cellID }
+ // The split moves as one (into Pinned, a folder, another space); a pane leaves it through
+ // the menu or ⌥ on its close button, as in Arc.
+ override func dragItemID(at point: NSPoint) -> UUID? { model?.id }
override func click(_ event: NSEvent, at point: NSPoint) {
guard let c = cell(at: point), let list else { return }
list.store.selectTab(c.cellID, window: list.ui.windowID)
}
+ // Arc shows the split's menu over any pane; each pane's own items are a submenu in it.
override func contextMenu(at point: NSPoint) -> NSMenu? {
guard let m = model, let list else { return nil }
- if let c = cell(at: point) { return SidebarMenus.splitCell(c.cellID, list: list) }
return SidebarMenus.split(m, list: list)
}
@@ -1188,15 +1192,20 @@ final class SplitCellView: NSView, ArcTooltipTarget {
needsLayout = true
}
- private func refreshClose() {
+ func refreshClose() {
close?.removeFromSuperview()
close = nil
guard hovering, let row, let list = row.list else { needsLayout = true; return }
let id = cellID
- let b = SidebarGlyphButton(symbol: "xmark", size: 20, iconSize: 11, help: "Close pane", optionHelp: "Separate from Split View", colors: row.colors) { [weak list] in
+ // Arc 1.171: an open pinned split shows a minus (the whole split closes and stays pinned),
+ // like an open pinned tab; otherwise the ✕ takes this pane out.
+ let keep = row.model.map { !$0.today && $0.selected } ?? false
+ let b = SidebarGlyphButton(symbol: "xmark", size: 20, iconSize: 11, help: keep ? "Close and Keep Pinned (⌘W)" : "Close pane",
+ optionHelp: "Separate from Split View", colors: row.colors) { [weak list] in
// Option-click un-splits instead of closing (Arc flag option-click-split-tab-close-button-to-unsplit).
- if NSEvent.modifierFlags.contains(.option) { list?.store.separateFromSplit(id) } else { list?.actions.closeTab(id) }
+ if NSEvent.modifierFlags.contains(.option) { list?.store.separateFromSplit(id) } else if keep { list?.actions.closeTab(id) } else { list?.actions.closePane(id) }
}
+ if keep { b.setCloseMark(minus: true, help: "Close and Keep Pinned (⌘W)") }
addSubview(b)
close = b
needsLayout = true
diff --git a/Sources/Cra/UI/Sidebar/List/SidebarView.swift b/Sources/Cra/UI/Sidebar/List/SidebarView.swift
index f1e5bcc..4e391ca 100644
--- a/Sources/Cra/UI/Sidebar/List/SidebarView.swift
+++ b/Sources/Cra/UI/Sidebar/List/SidebarView.swift
@@ -540,8 +540,10 @@ final class SpaceDockView: NSView {
withObservationTracking {
colors = SidebarColors(store.focusedSpace(window: ui.windowID).theme.palette)
incognito = store.window(ui.windowID).isIncognito
- spaces = incognito ? [] : store.orderedSpaces
- focused = store.focusedSpaceID(window: ui.windowID)
+ let f = store.focusedSpaceID(window: ui.windowID)
+ focused = f
+ // Arc's single-space mode drops the lone space icon along with the header.
+ spaces = incognito || store.hidesSpaceHeader(f) ? [] : store.orderedSpaces
} onChange: { [weak self] in
Task { @MainActor in
guard let self, !self.syncQueued else { return }
diff --git a/Sources/Cra/UI/Sidebar/List/SpaceColumnView.swift b/Sources/Cra/UI/Sidebar/List/SpaceColumnView.swift
index 1518f28..79bb4a7 100644
--- a/Sources/Cra/UI/Sidebar/List/SpaceColumnView.swift
+++ b/Sources/Cra/UI/Sidebar/List/SpaceColumnView.swift
@@ -26,6 +26,7 @@ final class SpaceColumnView: NSView {
list = SpaceListView(spaceID: spaceID, store: store, ui: ui, actions: actions, favicons: favicons)
super.init(frame: .zero)
favorites.onHeightChange = { [weak self] animated in self?.relayout(animated: animated) }
+ header.onHiddenChange = { [weak self] in self?.relayout(animated: true) }
addSubview(list)
addSubview(favorites)
addSubview(header)
@@ -55,8 +56,9 @@ final class SpaceColumnView: NSView {
let fh = favorites.height(forWidth: w - 16)
let set = { (v: NSView, f: NSRect) in if v.frame != f { animated ? (v.animator().frame = f) : (v.frame = f) } }
set(favorites, NSRect(x: 8, y: 0, width: w - 16, height: fh))
- set(header, NSRect(x: 10, y: fh, width: w - 20, height: 31))
- let top = fh + 31 + 3
+ let hh: CGFloat = header.isHidden ? 0 : 31
+ set(header, NSRect(x: 10, y: fh, width: w - 20, height: hh))
+ let top = fh + hh + 3
set(list, NSRect(x: 0, y: top, width: w, height: max(0, bounds.height - top)))
}
}
@@ -76,6 +78,8 @@ final class SpaceHeaderView: NSView {
private var collapsed = false
private var colors = SidebarColors()
private var syncQueued = false
+ /// The column lays out again when Arc's single-space mode hides or shows the header.
+ var onHiddenChange: (() -> Void)?
init(spaceID: UUID, store: SidebarStore, actions: SidebarActions) {
self.spaceID = spaceID
@@ -98,12 +102,14 @@ final class SpaceHeaderView: NSView {
private func sync() {
syncQueued = false
+ var hide = false
withObservationTracking {
guard let space = store.space(spaceID) else { return }
emoji.stringValue = space.emoji
title.stringValue = space.title
colors = SidebarColors(space.theme.palette)
collapsed = store.isPinnedCollapsed(spaceID)
+ hide = store.hidesSpaceHeader(spaceID)
} onChange: { [weak self] in
Task { @MainActor in
guard let self, !self.syncQueued else { return }
@@ -112,6 +118,10 @@ final class SpaceHeaderView: NSView {
}
}
refresh()
+ if hide != isHidden {
+ isHidden = hide
+ onHiddenChange?()
+ }
}
private func refresh() {
@@ -159,6 +169,10 @@ final class SpaceHeaderView: NSView {
let m = NSMenu()
m.autoenablesItems = false
MenuItems.add(m, collapsed ? "Expand Pinned Tabs" : "Collapse Pinned Tabs") { store.togglePinnedCollapsed(id) }
+ // Arc offers this only while there is one space; Show Space Header brings it back.
+ if store.orderedSpaces.count == 1 {
+ MenuItems.add(m, "Hide Space Header") { store.settings.showSpaceHeaderOnSingleSpace = false }
+ }
m.addItem(.separator())
MenuItems.add(m, "Edit Space…") { actions.editSpace(space) }
MenuItems.add(m, "New Folder") { actions.performAction("newFolder") }
@@ -333,7 +347,7 @@ final class FavoritesGridView: NSView {
}
func moveFavorite(_ dragged: UUID, before target: UUID, after: Bool) {
- guard dragged != target, let space = store.space(spaceID),
+ guard dragged != target, store.item(dragged)?.isSplit != true, let space = store.space(spaceID),
let idx = store.item(space.favoritesContainerID)?.children.firstIndex(of: target) else { return }
store.moveItem(dragged, to: space.favoritesContainerID, index: idx + (after ? 1 : 0))
}
diff --git a/Sources/Cra/UI/Windows/LittleWindowController.swift b/Sources/Cra/UI/Windows/LittleWindowController.swift
index 8a01cca..6e66eec 100644
--- a/Sources/Cra/UI/Windows/LittleWindowController.swift
+++ b/Sources/Cra/UI/Windows/LittleWindowController.swift
@@ -573,6 +573,8 @@ final class LittleWindowController: NSWindowController, NSWindowDelegate, @preco
case "goForward": browser?.goForward()
case "reload": browser?.reload()
case "hardReload": browser?.reloadIgnoringCache()
+ case "clearCache": browser?.clearSiteDataAndReload(cookies: false)
+ case "clearCookies": browser?.clearSiteDataAndReload(cookies: true)
case "stop": browser?.stopLoading()
case "zoomIn": if let b = browser { b.setZoomLevel(b.zoomLevel() + 0.5) }
case "zoomOut": if let b = browser { b.setZoomLevel(b.zoomLevel() - 0.5) }
diff --git a/Sources/Cra/UI/Windows/MainWindowController.swift b/Sources/Cra/UI/Windows/MainWindowController.swift
index 52ee1d9..17ddf04 100644
--- a/Sources/Cra/UI/Windows/MainWindowController.swift
+++ b/Sources/Cra/UI/Windows/MainWindowController.swift
@@ -398,10 +398,11 @@ final class MainWindowController: NSWindowController, NSWindowDelegate, BrowserM
}
/// Arc's "Close this Split Pane" (⌃⇧-): the pane's tab closes like any tab;
- /// the split keeps the other panes.
+ /// the split keeps the other panes. A pinned split's pane leaves it (closing it
+ /// would only unload the whole split).
func closeSplitPane(_ id: UUID) {
guard store.splitContaining(id) != nil else { closeTab(id); return }
- if store.item(id)?.isEmptyTab == true {
+ if store.item(id)?.isEmptyTab == true || store.isPinned(id) {
store.archiveTab(id, reason: .manual)
} else {
closeTab(id)
@@ -1218,15 +1219,19 @@ final class MainWindowController: NSWindowController, NSWindowDelegate, BrowserM
func closeTab(_ id: UUID) {
guard let item = store.item(id), item.isTab else { return }
if store.isPinned(id) {
- let wasSelected = selectedTabID == id
- _ = store.resetPinnedTab(id)
- for w in app.mainWindows { w.browsers.unload(id) }
+ // A pinned split closes as one: every pane unloads and goes back to its page.
+ let panes = store.paneTabIDs(for: id)
+ let wasSelected = selectedTabID.map(panes.contains) ?? false
+ for p in panes {
+ _ = store.resetPinnedTab(p)
+ for w in app.mainWindows { w.browsers.unload(p) }
+ }
if wasSelected {
// Arc goes back to the tab used before this one, if it is still open. A pinned
// tab that was closed (unloaded) doesn't count: two of them would otherwise hand
// the selection back and forth on every ⌘W, reloading each other.
let back = store.recentTabs(in: focusedSpaceID, limit: .max)
- .first { $0 != id && (!store.isPinned($0) || app.runtime(for: $0) != nil) }
+ .first { !panes.contains($0) && (!store.isPinned($0) || app.runtime(for: $0) != nil) }
store.selectTab(back, window: windowID)
}
} else {
@@ -1645,8 +1650,8 @@ final class MainWindowController: NSWindowController, NSWindowDelegate, BrowserM
actions.runExtension = { [weak self] id in self?.runExtensionAction(id) }
actions.addExtension = { [weak self] in self?.openTab("https://chromewebstore.google.com/category/extensions") }
actions.manageExtensions = { [weak self] in self?.openTab("chrome://extensions") }
- actions.clearCache = { [weak self] in self?.clearSiteData(cookies: false) }
- actions.clearCookies = { [weak self] in self?.clearSiteData(cookies: true) }
+ actions.clearCache = { [weak self] in self?.currentBrowser?.clearSiteDataAndReload(cookies: false) }
+ actions.clearCookies = { [weak self] in self?.currentBrowser?.clearSiteDataAndReload(cookies: true) }
actions.siteSettings = { [weak self] in
guard let origin = URL(string: url).flatMap({ u in u.host.map { "\(u.scheme ?? "https")://\($0)" } }) else { return }
self?.openTab("chrome://settings/content/siteDetails?site=" + (origin.addingPercentEncoding(withAllowedCharacters: .alphanumerics) ?? origin))
@@ -1666,23 +1671,6 @@ final class MainWindowController: NSWindowController, NSWindowDelegate, BrowserM
NSSharingServicePicker(items: [url]).show(relativeTo: rect, of: view, preferredEdge: .minY)
}
- /// Arc's "Clear cookies and refresh the current page" (and the cache variant): this site's
- /// cookies, or the HTTP cache, then a reload.
- private func clearSiteData(cookies: Bool) {
- guard let b = currentBrowser, let u = URL(string: b.currentURL), let host = u.host, let scheme = u.scheme else { return }
- let done: (String?, String?) -> Void = { _, error in
- if let error { NSLog("Cra: clearing site data failed: %@", error) }
- DispatchQueue.main.async { b.reload() }
- }
- if cookies {
- let params = ["origin": "\(scheme)://\(host)\(u.port.map { ":\($0)" } ?? "")", "storageTypes": "cookies"]
- let json = String(decoding: (try? JSONSerialization.data(withJSONObject: params)) ?? Data("{}".utf8), as: UTF8.self)
- b.sendDevToolsMethod("Storage.clearDataForOrigin", params: json, completion: done)
- } else {
- b.sendDevToolsMethod("Network.clearBrowserCache", params: "{}", completion: done)
- }
- }
-
/// Arc's "Capture the full page": the whole document (beyond the viewport) as a PNG in Downloads.
func captureFullPage() {
guard let b = currentBrowser else { return }
@@ -1796,7 +1784,10 @@ final class MainWindowController: NSWindowController, NSWindowDelegate, BrowserM
let h = CommandBarView.height(forRows: rows)
let w = commandBar.panelWidth
let wf = window.frame
- commandPanel.setFrame(NSRect(x: wf.midX - w / 2, y: wf.midY - h / 2 + 40, width: w, height: h), display: true)
+ // The field stays put and rows hang below it: centred as a full bar would be, so a
+ // shorter list while typing doesn't move what you type into.
+ let top = wf.midY + CommandBarView.height(forRows: SuggestionEngine.maxRows) / 2 + 40
+ commandPanel.setFrame(NSRect(x: wf.midX - w / 2, y: top - h, width: w, height: h), display: true)
}
private func hideCommandPanel() {
diff --git a/Sources/CraCEF/CraCEF.mm b/Sources/CraCEF/CraCEF.mm
index 8be7f7b..e5a770c 100644
--- a/Sources/CraCEF/CraCEF.mm
+++ b/Sources/CraCEF/CraCEF.mm
@@ -2211,4 +2211,9 @@ static id CraTopLevelWindow(id element) {
[CraCEFRuntime closeAllBrowsersAndQuit];
}
+// Chromium sends this when "Stay" is picked on a "Leave site?" dialog, to stop a quit in
+// progress (chrome_browser_application_mac::CancelTerminate). Cra's quit force-closes pages,
+// which never asks, so there's nothing to cancel; without the method Cra crashed on "Stay".
+- (void)cancelTerminate:(id)sender {}
+
@end
diff --git a/docs/arc-reverse-engineering.md b/docs/arc-reverse-engineering.md
index dde3d1d..7626170 100644
--- a/docs/arc-reverse-engineering.md
+++ b/docs/arc-reverse-engineering.md
@@ -642,6 +642,38 @@ isolated test instance; composites in docs/screenshots/compare-*.png.
Option-click to unsplit, drop-on-row-right-half to split. Not yet: the drop-region placeholder over the
content (CEF page windows receive the drag), the window shrink effect, and a 1:1 divider feel.
+### Pinned splits and the split menu (Arc 1.171, 30 Oct)
+Observed live on a throwaway Today split (example.com | example.org), archived afterwards.
+- [O] Tabs ▸ Pin Tab (⌘D) with a pane focused pins the WHOLE split (appended to Pinned); the item then reads
+ "Unpin Tab" (the word stays "Tab"). Pressing a split row and releasing elsewhere drags the whole split:
+ Pinned → Today moved both panes as one item. A pane never leaves by dragging; only through the menu or ⌥✕.
+- [O] File ▸ Close Tab on an open pinned split closes the whole split (both panes stay pinned, nothing selected).
+ The open pinned split's hover button is a minus (like an open pinned tab); a closed one shows ✕. The button
+ sits once at the row's trailing end, not per pane (Cra still draws it per pane).
+- [O] Right-click anywhere on a split row (either pane) shows one menu: Share Split View… | Separate All Tabs,
+ Add Tab… (disabled while the split is closed), Convert to Vertical Split View | "Tab Options" header, one
+ submenu per pane titled with its page (Separate from Split View | Share ▸, Mute, Copy Link, Copy link as
+ Markdown | Archive Item) | Change Icon…, Rename… | Duplicate, Move to ▸ (spaces with a check on the current
+ one, New Space…) | Archive Item, Archive Tabs Below (Today only). No Pin item.
+- Cra (30 Oct): split rows drag as one item, ⌘D pins/unpins the split, ⌘W closes a pinned split as a whole,
+ the menu follows Arc's minus Share/Change Icon/Duplicate, pinning makes each pane's page its home, and a new
+ pane in a pinned split takes its first page as home.
+
+### Clear cookies / cache (Arc 1.171, 30 Oct)
+- [O] Command bar: "clear" lists Clear Cache and Refresh (selected, above the typed row), then "clear", then
+ Clear Cookies and Refresh; "clear cook" puts Clear Cookies and Refresh first; both rows use a trash glyph.
+ "cache"/"cookies" alone don't surface them. View menu: Force Refresh the Page, Clear Cookies and Refresh,
+ Clear Cache and Refresh. Strings: "Clear cookies and refresh the current page." (site-scoped).
+- [O] Arc lists a matching command above the typed row in general: "sett" → Settings, "new" → Add Split View,
+ "clear" in a main window → Clear Unpinned Tabs. Pages/history follow a confidence rule not reproduced.
+
+### One space (Arc 1.171, static)
+- [O strings] Defaults key `showSpaceHeaderOnSingleUnnamedSpaces` (+ `…DidChange` action); the space context
+ menu has "Show Space Header" / "Hide Space Header" ("Menu item to toggle space header visibility").
+ Not observed live: it needs a one-space Arc, and rewriting StorableSidebar.json risks syncing deleted spaces.
+ Cra: Hide Space Header on the header's menu with one space, Show Space Header on the list's menu, and
+ Settings ▸ Tabs ▸ "Show the space header with only one space"; hidden also drops the dock's lone icon.
+
### DevTools docking, Arc's way (25 Oct)
Evidence from Arc 1.170.0: the ArcCore framework (REA `inspect-macho`, sha256 0a51a5c7…) carries