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.
Split panes show their controls on focus and hover, and a ring marks the focused pane, as in Arc
Victor2b746ac9a60f
diff --git a/CLAUDE.md b/CLAUDE.mdindex 78da044..9cedda5 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -50,6 +50,6 @@ touches it anyway, not as a side errand.imports AppKit for `Shortcut`'s event matching.- `Services/Import/`: the parsers for other browsers' files. Tested on `Tests/Fixtures` by`scripts/test-store.sh`.-- `UI/ToolbarComposition.swift`, `UI/Windows/ExtensionLaunch.swift`,- `Services/DevToolsToggle.swift` and `UI/Windows/FloatingSidebarGeometry.swift`: policies,- tested by `scripts/test-policies.sh` and `scripts/test-floating-sidebar.sh`.+- `UI/Windows/ExtensionLaunch.swift`, `Services/DevToolsToggle.swift` and+ `UI/Windows/FloatingSidebarGeometry.swift`: policies, tested by+ `scripts/test-policies.sh` and `scripts/test-floating-sidebar.sh`.diff --git a/Packages/CraCore/Sources/CraCore/ToolbarComposition.swift b/Packages/CraCore/Sources/CraCore/ToolbarComposition.swiftnew file mode 100644index 0000000..196b792--- /dev/null+++ b/Packages/CraCore/Sources/CraCore/ToolbarComposition.swift@@ -0,0 +1,71 @@+import Foundation++/// Which buttons Arc's toolbar carries, in order, for a pane's state; PaneToolbarView makes+/// and places the views. Measured against Arc 1.170: the full bar is sidebar toggle ← → ↻ on+/// the left and pinned extensions, Extensions, Split View on the right; the developer bar swaps+/// the navigation for copy · divider · Console, Network, Inspect (Arc's Toggle Console, Toggle+/// Network Panel and Inspect Element, GitHub #88; Arc's Capture Window and Capture between them+/// are not in Cra). The toggle is there only while the sidebar is hidden or floating: otherwise+/// the sidebar's header carries it (Arc 1.171, GitHub #50).+///+/// A split pane's bar (Arc 1.171, GitHub #178) has no toggle and no Split View button. The+/// focused pane carries ← → ↻, the address, the pinned extensions, Extensions, the split options+/// and close; the other panes show only Arc's essential controls (`onlyShowEssentialControls`:+/// ← →, the address and close) until the pointer is over their bar (Arc's `onHover` toolbar+/// blueprint), which reveals the rest.+public struct ToolbarComposition: Equatable, Sendable {+ public enum Kind: Equatable, Sendable { case noTab, emptyPane, normal, developer }++ public enum Item: Equatable, Sendable {+ case toggleSidebar+ case back(enabled: Bool)+ case forward(enabled: Bool)+ /// An ✕ while the page loads.+ case reload(loading: Bool, enabled: Bool)+ case copyURL+ case divider+ case console+ case network+ case inspect+ case pinnedExtension(String)+ case extensions+ case addSplit+ case splitOptions+ case closePane+ }++ public var left: [Item] = []+ public var right: [Item] = []++ /// `hovered`: the pointer is over this bar, which reveals an unfocused pane's controls.+ public init(kind: Kind, inSplit: Bool, sidebarVisible: Bool, focusedPane: Bool, hovered: Bool = false, canGoBack: Bool,+ canGoForward: Bool, isLoading: Bool, pinnedExtensions: [String], hasExtensions: Bool) {+ // Arc's essential controls only: a split pane that neither has the focus nor the pointer.+ let essentialOnly = inSplit && !focusedPane && !hovered+ // Never in a split pane or an empty one.+ if !inSplit, !sidebarVisible, kind != .emptyPane { left.append(.toggleSidebar) }+ switch kind {+ case .noTab:+ left += [.back(enabled: false), .forward(enabled: false), .reload(loading: false, enabled: false)]+ case .emptyPane:+ left = [.back(enabled: false), .forward(enabled: false)]+ case .normal:+ left += [.back(enabled: canGoBack), .forward(enabled: canGoForward)]+ if !essentialOnly { left.append(.reload(loading: isLoading, enabled: true)) }+ case .developer:+ right += [.copyURL, .divider, .console, .network, .inspect]+ }+ // Arc's right end: pinned extensions, the Extensions button, then Split View (not in a+ // split); also on the no-tab bar.+ if !essentialOnly, kind != .emptyPane {+ right += pinnedExtensions.map(Item.pinnedExtension)+ if hasExtensions { right.append(.extensions) }+ if !inSplit { right.append(.addSplit) }+ }+ if inSplit {+ // On a hovered pane too: its bar then doesn't move when a click on it takes the focus.+ if !essentialOnly, kind != .emptyPane { right.append(.splitOptions) }+ right.append(.closePane)+ }+ }+}diff --git a/Packages/CraCore/Sources/CraCore/ToolbarExtensionFit.swift b/Packages/CraCore/Sources/CraCore/ToolbarExtensionFit.swiftindex b322d4d..55817cb 100644--- a/Packages/CraCore/Sources/CraCore/ToolbarExtensionFit.swift+++ b/Packages/CraCore/Sources/CraCore/ToolbarExtensionFit.swift@@ -17,3 +17,42 @@ public enum ToolbarExtensionFit {return hidden}}++/// What a narrow toolbar leaves out so the address keeps room, after Arc 1.171's `…HasRoom`+/// flags (`numberOfExtensionsThatFit`, `refreshHasRoom`, `settingsHasRoom`). Measured live on a+/// split (GitHub #178, 4 Nov 2026): a 387 pt pane keeps ↻ with the address whole; at 350 pt ↻+/// is gone, the domain is cut short and the Site Control Center stays; at 215 pt (Arc 1.170,+/// 24 Oct) the sliders are gone too. So the pins go first, from the front; then ↻ while the+/// address still doesn't fit whole; the sliders only once the address would be squeezed below+/// `minimum`.+public enum ToolbarRoom {+ public struct Plan: Equatable, Sendable {+ public var hiddenPins: Int+ public var hidesReload: Bool+ public var hidesSettings: Bool++ public init(hiddenPins: Int = 0, hidesReload: Bool = false, hidesSettings: Bool = false) {+ (self.hiddenPins, self.hidesReload, self.hidesSettings) = (hiddenPins, hidesReload, hidesSettings)+ }+ }++ /// Between Arc's two narrow observations: room for the link glyph and a few letters.+ public static let minimumAddress: CGFloat = 80++ /// `room`: the address's space with every button shown; each hidden button adds its width.+ /// `reload` / `settings`: those buttons' widths, nil when the bar has none.+ public static func plan(pins: [CGFloat], reload: CGFloat?, settings: CGFloat?, needed: CGFloat,+ room: CGFloat, minimum: CGFloat = minimumAddress) -> Plan {+ var plan = Plan()+ plan.hiddenPins = ToolbarExtensionFit.hiddenCount(widths: pins, needed: needed) { room + $0 }+ var space = room + pins.prefix(plan.hiddenPins).reduce(0, +)+ if space < needed, let reload {+ plan.hidesReload = true+ space += reload+ }+ if space < min(needed, minimum), let settings {+ plan.hidesSettings = true+ }+ return plan+ }+}diff --git a/Packages/CraCore/Tests/CraCoreTests/ToolbarCompositionTests.swift b/Packages/CraCore/Tests/CraCoreTests/ToolbarCompositionTests.swiftnew file mode 100644index 0000000..8a180f5--- /dev/null+++ b/Packages/CraCore/Tests/CraCoreTests/ToolbarCompositionTests.swift@@ -0,0 +1,83 @@+import CraCore+import Testing++/// The toolbar's buttons (Arc 1.170/1.171). A split pane's bar follows focus and hover (GitHub #178).+struct ToolbarCompositionTests {+ typealias T = ToolbarComposition++ private func bar(_ kind: T.Kind, split: Bool = false, sidebar: Bool = false, focused: Bool = true, hovered: Bool = false,+ back: Bool = false, forward: Bool = false, loading: Bool = false, pinned: [String] = [],+ extensions: Bool = false) -> T {+ T(kind: kind, inSplit: split, sidebarVisible: sidebar, focusedPane: focused, hovered: hovered, canGoBack: back,+ canGoForward: forward, isLoading: loading, pinnedExtensions: pinned, hasExtensions: extensions)+ }++ @Test func theFullBar() {+ let full = bar(.normal, back: true, loading: true, pinned: ["a", "b"], extensions: true)+ // Toggle, ← → and ↻ (an ✕ while loading); pinned extensions, Extensions, Split View.+ #expect(full.left == [.toggleSidebar, .back(enabled: true), .forward(enabled: false), .reload(loading: true, enabled: true)])+ #expect(full.right == [.pinnedExtension("a"), .pinnedExtension("b"), .extensions, .addSplit])+ }++ @Test func noExtensionsButtonWithoutExtensions() {+ #expect(bar(.normal).right == [.addSplit])+ }++ @Test func theShownSidebarCarriesTheToggle() {+ // Arc 1.171, #50: the sidebar's header has the toggle, the bar none.+ #expect(bar(.normal, sidebar: true).left == [.back(enabled: false), .forward(enabled: false), .reload(loading: false, enabled: true)])+ #expect(bar(.noTab, sidebar: true).left.first == .back(enabled: false))+ #expect(bar(.developer, sidebar: true).left.isEmpty)+ }++ @Test func theFocusedPaneHasEverythingButTheToggleAndSplitView() {+ // Arc 1.171 (#178): ← → ↻ · address · pinned extensions · Extensions · options · close.+ let pane = bar(.normal, split: true, back: true, loading: true, pinned: ["a"], extensions: true)+ #expect(pane.left == [.back(enabled: true), .forward(enabled: false), .reload(loading: true, enabled: true)])+ #expect(pane.right == [.pinnedExtension("a"), .extensions, .splitOptions, .closePane])+ }++ @Test func anUnfocusedPaneShowsOnlyTheEssentials() {+ // Arc's onlyShowEssentialControls: ← →, the address and close.+ let pane = bar(.normal, split: true, focused: false, back: true, pinned: ["a"], extensions: true)+ #expect(pane.left == [.back(enabled: true), .forward(enabled: false)])+ #expect(pane.right == [.closePane])+ }++ @Test func hoveringAnUnfocusedPaneRevealsItsControls() {+ // Arc's onHover blueprint: the focused pane's set, so a click that focuses it moves nothing.+ let pane = bar(.normal, split: true, focused: false, hovered: true, pinned: ["a"], extensions: true)+ #expect(pane.left == [.back(enabled: false), .forward(enabled: false), .reload(loading: false, enabled: true)])+ #expect(pane.right == [.pinnedExtension("a"), .extensions, .splitOptions, .closePane])+ #expect(pane == bar(.normal, split: true, pinned: ["a"], extensions: true))+ }++ @Test func hoverChangesNothingOutsideASplit() {+ let a = bar(.normal, pinned: ["a"], extensions: true)+ #expect(bar(.normal, hovered: true, pinned: ["a"], extensions: true) == a)+ #expect(bar(.normal, focused: false, pinned: ["a"], extensions: true) == a)+ }++ @Test func anEmptyPaneHasGreyedNavigationAndClose() {+ for focused in [true, false] {+ for hovered in [true, false] {+ let pane = bar(.emptyPane, split: true, focused: focused, hovered: hovered, pinned: ["a"], extensions: true)+ #expect(pane.left == [.back(enabled: false), .forward(enabled: false)])+ #expect(pane.right == [.closePane])+ }+ }+ }++ @Test func noTabGreysTheNavigation() {+ let noTab = bar(.noTab, pinned: ["a"], extensions: true)+ #expect(noTab.left == [.toggleSidebar, .back(enabled: false), .forward(enabled: false), .reload(loading: false, enabled: false)])+ #expect(noTab.right == [.pinnedExtension("a"), .extensions, .addSplit])+ }++ @Test func theDeveloperBar() {+ // Copy · divider · Console, Network, Inspect before the right end (Arc 1.170, #88).+ let dev = bar(.developer, pinned: ["a"])+ #expect(dev.left == [.toggleSidebar])+ #expect(dev.right == [.copyURL, .divider, .console, .network, .inspect, .pinnedExtension("a"), .addSplit])+ }+}diff --git a/Packages/CraCore/Tests/CraCoreTests/ToolbarExtensionFitTests.swift b/Packages/CraCore/Tests/CraCoreTests/ToolbarExtensionFitTests.swiftindex 750a9ab..26c75b4 100644--- a/Packages/CraCore/Tests/CraCoreTests/ToolbarExtensionFitTests.swift+++ b/Packages/CraCore/Tests/CraCoreTests/ToolbarExtensionFitTests.swift@@ -29,3 +29,40 @@ struct ToolbarExtensionFitTests {#expect(hidden(pins: 0, space: 10, address: 200) == 0)}}++/// What a narrow split pane drops, in Arc 1.171's order (GitHub #178).+struct ToolbarRoomTests {+ private let pins: [CGFloat] = [34, 34]++ @Test func everythingStaysWhileTheAddressFits() {+ #expect(ToolbarRoom.plan(pins: pins, reload: 37, settings: 34, needed: 150, room: 200) == .init())+ }++ @Test func pinsGoBeforeRefresh() {+ // 120 + one pin = 154 ≥ 150.+ #expect(ToolbarRoom.plan(pins: pins, reload: 37, settings: 34, needed: 150, room: 120) == .init(hiddenPins: 1))+ }++ @Test func refreshGoesOnceThePinsAreNotEnough() {+ // 40 + 68 = 108 < 150: ↻ goes too, and the address, cut short, keeps the sliders.+ #expect(ToolbarRoom.plan(pins: pins, reload: 37, settings: 34, needed: 150, room: 40)+ == .init(hiddenPins: 2, hidesReload: true))+ }++ @Test func theSlidersGoOnlyWhenTheAddressWouldBeSqueezed() {+ // A 215 pt pane (Arc 1.170): ← → · options · ✕ and the address only.+ #expect(ToolbarRoom.plan(pins: [], reload: 37, settings: 34, needed: 150, room: 0)+ == .init(hidesReload: true, hidesSettings: true))+ #expect(ToolbarRoom.plan(pins: [], reload: 37, settings: 34, needed: 150, room: 50)+ == .init(hidesReload: true))+ }++ @Test func aShortAddressNeverCostsTheSliders() {+ // Needs 60: ↻ makes room (30 + 37 = 67), nothing else goes.+ #expect(ToolbarRoom.plan(pins: [], reload: 37, settings: 34, needed: 60, room: 30) == .init(hidesReload: true))+ }++ @Test func missingButtonsAreNotHidden() {+ #expect(ToolbarRoom.plan(pins: [], reload: nil, settings: nil, needed: 150, room: 0) == .init())+ }+}diff --git a/Sources/Cra/UI/PaneToolbarView.swift b/Sources/Cra/UI/PaneToolbarView.swiftindex 7f3f10f..279d5f9 100644--- a/Sources/Cra/UI/PaneToolbarView.swift+++ b/Sources/Cra/UI/PaneToolbarView.swift@@ -22,6 +22,8 @@ final class PaneToolbarView: NSView {var kind = Kind.noTabvar inSplit = falsevar focusedPane = true+ /// The pointer is over the bar: an unfocused pane shows its controls (Arc's onHover blueprint).+ var hovered = falsevar canGoBack = falsevar canGoForward = falsevar isLoading = false@@ -64,6 +66,11 @@ final class PaneToolbarView: NSView {/// Arc lifts the whole developer bar ~9% toward white while its address field is edited.private let editVeil = NSView()private var press = WindowDragGesture()+ /// Not store state: the tracking area sets it and syncs.+ private var hovered = false {+ didSet { if hovered != oldValue { sync() } }+ }+ private var hoverArea: NSTrackingArea?init(paneTabID: UUID?, store: SidebarStore, ui: SidebarUIState, actions: SidebarActions) {self.paneTabID = paneTabID@@ -101,6 +108,24 @@ final class PaneToolbarView: NSView {(superview as? PaneCardView)?.developerBar = model.kind == .developer ? model.fill : nil}+ // Arc reveals an unfocused pane's controls while the pointer is over its bar (its+ // ContentToolbarInteractionTracker hover session). Active always: the key window is often+ // a page's.+ override func updateTrackingAreas() {+ super.updateTrackingAreas()+ if let hoverArea { removeTrackingArea(hoverArea) }+ let area = NSTrackingArea(rect: .zero, options: [.mouseEnteredAndExited, .activeAlways, .inVisibleRect], owner: self)+ addTrackingArea(area)+ hoverArea = area+ if let window {+ let inside = !isHiddenOrHasHiddenAncestor && bounds.contains(convert(window.mouseLocationOutsideOfEventStream, from: nil))+ if inside != hovered { hovered = inside }+ }+ }++ override func mouseEntered(with event: NSEvent) { hovered = true }+ override func mouseExited(with event: NSEvent) { hovered = false }+// MARK: Modelprivate func scheduleSync() {@@ -126,6 +151,7 @@ final class PaneToolbarView: NSView {let item = paneTabID.flatMap { store.item($0) } ?? (paneTabID == nil ? store.selectedTab(window: ui.windowID) : nil)m.inSplit = paneTabID != nil && ui.splitPaneIDs.count > 1m.focusedPane = paneTabID == nil || store.selectedTabID(window: ui.windowID) == paneTabID+ m.hovered = m.inSplit && hoveredlet nav = paneTabID.map { ui.navState(for: $0) }?? TabNavState(canGoBack: ui.canGoBack, canGoForward: ui.canGoForward, isLoading: ui.isLoading, themeColor: ui.pageThemeColor)m.canGoBack = nav.canGoBack@@ -237,7 +263,7 @@ final class PaneToolbarView: NSView {hairline.isHidden = m.hairline == nilhairline.layer?.backgroundColor = m.hairline?.cgColorlet bar = ToolbarComposition(kind: m.kind, inSplit: m.inSplit, sidebarVisible: m.sidebarVisible, focusedPane: m.focusedPane,- canGoBack: m.canGoBack, canGoForward: m.canGoForward, isLoading: m.isLoading,+ hovered: m.hovered, canGoBack: m.canGoBack, canGoForward: m.canGoForward, isLoading: m.isLoading,pinnedExtensions: m.pinned.map(\.id), hasExtensions: m.hasExtensions)// The no-tab bar and an empty pane show navigation that does nothing (Arc greys it out).let wide = m.kind == .noTab || m.kind == .emptyPane@@ -269,11 +295,16 @@ final class PaneToolbarView: NSView {// Arc: the 16 pt action icon with its badge, and no tooltip (Arc 1.171, #106).b.configure(symbol: nil, image: ExtensionStore.shared.badged(e?.icon, e?.badge, tint: m.fgDim), help: "", enabled: true,width: 34, iconSize: 16, tint: m.fgDim, hover: m.hover)- b.action = { [weak self] in self?.actions.runExtension(id) }+ let pane = paneTabID+ b.action = { [weak self] in+ if let pane { self?.actions.paneRunExtension(pane, id) } else { self?.actions.runExtension(id) }+ }b.menuProvider = { ExtensionStore.shared.entries.first { $0.extensionID == id }.map(ExtensionsMenu.iconMenu) }return bcase .extensions:- return glyph("extensions", "slider.horizontal.2.square", help: "Extensions", width: 34, iconSize: 16) { $0.actions.showExtensionsMenu() }+ return glyph("extensions", "slider.horizontal.2.square", help: "Extensions", width: 34, iconSize: 16) {+ if let pane = $0.paneTabID { $0.actions.paneExtensionsMenu(pane) } else { $0.actions.showExtensionsMenu() }+ }case .addSplit:return glyph("split", "square.split.2x1", help: "Add Split View (⌃⇧=)", width: 34, iconSize: 16) { $0.actions.performAction("addSplitView") }case .splitOptions:@@ -330,13 +361,6 @@ final class PaneToolbarView: NSView {b.cornerRadius = m.kind == .developer ? 6 : 7b.iconRowHeight = bh}- // Left group: icons edge to edge, the first (toggle or ←) centred 21 pt from the card edge (Arc 1.171).- var x: CGFloat = m.kind == .emptyPane ? 1 : 2.5- for b in left {- b.frame = NSRect(x: x, y: (h - bh) / 2, width: b.width, height: bh)- x += b.width- }- let leftEnd = left.isEmpty ? 0 : x// Right group, from the trailing edge: pinned extensions … Split View 6 pt in; a split pane's// close 4 pt in; developer copy | Console, Network, Inspect | spaced as in Arc 1.170 (#88).var rx = w - (m.inSplit ? 4 : (right.isEmpty ? 0 : 6))@@ -347,21 +371,33 @@ final class PaneToolbarView: NSView {devGroup = Array(trailing[(i - 1)...end])trailing.removeSubrange((i - 1)...end)}- // Arc hides pins from the front until the address fits whole (ToolbarExtensionFit); the- // Extensions menu still has them.+ // A narrow bar keeps the address (ToolbarRoom, Arc's …HasRoom): the pins go from the front,+ // then ↻, then the sliders. The Extensions menu still has the pins; ⌘R still reloads.+ let widthOf = { (v: NSView) in (v as? ToolbarGlyphButton)?.width ?? 26 }let pins = trailing.filter { v in m.pinned.contains { buttons["ext:" + $0.id] === v } }- var hidden = 0- if m.kind == .normal, !pins.isEmpty {- let widthOf = { (v: NSView) in (v as? ToolbarGlyphButton)?.width ?? 26 }- let allRight = trailing.reduce(0) { $0 + widthOf($1) }- let a = leftEnd + (left.isEmpty ? 0 : 6)- hidden = ToolbarExtensionFit.hiddenCount(widths: pins.map(widthOf), needed: urlButton.idealWidth) { freed in- rx - (allRight - freed) - 6 - a - 2 * (8 + 6)- }+ let reload = left.first { $0 === buttons["reload"] }+ let settings = trailing.first { $0 === buttons["extensions"] }+ var plan = ToolbarRoom.Plan()+ if m.kind == .normal {+ let start: CGFloat = 2.5+ let leftEnd = left.isEmpty ? 0 : start + left.reduce(0) { $0 + widthOf($1) }+ let room = rx - trailing.reduce(0) { $0 + widthOf($1) } - 6 - (leftEnd + (left.isEmpty ? 0 : 6)) - 2 * (8 + 6)+ plan = ToolbarRoom.plan(pins: pins.map(widthOf), reload: reload.map(widthOf), settings: settings.map(widthOf),+ needed: urlButton.idealWidth, room: room)}- for (i, v) in pins.enumerated() { v.isHidden = i < hidden }- let dropped = pins.prefix(hidden)+ for (i, v) in pins.enumerated() { v.isHidden = i < plan.hiddenPins }+ reload?.isHidden = plan.hidesReload+ settings?.isHidden = plan.hidesSettings+ let dropped: [NSView] = Array(pins.prefix(plan.hiddenPins)) + (plan.hidesSettings ? settings.map { [$0] } ?? [] : [])trailing.removeAll { v in dropped.contains { $0 === v } }+ // Left group: icons edge to edge, the first (toggle or ←) centred 21 pt from the card edge (Arc 1.171).+ var x: CGFloat = m.kind == .emptyPane ? 1 : 2.5+ let shownLeft = left.filter { !(plan.hidesReload && $0 === reload) }+ for b in shownLeft {+ b.frame = NSRect(x: x, y: (h - bh) / 2, width: b.width, height: bh)+ x += b.width+ }+ let leftEnd = shownLeft.isEmpty ? 0 : xfor v in trailing.reversed() {let bw = (v as? ToolbarGlyphButton)?.width ?? 26rx -= bw@@ -450,6 +486,8 @@ final class PaneToolbarView: NSView {private func showSplitMenu(from view: NSView?) {guard let id = paneTabID, let view else { return }+ // A hovered pane's options act on that pane: Copy Link and Flip read the focused one.+ actions.focusPane(id)let menu = NSMenu()let items: [(String, String, () -> Void)?] = [("Separate Tab from Split", "separateFromSplit", { [weak self] in self?.actions.separatePane(id) }),diff --git a/Sources/Cra/UI/ShellView.swift b/Sources/Cra/UI/ShellView.swiftindex 785c6d9..62def24 100644--- a/Sources/Cra/UI/ShellView.swift+++ b/Sources/Cra/UI/ShellView.swift@@ -95,6 +95,8 @@ final class ShellView: NSView {loadingIndicator.isDark = isDarkTheme}}+ /// The ring around the focused split pane: the space's shadedDark (PaneCardView.focusRing).+ var focusRingColor: NSColor? { didSet { if focusRingColor != oldValue { updateFocusRings() } } }/// Each tab's page background ("#RRGGBB"), painted under its page window (PaneCardView.pageColor).var pageColors: [UUID: String] = [:] {didSet { for c in paneCards where c.pageColor != pageColors[c.tabID] { c.pageColor = pageColors[c.tabID] } }@@ -339,6 +341,8 @@ final class ShellView: NSView {focusedPaneID = focused ?? ids.firstemptyPaneIDs = emptyhasTab = !ids.isEmpty+ // A click into another pane changes only the focus; the ring moves in the same pass.+ defer { updateFocusRings() }for h in handles { h.orientation = orientation }guard structural else {@@ -446,6 +450,16 @@ final class ShellView: NSView {}}+ /// Arc rings the focused pane while the window shows several; one pane fills the window+ /// unmarked. A page in full screen has no card around it.+ private func updateFocusRings() {+ let ringed = paneCards.count > 1 && !contentFullscreen+ for c in paneCards {+ let ring = ringed && c.tabID == focusedPaneID ? focusRingColor : nil+ if c.focusRing != ring { c.focusRing = ring }+ }+ }+private func paneLayout(in bounds: NSRect) -> SplitPaneLayout.Result {let ids = paneCards.map(\.tabID)let panes = ids.map { SplitPaneLayout.Pane(id: $0, factor: paneFactors[$0] ?? (1 / CGFloat(max(1, ids.count)))) }@@ -636,6 +650,7 @@ final class ShellView: NSView {func layoutContentChildren(animated: Bool = false) {let cb = contentContainer.bounds+ updateFocusRings()let toolbarVisible = showToolbar && !contentFullscreenlet layout = paneLayout(in: cb)for c in paneCards {diff --git a/Sources/Cra/UI/SidebarUIState.swift b/Sources/Cra/UI/SidebarUIState.swiftindex 5407e53..9e155f0 100644--- a/Sources/Cra/UI/SidebarUIState.swift+++ b/Sources/Cra/UI/SidebarUIState.swift@@ -224,6 +224,10 @@ final class SidebarActions {var runExtension: (String) -> Void = { _ in }/// Toolbar Extensions button: the extensions menu, under the pointer.var showExtensionsMenu: () -> Void = {}+ /// Split view: a pane's pinned extension or Extensions button. The pane takes the focus+ /// first, so the action and the Site Control Center describe its page (GitHub #178).+ var paneRunExtension: (UUID, String) -> Void = { _, _ in }+ var paneExtensionsMenu: (UUID) -> Void = { _ in }/// The developer bar's address field: a typed URL or search, in the selected tab.var loadTyped: (String) -> Void = { _ in }/// A typed URL or search in a new tab (⌘ + New Tab pastes the clipboard's text).diff --git a/Sources/Cra/UI/SplitView/PaneCardView.swift b/Sources/Cra/UI/SplitView/PaneCardView.swiftindex f757971..013b527 100644--- a/Sources/Cra/UI/SplitView/PaneCardView.swift+++ b/Sources/Cra/UI/SplitView/PaneCardView.swift@@ -35,7 +35,13 @@ final class PaneCardView: NSView {refreshBackground()}}- var cornerRadius: CGFloat = CraMetrics.contentCornerRadius { didSet { layer?.cornerRadius = cornerRadius; needsLayout = true } }+ var cornerRadius: CGFloat = CraMetrics.contentCornerRadius {+ didSet {+ layer?.cornerRadius = cornerRadius+ ring.layer?.cornerRadius = cornerRadius+ needsLayout = true+ }+ }/// White page card, or Arc's tinted translucent empty pane.var hasPage = true { didSet { refreshBackground() } }var isDark = false { didSet { refreshBackground() } }@@ -63,6 +69,16 @@ final class PaneCardView: NSView {}var showsElsewhere = false { didSet { elsewhereView.isHidden = !showsElsewhere } }private let elsewhereView = NSView()+ /// Arc's ring around the focused split pane (its focusBorderLayer, GitHub #178): 2 pt in the+ /// space's shadedDark, along the card's rounded edge, over the bar and the page. nil = none.+ var focusRing: NSColor? {+ didSet {+ guard focusRing != oldValue else { return }+ ring.isHidden = focusRing == nil+ ring.layer?.borderColor = focusRing?.cgColor+ }+ }+ private let ring = FocusRingView()/// The card shows another tab now (a tab switch with one pane before and after): the same/// card and toolbar follow it.@@ -101,6 +117,9 @@ final class PaneCardView: NSView {addSubview(toolbarBackground)addSubview(hairline)addSubview(toolbarHost)+ ring.isHidden = true+ ring.layer?.cornerRadius = cornerRadius+ addSubview(ring)refreshBackground()appearanceObservation = NSApp.observe(\.effectiveAppearance) { [weak self] _, _ inMainActor.assumeIsolated { self?.refreshBackground() }@@ -109,6 +128,12 @@ final class PaneCardView: NSView {required init?(coder: NSCoder) { fatalError() }+ /// The ring stays the topmost view: the shell docks DevTools into the focused card later.+ override func didAddSubview(_ subview: NSView) {+ super.didAddSubview(subview)+ if subview !== ring, ring.superview === self { addSubview(ring, positioned: .above, relativeTo: nil) }+ }+private func refreshBackground() {// Measured on Arc 1.170 (Victor theme, 2x): the empty pane is the// gradient plus about +9/+11/+12 per channel, i.e. a white veil at ~0.2.@@ -148,6 +173,7 @@ final class PaneCardView: NSView {elsewhereView.layer?.maskedCorners = pageBackground.layer?.maskedCorners ?? []let wb = frozenWebBounds ?? webArea.boundsfor sub in webArea.subviews where sub.frame != wb { sub.frame = wb }+ ring.frame = b}/// The snapshot (the tab switcher's thumbnail of the top of the page), blurred hard enough@@ -162,3 +188,19 @@ final class PaneCardView: NSView {return result}}++/// A stroke along its bounds' rounded edge (the layer's border), drawn over the card's other+/// views. One static layer: a focus change recolours or hides it, nothing redraws per frame.+private final class FocusRingView: NSView {+ override init(frame: NSRect) {+ super.init(frame: frame)+ wantsLayer = true+ layer?.borderWidth = 2+ layer?.cornerCurve = .continuous+ }++ required init?(coder: NSCoder) { fatalError() }++ /// Clicks go to the bar and the page under it.+ override func hitTest(_ point: NSPoint) -> NSView? { nil }+}diff --git a/Sources/Cra/UI/ToolbarComposition.swift b/Sources/Cra/UI/ToolbarComposition.swiftdeleted file mode 100644index c425672..0000000--- a/Sources/Cra/UI/ToolbarComposition.swift+++ /dev/null@@ -1,63 +0,0 @@-import Foundation--/// Which buttons Arc's toolbar carries, in order, for a pane's state; PaneToolbarView makes-/// and places the views. Measured against Arc 1.170: the full bar is sidebar toggle ← → ↻ on-/// the left and pinned extensions, Extensions, Split View on the right; a split pane has only-/// ← → and its options (focused pane) and close; the developer bar swaps the navigation for-/// copy · divider · Console, Network, Inspect (Arc's Toggle Console, Toggle Network Panel and-/// Inspect Element, GitHub #88; Arc's Capture Window and Capture between them are not in Cra).-/// The toggle is there only while the sidebar is hidden or floating: otherwise the sidebar's-/// header carries it (Arc 1.171, GitHub #50).-struct ToolbarComposition: Equatable {- enum Kind: Equatable { case noTab, emptyPane, normal, developer }-- enum Item: Equatable {- case toggleSidebar- case back(enabled: Bool)- case forward(enabled: Bool)- /// An ✕ while the page loads.- case reload(loading: Bool, enabled: Bool)- case copyURL- case divider- case console- case network- case inspect- case pinnedExtension(String)- case extensions- case addSplit- case splitOptions- case closePane- }-- var left: [Item] = []- var right: [Item] = []-- init(kind: Kind, inSplit: Bool, sidebarVisible: Bool, focusedPane: Bool, canGoBack: Bool, canGoForward: Bool, isLoading: Bool,- pinnedExtensions: [String], hasExtensions: Bool) {- // Never in a split pane (Arc 1.170: only ← → in a pane) or an empty one.- if !inSplit, !sidebarVisible, kind != .emptyPane { left.append(.toggleSidebar) }- switch kind {- case .noTab:- left += [.back(enabled: false), .forward(enabled: false), .reload(loading: false, enabled: false)]- case .emptyPane:- left = [.back(enabled: false), .forward(enabled: false)]- case .normal:- // Split panes drop refresh too.- left += [.back(enabled: canGoBack), .forward(enabled: canGoForward)]- if !inSplit { left.append(.reload(loading: isLoading, enabled: true)) }- case .developer:- right += [.copyURL, .divider, .console, .network, .inspect]- }- // Arc's right end: pinned extensions, the Extensions button, then Split View; also on- // the no-tab bar. A split pane has its options (focused pane only) and close instead.- if !inSplit, kind != .emptyPane {- right += pinnedExtensions.map(Item.pinnedExtension)- if hasExtensions { right.append(.extensions) }- right.append(.addSplit)- }- if inSplit {- if focusedPane, kind != .emptyPane { right.append(.splitOptions) }- right.append(.closePane)- }- }-}diff --git a/Sources/Cra/UI/Windows/MainWindowController.swift b/Sources/Cra/UI/Windows/MainWindowController.swiftindex 128ec0f..99e1c63 100644--- a/Sources/Cra/UI/Windows/MainWindowController.swift+++ b/Sources/Cra/UI/Windows/MainWindowController.swift@@ -279,6 +279,15 @@ final class MainWindowController: NSWindowController, NSWindowDelegate, BrowserMbuttonBottomY: self?.store.settings.showToolbar == false ? button?.minY : nil)}sidebarActions.showExtensionsMenu = { [weak self] in self?.showToolbarExtensionsMenu() }+ sidebarActions.paneRunExtension = { [weak self] pane, id in+ guard let self else { return }+ self.focusPaneNow(pane)+ self.sidebarActions.runExtension(id)+ }+ sidebarActions.paneExtensionsMenu = { [weak self] pane in+ self?.focusPaneNow(pane)+ self?.showToolbarExtensionsMenu()+ }// Popups from an extension's shortcut or chrome.action.openPopup() hang where the// menu bar's do: under the extension's toolbar button, else at the card's right end.// Arc puts every popup in one place, whatever opened it.@@ -364,6 +373,8 @@ final class MainWindowController: NSWindowController, NSWindowDelegate, BrowserMwindow?.backgroundColor = palette.vibrant ? .clear : NSColor(palette.gradientColors.first ?? .gray)}+ let ring = NSColor(space.theme.shadedDark)+ if shell.focusRingColor != ring { shell.focusRingColor = ring }browsers.pruneMissingTabs()let selected = selectedTabID// Split view: the selected tab's split decides which panes are on screen.@@ -2155,6 +2166,15 @@ final class MainWindowController: NSWindowController, NSWindowDelegate, BrowserM})}+ /// Selects a split pane and brings the shell along at once (refresh otherwise runs on the next+ /// turn), so the focused card, the visible page and the profile are that pane's when the+ /// caller reads them.+ private func focusPaneNow(_ id: UUID) {+ guard selectedTabID != id else { return }+ store.selectTab(id, window: windowID)+ refresh()+ }+/// Arc's sliders button (toolbar and URL pill): the Site Control Center, hung under the/// button that was clicked (buttons are 32 × 28), not wherever the pointer is in it.private func showToolbarExtensionsMenu() {diff --git a/Tests/PolicyTests.swift b/Tests/PolicyTests.swiftindex d43afdf..a16a293 100644--- a/Tests/PolicyTests.swift+++ b/Tests/PolicyTests.swift@@ -1,50 +1,20 @@import Foundation-/// The decisions pulled out of the window controllers: the toolbar's buttons (Arc 1.170), what-/// an extension click does, and the DevTools toggle. Table tests, no AppKit views.+/// The decisions pulled out of the window controllers: what an extension click does, the+/// DevTools toggle and the feature flags (the toolbar's buttons moved to CraCore). Table tests,+/// no AppKit views.@mainenum PolicyTests {private static var checks = 0@MainActorstatic func main() {- toolbar()extensionLaunch()devToolsToggle()featureFlags()print("Policies: \(checks) checks passed")}- private static func toolbar() {- typealias T = ToolbarComposition- func bar(_ kind: T.Kind, split: Bool = false, sidebar: Bool = false, focused: Bool = true, back: Bool = false,- forward: Bool = false, loading: Bool = false, pinned: [String] = [], extensions: Bool = false) -> T {- T(kind: kind, inSplit: split, sidebarVisible: sidebar, focusedPane: focused, canGoBack: back, canGoForward: forward,- isLoading: loading, pinnedExtensions: pinned, hasExtensions: extensions)- }- let full = bar(.normal, back: true, loading: true, pinned: ["a", "b"], extensions: true)- expect(full.left == [.toggleSidebar, .back(enabled: true), .forward(enabled: false), .reload(loading: true, enabled: true)],- "the full bar: toggle, ← → and ↻ (an ✕ while loading)")- expect(full.right == [.pinnedExtension("a"), .pinnedExtension("b"), .extensions, .addSplit],- "the right end: pinned extensions, Extensions, Split View")- expect(bar(.normal).right == [.addSplit], "no Extensions button without extensions")- expect(bar(.normal, sidebar: true).left == [.back(enabled: false), .forward(enabled: false), .reload(loading: false, enabled: true)]- && bar(.noTab, sidebar: true).left.first == .back(enabled: false) && bar(.developer, sidebar: true).left.isEmpty,- "the sidebar shown: its header carries the toggle, the bar has none (Arc 1.171, #50)")- let pane = bar(.normal, split: true, back: true, pinned: ["a"], extensions: true)- expect(pane.left == [.back(enabled: true), .forward(enabled: false)] && pane.right == [.splitOptions, .closePane],- "a focused split pane: only ← →, then its options and close")- expect(bar(.normal, split: true, focused: false).right == [.closePane], "an unfocused pane has only its close button")- expect(bar(.emptyPane, split: true).left == [.back(enabled: false), .forward(enabled: false)]- && bar(.emptyPane, split: true).right == [.closePane], "an empty pane: greyed ← → and close")- let noTab = bar(.noTab, pinned: ["a"], extensions: true)- expect(noTab.left == [.toggleSidebar, .back(enabled: false), .forward(enabled: false), .reload(loading: false, enabled: false)]- && noTab.right == [.pinnedExtension("a"), .extensions, .addSplit], "no tab: greyed navigation, the right end as usual")- let dev = bar(.developer, pinned: ["a"])- expect(dev.left == [.toggleSidebar] && dev.right == [.copyURL, .divider, .console, .network, .inspect, .pinnedExtension("a"), .addSplit],- "the developer bar: copy · divider · Console, Network, Inspect before the right end (Arc 1.170, #88)")- }-private static func extensionLaunch() {typealias E = ExtensionLaunch.Extensionlet popup = E(id: "pop", popupPath: "popup.html", optionsPath: "options.html")diff --git a/docs/arc-reverse-engineering.md b/docs/arc-reverse-engineering.mdindex e52caf2..f56706b 100644--- a/docs/arc-reverse-engineering.md+++ b/docs/arc-reverse-engineering.md@@ -715,8 +715,9 @@ isolated test instance; composites in docs/screenshots/compare-*.png.frames at 27 fps); the command bar fades in over the new pane, horizontally centred on it but kept inside thewindow (right margin ~80 pt), with Arc's "Search or Enter URL…" new-tab bar, not the edit-URL bar.- [O] Pane cards: 10 pt gap, both cards rounded; each pane has its own toolbar with ← → and a close ✕ at the- right (no refresh button); the focused pane additionally shows a split-options button (rectangle.split- glyph) just before its ✕. The URL is centred; in narrow panes the link glyph is dropped.+ right; the focused pane additionally shows a split-options button (rectangle.split glyph) just before its ✕.+ The URL is centred; in narrow panes the link glyph is dropped. (These panes were ~215 pt wide, too narrow for+ ↻ and the sliders: see "Split pane bars and the focus ring" below, GitHub #178.)- [O] The empty pane is the window gradient plus a white veil of about +9/+11/+12 per channel (≈ 0.2 alpha),with a hairline under its toolbar.- [O] Hovering the gap between panes shows no handle. Dragging from the gap did not resize in our runs: Arc@@ -742,6 +743,27 @@ 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 thecontent (CEF page windows receive the drag), the window shrink effect, and a 1:1 divider feel.+### Split pane bars and the focus ring (Arc 1.171, 4 Nov, GitHub #178)+Offline Arc (fake home, see "One space") with a Today split of two local pages, read over AX (button+descriptions and frames) at window widths 1400 → 926 (Arc's minimum), plus window captures and real-pointer hover.+- [O static] The bar's state has `onlyShowEssentialControls`, `isHovered`, a `blueprintType` of `onHover | always`+ (ContentToolbarInteractionTracker's hover session), and per-item `urlDomainHasRoom`, `numberOfExtensionsThatFit`,+ `refreshHasRoom`, `copyHasRoom`, `settingsHasRoom`. The ring is a `focusBorderLayer`.+- [O] Focused pane: Go back, Go forward, Reload this page | address (Copy Current URL, security glyph) | pinned+ extensions (in the reporter's capture; the offline copy has none), Site Control Center, Split View Menu,+ Close Split View Pane. Unfocused pane: Go back, Go forward | address | Close Split View Pane only.+- [O] Pointer over an unfocused pane's bar: Reload, Site Control Center and Split View Menu appear there too (the+ focused pane's set); the ring stays where it is. Pressing that Reload reloads the pane and moves the focus (and+ the ring) to it; the other pane drops back to the essentials.+- [O] Narrow: a 387 pt pane (window 1000) keeps everything; a ~350 pt pane (window 926) drops Reload, cuts the+ domain short ("....lvh.me") and keeps the Site Control Center; a 215 pt pane (Arc 1.170, above) has neither.+- [O] Ring: 2 pt (4 px at 2x), solid, along the card's rounded edge and over the bar's edge, in the space's+ `primaryColorPalette.shadedDark` (#6B5709 measured on Victor's yellow space, P3 capture; #B60222 vs Arc's stored+ #B70021 on the reporter's red space). None on the unfocused pane or on a lone pane.+- Cra: ToolbarComposition (`hovered`, essentials only on an unfocused, unhovered pane), ToolbarRoom (pins, then ↻,+ then the sliders below an 80 pt address, a guess between the two narrow observations), PaneCardView.focusRing+ (theme.shadedDark). A control on an unfocused pane focuses it first, as Arc's Reload does.+### 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 readsdiff --git a/docs/development.md b/docs/development.mdindex a0cc481..391352f 100644--- a/docs/development.md+++ b/docs/development.md@@ -93,7 +93,7 @@ app it builds.- `scripts/test-store.sh`: the real `SidebarStore`, `AppComposition` and importers on a`ManualScheduler`, against the made-up Arc and Chromium profiles in `Tests/Fixtures`.- `scripts/test-policies.sh`: the decisions pulled out of the window controllers- (`ToolbarComposition`, `ExtensionLaunch`, `DevToolsToggle`, `FeatureFlags`).+ (`ExtensionLaunch`, `DevToolsToggle`, `FeatureFlags`).- `scripts/test-perf.sh`: the performance recorder on a real main run loop: injected stalls,hang files with a `sample` stack, the session marker, ownership, the recording switch([performance.md](performance.md)).diff --git a/docs/testing.md b/docs/testing.mdindex 0414bb3..96edf39 100644--- a/docs/testing.md+++ b/docs/testing.md@@ -9,8 +9,8 @@ Commands for each piece are in [development.md](development.md#tests).may sleep, which buttons a toolbar has) is a value type with a table test. What performsit (an `NSView`, a CEF call) gets no unit test; scenarios cover it.2. **Only test at seams that exist in production.** When logic can only be reached by building- a window, move the logic (`ToolbarComposition`, `ExtensionLaunch`, `DevToolsToggle`);- don't add a test hook to the window.+ a window, move the logic (into CraCore like `ToolbarComposition`, or a policy like+ `ExtensionLaunch`); don't add a test hook to the window.3. **No sleeps, no wall clock.** Decisions taken from time use the app's clock(`Scheduler`, injected through `AppComposition`); a test passes a `ManualScheduler` andadvances it, so the 30-minute archive pass runs in a millisecond.diff --git a/scripts/mutate.py b/scripts/mutate.pyindex 041791e..910bff8 100755--- a/scripts/mutate.py+++ b/scripts/mutate.py@@ -22,7 +22,6 @@ MIN_SCORE = 70.0TARGETS = [("Sources/Cra/Services/DevToolsToggle.swift", ["bash", "scripts/test-policies.sh"]),("Sources/Cra/UI/Windows/ExtensionLaunch.swift", ["bash", "scripts/test-policies.sh"]),- ("Sources/Cra/UI/ToolbarComposition.swift", ["bash", "scripts/test-policies.sh"]),("Sources/Cra/Services/SidebarIntegrity.swift", ["bash", "scripts/test-store.sh"]),("Sources/Cra/App/AppComposition.swift", ["bash", "scripts/test-store.sh"]),("Sources/Cra/App/FeatureFlags.swift", ["bash", "scripts/test-policies.sh"]),diff --git a/scripts/test-policies.sh b/scripts/test-policies.shindex 5b7ff25..aa9fb72 100755--- a/scripts/test-policies.sh+++ b/scripts/test-policies.sh@@ -1,11 +1,11 @@#!/bin/bash-# Decisions pulled out of the window controllers (toolbar buttons, extension clicks, DevTools toggle).+# Decisions pulled out of the window controllers (extension clicks, DevTools toggle, feature flags).set -euo pipefailcd "$(dirname "$0")/.."TEST_DIR="$(mktemp -d /tmp/cra-policy-tests.XXXXXX)"trap 'rm -rf "$TEST_DIR"' EXITxcrun swiftc -swift-version 5 -parse-as-library ${CRA_TEST_SWIFTC_FLAGS:-} \- Sources/Cra/UI/ToolbarComposition.swift Sources/Cra/UI/Windows/ExtensionLaunch.swift Sources/Cra/Services/DevToolsToggle.swift Sources/Cra/App/FeatureFlags.swift \+ Sources/Cra/UI/Windows/ExtensionLaunch.swift Sources/Cra/Services/DevToolsToggle.swift Sources/Cra/App/FeatureFlags.swift \Tests/PolicyTests.swift -o "$TEST_DIR/policy-tests""$TEST_DIR/policy-tests"[ -z "${CRA_TEST_KEEP:-}" ] || cp "$TEST_DIR/policy-tests" "$CRA_TEST_KEEP/"