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.
Toolbar keeps a tab's colour while its page comes back, fades to new reports like Arc (#84) (#98)
Victor Kildahl8309a42f9cb5
diff --git a/Packages/CraCore/Sources/CraCore/ToolbarColor.swift b/Packages/CraCore/Sources/CraCore/ToolbarColor.swiftnew file mode 100644index 0000000..17bac26--- /dev/null+++ b/Packages/CraCore/Sources/CraCore/ToolbarColor.swift@@ -0,0 +1,12 @@+import Foundation++/// A tab's toolbar colour (Arc 1.171, measured for GitHub #84): the colour its page reported,+/// else the one the tab showed last (TabData.themeColor), so a slept or restored tab keeps its+/// bar while the page loads again. Nil means Arc's white bar: a page Arc has never shown gets+/// it, over a black canvas in dark mode too, until the page finishes loading.+public enum ToolbarColor {+ /// "#RRGGBB", or nil for white. An empty, "none" or malformed value counts as unknown.+ public static func hex(reported: String?, remembered: String?) -> String? {+ [reported, remembered].lazy.compactMap { $0 }.first { HexColor.components($0) != nil }+ }+}diff --git a/Packages/CraCore/Tests/CraCoreTests/ToolbarColorTests.swift b/Packages/CraCore/Tests/CraCoreTests/ToolbarColorTests.swiftnew file mode 100644index 0000000..e7afe88--- /dev/null+++ b/Packages/CraCore/Tests/CraCoreTests/ToolbarColorTests.swift@@ -0,0 +1,21 @@+import CraCore+import Testing++struct ToolbarColorTests {+ @Test(arguments: [+ // The page's own report wins over what the tab remembers.+ ("#602040", "#205060", "#602040" as String?),+ // Not reported yet (no live page, or a page still loading): the remembered colour.+ ("", "#205060", "#205060"),+ (nil, "#205060", "#205060"),+ ("none", "#205060", "#205060"),+ // Nothing known: white, never the canvas.+ ("", nil, nil),+ (nil, nil, nil),+ (nil, "", nil),+ ("rgb(1, 2, 3)", "#12345", nil),+ ] as [(String?, String?, String?)])+ func reportedThenRememberedThenWhite(reported: String?, remembered: String?, bar: String?) {+ #expect(ToolbarColor.hex(reported: reported, remembered: remembered) == bar)+ }+}diff --git a/Sources/Cra/UI/PaneToolbarView.swift b/Sources/Cra/UI/PaneToolbarView.swiftindex f3743ce..81eabca 100644--- a/Sources/Cra/UI/PaneToolbarView.swift+++ b/Sources/Cra/UI/PaneToolbarView.swift@@ -146,11 +146,11 @@ final class PaneToolbarView: NSView {m.pinned = extensions.pinnedIDs.compactMap { id inentries.first { $0.extensionID == id }.map { Model.Ext(id: id, name: $0.name, icon: extensions.toolbarIcon(for: $0)) }}- // Arc's toolbar colour: the page's theme-color when it declares one, else white until the- // page reports one (MainWindowController.browserManagerDidUpdate uses the same rule).+ // Arc's toolbar colour (ToolbarColor): the page's report, else the tab's last colour, else+ // white (MainWindowController.toolbarColors uses the same rule for the card behind the bar).+ // The tab's own colour counts until its page is live: retarget builds this before it is.let onCard = m.kind == .normal || m.kind == .developer- let theme = nav.themeColor- let cardHex = theme != "none" && !theme.isEmpty && HexColor.components(theme) != nil ? theme : nil+ let cardHex = ToolbarColor.hex(reported: nav.themeColor, remembered: item?.tab?.themeColor)let light = (cardHex.flatMap(HexColor.luminance) ?? 1) > 0.6if onCard {m.fill = cardHex.map { NSColor(hex: $0) } ?? .white@@ -211,6 +211,17 @@ final class PaneToolbarView: NSView {private func apply(old: Model) {let m = model+ // A tab's bar fades to the colour its page reports, like Arc's (white to the page's colour over+ // 14-16 frames at 100 fps, ease in and out, measured for GitHub #84). A tab switch is instant.+ if m.kind == .normal, old.kind == .normal, m.tabID != nil, m.tabID == old.tabID, m.fill != old.fill, let layer {+ let fade = CABasicAnimation(keyPath: "backgroundColor")+ fade.fromValue = layer.presentation()?.backgroundColor ?? old.fill.cgColor+ fade.duration = 0.18+ fade.timingFunction = CAMediaTimingFunction(name: .easeInEaseOut)+ layer.add(fade, forKey: "barFade")+ } else {+ layer?.removeAnimation(forKey: "barFade")+ }layer?.backgroundColor = m.fill.cgColorstripes.isHidden = !m.stripes// The card under the bar takes its colour and height (Arc's developer bar is 40 pt, 32 otherwise).@@ -600,7 +611,7 @@ final class ToolbarURLButton: NSView, NSTextFieldDelegate {// SwiftUI's .transition(.opacity) on the status swap.let fade = CATransition()fade.type = .fade- fade.duration = 0.15+ fade.duration = 0.18content.layer?.add(fade, forKey: "fade")}if let status {diff --git a/Sources/Cra/UI/SplitView/PaneCardView.swift b/Sources/Cra/UI/SplitView/PaneCardView.swiftindex 2761d95..f757971 100644--- a/Sources/Cra/UI/SplitView/PaneCardView.swift+++ b/Sources/Cra/UI/SplitView/PaneCardView.swift@@ -46,7 +46,7 @@ final class PaneCardView: NSView {var pageColor: String? { didSet { refreshBackground() } }/// The canvas follows the appearance pages get (the app's), not the space theme's.private var appearanceObservation: NSKeyValueObservation?- /// The toolbar's colour (the page's theme-color, white until it reports one). A white backing+ /// The toolbar's colour (ToolbarColor: the page's, else the tab's last, else white). A white backing/// under a dark bar shows through the bar's anti-aliased left edge as a 1px light line.var toolbarColor: String? { didSet { refreshBackground() } }/// The no-tab stand-in: toolbar on the gradient, no card at all.diff --git a/Sources/Cra/UI/Windows/MainWindowController.swift b/Sources/Cra/UI/Windows/MainWindowController.swiftindex 80230ef..9083f2e 100644--- a/Sources/Cra/UI/Windows/MainWindowController.swift+++ b/Sources/Cra/UI/Windows/MainWindowController.swift@@ -352,6 +352,9 @@ final class MainWindowController: NSWindowController, NSWindowDelegate, BrowserMlet empty = Set(panes.filter { store.item($0)?.isEmptyTab == true })if shell.showToolbar != store.settings.showToolbar { shell.showToolbar = store.settings.showToolbar }if shell.edgeToEdge != store.settings.edgeToEdgeContent { shell.edgeToEdge = store.settings.edgeToEdgeContent }+ // Before setPanes: a pane whose page is not live yet gets its bar colour now, not white.+ let bars = toolbarColors(panes: panes)+ if bars != shell.toolbarColors { shell.toolbarColors = bars }shell.setPanes(panes, factors: factors, orientation: split?.split?.orientation ?? .horizontal, focused: selected, empty: empty, animated: true)// A page is on screen in one window at a time. Arc keeps the tab selected in every window// that has it open: the window in use holds the page, the others show a blurred snapshot@@ -473,12 +476,21 @@ final class MainWindowController: NSWindowController, NSWindowDelegate, BrowserMsyncSidebarUI()let colors = browsers.runtimes.compactMapValues { $0.backgroundColor.isEmpty ? nil : $0.backgroundColor }if colors != shell.pageColors { shell.pageColors = colors }- // Same rule as PaneToolbarView's bar colour.- let bars = browsers.runtimes.compactMapValues { rt in HexColor.components(rt.themeColor) != nil ? rt.themeColor : nil }+ let bars = toolbarColors(panes: shell.paneIDs)if bars != shell.toolbarColors { shell.toolbarColors = bars }if tabID == browsers.visibleTabID { window?.title = store.item(tabID)?.displayTitle ?? "Cra" }}+ /// Each live page's and each pane's bar colour, by PaneToolbarView's rule (ToolbarColor):+ /// a pane shows before browsers.show creates its page, so it falls back to what the tab remembers.+ private func toolbarColors(panes: [UUID]) -> [UUID: String] {+ var bars: [UUID: String] = [:]+ for id in Set(browsers.runtimes.keys).union(panes) {+ bars[id] = ToolbarColor.hex(reported: browsers.runtime(for: id)?.themeColor, remembered: store.item(id)?.tab?.themeColor)+ }+ return bars+ }+func browserManager(statusMessage: String) {overlay.status = statusMessageshell.statusVisible = !statusMessage.isEmptydiff --git a/docs/arc-reverse-engineering.md b/docs/arc-reverse-engineering.mdindex 8ac6c19..117276e 100644--- a/docs/arc-reverse-engineering.md+++ b/docs/arc-reverse-engineering.md@@ -1981,6 +1981,24 @@ canvas, an unstyled page (no background, no color-scheme) showed black text on b(4 s with a slow image). The page now reports its background on every frame while it is parsed(kLoadingBackgroundProbe; frames wait for render-blocking stylesheets), so it turns white with its first paint.+### The toolbar on a tab switch (Arc 1.171, 2 Nov 2026, issue #84, app-only recordings at 100 fps)++New tabs (⌘T + a file:// URL) in a fresh main window, macOS Dark, test pages with a 1 s busy-wait in `<head>`;+Cra's runs switch tabs with `cra://debug?selectTab=` in a CRA_TEST_BACKGROUND copy.++- [O] A page Arc has never shown: bar #FDFDFD over a #000000 page until the page paints, and still white about+ 16 frames after it. Then it cross-fades white → the page's colour in 14–16 frames, ease in and out. A page+ whose load is held open (an image that never answers) keeps the white bar after it has painted, theme-color+ or not.+- [O] The colour it settles on was the page's background: `html{background:#203040}` with+ `<meta name="theme-color" content="#602040">` gave a #203040 bar (#1C2E3E captured). Cra's probe still prefers+ theme-color (one test page; not changed in #84).+- [O] Little Arc's bar is the space's colour whatever the page (#1A0C20 in Victor's space on all four pages).+- Cra 0.1.25 retargeted the pane card before `browsers.show` created the tab's page, so a restored, slept or+ handed-over tab showed a white bar for 3–5 frames before its remembered colour (Arc: the remembered colour+ at once), on tab and space switches alike. Now the bar takes ToolbarColor (CraCore): the page's report,+ else TabData.themeColor, else white, and fades to a new report over 0.18 s (14–15 frames).+## Sidebar toggle and the command bar's leading glyph (Arc 1.171, 1 Nov 2026, issue #50, live captures at 2x)Victor's Arc (toolbar shown, full URLs on), window captures by id; Little Arc with keys posted to its pid for