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.
Folders take Arc's palette tones: an opaque front on dark themes, the mid tone on the back panel
Victor6fc5885c123f
diff --git a/Packages/CraCore/Sources/CraCore/ThemeTones.swift b/Packages/CraCore/Sources/CraCore/ThemeTones.swiftindex 7bea670..6590be7 100644--- a/Packages/CraCore/Sources/CraCore/ThemeTones.swift+++ b/Packages/CraCore/Sources/CraCore/ThemeTones.swift@@ -59,10 +59,87 @@ extension SpaceTheme {return RGB(o.0, o.1, o.2)}+ /// OKLab lightness (0 black … 1 white).+ public static func oklabLightness(_ c: RGB) -> Double {+ func lin(_ x: Double) -> Double { x <= 0.04045 ? x / 12.92 : pow((x + 0.055) / 1.055, 2.4) }+ let (r, g, b) = (lin(c.r), lin(c.g), lin(c.b))+ let l = cbrt(0.4122214708 * r + 0.5363325363 * g + 0.0514459929 * b)+ let m = cbrt(0.2119034982 * r + 0.6806995451 * g + 0.1073969566 * b)+ let s = cbrt(0.0883024619 * r + 0.2817188376 * g + 0.6299787005 * b)+ return 0.2104542553 * l + 0.7936177850 * m - 0.0040720468 * s+ }++ /// Arc's primaryColorPalette.midTone, which Cra doesn't store: the theme colour while its OKLab+ /// lightness is within 0.68…0.794, else the most saturated colour of its hue at the nearer bound.+ /// Fits Arc's three palettes within 2/255 (Arc's light-blue #6CBAD9 is its own midTone, Victor+ /// #F8D558 → #E9B300, JYSK #010220 → #8389FF).+ public static func midTone(_ hex: String?) -> RGB {+ let base = paletteBase(hex)+ return oklabLightness(base) <= midToneCeiling ? base : edge(hex, lightness: midToneCeiling)+ }++ /// Arc's primaryColorPalette.tintedLight: the theme colour (raised to 0.68 like midTone) mixed+ /// toward white in sRGB until its OKLab lightness is 0.95. Arc's three: #6CBAD9 → #E4F2F8,+ /// #F8D558 → #FCEDBC, #010220 → #ECEDFF (within 2/255).+ public static func tintedLight(_ hex: String?) -> RGB {+ let base = paletteBase(hex)+ guard oklabLightness(base) < 0.95 else { return base }+ var lo = 0.0, hi = 1.0+ for _ in 0..<30 {+ let t = (lo + hi) / 2+ if oklabLightness(base.mixed(with: .white, t)) < 0.95 { lo = t } else { hi = t }+ }+ return base.mixed(with: .white, lo)+ }++ private static let midToneFloor = 0.68, midToneCeiling = 0.794++ private static func paletteBase(_ hex: String?) -> RGB {+ let c = HexColor.components(hex ?? "") ?? (0.5, 0.5, 0.5)+ let rgb = RGB(c.r, c.g, c.b)+ return oklabLightness(rgb) >= midToneFloor ? rgb : edge(hex, lightness: midToneFloor)+ }++ /// The colour of `hex`'s HSB hue on the sRGB gamut's edge (full saturation, or full brightness+ /// when that is too dark) with the given OKLab lightness. Greys stay grey.+ private static func edge(_ hex: String?, lightness target: Double) -> RGB {+ let c = HexColor.components(hex ?? "") ?? (0.5, 0.5, 0.5)+ let (h, s, _) = hsb(c.r, c.g, c.b)+ func at(_ s: Double, _ v: Double) -> RGB { let o = rgb(h: h, s: s, v: v); return RGB(o.0, o.1, o.2) }+ // Bisect x in 0...1 for f(x) = target, f rising.+ func solve(_ f: (Double) -> Double) -> Double {+ var lo = 0.0, hi = 1.0+ for _ in 0..<30 { let x = (lo + hi) / 2; if f(x) < target { lo = x } else { hi = x } }+ return (lo + hi) / 2+ }+ if s < 0.05 { return at(0, solve { oklabLightness(at(0, $0)) }) }+ if target <= oklabLightness(at(1, 1)) { return at(1, solve { oklabLightness(at(1, $0)) }) }+ return at(1 - solve { oklabLightness(at(1 - $0, 1)) }, 1)+ }+/// The colour Arc builds the space's palette from.public var paletteSource: String? { accent ?? colors.first }public var shadedDark: RGB { Self.shadedDark(paletteSource) }+ public var midTone: RGB { Self.midTone(paletteSource) }+ public var tintedLight: RGB { Self.tintedLight(paletteSource) }+}++/// Arc's folder glyph colours (FolderIcon's ColorSpec, measured 4 Nov 2026 on offline-Arc 2x+/// captures of a light-blue, a gold and the default dark theme). Every panel is opaque. The back+/// panel is always the palette's midTone. Light themes: front tintedLight, outline shadedDark.+/// Dark themes swap these: front shadedDark, outline tintedLight.+public struct FolderTones: Equatable, Sendable {+ public var outline: RGB+ public var front: RGB+ public var back: RGB++ public init(outline: RGB, front: RGB, back: RGB) { (self.outline, self.front, self.back) = (outline, front, back) }++ public init(themeColor hex: String?, dark: Bool) {+ let light = SpaceTheme.tintedLight(hex), shaded = SpaceTheme.shadedDark(hex)+ self.init(outline: dark ? light : shaded, front: dark ? shaded : light, back: SpaceTheme.midTone(hex))+ }}/// Arc's hover tips (ArcTooltipConfiguration.colorPalette) are painted from the palette of thediff --git a/Packages/CraCore/Tests/CraCoreTests/ThemeTonesTests.swift b/Packages/CraCore/Tests/CraCoreTests/ThemeTonesTests.swiftindex e9ff461..5c48624 100644--- a/Packages/CraCore/Tests/CraCoreTests/ThemeTonesTests.swift+++ b/Packages/CraCore/Tests/CraCoreTests/ThemeTonesTests.swift@@ -58,6 +58,42 @@ struct ThemeTonesTests {if a.s < 0.05 { #expect(b.s < 0.001) } else { #expect(abs(a.h - b.h) < 0.002) }}+ /// Arc's primaryColorPalette for three theme colours: Arc's default dark theme, Victor's gold and+ /// a light blue (an offline Arc's StorableSidebar.json, 4 Nov 2026).+ @Test(arguments: [+ ("#010220", (131.0, 137.0, 255.0), (236.0, 237.0, 255.0)),+ ("#F8D558", (233.0, 179.0, 0.0), (252.0, 237.0, 188.0)),+ ("#6CBAD9", (108.0, 186.0, 217.0), (228.0, 242.0, 248.0)),+ ])+ func midToneAndTintedLightMatchArcsPalette(hex: String, mid: (Double, Double, Double), tinted: (Double, Double, Double)) {+ #expect(Self.close(SpaceTheme.midTone(hex), mid, within: 2.5))+ #expect(Self.close(SpaceTheme.tintedLight(hex), tinted, within: 2.5))+ }++ /// Arc's folder glyph: midTone back on every theme; the front and outline trade tintedLight+ /// and shadedDark between light and dark themes. Dark fronts are opaque (an X report on+ /// 4 Nov: the open folder looked see-through on dark themes only).+ @Test func folderTonesSwapFrontAndOutlineOnDarkThemes() {+ let light = FolderTones(themeColor: "#6CBAD9", dark: false)+ let dark = FolderTones(themeColor: "#010220", dark: true)+ #expect(light.front == SpaceTheme.tintedLight("#6CBAD9"))+ #expect(light.outline == SpaceTheme.shadedDark("#6CBAD9"))+ #expect(dark.front == SpaceTheme.shadedDark("#010220"))+ #expect(dark.outline == SpaceTheme.tintedLight("#010220"))+ #expect(light.back == SpaceTheme.midTone("#6CBAD9") && dark.back == SpaceTheme.midTone("#010220"))+ // Arc's default dark theme, sampled off the glyph: front #1F2AFF, outline #ECEDFF. The+ // front is shadedDark's fit, which runs more saturated than Arc's on this blue (#0F17FF).+ #expect(Self.close(dark.front, (31, 42, 255), within: 20))+ #expect(Self.close(dark.outline, (236, 237, 255), within: 2))+ }++ @Test(arguments: ["#808080", "#202020", "#EEEEEE"])+ func greyTonesStayGrey(hex: String) {+ for c in [SpaceTheme.midTone(hex), SpaceTheme.tintedLight(hex)] {+ #expect(abs(c.r - c.g) < 0.001 && abs(c.g - c.b) < 0.001)+ }+ }+@Test func themeWithoutAccentUsesItsFirstColour() {let theme = SpaceTheme(colors: ["#2861B3", "#FFFFFF"], intensity: 1, noise: 0, appearance: "dark")#expect(theme.shadedDark == SpaceTheme.shadedDark("#2861B3"))diff --git a/Sources/Cra/App/AppDelegate.swift b/Sources/Cra/App/AppDelegate.swiftindex 1b3891b..f5345a0 100644--- a/Sources/Cra/App/AppDelegate.swift+++ b/Sources/Cra/App/AppDelegate.swift@@ -674,6 +674,10 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSMenuItemValidation {if let id = UUID(uuidString: f) { SpaceListView.debugFolderPreview(id, ui: main.sidebarUI) } else { FolderPreviewController.shared.close() }return}+ if let t = dict["expandFolder"] {+ for item in store.items.values where item.isFolder && item.title == t { store.setExpanded(item.id, true) }+ return+ }if dict["littlePopup"] != nil { littleWindows.first?.togglePopup(); return }if let c = dict["combine"], let content = main.window?.contentView {let tabs = store.children(of: store.focusedSpace.todayContainerID).filter { $0.tab != nil }diff --git a/Sources/Cra/UI/Sidebar/List/SidebarRowViews.swift b/Sources/Cra/UI/Sidebar/List/SidebarRowViews.swiftindex c7df875..d904639 100644--- a/Sources/Cra/UI/Sidebar/List/SidebarRowViews.swift+++ b/Sources/Cra/UI/Sidebar/List/SidebarRowViews.swift@@ -407,10 +407,10 @@ final class FolderGlyphView: NSView {private let frontPanel = CAShapeLayer()private let frontShade = CAGradientLayer()private let frontShadeMask = CAShapeLayer()- /// The back panel shows only outside the front one. Light themes fill both opaquely, so the- /// front hides the back's outline anyway; dark themes fill them with translucent white, and- /// without this the open folder showed the back's edges through the front (reported on X,- /// 4 Nov). The mask is the front panel's shape cut out of a larger square, turned with the+ /// The back panel shows only outside the front one. Theme folders are opaque (FolderTones), so+ /// the front hides the back's outline anyway; the White and Black icon styles fill with+ /// translucent tones, and without this an open folder showed the back's edges through the+ /// front. The mask is the front panel's shape cut out of a larger square, turned with the/// front's own transform so it moves with it.private let backHolder = CALayer()private let frontHole = CAShapeLayer()@@ -457,13 +457,12 @@ final class FolderGlyphView: NSView {override var isFlipped: Bool { true }override func hitTest(_ point: NSPoint) -> NSView? { nil }- func show(expanded: Bool, peeked: Bool = false, live: Bool, tint: NSColor, fillColor: NSColor, animated: Bool = false) {+ func show(expanded: Bool, peeked: Bool = false, live: Bool, tint: NSColor, fillColor: NSColor, backColor: NSColor? = nil, animated: Bool = false) {CATransaction.begin()CATransaction.setDisableActions(true)- for l in [back, frontPanel] {- l.fillColor = fillColor.cgColor- l.strokeColor = tint.cgColor- }+ back.fillColor = (backColor ?? fillColor).cgColor+ frontPanel.fillColor = fillColor.cgColor+ for l in [back, frontPanel] { l.strokeColor = tint.cgColor }mark.isHidden = !livemark.contentTintColor = tintdots.isHidden = !peeked || expanded || live@@ -1345,6 +1344,7 @@ struct FolderRowModel: Equatable {var live: Boolvar tint: NSColorvar fill: NSColor+ var back: NSColorvar tabCount: Intvar liveBusy: Bool/// The warning button's tip after a failed refresh.@@ -1376,7 +1376,7 @@ final class FolderRowView: SidebarRowView, NSTextFieldDelegate {// The same folder opening or closing turns its glyph; a row taking another folder doesn't.let toggled = model.map { $0.id == m.id && $0.expanded != m.expanded } ?? falsemodel = m- glyph.show(expanded: m.expanded, peeked: m.peeked, live: m.live, tint: m.tint, fillColor: m.fill, animated: toggled && window != nil)+ glyph.show(expanded: m.expanded, peeked: m.peeked, live: m.live, tint: m.tint, fillColor: m.fill, backColor: m.back, animated: toggled && window != nil)titleLabel.stringValue = m.titletitleLabel.textColor = colors.textPrimarysetAccessibilityLabel(m.title)diff --git a/Sources/Cra/UI/Sidebar/List/SpaceListView.swift b/Sources/Cra/UI/Sidebar/List/SpaceListView.swiftindex 1b6c702..d8eb432 100644--- a/Sources/Cra/UI/Sidebar/List/SpaceListView.swift+++ b/Sources/Cra/UI/Sidebar/List/SpaceListView.swift@@ -255,7 +255,7 @@ final class SpaceListView: NSView, NSDraggingSource {row.content = .folder(FolderRowModel(id: item.id, depth: depth, title: item.title ?? "Folder", renameText: item.title ?? "",editing: renaming == item.id, expanded: expanded, peeked: !peeked.isEmpty, live: item.isLiveFolder,- tint: NSColor(glyph.tint), fill: NSColor(glyph.fill),+ tint: NSColor(glyph.tint), fill: NSColor(glyph.fill), back: NSColor(glyph.back),tabCount: expanded ? 0 : store.tabs(under: item.id).count,liveBusy: refreshing.contains(item.id), liveError: item.liveFolder.flatMap(LiveFolderText.warning)?.help,liveSignInURL: item.liveFolder.flatMap(LiveFolderText.warning)?.signInURL,diff --git a/Sources/Cra/UI/Theme.swift b/Sources/Cra/UI/Theme.swiftindex b488a6b..b7f136d 100644--- a/Sources/Cra/UI/Theme.swift+++ b/Sources/Cra/UI/Theme.swift@@ -7,6 +7,8 @@ extension Color {let c = HexColor.components(hex) ?? (0.5, 0.5, 0.5)self.init(.sRGB, red: c.r, green: c.g, blue: c.b, opacity: 1)}++ init(_ c: RGB) { self.init(.sRGB, red: c.r, green: c.g, blue: c.b, opacity: 1) }}extension NSColor {@@ -34,9 +36,10 @@ struct SpacePalette {let pillFill: Colorlet toolbarFill: Colorlet folderTint: Color- /// Arc 1.170: folder glyphs are a cream fill (theme colour pulled 80% to white) with an outline in the- /// toolbar colour. Dark themes use a light outline over a faint white fill instead.+ /// Arc's folder glyph (FolderTones): an opaque front in tintedLight (light themes) or shadedDark+ /// (dark), the outline in the other one, and the back panel in midTone.let folderFill: Color+ let folderBack: Color/// Selected row in the command bar (Arc tints it with the space color).let commandHighlight: Colorlet noise: Double@@ -59,11 +62,11 @@ struct SpacePalette {}/// Outline and fill for a folder glyph; nil (Auto) is the theme's pair.- func folderColors(_ style: FolderIconStyle?) -> (tint: Color, fill: Color) {+ func folderColors(_ style: FolderIconStyle?) -> (tint: Color, fill: Color, back: Color) {switch style {- case nil: return (folderTint, folderFill)- case .white?: return (.white.opacity(0.92), .white.opacity(0.22))- case .black?: return (.black.opacity(0.8), .black.opacity(0.12))+ case nil: return (folderTint, folderFill, folderBack)+ case .white?: return (.white.opacity(0.92), .white.opacity(0.22), .white.opacity(0.22))+ case .black?: return (.black.opacity(0.8), .black.opacity(0.12), .black.opacity(0.12))}}}@@ -122,6 +125,7 @@ extension SpaceTheme {if stops.count == 1 { stops.append(SpaceTheme.mix(base[0], towardWhite: !dark, amount: pull + 0.15)) }let accent = SpaceTheme.mix(base[0], towardWhite: dark, amount: dark ? 0.25 : -0.0)+ let folder = FolderTones(themeColor: self.accent ?? base[0], dark: dark)return SpacePalette(isDark: dark,gradientColors: stops,@@ -135,9 +139,9 @@ extension SpaceTheme {pillFill: dark ? .white.opacity(0.08) : .black.opacity(0.045),// Arc: the toolbar is the first theme color at ~46% (dark) / lightened a touch (dark themes).toolbarFill: SpaceTheme.toolbarColor(self.accent ?? base[0], dark: dark),- // Dark themes: the toolbar shade vanished on the dark sidebar, so the outline is light ink there.- folderTint: dark ? .white.opacity(0.85) : SpaceTheme.toolbarColor(self.accent ?? base[0], dark: dark),- folderFill: dark ? .white.opacity(0.14) : SpaceTheme.mix(base[0], towardWhite: true, amount: 0.8),+ folderTint: Color(folder.outline),+ folderFill: Color(folder.front),+ folderBack: Color(folder.back),commandHighlight: dark ? accent.opacity(0.55) : SpaceTheme.mix(base[0], towardWhite: false, amount: 0.45).opacity(0.75),noise: noise,// Calibrated against Arc's rendering of a 0.25-intensity vibrant theme.diff --git a/Tests/Snapshots/pinned-folder.png b/Tests/Snapshots/pinned-folder.pngindex 788c546..91d6e62 100644Binary files a/Tests/Snapshots/pinned-folder.png and b/Tests/Snapshots/pinned-folder.png differdiff --git a/docs/arc-reverse-engineering.md b/docs/arc-reverse-engineering.mdindex 6fd4e54..facb4ab 100644--- a/docs/arc-reverse-engineering.md+++ b/docs/arc-reverse-engineering.md@@ -117,10 +117,18 @@ Legend: [O] observed in shipped artifact or data file, [I] inference, [U] unknowCATransaction with actions on, so Core Animation's implicit 0.25 s (recorded: 50% at ~95 ms, 90% at ~165 ms in Arc;~105 / ~175 ms in Cra). Colours come from outside (`ColorSpec`): on onegold theme the back was #E9B300, the front #FCEDBC and every edge black at ~26%; how the back colour follows the- theme was not worked out, so Cra keeps its measured outline over cream. Cra: FolderGlyphView.- Dark themes fill both panels with translucent white, so the open back panel's edges showed through the- front (reported on X, 4 Nov); Cra masks the back with the front panel's shape (`frontHole`, turned with the- front's transform), which is what the opaque light-theme fill does anyway.+ theme is worked out in the next entry. Cra: FolderGlyphView. Cra masks the back with the front panel's shape+ (`frontHole`, turned with the front's transform) for the translucent White and Black icon styles.+- [O] Folder glyph colours (4 Nov, offline Arc 1.171, 2x window captures in sRGB of the default dark theme, a+ dark gold and a light blue, folders opened over AX `AXDisclosing`): every panel is opaque and comes from the+ theme's primaryColorPalette. Back = midTone on every theme. Light themes: front tintedLight (#E4F2F8 exact),+ outline shadedDark (#00607D against #005F7D). Dark themes swap them: front shadedDark (#1F2AFF exact),+ outline tintedLight (#ECEDFF exact). The back reads a little darker under its 0 → 0.36 shade (midTone #8389FF+ shows #797FEF). Cra had a translucent white front on dark themes (white 0.14 over the sidebar; an X report on+ 4 Nov said the open folder looked see-through next to light mode) and cream on both light panels.+ Palette fits (`SpaceTheme.midTone` / `tintedLight`, Arc's three palettes within 2/255): midTone = the theme+ colour with its OKLab lightness clamped to 0.68…0.794, at the nearer bound the gamut edge of its HSB hue;+ tintedLight = that colour (floored at 0.68) mixed toward white in sRGB to OKLab 0.95. Cra: FolderTones.- [O] Sidebar glyphs (29 Oct, 1x and 2x captures, fitted pixel by pixel): the tab row's hover ✕ is two 2 ptround-capped strokes 4.25 pt out from a centre on a whole point, white 0.6 over the hover fill; at 1x it isperfectly symmetric (176/142/85), which no SF Symbol size reproduces (xmark 13.5 bold is closest at 2x but