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.
Space tooltip as in Arc: the space's profile, its ⌃N keys, and every tip in the space's own tones (#152) (#161)
Victor Kildahl79df5b06bf9e
diff --git a/Packages/CraCore/Sources/CraCore/KeyChord.swift b/Packages/CraCore/Sources/CraCore/KeyChord.swiftindex d509e7d..7357079 100644--- a/Packages/CraCore/Sources/CraCore/KeyChord.swift+++ b/Packages/CraCore/Sources/CraCore/KeyChord.swift@@ -40,20 +40,23 @@ public struct KeyChord: Codable, Hashable {public static let delete = "\u{8}"/// How menus and the command bar show it: ⌃⌥⇧⌘ in Apple's order, then the key.- public var display: String {- var s = ""- if keys.contains(.control) { s += "⌃" }- if keys.contains(.option) { s += "⌥" }- if keys.contains(.shift) { s += "⇧" }- if keys.contains(.command) { s += "⌘" }+ public var display: String { caps.joined() }++ /// One glyph per key, as a tooltip's key caps show them: ⌃3 is ["⌃", "3"].+ public var caps: [String] {+ var s: [String] = []+ if keys.contains(.control) { s.append("⌃") }+ if keys.contains(.option) { s.append("⌥") }+ if keys.contains(.shift) { s.append("⇧") }+ if keys.contains(.command) { s.append("⌘") }switch key {- case Self.tab: s += "⇥"- case Self.left: s += "←"- case Self.right: s += "→"- case Self.up: s += "↑"- case Self.down: s += "↓"- case Self.delete: s += "⌫"- default: s += key.uppercased()+ case Self.tab: s.append("⇥")+ case Self.left: s.append("←")+ case Self.right: s.append("→")+ case Self.up: s.append("↑")+ case Self.down: s.append("↓")+ case Self.delete: s.append("⌫")+ default: s.append(key.uppercased())}return s}diff --git a/Packages/CraCore/Sources/CraCore/ThemeTones.swift b/Packages/CraCore/Sources/CraCore/ThemeTones.swiftnew file mode 100644index 0000000..7bea670--- /dev/null+++ b/Packages/CraCore/Sources/CraCore/ThemeTones.swift@@ -0,0 +1,93 @@+import Foundation++/// An sRGB colour, 0...1 a channel.+public struct RGB: Equatable, Sendable {+ public var r, g, b: Double+ public init(_ r: Double, _ g: Double, _ b: Double) { (self.r, self.g, self.b) = (r, g, b) }++ /// `self` moved toward `other` by `t` (0...1), channel by channel.+ public func mixed(with other: RGB, _ t: Double) -> RGB {+ RGB(r + (other.r - r) * t, g + (other.g - g) * t, b + (other.b - b) * t)+ }++ public static let white = RGB(1, 1, 1)+ public static let black = RGB(0, 0, 0)+}++extension SpaceTheme {+ public static func hsb(_ r: Double, _ g: Double, _ b: Double) -> (h: Double, s: Double, v: Double) {+ let mx = max(r, g, b), mn = min(r, g, b), d = mx - mn+ var h = 0.0+ if d > 0.00001 {+ if mx == r { h = ((g - b) / d).truncatingRemainder(dividingBy: 6) }+ else if mx == g { h = (b - r) / d + 2 }+ else { h = (r - g) / d + 4 }+ h /= 6+ if h < 0 { h += 1 }+ }+ return (h, mx > 0 ? d / mx : 0, mx)+ }++ public static func rgb(h: Double, s: Double, v: Double) -> (Double, Double, Double) {+ let i = floor(h * 6), f = h * 6 - i+ let p = v * (1 - s), q = v * (1 - f * s), t = v * (1 - (1 - f) * s)+ switch Int(i) % 6 {+ case 0: return (v, t, p)+ case 1: return (q, v, p)+ case 2: return (p, v, t)+ case 3: return (p, q, v)+ case 4: return (t, p, v)+ default: return (v, p, q)+ }+ }++ /// Arc's primaryColorPalette.shadedDark, which Cra doesn't store: the theme colour's hue,+ /// strongly saturated, at 10 % luminance. Arc's own values all sit at 0.095–0.102 (Victor+ /// #6F5614 for #F8D558, JYSK #1F2AFF, and #B70021 and #24569F on the spaces in GitHub #152).+ /// Greys stay grey.+ public static func shadedDark(_ hex: String?) -> RGB {+ let c = HexColor.components(hex ?? "") ?? (0.5, 0.5, 0.5)+ let (h, s, _) = hsb(c.r, c.g, c.b)+ let ds = s < 0.05 ? 0 : 0.94+ func lin(_ x: Double) -> Double { x <= 0.04045 ? x / 12.92 : pow((x + 0.055) / 1.055, 2.4) }+ var lo = 0.0, hi = 1.0+ for _ in 0..<20 {+ let v = (lo + hi) / 2, o = rgb(h: h, s: ds, v: v)+ if 0.2126 * lin(o.0) + 0.7152 * lin(o.1) + 0.0722 * lin(o.2) < 0.1 { lo = v } else { hi = v }+ }+ let o = rgb(h: h, s: ds, v: lo)+ return RGB(o.0, o.1, o.2)+ }++ /// The colour Arc builds the space's palette from.+ public var paletteSource: String? { accent ?? colors.first }++ public var shadedDark: RGB { Self.shadedDark(paletteSource) }+}++/// Arc's hover tips (ArcTooltipConfiguration.colorPalette) are painted from the palette of the+/// space the window is in, whichever control or space icon they belong to. In Arc's data every+/// tone is shadedDark (= light.maxContrastColor) or a mix of it, the same on all four spaces+/// measured (Victor and JYSK in Arc's StorableSidebar.json, CloudDev and RM in GitHub #152):+/// - fill: dark.background, shadedDark at 30 %;+/// - title: dark.title, white with 15 % of shadedDark;+/// - badge: light.hover, white with 20 % of shadedDark: the profile pill and the key caps;+/// - ink: shadedDark itself: the profile's name, the avatar and the caps' glyphs.+/// The tip mixes two of Arc's schemes, which is why the pill reads as a light chip on a dark capsule.+public struct TooltipTones: Equatable, Sendable {+ public var fill: RGB+ public var title: RGB+ public var badge: RGB+ public var ink: RGB++ public init(fill: RGB, title: RGB, badge: RGB, ink: RGB) {+ (self.fill, self.title, self.badge, self.ink) = (fill, title, badge, ink)+ }++ public init(shadedDark ink: RGB) {+ self.init(fill: RGB.black.mixed(with: ink, 0.30), title: RGB.white.mixed(with: ink, 0.15),+ badge: RGB.white.mixed(with: ink, 0.20), ink: ink)+ }++ public init(theme: SpaceTheme) { self.init(shadedDark: theme.shadedDark) }+}diff --git a/Packages/CraCore/Tests/CraCoreTests/KeyChordTests.swift b/Packages/CraCore/Tests/CraCoreTests/KeyChordTests.swiftindex 0915b58..33fc3cc 100644--- a/Packages/CraCore/Tests/CraCoreTests/KeyChordTests.swift+++ b/Packages/CraCore/Tests/CraCoreTests/KeyChordTests.swift@@ -31,6 +31,13 @@ struct KeyChordTests {#expect(chord.display == shown)}+ /// A tooltip's key caps: one per modifier, then the key (Arc's space tip shows ⌃ and 3).+ @Test func capsSplitTheDisplay() {+ #expect(KeyChord(key: "3", modifiers: KeyChord.Modifiers.control.rawValue).caps == ["⌃", "3"])+ #expect(KeyChord(key: "l", modifiers: Self.command | KeyChord.Modifiers.shift.rawValue).caps == ["⇧", "⌘", "L"])+ #expect(KeyChord(key: KeyChord.left, modifiers: KeyChord.Modifiers([.control, .option]).rawValue).caps == ["⌃", "⌥", "←"])+ }+@Test func keysReadsTheStoredBits() {let chord = KeyChord(key: "s", modifiers: Self.command | KeyChord.Modifiers.shift.rawValue)#expect(chord.keys == KeyChord.Modifiers([.command, .shift]))diff --git a/Packages/CraCore/Tests/CraCoreTests/ThemeTonesTests.swift b/Packages/CraCore/Tests/CraCoreTests/ThemeTonesTests.swiftnew file mode 100644index 0000000..e9ff461--- /dev/null+++ b/Packages/CraCore/Tests/CraCoreTests/ThemeTonesTests.swift@@ -0,0 +1,65 @@+import CraCore+import Foundation+import Testing++/// Arc's tooltip tones against Arc's own palettes: Victor's space and Arc's default theme from+/// StorableSidebar.json (semanticColorPalette), and the two spaces measured in GitHub #152.+struct ThemeTonesTests {+ struct Space: Sendable, CustomTestStringConvertible {+ let name: String+ /// primaryColorPalette.shadedDark, 0...255 (Arc's extended sRGB can leave the range).+ let shadedDark: (Double, Double, Double)+ /// dark.background, dark.title, light.hover, light.maxContrastColor.+ let fill, title, badge, ink: (Double, Double, Double)+ var testDescription: String { name }+ }++ static let spaces = [+ Space(name: "Victor", shadedDark: (111.42, 85.74, -20.46),+ fill: (33.42, 25.72, -6.14), title: (233.46, 229.61, 213.68), badge: (226.29, 221.15, 199.91), ink: (111.42, 85.74, -20.46)),+ Space(name: "Arc default", shadedDark: (31.06, 42.36, 261.65),+ fill: (9.31, 12.70, 78.49), title: (221.42, 223.11, 255.99), badge: (210.27, 212.48, 256.08), ink: (31.06, 42.36, 261.65)),+ // GitHub #152's token table (CloudDev red, RM blue).+ Space(name: "CloudDev", shadedDark: (183, 0, 33), fill: (55, 0, 10), title: (244, 217, 222), badge: (241, 204, 211), ink: (183, 0, 33)),+ Space(name: "RM", shadedDark: (36, 86, 159), fill: (11, 26, 48), title: (222, 230, 241), badge: (211, 221, 236), ink: (36, 86, 159)),+ ]++ static func close(_ c: RGB, _ e: (Double, Double, Double), within: Double) -> Bool {+ abs(c.r * 255 - e.0) <= within && abs(c.g * 255 - e.1) <= within && abs(c.b * 255 - e.2) <= within+ }++ /// Every tone is a mix of shadedDark: what Arc stores lands within rounding.+ @Test(arguments: spaces)+ func tonesAreArcsPaletteSlots(space: Space) {+ let sd = RGB(space.shadedDark.0 / 255, space.shadedDark.1 / 255, space.shadedDark.2 / 255)+ let t = TooltipTones(shadedDark: sd)+ #expect(Self.close(t.fill, space.fill, within: 1))+ #expect(Self.close(t.title, space.title, within: 1))+ #expect(Self.close(t.badge, space.badge, within: 1))+ #expect(Self.close(t.ink, space.ink, within: 1))+ }++ /// Cra rebuilds shadedDark from the theme colour: Victor's #F8D558 lands next to Arc's+ /// (which runs below 0 in blue, so the screen shows 0), and so does its tip's fill.+ @Test func victorsThemeRebuildsArcsShade() {+ let theme = SpaceTheme(colors: ["#F8D558", "#A4F554"], intensity: 0.25, noise: 0.35, appearance: "light", vibrant: true, accent: "#F8D558")+ #expect(Self.close(theme.shadedDark, (111.42, 85.74, 0), within: 8))+ #expect(Self.close(TooltipTones(theme: theme).fill, (33.42, 25.72, 0), within: 3))+ }++ /// Arc's shadedDark sits at 10 % luminance in the theme's hue; greys stay grey.+ @Test(arguments: ["#F8D558", "#E63333", "#2861B3", "#3A8F5C", "#808080"])+ func shadedDarkKeepsTheHueAtTenPercentLuminance(hex: String) {+ let c = SpaceTheme.shadedDark(hex)+ func lin(_ x: Double) -> Double { x <= 0.04045 ? x / 12.92 : pow((x + 0.055) / 1.055, 2.4) }+ #expect(abs(0.2126 * lin(c.r) + 0.7152 * lin(c.g) + 0.0722 * lin(c.b) - 0.1) < 0.002)+ let src = HexColor.components(hex)!+ let a = SpaceTheme.hsb(src.r, src.g, src.b), b = SpaceTheme.hsb(c.r, c.g, c.b)+ if a.s < 0.05 { #expect(b.s < 0.001) } else { #expect(abs(a.h - b.h) < 0.002) }+ }++ @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 62bbe64..c949038 100644--- a/Sources/Cra/App/AppDelegate.swift+++ b/Sources/Cra/App/AppDelegate.swift@@ -52,6 +52,16 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSMenuItemValidation {SoftwareUpdater.shared.start(app: self)buildMenus()store.hasPage = { [unowned self] in self.runtime(for: $0) != nil }+ // A tip takes the tones of the space its browser window is in (the sidebar may be a+ // floating panel, a child of that window).+ ArcTooltipController.shared.tones = { [unowned self] window in+ var w: NSWindow? = window+ while let x = w {+ if let m = mainWindows.first(where: { $0.window === x }) { return TooltipTones(theme: m.focusedSpace.theme) }+ w = x.parent+ }+ return nil+ }NotificationCenter.default.addObserver(forName: .craKeyBindingsChanged, object: nil, queue: .main) { [weak self] _ inTask { @MainActor in self?.buildMenus() }}@@ -633,6 +643,11 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSMenuItemValidation {return}if dict["siteControls"] != nil { main.debugSiteControls(); return }+ // The n-th space icon's tip, without a pointer.+ if let n = dict["spaceTip"].flatMap({ Int($0) }), let content = main.window?.contentView {+ ArcTooltipController.shared.debugShowSpaceTip(n, in: content)+ return+ }if let t = dict["tooltip"], let content = main.window?.contentView {ArcTooltipController.shared.debugShow(t, in: content, at: NSRect(x: 380, y: content.bounds.height - 120, width: 28, height: 28))returndiff --git a/Sources/Cra/UI/ArcTooltip.swift b/Sources/Cra/UI/ArcTooltip.swiftindex 3085841..cb1ab7d 100644--- a/Sources/Cra/UI/ArcTooltip.swift+++ b/Sources/Cra/UI/ArcTooltip.swift@@ -31,6 +31,11 @@ final class ArcTooltipController {/// next one waits for the pointer to rest the full delay.var paused = false { didSet { if paused { dismiss() } } }+ /// The tones of the space a window is in (AppDelegate). Arc paints every tip in a browser+ /// window from that space's palette, whichever control or space icon it belongs to; windows+ /// without a space (Little Windows) get nil and Little Arc's navy.+ var tones: (NSWindow) -> TooltipTones? = { _ in nil }+private init() {clickMonitor = NSEvent.addLocalMonitorForEvents(matching: [.leftMouseDown, .rightMouseDown, .keyDown]) { [weak self] e inself?.dismiss()@@ -68,7 +73,7 @@ final class ArcTooltipController {// On mouse idle: every move restarts the wait.pendingFor = viewtimer?.invalidate()- timer = Timer.scheduledTimer(withTimeInterval: Self.idleDelay, repeats: false) { [weak self, weak view] _ in+ timer = Timer.scheduledTimer(withTimeInterval: view.idleDelay, repeats: false) { [weak self, weak view] _ inTask { @MainActor inguard let self, let view, self.pendingFor === view, !self.paused else { return }self.show(for: view)@@ -106,22 +111,46 @@ final class ArcTooltipController {show(for: a)}+ /// Testing: the tip of the n-th space icon (1-based, left to right) in the dock under `view`,+ /// or with 0 the Library button's.+ func debugShowSpaceTip(_ n: Int, in view: NSView) {+ func all<T: NSView>(_ v: NSView, _ t: T.Type) -> [T] { v.subviews.flatMap { ($0 as? T).map { [$0] } ?? all($0, t) } }+ if n == 0, let library = all(view, LibraryButtonView.self).first,+ let tip = all(library, ArcTooltipAnchorView.self).first(where: { $0.placement == .trailing }) {+ show(for: tip)+ return+ }+ let cells = all(view, SpaceCellView.self).filter { $0.window != nil }.sorted { $0.screenFrame.minX < $1.screenFrame.minX }+ guard n >= 1, n <= cells.count else { return }+ show(for: cells[n - 1])+ }+private func show(for view: any ArcTooltipTarget) {cancelPending()guard let window = view.hostWindow, !view.text.isEmpty else { return }removePanel()let p = LittleTooltipPanel()let option = NSEvent.modifierFlags.contains(.option) ? view.optionText : nil+ let colors = tones(window).map(ArcTooltipLabel.Colors.init) ?? .littlelet label = ArcTooltipLabel(text: option ?? view.text, keys: option == nil ? view.keys : [],- subtitle: option == nil ? view.subtitle : nil)+ subtitle: option == nil ? view.subtitle : nil, badge: option == nil ? view.badge : nil,+ colors: colors)let size = label.frame.sizep.contentView = label// Buttons: off the bottom-trailing corner of a 16 pt box around the glyph.// Rows: Arc's .cursor anchor, 13 pt right of and 14 pt below the pointer.+ // Space icons: centred, its bottom 19.75 pt above the icon's centre. The Library button:+ // 19.5 pt right of its centre, centred on it (Arc 1.171, 2x, 3 Nov 2026).let r = view.screenFramelet mouse = NSEvent.mouseLocation- let anchor = view.followsCursor ? NSPoint(x: mouse.x + 13, y: mouse.y - 14) : NSPoint(x: r.midX + 8, y: r.midY - 7)- var origin = NSPoint(x: anchor.x, y: anchor.y - size.height)+ var origin: NSPoint+ switch view.placement {+ case .above: origin = NSPoint(x: r.midX - size.width / 2, y: r.midY + 19.75)+ case .trailing: origin = NSPoint(x: r.midX + 19.5, y: r.midY - size.height / 2)+ case .corner:+ let anchor = view.followsCursor ? NSPoint(x: mouse.x + 13, y: mouse.y - 14) : NSPoint(x: r.midX + 8, y: r.midY - 7)+ origin = NSPoint(x: anchor.x, y: anchor.y - size.height)+ }if let screen = window.screen?.visibleFrame {origin.x = min(max(origin.x, screen.minX + 4), screen.maxX - size.width - 4)if origin.y < screen.minY + 4 { origin.y = (view.followsCursor ? mouse.y : r.midY) + 7 }@@ -168,6 +197,27 @@ protocol ArcTooltipTarget: AnyObject {var onShow: (() -> Void)? { get }var screenFrame: NSRect { get }var hostWindow: NSWindow? { get }+ /// A profile pill after the text (Arc's space icons).+ var badge: String? { get }+ /// How long the pointer rests before the tip shows.+ var idleDelay: TimeInterval { get }+ var placement: ArcTooltipPlacement { get }+}++extension ArcTooltipTarget {+ var badge: String? { nil }+ var idleDelay: TimeInterval { ArcTooltipController.idleDelay }+ var placement: ArcTooltipPlacement { .corner }+}++/// Where a control's tip goes (Arc: ArcTooltipConfiguration.preferredAnchor).+enum ArcTooltipPlacement {+ /// Off the bottom-trailing corner, or by the pointer for `followsCursor`.+ case corner+ /// Centred above (the dock's space icons).+ case above+ /// Beside it, centred (the dock's Library button).+ case trailing}/// Tracks the pointer over an AppKit control without taking its clicks.@@ -180,6 +230,7 @@ final class ArcTooltipAnchorView: NSView, ArcTooltipTarget {/// Shown instead while ⌥ is held (the split close button un-splits on ⌥-click).var optionText: String?var onShow: (() -> Void)?+ var placement = ArcTooltipPlacement.cornervar screenFrame: NSRect { window?.convertToScreen(convert(bounds, to: nil)) ?? .zero }var hostWindow: NSWindow? { window }@@ -294,16 +345,36 @@ extension View {}}-/// The tip itself: 28 pt navy capsule, 12 pt medium text, 18 pt key caps with a darker-/// bottom edge (Arc sidebar, 1x captures; Little Arc's larger tip is LittleTooltip).+/// The tip itself: 28 pt capsule in the window's space tones with a one-pixel ring of white at+/// 10 %, 12 pt medium text, then 19 pt key caps 6 pt on, 3 pt apart and 10 pt from the end: a face+/// inset 1 pt on the sides and top and 2.5 pt at the bottom, over the darker edge (Arc 1.171, 2x+/// captures of "View Library ⇧⌘L" and the space icons; Little Arc's larger tip is LittleTooltip).+/// A space icon's tip adds its profile in a pill between the text and the caps.final class ArcTooltipLabel: NSView {- static let capEdge = NSColor(red: 119 / 255, green: 122 / 255, blue: 211 / 255, alpha: 1)static let maxTextWidth: CGFloat = 280- static let fill = NSColor(LittlePalette.tooltip)- static let ink = NSColor(LittlePalette.tooltipText)- static let cap = NSColor(LittlePalette.tooltipCap)- static let capGlyph = NSColor(LittlePalette.tooltipCapGlyph)private static let font = NSFont.systemFont(ofSize: 12, weight: .medium)+ private static let cap: CGFloat = 19+ private static let capGap: CGFloat = 3+ private static let textToCaps: CGFloat = 6+ private static let capsTrailing: CGFloat = 10++ struct Colors {+ var fill, title, cap, capGlyph, capEdge: NSColor++ init(fill: NSColor, title: NSColor, cap: NSColor, capGlyph: NSColor, capEdge: NSColor) {+ (self.fill, self.title, self.cap, self.capGlyph, self.capEdge) = (fill, title, cap, capGlyph, capEdge)+ }++ init(_ t: TooltipTones) {+ self.init(fill: NSColor(t.fill), title: NSColor(t.title), cap: NSColor(t.badge), capGlyph: NSColor(t.ink),+ capEdge: NSColor(t.badge.mixed(with: t.ink, 0.5)))+ }++ /// Little Arc's tip, whatever space is focused.+ static let little = Colors(fill: NSColor(LittlePalette.tooltip), title: NSColor(LittlePalette.tooltipText),+ cap: NSColor(LittlePalette.tooltipCap), capGlyph: NSColor(LittlePalette.tooltipCapGlyph),+ capEdge: NSColor(red: 119 / 255, green: 122 / 255, blue: 211 / 255, alpha: 1))+ }static func width(of text: String) -> CGFloat {(text as NSString).size(withAttributes: [.font: font]).width@@ -312,19 +383,20 @@ final class ArcTooltipLabel: NSView {private let title = NSTextField(wrappingLabelWithString: "")private let sub = NSTextField.sidebarLabel(size: 11)private var caps: [NSView] = []+ private var pill: ProfilePill?private let multiline: Bool- init(text: String, keys: [String], subtitle: String? = nil) {+ init(text: String, keys: [String], subtitle: String? = nil, badge: String? = nil, colors: Colors = .little) {let wraps = Self.width(of: text) > Self.maxTextWidthmultiline = wraps || subtitle != nilsuper.init(frame: .zero)wantsLayer = true- // No border: unlike Little Arc's tip, the sidebar one goes straight from fill to backdrop.// Two or more lines get a rounded rectangle (Cra's choice; Arc's multi-line tip wasn't observed).- layer?.backgroundColor = Self.fill.cgColor+ layer?.backgroundColor = colors.fill.cgColor+ layer?.borderColor = colors.fill.blended(withFraction: 0.1, of: .white)?.cgColorlayer?.cornerRadius = multiline ? 10 : 14title.font = Self.font- title.textColor = Self.ink+ title.textColor = colors.titletitle.stringValue = text// Long titles wrap at a fixed width (ArcTooltipConfiguration.maxWidth; Arc's value is unknown).title.maximumNumberOfLines = wraps ? 3 : 1@@ -333,26 +405,31 @@ final class ArcTooltipLabel: NSView {addSubview(title)if let subtitle {sub.stringValue = subtitle- sub.textColor = Self.ink.withAlphaComponent(0.6)+ sub.textColor = colors.title.withAlphaComponent(0.6)addSubview(sub)}+ if let badge, !multiline {+ let p = ProfilePill(name: badge, fill: colors.cap, ink: colors.capGlyph)+ pill = p+ addSubview(p)+ }for k in keys {let edge = NSView()edge.wantsLayer = true- edge.layer?.backgroundColor = Self.capEdge.cgColor- edge.layer?.cornerRadius = 4+ edge.layer?.backgroundColor = colors.capEdge.cgColor+ edge.layer?.cornerRadius = 4.5edge.layer?.cornerCurve = .continuous- let face = NSView(frame: NSRect(x: 0, y: 2, width: 18, height: 16))+ let face = NSView(frame: NSRect(x: 1, y: 2.5, width: Self.cap - 2, height: Self.cap - 3.5))face.wantsLayer = true- face.layer?.backgroundColor = Self.cap.cgColor- face.layer?.cornerRadius = 4+ face.layer?.backgroundColor = colors.cap.cgColor+ face.layer?.cornerRadius = 3.5face.layer?.cornerCurve = .continuousedge.addSubview(face)let glyph = NSTextField.sidebarLabel(size: 10, weight: .bold)glyph.stringValue = k- glyph.textColor = Self.capGlyph+ glyph.textColor = colors.capGlyphglyph.alignment = .center- glyph.frame = NSRect(x: -SidebarText.inset, y: (16 - 13) / 2, width: 18 + 2 * SidebarText.inset, height: 13)+ glyph.frame = NSRect(x: -SidebarText.inset, y: (face.frame.height - 13) / 2, width: face.frame.width + 2 * SidebarText.inset, height: 13)face.addSubview(glyph)caps.append(edge)addSubview(edge)@@ -362,6 +439,11 @@ final class ArcTooltipLabel: NSView {required init?(coder: NSCoder) { fatalError() }+ override func viewDidMoveToWindow() {+ super.viewDidMoveToWindow()+ layer?.borderWidth = 1 / (window?.backingScaleFactor ?? 2)+ }+private var titleSize: NSSize {let w = multiline && title.maximumNumberOfLines > 1 ? Self.maxTextWidth : ceil(Self.width(of: title.stringValue))let h = title.cell?.cellSize(forBounds: NSRect(x: 0, y: 0, width: w + 2 * SidebarText.inset, height: 1000)).height ?? 15@@ -374,19 +456,26 @@ final class ArcTooltipLabel: NSView {let subSize = sub.superview == nil ? .zero : NSSize(width: ceil(sub.attributedStringValue.size().width), height: 14)let textW = max(ts.width, subSize.width)let textH = ts.height + (sub.superview == nil ? 0 : 1 + subSize.height)- let keysW = caps.isEmpty ? 0 : CGFloat(caps.count) * 18 + CGFloat(caps.count - 1) * 3- let contentH = max(textH, caps.isEmpty ? 0 : 18)+ let keysW = caps.isEmpty ? 0 : CGFloat(caps.count) * Self.cap + CGFloat(caps.count - 1) * Self.capGap+ let pillW = pill.map { ProfilePill.gap + $0.frame.width } ?? 0+ let contentH = max(textH, caps.isEmpty ? 0 : Self.cap)let h = max(28, contentH + (multiline ? 12 : 0))- let w = 10 + textW + (caps.isEmpty ? 0 : 7 + keysW) + (caps.isEmpty ? 10 : 8)+ let trailing: CGFloat = !caps.isEmpty ? Self.capsTrailing : pill != nil ? ProfilePill.trailing : 10+ let w = 10 + textW + pillW + (caps.isEmpty ? 0 : Self.textToCaps + keysW) + trailingsetFrameSize(NSSize(width: ceil(w), height: ceil(h)))// VStack(spacing: 1), centred.let top = (h + textH) / 2title.frame = NSRect(x: 10 - SidebarText.inset, y: top - ts.height, width: ts.width + 2 * SidebarText.inset, height: ts.height)sub.frame = NSRect(x: 10 - SidebarText.inset, y: top - ts.height - 1 - subSize.height, width: subSize.width + 2 * SidebarText.inset, height: subSize.height)- var x = 10 + textW + 7+ var x = 10 + textW+ if let pill {+ pill.setFrameOrigin(NSPoint(x: x + ProfilePill.gap, y: (h - pill.frame.height) / 2))+ x += pillW+ }+ x += Self.textToCapsfor c in caps {- c.frame = NSRect(x: x, y: (h - 18) / 2, width: 18, height: 18)- x += 18 + 3+ c.frame = NSRect(x: x, y: (h - Self.cap) / 2, width: Self.cap, height: Self.cap)+ x += Self.cap + Self.capGap}}@@ -402,3 +491,74 @@ final class ArcTooltipLabel: NSView {return (String(help[..<open.lowerBound]), caps)}}++/// The profile in a space icon's tip (Arc's tooltip on SidebarDock items): a pill of the caps'+/// colour holding a smiley avatar and the profile's name, both in the caps' glyph colour. The+/// smiley is the same for every profile: it marks the pill as a+/// profile, it isn't the profile's icon. Arc 1.171, 2x captures of "Personal [Default] ⌃1" and+/// "Work [Work] ⌃2" (3 Nov 2026): pill 22 pt tall, 6 pt from the space's name and from the caps,+/// avatar 6 pt in, then the name in 11 pt medium (a size smaller than the tip's text) 3 pt on and+/// 6 pt from the pill's end. A Default-profile space says "Default".+final class ProfilePill: NSView {+ static let height: CGFloat = 22+ static let avatar: CGFloat = 14+ /// From the space's name to the pill.+ static let gap: CGFloat = 6+ /// From the pill to the tip's end when no caps follow (the pill's inset from the capsule).+ static let trailing: CGFloat = 3+ private static let leading: CGFloat = 6+ private static let nameGap: CGFloat = 3+ private static let nameTrailing: CGFloat = 6+ private static let font = NSFont.systemFont(ofSize: 11, weight: .medium)++ init(name: String, fill: NSColor, ink: NSColor) {+ let font = Self.font+ let label = NSTextField.sidebarLabel(size: font.pointSize)+ label.font = font+ label.stringValue = name+ label.textColor = ink+ label.lineBreakMode = .byClipping+ let textW = ceil((name as NSString).size(withAttributes: [.font: font]).width)+ let w = Self.leading + Self.avatar + Self.nameGap + textW + Self.nameTrailing+ super.init(frame: NSRect(x: 0, y: 0, width: w, height: Self.height))+ wantsLayer = true+ layer?.backgroundColor = fill.cgColor+ layer?.cornerRadius = Self.height / 2+ let face = ProfileAvatarView(frame: NSRect(x: Self.leading, y: (Self.height - Self.avatar) / 2, width: Self.avatar, height: Self.avatar))+ face.ink = ink+ addSubview(face)+ let th = ceil(label.intrinsicContentSize.height)+ label.frame = NSRect(x: Self.leading + Self.avatar + Self.nameGap - SidebarText.inset, y: (Self.height - th) / 2,+ width: textW + 2 * SidebarText.inset, height: th)+ addSubview(label)+ }++ required init?(coder: NSCoder) { fatalError() }+}++/// Arc's 14 pt profile smiley (ARC_ProfilesUI "archie", a template image): a disc of the ink at+/// 10 %, two upright eyes and a smile at full ink. Redrawn from the image's 2x pixels.+final class ProfileAvatarView: NSView {+ var ink = NSColor.black { didSet { needsDisplay = true } }++ override var isFlipped: Bool { true }++ override func draw(_ dirtyRect: NSRect) {+ let k = bounds.width / 14+ ink.withAlphaComponent(26 / 255).setFill()+ NSBezierPath(ovalIn: bounds).fill()+ ink.setFill()+ for x in [4.5, 8.0] {+ NSBezierPath(roundedRect: NSRect(x: x * k, y: 3 * k, width: 1.5 * k, height: 4 * k), xRadius: 0.75 * k, yRadius: 0.75 * k).fill()+ }+ // Fitted to the image's alpha at 1x and 2x (RMS 1.7/255): a quadratic, control point (7, 11.2).+ let smile = NSBezierPath()+ smile.move(to: NSPoint(x: 4.1 * k, y: 9.6 * k))+ smile.curve(to: NSPoint(x: 9.9 * k, y: 9.6 * k), controlPoint1: NSPoint(x: 6.03 * k, y: 10.67 * k),+ controlPoint2: NSPoint(x: 7.97 * k, y: 10.67 * k))+ smile.lineWidth = 1.35 * k+ smile.lineCapStyle = .round+ ink.setStroke()+ smile.stroke()+ }+}diff --git a/Sources/Cra/UI/Sidebar/List/SidebarView.swift b/Sources/Cra/UI/Sidebar/List/SidebarView.swiftindex 99a789b..24d2e12 100644--- a/Sources/Cra/UI/Sidebar/List/SidebarView.swift+++ b/Sources/Cra/UI/Sidebar/List/SidebarView.swift@@ -719,7 +719,10 @@ final class SpaceDockView: NSView {guard reorder == nil else { return }let i = index(at: point(event))hovered = i.map { order[$0] }- for (j, id) in order.enumerated() { if let c = cells[id] { j == i ? ArcTooltipController.shared.mouseMoved(in: c) : ArcTooltipController.shared.mouseExited(c) } }+ // The new cell first: its tip replaces the shown one in place. Leaving the old cell first+ // faded that tip out while the new one popped in, two tips for 60 ms (#152).+ if let i, let c = cells[order[i]] { ArcTooltipController.shared.mouseMoved(in: c) }+ for (j, id) in order.enumerated() where j != i { if let c = cells[id] { ArcTooltipController.shared.mouseExited(c) } }}override func mouseEntered(with event: NSEvent) { mouseMoved(with: event) }override func mouseExited(with event: NSEvent) {@@ -927,8 +930,18 @@ final class SpaceCellView: NSView, ArcTooltipTarget {return true}+ // Arc's tip: the space's name, its profile in a pill, then Go to Space N's keys for the+ // space's place in the order (⌃1–⌃9, the user's own if rebound; none past the ninth).var text: String { title }- var keys: [String] { [] }+ var keys: [String] {+ guard let i = store.spaceOrder.firstIndex(of: spaceID), i < 9 else { return [] }+ return KeyBindingRegistry.shared.action("space\(i + 1)")?.primary?.caps ?? []+ }+ var badge: String? { store.profile(store.space(spaceID)?.profileID)?.name ?? "Default" }+ // Arc 1.171: ~0.62 s after the pointer stops (two 120 Hz recordings, 3 Nov 2026), sooner+ // than a control's tip. Cra's panel takes ~0.07 s more to reach the screen.+ var idleDelay: TimeInterval { 0.55 }+ var placement: ArcTooltipPlacement { .above }var followsCursor: Bool { false }var subtitle: String? { nil }var optionText: String? { nil }@@ -966,7 +979,8 @@ final class LibraryButtonView: NSView {glyph.imageScaling = .scaleNoneglyph.image = LibraryGlyph.image(dark: false)addSubview(glyph)- (tip.text, tip.keys) = ArcTooltipLabel.split("Library (⇧⌘L)")+ (tip.text, tip.keys) = ArcTooltipLabel.split("View Library (⇧⌘L)")+ tip.placement = .trailingaddSubview(tip)bin.wantsLayer = truebinImage.cornerRadius = 8diff --git a/Sources/Cra/UI/Sidebar/NowPlayingTray.swift b/Sources/Cra/UI/Sidebar/NowPlayingTray.swiftindex 6fca274..d47ef02 100644--- a/Sources/Cra/UI/Sidebar/NowPlayingTray.swift+++ b/Sources/Cra/UI/Sidebar/NowPlayingTray.swift@@ -47,8 +47,7 @@ enum NowPlayingMetrics {/// The card's colours for a theme colour and scheme. Arc derives them from the window palette/// (`backgroundExtra`, `PlaybackControlForeground`, `tintedLight`, `shadedDark`); Cra has no Arc-/// palette, so its shades are rebuilt from the theme colour: Arc's shadedDark is the theme's hue,-/// strongly saturated, at ~10 % luminance (#6F5600 for #F8D558, #1F2AFF for a deep blue).+/// palette, so its shades are rebuilt from the theme colour (SpaceTheme.shadedDark).struct NowPlayingColors {let isDark: Boollet fill: NSColor@@ -68,17 +67,10 @@ struct NowPlayingColors {let o = SpaceTheme.rgb(h: h, s: s, v: v)return NSColor(srgbRed: o.0, green: o.1, blue: o.2, alpha: 1)}- // shadedDark: the brightness at which the saturated hue reaches 10 % luminance.- func lin(_ x: Double) -> Double { x <= 0.04045 ? x / 12.92 : pow((x + 0.055) / 1.055, 2.4) }- let ds = grey ? 0 : 0.94- var lo = 0.0, hi = 1.0- for _ in 0..<20 {- let v = (lo + hi) / 2, o = SpaceTheme.rgb(h: h, s: ds, v: v)- if 0.2126 * lin(o.0) + 0.7152 * lin(o.1) + 0.0722 * lin(o.2) < 0.1 { lo = v } else { hi = v }- }+ let shaded = SpaceTheme.shadedDark(hex)isDark = darkif dark {- fill = color(ds, lo * 0.15)+ fill = NSColor(RGB.black.mixed(with: shaded, 0.15))foreground = NSColor.white.withAlphaComponent(0.66)title = NSColor.white.withAlphaComponent(0.81)hover = NSColor.white.withAlphaComponent(0.07)@@ -92,7 +84,7 @@ struct NowPlayingColors {title = NSColor.black.withAlphaComponent(0.85)hover = NSColor.black.withAlphaComponent(0.08)placeholder = NSColor.black.withAlphaComponent(0.15)- trackFilled = color(ds, lo)+ trackFilled = NSColor(shaded)trackEmpty = NSColor.black.withAlphaComponent(0.18)knob = .white}diff --git a/Sources/Cra/UI/Theme.swift b/Sources/Cra/UI/Theme.swiftindex 33ab551..8653261 100644--- a/Sources/Cra/UI/Theme.swift+++ b/Sources/Cra/UI/Theme.swift@@ -1,5 +1,4 @@import AppKit-import AppKitimport SwiftUIextension Color {@@ -14,6 +13,10 @@ extension NSColor {let c = HexColor.components(hex) ?? (0.5, 0.5, 0.5)self.init(srgbRed: c.r, green: c.g, blue: c.b, alpha: 1)}++ convenience init(_ c: RGB, alpha: CGFloat = 1) {+ self.init(srgbRed: c.r, green: c.g, blue: c.b, alpha: alpha)+ }}/// Colors derived from a space theme, the way Arc derives a@@ -81,32 +84,6 @@ extension SpaceTheme {/// Arc's toolbar band: the first theme colour pushed to a dark, fully/// saturated shade on light themes (Victor: #72601D) and a muted,/// slightly darker one on dark themes (JYSK: #0E0B16).- static func hsb(_ r: Double, _ g: Double, _ b: Double) -> (h: Double, s: Double, v: Double) {- let mx = max(r, g, b), mn = min(r, g, b), d = mx - mn- var h = 0.0- if d > 0.00001 {- if mx == r { h = ((g - b) / d).truncatingRemainder(dividingBy: 6) }- else if mx == g { h = (b - r) / d + 2 }- else { h = (r - g) / d + 4 }- h /= 6- if h < 0 { h += 1 }- }- return (h, mx > 0 ? d / mx : 0, mx)- }-- static func rgb(h: Double, s: Double, v: Double) -> (Double, Double, Double) {- let i = floor(h * 6), f = h * 6 - i- let p = v * (1 - s), q = v * (1 - f * s), t = v * (1 - (1 - f) * s)- switch Int(i) % 6 {- case 0: return (v, t, p)- case 1: return (q, v, p)- case 2: return (p, v, t)- case 3: return (p, q, v)- case 4: return (t, p, v)- default: return (v, p, q)- }- }-/// Light: 46% brightness, saturation +0.10 (Victor #F8D558 → #725F1D, Arc #72601D)./// Dark: 60% saturation, 80% brightness (JYSK #010220 → #0A0B19, Arc #0E0B16)./// Arc's light-theme ink: the first theme colour pushed to ~13% brightnessdiff --git a/docs/arc-reverse-engineering.md b/docs/arc-reverse-engineering.mdindex 649694d..3a3a1ac 100644--- a/docs/arc-reverse-engineering.md+++ b/docs/arc-reverse-engineering.md@@ -974,9 +974,10 @@ of the sidebar strip, pixel runs at x=500 px (2x), y = 160/700/1200/1700/2100..immediate, maxWidth, colorPalette }`, `TooltipController { presentationTimer, lastTooltipDismissedAtTime,… }`. [O live, 1x recordings] Shown 1.60 s after the pointer's last move (two cases, 30 fps); movingstraight from one tip to another control swaps at once; pops in with no fade, fades out in ~2 frames.- Navy capsule 28 pt, no visible border, 12 pt medium text (fill 96 for "Canteen plan", 110 for+ Navy capsule 28 pt (the default theme's tones and ring, see "Space dock tooltip"), 12 pt medium text (fill 96 for "Canteen plan", 110 for"Archive this tab", 198 for "Close and Keep Pinned ⌘W"), 10 pt side padding, 7 pt text→caps, caps- ~18 pt with a darker 2 px bottom band (~#777AD3), 3 pt apart. Button tips hang off the bottom-trailing+ ~18 pt with a darker 2 px bottom band (~#777AD3), 3 pt apart (re-measured at 2x on 3 Nov: 19 pt, 6 pt from+ the text, 10 pt to the end; the 1x widths left out the ring's pixel on each side). Button tips hang off the bottom-trailingcorner of a 16 pt box around the glyph (fill top-left = glyph centre + (8, 7)); row tips ("Canteen plan",the title) follow the cursor at +(13, 14).- Cra: `ArcTooltip.swift` (`.arcTooltip(help)`, one shared non-activating child panel, `(⌘W)` suffixes@@ -1755,7 +1756,8 @@ iconOffsetXAnimator, iconBounceAnimator, lazy g / vx0 / vy0 / projectileMotionDu- The tab list behind is hidden from 3 pt above the first row and fades back in linearly over the 170 pt above it.- Opens 0.2 s into the hover: rows fade in and rise 5 pt in ~0.12 s, bottom row first, ~25 ms apart; the fade comesin over ~0.18 s. Closes ~0.07 s after the pointer leaves: rows gone within ~0.05 s (bottom first), the fade- out over ~0.13 s. Arc's own "View Library ⇧⌘L" tooltip shows under the button meanwhile.+ out over ~0.13 s. Arc's own "View Library ⇧⌘L" tooltip shows meanwhile (beside the button, see "Space dock+ tooltip").- Cra: DownloadsTray / DownloadsTrayMask (sidebar), DownloadHistory (downloads.json). The mask must be a singleGeometryReader gradient: fixed-height layers in it raised the sidebar's minimum height and the window grew.@@ -1786,6 +1788,42 @@ strings "Opens the tab switcher, where you can cycle through recent tabs like Copixel. Thumbnails come from `Page.captureScreenshot` of the visible viewport (Chromium draws nothing for hiddenpages), taken 1 s after a tab shows or finishes loading and again for the current tab when the switcher opens.+### Space dock tooltip and tooltip tones (Arc 1.171, 3 Nov 2026, issue #152, offline Arc + Arc's data)++- [O data] Every tip in a browser window takes the palette of the space that window is in, whichever control or+ space icon it belongs to (`ArcTooltipConfiguration.colorPalette`). Hovering the Work icon while Personal is+ focused gives "Work" in Personal's yellow-brown; the Library tip changes with the space too. The four tones+ are slots of the semantic palette, and all four are mixes of `primaryColorPalette.shadedDark` (=+ `light.maxContrastColor`), checked on Victor's yellow theme and Arc's default theme (StorableSidebar.json),+ and on the issue's CloudDev and RM: fill = `dark.background` = shadedDark × 0.30; text = `dark.title` =+ white with 15 % of shadedDark; pill and key caps = `light.hover` = white with 20 %; profile name, avatar and+ cap glyphs = shadedDark. Cap edge = halfway between the cap face and the glyph colour (160/148/97 measured,+ 161/146/96 predicted). Ring: one device pixel of white at 10 % over the fill (on Arc's default theme exactly+ Little Arc's `#22255D` around `#0A0D4B`, which is that theme's fill: Little Arc uses the default palette).+ The navy measured on 27 Oct was the default theme's: the JYSK space has no windowTheme.+- [O live, 2x] Space icon tip: "<space> [☺ <profile>] ⌃N". A Default-profile space says "Default" (Arc's+ Local State calls that profile "Your Arc"); N is the space's place in the order. Capsule 28 pt, centred on the+ icon, its bottom 19.75 pt above the icon's centre. Name 12 pt medium, 10 pt in; profile pill 6 pt after it,+ 22 pt tall, 3 pt from the capsule's edges: avatar 14 pt, 6 pt in and centred, then the name in 11 pt medium+ (cap height 8 pt against the title's 9) 3 pt on, 6 pt to the pill's end (pill = 29 pt + the name). Caps 6 pt+ on, 19 × 19 pt, 3 pt apart, 10 pt to the capsule's end; each a face inset 1 pt on the sides and top and 2.5 pt+ at the bottom over the darker edge. "View Library ⇧⌘L" uses the same caps; its tip hangs 19.5 pt right of the+ button's centre, centred on it. Widths: Personal 191.5, Work 160, View Library 161.5 pt.+- [O live] Avatar: `ARC_ProfilesUI.bundle` "archie", a 14 pt template image: disc at alpha 26/255, two upright+ eyes and a smile at full alpha, drawn in the ink. The same glyph on every profile.+- [O live, 120 Hz] The dock tip shows ~0.6 s after the pointer stops (0.62–0.65 s in two recordings), sooner+ than a control's 1.6 s. Moving along the icons replaces it in place in one frame. The cell's hover fill fades+ in over ~0.2 s.+- Cra: `ArcTooltipController.tones` (AppDelegate: the window's focused space → CraCore `TooltipTones`, nil and+ Little Arc's navy elsewhere); `SpaceTheme.shadedDark` rebuilds Arc's shade from the theme colour (the hue at+ 10 % luminance, the rule Now Playing already used); `SpaceCellView` gives the name, the profile and+ `space<N>`'s keys; `ProfilePill` / `ProfileAvatarView` (the smiley redrawn as a path, fitted to the image's+ pixels at RMS 1.7/255). Compared side by side with Arc in both themes: widths within 1 px at 2x, tones+ within ~5/255 where Arc's shade stays in the sRGB gamut. The dock's timer is 0.55 s: with a real pointer Cra's+ tip reached the screen 0.69 s after the last move at 0.6. The dock enters the new cell before leaving the+ others, so the tip is replaced in place either way (it used to fade one out while the next popped in, moving+ right). Not done: the cell's hover-fill fade.+### Space dock: press area, fills and reordering (Arc 1.170, 27 Oct 2026, ObjC metadata + AX tree + captures)- [O static] `SidebarDock.SidebarDockView` holds an NSCollectionView (`SidebarDockCollectionViewLayout`, with