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.
Extension badges like Arc, no tooltip on pinned buttons, Extensions menu shows the manifest icon (#106 follow-up) (#125)
Victor Kildahlb7a9a55d0ead
diff --git a/Packages/CraCore/Sources/CraCore/ExtensionActionState.swift b/Packages/CraCore/Sources/CraCore/ExtensionActionState.swiftindex ab741e2..b73c9fe 100644--- a/Packages/CraCore/Sources/CraCore/ExtensionActionState.swift+++ b/Packages/CraCore/Sources/CraCore/ExtensionActionState.swift@@ -10,22 +10,29 @@ public struct ExtensionActionState: Equatable, Sendable {public var badgeText = ""/// "#RRGGBBAA".public var badgeColor = ""+ /// "#RRGGBBAA" (chrome.action.setBadgeTextColor).+ public var badgeTextColor = ""- public init(icon: Data? = nil, title: String = "", badgeText: String = "", badgeColor: String = "") {+ public init(icon: Data? = nil, title: String = "", badgeText: String = "", badgeColor: String = "",+ badgeTextColor: String = "") {self.icon = iconself.title = titleself.badgeText = badgeTextself.badgeColor = badgeColor+ self.badgeTextColor = badgeTextColor}- public var isEmpty: Bool { icon == nil && title.isEmpty && badgeText.isEmpty && badgeColor.isEmpty }+ public var isEmpty: Bool {+ icon == nil && title.isEmpty && badgeText.isEmpty && badgeColor.isEmpty && badgeTextColor.isEmpty+ }/// Chrome's rule, value by value: what the extension set for the tab, else what it set for/// every tab.public func over(_ fallback: ExtensionActionState) -> ExtensionActionState {ExtensionActionState(icon: icon ?? fallback.icon, title: title.isEmpty ? fallback.title : title,badgeText: badgeText.isEmpty ? fallback.badgeText : badgeText,- badgeColor: badgeColor.isEmpty ? fallback.badgeColor : badgeColor)+ badgeColor: badgeColor.isEmpty ? fallback.badgeColor : badgeColor,+ badgeTextColor: badgeTextColor.isEmpty ? fallback.badgeTextColor : badgeTextColor)}}@@ -63,7 +70,8 @@ public struct ExtensionActionUpdate: Equatable, Sendable {self.init(extensionID: id, profile: profile, targetID: target,state: ExtensionActionState(icon: icon, title: p["title"] as? String ?? "",badgeText: p["badgeText"] as? String ?? "",- badgeColor: p["badgeColor"] as? String ?? ""))+ badgeColor: p["badgeColor"] as? String ?? "",+ badgeTextColor: p["badgeTextColor"] as? String ?? ""))}}diff --git a/Packages/CraCore/Sources/CraCore/ExtensionBadge.swift b/Packages/CraCore/Sources/CraCore/ExtensionBadge.swiftnew file mode 100644index 0000000..2fd0742--- /dev/null+++ b/Packages/CraCore/Sources/CraCore/ExtensionBadge.swift@@ -0,0 +1,80 @@+import CoreGraphics+import Foundation++/// An extension's toolbar badge (chrome.action.setBadgeText) as Arc draws it: Chromium's+/// IconWithBadgeImageSource at half size, its 28 pt icon area centred on the 16 pt icon. Arc 1.171,+/// measured 2 Nov 2026 for #106: "42" is an 8 × 7 pt badge 1 pt in from the icon's bottom right,+/// with a 0.5 pt ring cut out of the icon around it.+public struct ExtensionBadge: Equatable, Sendable {+ public struct RGBA: Equatable, Sendable {+ public var r, g, b, a: Double+ public init(r: Double, g: Double, b: Double, a: Double = 1) { (self.r, self.g, self.b, self.a) = (r, g, b, a) }++ /// "#RRGGBBAA" (the action's colours) or "#RRGGBB".+ public init?(hex: String) {+ var s = hex.trimmingCharacters(in: .whitespaces)+ if s.hasPrefix("#") { s.removeFirst() }+ guard s.count == 6 || s.count == 8, let v = UInt32(s, radix: 16) else { return nil }+ let rgba = s.count == 8 ? v : v << 8 | 0xff+ self.init(r: Double(rgba >> 24 & 0xff) / 255, g: Double(rgba >> 16 & 0xff) / 255,+ b: Double(rgba >> 8 & 0xff) / 255, a: Double(rgba & 0xff) / 255)+ }++ /// WCAG relative luminance (Chromium's color_utils::GetRelativeLuminance).+ var luminance: Double {+ func linear(_ c: Double) -> Double { c <= 0.04045 ? c / 12.92 : pow((c + 0.055) / 1.055, 2.4) }+ return 0.2126 * linear(r) + 0.7152 * linear(g) + 0.0722 * linear(b)+ }+ }++ /// Chromium measures and lays the badge out at full size, in this font (CONTEXT_BADGE: 9 pt bold).+ public static let measuringFontSize = 9.0+ /// What Arc draws: everything at half size.+ public static let scale = 0.5+ public static var fontSize: Double { measuringFontSize * scale }++ public let text: String+ public let background: RGBA+ public let textColor: RGBA+ /// In icon points, origin top left.+ public let frame: CGRect+ /// Cleared out of the icon under the badge.+ public let cutout: CGRect+ public let cornerRadius: Double+ public let cutoutCornerRadius: Double++ /// Nil without text. `textWidth` is the text's width in the measuring font. `defaultBackground`+ /// applies when the extension set no colour (or a transparent one).+ public init?(state: ExtensionActionState, iconSize: Double = 16, defaultBackground: RGBA,+ textWidth: (String) -> Double) {+ guard !state.badgeText.isEmpty else { return nil }+ text = state.badgeText+ // Chromium makes the background opaque so the text reads (crbug.com/40472744).+ if let c = RGBA(hex: state.badgeColor), c.a > 0 {+ background = RGBA(r: c.r, g: c.g, b: c.b)+ } else {+ background = defaultBackground+ }+ if let c = RGBA(hex: state.badgeTextColor), c.a > 0 {+ textColor = c+ } else {+ // color_utils::GetColorWithMaxContrast: white on dark, Google Grey 900 on light.+ textColor = background.luminance < 0.211692036 ? RGBA(r: 1, g: 1, b: 1) : RGBA(hex: "#202124")!+ }+ // IconWithBadgeImageSource::SetBadge, in Chromium's units.+ let area = 28, height = 14+ var width = Int(min(23, textWidth(text).rounded(.up))) + 2 * 2+ if width % 2 != area % 2 { width += 1 }+ width = max(height, width)+ let x = width >= 20 ? (area - width) / 2 : area - width+ let full = CGRect(x: x, y: area - height, width: width, height: height)+ let s = Self.scale, origin = (iconSize - Double(area) * s) / 2+ func place(_ r: CGRect) -> CGRect {+ CGRect(x: origin + r.minX * s, y: origin + r.minY * s, width: r.width * s, height: r.height * s)+ }+ frame = place(full)+ cutout = place(full.insetBy(dx: -1, dy: -1))+ cornerRadius = 4 * s+ cutoutCornerRadius = 3 * s+ }+}diff --git a/Packages/CraCore/Tests/CraCoreTests/ExtensionActionStateTests.swift b/Packages/CraCore/Tests/CraCoreTests/ExtensionActionStateTests.swiftindex 3d3beb3..01a0659 100644--- a/Packages/CraCore/Tests/CraCoreTests/ExtensionActionStateTests.swift+++ b/Packages/CraCore/Tests/CraCoreTests/ExtensionActionStateTests.swift@@ -18,12 +18,13 @@ struct ExtensionActionStateTests {let u = try #require(ExtensionActionUpdate(params: Self.params(["id": "abc", "profile": "Profile 1", "targetId": "T1","icon": "data:image/png;base64," + Self.png.base64EncodedString(),- "title": "Omega: auto", "badgeText": "3", "badgeColor": "#FF0000FF",+ "title": "Omega: auto", "badgeText": "3", "badgeColor": "#FF0000FF", "badgeTextColor": "#FFFFFFFF",])))#expect(u.extensionID == "abc")#expect(u.profile == "Profile 1")#expect(u.targetID == "T1")- #expect(u.state == ExtensionActionState(icon: Self.png, title: "Omega: auto", badgeText: "3", badgeColor: "#FF0000FF"))+ #expect(u.state == ExtensionActionState(icon: Self.png, title: "Omega: auto", badgeText: "3", badgeColor: "#FF0000FF",+ badgeTextColor: "#FFFFFFFF"))}@Test func everyTabEventHasNoTarget() throws {diff --git a/Packages/CraCore/Tests/CraCoreTests/ExtensionBadgeTests.swift b/Packages/CraCore/Tests/CraCoreTests/ExtensionBadgeTests.swiftnew file mode 100644index 0000000..47ae2bf--- /dev/null+++ b/Packages/CraCore/Tests/CraCoreTests/ExtensionBadgeTests.swift@@ -0,0 +1,55 @@+import CoreGraphics+import CraCore+import Testing++struct ExtensionBadgeTests {+ static let grey = ExtensionBadge.RGBA(r: 0.5, g: 0.5, b: 0.5)++ static func badge(_ text: String, color: String = "", textColor: String = "", width: Double) -> ExtensionBadge? {+ ExtensionBadge(state: ExtensionActionState(badgeText: text, badgeColor: color, badgeTextColor: textColor),+ defaultBackground: grey) { _ in width }+ }++ @Test func noTextNoBadge() {+ #expect(Self.badge("", color: "#FB8C00FF", width: 0) == nil)+ }++ @Test func fortyTwoMatchesArc() throws {+ // Arc 1.171: "42" on a 16 pt icon is 8 × 7 pt, 1 pt in from the icon's bottom right.+ let b = try #require(Self.badge("42", color: "#FB8C00FF", width: 10.6))+ #expect(b.frame == CGRect(x: 7, y: 8, width: 8, height: 7))+ #expect(b.cutout == CGRect(x: 6.5, y: 7.5, width: 9, height: 8))+ #expect(b.cornerRadius == 2)+ #expect(b.cutoutCornerRadius == 1.5)+ }++ @Test(arguments: [+ // Never narrower than tall.+ (3.0, CGRect(x: 8, y: 8, width: 7, height: 7)),+ // Odd widths are made even, like the 28 pt icon area.+ (11.0, CGRect(x: 7, y: 8, width: 8, height: 7)),+ // 20 and wider (in Chromium's units) is centred, not right-aligned.+ (16.0, CGRect(x: 3, y: 8, width: 10, height: 7)),+ // Text wider than 23 is clipped to it.+ (40.0, CGRect(x: 1, y: 8, width: 14, height: 7)),+ ])+ func widthAndAlignment(textWidth: Double, frame: CGRect) throws {+ #expect(try #require(Self.badge("x", width: textWidth)).frame == frame)+ }++ @Test func textContrastsWithTheBackground() throws {+ // Orange is light: Google Grey 900 text, as in Arc's capture.+ #expect(try #require(Self.badge("1", color: "#FB8C00FF", width: 5)).textColor == ExtensionBadge.RGBA(hex: "#202124"))+ #expect(try #require(Self.badge("1", color: "#1A73E8FF", width: 5)).textColor == ExtensionBadge.RGBA(r: 1, g: 1, b: 1))+ // chrome.action.setBadgeTextColor wins.+ #expect(try #require(Self.badge("1", color: "#FB8C00FF", textColor: "#FFFFFFFF", width: 5)).textColor+ == ExtensionBadge.RGBA(r: 1, g: 1, b: 1))+ }++ @Test func backgroundIsOpaqueOrTheDefault() throws {+ #expect(try #require(Self.badge("1", color: "#FF000080", width: 5)).background == ExtensionBadge.RGBA(r: 1, g: 0, b: 0))+ // Unset reaches Cra as transparent black.+ #expect(try #require(Self.badge("1", color: "#00000000", width: 5)).background == Self.grey)+ #expect(try #require(Self.badge("1", width: 5)).background == Self.grey)+ }+}diff --git a/Sources/Cra/Services/ExtensionStore.swift b/Sources/Cra/Services/ExtensionStore.swiftindex dd6a89b..ef28d6e 100644--- a/Sources/Cra/Services/ExtensionStore.swift+++ b/Sources/Cra/Services/ExtensionStore.swift@@ -350,6 +350,72 @@ final class ExtensionStore {return image}+ /// The badge the extension shows on `tab` (chrome.action.setBadgeText), laid out as Arc does.+ func badge(for e: Entry, profile: String, tab: UUID?) -> ExtensionBadge? {+ let font = Self.badgeFont(size: ExtensionBadge.measuringFontSize)+ return ExtensionBadge(state: actions.state(extensionID: e.extensionID, profile: profile, tab: tab),+ defaultBackground: Self.badgeDefaultBackground) { text in+ Double((text as NSString).size(withAttributes: [.font: font]).width)+ }+ }++ /// The badge's colour when the extension set none: Chromium's neutral container (kColorRefNeutral15+ /// dark, 94 light). Arc's dark one measures the same (1.171); light mode not seen in Arc.+ static var badgeDefaultBackground: ExtensionBadge.RGBA {+ let dark = NSApp.effectiveAppearance.bestMatch(from: [.darkAqua, .aqua]) == .darkAqua+ return ExtensionBadge.RGBA(hex: dark ? "#282828" : "#EFEDED")!+ }++ /// The badge's bold system font at SF's optical size 24, between its text and display designs:+ /// with it "7", "42" and "1234" take Arc's widths exactly (CoreText's own choice at 9 pt is wider,+ /// the display design narrower; measured 2 Nov 2026).+ static func badgeFont(size: Double) -> NSFont {+ let opticalSize = 0x6F70737A // 'opsz'+ let base = NSFont.systemFont(ofSize: size, weight: .bold)+ let descriptor = base.fontDescriptor.addingAttributes([+ NSFontDescriptor.AttributeName(rawValue: kCTFontVariationAttribute as String): [opticalSize: 24],+ ])+ return NSFont(descriptor: descriptor, size: size) ?? base+ }++ /// Recent badged icons, so a redraw sees the same image until icon, badge or ink change.+ @ObservationIgnored private var badgedIcons: [(icon: NSImage, badge: ExtensionBadge, tint: NSColor, image: NSImage)] = []++ /// `icon` with `badge` drawn into it the way Chromium does (IconWithBadgeImageSource): a ring+ /// cut out of the icon, then the badge. The buttons draw the result as is, so a template icon+ /// takes `tint` first and the badge keeps its own colours.+ func badged(_ icon: NSImage?, _ badge: ExtensionBadge?, tint: NSColor) -> NSImage? {+ guard let icon, let badge else { return icon }+ if let hit = badgedIcons.first(where: { $0.icon === icon && $0.badge == badge && $0.tint == tint }) { return hit.image }+ let side = 16.0+ let image = NSImage(size: NSSize(width: side, height: side), flipped: true) { _ in+ let fit = min(side / max(icon.size.width, 1), side / max(icon.size.height, 1))+ let w = icon.size.width * fit, h = icon.size.height * fit+ let box = NSRect(x: (side - w) / 2, y: (side - h) / 2, width: w, height: h)+ icon.draw(in: box, from: .zero, operation: .sourceOver, fraction: 1, respectFlipped: true, hints: nil)+ if icon.isTemplate {+ tint.setFill()+ box.fill(using: .sourceAtop)+ }+ NSGraphicsContext.current?.compositingOperation = .clear+ NSBezierPath(roundedRect: badge.cutout, xRadius: badge.cutoutCornerRadius, yRadius: badge.cutoutCornerRadius).fill()+ NSGraphicsContext.current?.compositingOperation = .sourceOver+ badge.background.color.setFill()+ NSBezierPath(roundedRect: badge.frame, xRadius: badge.cornerRadius, yRadius: badge.cornerRadius).fill()+ let font = Self.badgeFont(size: ExtensionBadge.fontSize)+ let centred = NSMutableParagraphStyle()+ centred.alignment = .center+ centred.lineBreakMode = .byClipping+ let line = font.ascender - font.descender+ (badge.text as NSString).draw(in: NSRect(x: badge.frame.minX, y: badge.frame.midY - line / 2, width: badge.frame.width, height: line),+ withAttributes: [.font: font, .foregroundColor: badge.textColor.color, .paragraphStyle: centred])+ return true+ }+ badgedIcons.append((icon, badge, tint, image))+ if badgedIcons.count > 32 { badgedIcons.removeFirst() }+ return image+ }+/// An icon as a one-ink template, the way Arc's own toolbar glyphs read. An icon drawn on a/// plate (one colour covering most of it: Bitwarden's blue square, Vercel's black disc) keeps/// what stands out from the plate, so Bitwarden becomes its shield. Without a plate, colour@@ -437,3 +503,7 @@ final class ExtensionStore {extension Notification.Name {static let craPinnedExtensionsChanged = Notification.Name("craPinnedExtensionsChanged")}++extension ExtensionBadge.RGBA {+ var color: NSColor { NSColor(srgbRed: r, green: g, blue: b, alpha: a) }+}diff --git a/Sources/Cra/UI/ExtensionsMenu.swift b/Sources/Cra/UI/ExtensionsMenu.swiftindex e5c5b67..207f47e 100644--- a/Sources/Cra/UI/ExtensionsMenu.swift+++ b/Sources/Cra/UI/ExtensionsMenu.swift@@ -22,13 +22,13 @@ final class ExtensionsMenu: NSObject, NSMenuDelegate, NSMenuItemValidation {let store = ExtensionStore.sharedstore.reload()let entries = app.main.extensionEntries.sorted { $0.name < $1.name }- // Each extension's icon as it is now on the focused page (chrome.action.setIcon).let profile = app.main.profileDirectoryName, tab = app.main.selectedTabIDfor e in entries {let item = NSMenuItem(title: e.name, action: #selector(runExtension(_:)), keyEquivalent: "")item.target = selfitem.representedObject = e.extensionID- item.image = Self.menuIcon(store.liveIcon(for: e, profile: profile, tab: tab))+ // Arc lists the manifest's action icon here, not the one the extension set (#106).+ item.image = Self.menuIcon(e.icon)menu.addItem(item)}if !entries.isEmpty { menu.addItem(.separator()) }@@ -48,7 +48,7 @@ final class ExtensionsMenu: NSObject, NSMenuDelegate, NSMenuItemValidation {let item = NSMenuItem(title: e.name, action: #selector(togglePin(_:)), keyEquivalent: "")item.target = selfitem.representedObject = e.extensionID- item.image = Self.menuIcon(store.liveIcon(for: e, profile: profile, tab: tab))+ item.image = Self.menuIcon(e.icon)item.state = store.isPinned(e.extensionID) ? .on : .offpinMenu.addItem(item)}diff --git a/Sources/Cra/UI/PaneToolbarView.swift b/Sources/Cra/UI/PaneToolbarView.swiftindex fc09f6c..66385be 100644--- a/Sources/Cra/UI/PaneToolbarView.swift+++ b/Sources/Cra/UI/PaneToolbarView.swift@@ -18,7 +18,7 @@ final class PaneToolbarView: NSView {private struct Model: Equatable {typealias Kind = ToolbarComposition.Kind- struct Ext: Equatable { let id: String; let name: String; let icon: NSImage? }+ struct Ext: Equatable { let id: String; let name: String; let icon: NSImage?; let badge: ExtensionBadge? }var kind = Kind.noTabvar inSplit = falsevar focusedPane = true@@ -150,7 +150,8 @@ final class PaneToolbarView: NSView {m.hasExtensions = !entries.isEmptym.pinned = extensions.pinnedIDs.compactMap { id inentries.first { $0.extensionID == id }.map {- Model.Ext(id: id, name: $0.name, icon: extensions.toolbarIcon(for: $0, profile: profile, tab: m.tabID))+ Model.Ext(id: id, name: $0.name, icon: extensions.toolbarIcon(for: $0, profile: profile, tab: m.tabID),+ badge: extensions.badge(for: $0, profile: profile, tab: m.tabID))}}// Arc's toolbar colour (ToolbarColor): the page's report, else the tab's last colour, else@@ -265,7 +266,9 @@ final class PaneToolbarView: NSView {case .pinnedExtension(let id):let e = m.pinned.first { $0.id == id }let b = button("ext:" + id) { ToolbarGlyphButton() }- b.configure(symbol: nil, image: e?.icon, help: e?.name ?? "", enabled: true, width: 34, iconSize: 18, tint: m.fgDim, hover: m.hover)+ // 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) }b.menuProvider = { ExtensionStore.shared.entries.first { $0.extensionID == id }.map(ExtensionsMenu.iconMenu) }return bdiff --git a/Sources/Cra/UI/Sidebar/List/SidebarView.swift b/Sources/Cra/UI/Sidebar/List/SidebarView.swiftindex bbecf91..12eefc8 100644--- a/Sources/Cra/UI/Sidebar/List/SidebarView.swift+++ b/Sources/Cra/UI/Sidebar/List/SidebarView.swift@@ -342,7 +342,10 @@ final class SidebarTopBarView: NSView {?? store.profileDirectoryName(space: store.focusedSpaceID(window: ui.windowID))let entries = ext.entries(inProfile: profile)let pinned = ext.pinnedIDs.compactMap { id in- entries.first { $0.extensionID == id }.map { (id, $0.name, ext.toolbarIcon(for: $0, profile: profile, tab: tab?.id)) }+ entries.first { $0.extensionID == id }.map {+ (id, $0.name, ext.badged(ext.toolbarIcon(for: $0, profile: profile, tab: tab?.id),+ ext.badge(for: $0, profile: profile, tab: tab?.id), tint: colors.textSecondary))+ }}pill.show(text: text, url: url, hasTab: tab != nil, colors: colors, active: active,pinned: pinned, hasExtensions: !entries.isEmpty)@@ -496,9 +499,10 @@ final class SidebarURLPill: NSView {accessories.forEach { $0.removeFromSuperview() }accessories = []guard showAccessories, hasTab, let m = model, let actions else { needsLayout = true; return }- for (id, name, icon) in m.pinned {+ for (id, _, icon) in m.pinned {let b = ToolbarGlyphButton()- b.configure(symbol: nil, image: icon, help: name, enabled: true, width: 28, iconSize: 16, tint: colors.textSecondary)+ // Arc's pinned extension buttons have no tooltip (#106).+ b.configure(symbol: nil, image: icon, help: "", enabled: true, width: 28, iconSize: 16, tint: colors.textSecondary)b.action = { actions.runExtension(id) }b.menuProvider = { ExtensionStore.shared.entries.first { $0.extensionID == id }.map(ExtensionsMenu.iconMenu) }accessories.append(b)diff --git a/Sources/Cra/UI/SiteControlCenter.swift b/Sources/Cra/UI/SiteControlCenter.swiftindex 88f91a0..faaf2fe 100644--- a/Sources/Cra/UI/SiteControlCenter.swift+++ b/Sources/Cra/UI/SiteControlCenter.swift@@ -94,9 +94,15 @@ final class SiteControlCenterView: NSView {build()}- /// The tiles' icons as the extensions set them now (chrome.action.setIcon).+ /// The tiles' icons as the extensions set them now, badge included (chrome.action.setIcon,+ /// setBadgeText; Arc's tiles show both).private func liveIcons() -> [String: NSImage?] {- Dictionary(uniqueKeysWithValues: orderedExtensions.map { ($0.extensionID, extensions.liveIcon(for: $0, profile: profile, tab: tab)) })+ Dictionary(uniqueKeysWithValues: orderedExtensions.map { ($0.extensionID, liveIcon($0)) })+ }++ private func liveIcon(_ e: ExtensionStore.Entry) -> NSImage? {+ extensions.badged(extensions.liveIcon(for: e, profile: profile, tab: tab), extensions.badge(for: e, profile: profile, tab: tab),+ tint: colors.secondary)}private func build() {@@ -121,7 +127,7 @@ final class SiteControlCenterView: NSView {let tile = SiteExtensionTile(entry: e, pinned: extensions.isPinned(e.extensionID), colors: colors,run: { [actions] in actions.runExtension(e.extensionID) },togglePin: { ExtensionStore.shared.setPinned(e.extensionID, !ExtensionStore.shared.isPinned(e.extensionID)) })- tile.show(icon: extensions.liveIcon(for: e, profile: profile, tab: tab))+ tile.show(icon: liveIcon(e))extensionTiles[e.extensionID] = tilereturn tile}diff --git a/docs/arc-reverse-engineering.md b/docs/arc-reverse-engineering.mdindex b2c2264..3f24c7e 100644--- a/docs/arc-reverse-engineering.md+++ b/docs/arc-reverse-engineering.md@@ -2298,3 +2298,24 @@ tap with a real Shift key held around them; the space read from each window's `sstep focuses the space on Cra's usual space-change spring (Dia's 0.4 s, slower than Arc's here), or slides theLibrary in or out like its button. On the Spaces page the cards take the wheel first (10 pt per line, as in Arc)and the wheel leaves the Library only at their end.++### Extension action icons, badges and tooltips (Arc 1.171, 2 Nov 2026, issue #106, offline Arc + probe)+- [O live] Offline Arc (fake home with the Storable*.json files minus both sync states, `--load-extension` with+ a probe, pinned through the fake profile's `extensions.pinned_extensions`). Probe: red top-level `icons`, blue+ `action.default_icon`, then `setIcon` (green disc), `setTitle` and `setBadgeText` on alarms.+- Icon: the pinned button and the Site Control Center tile show the action's `default_icon` (blue), not the+ top-level `icons`, and follow `setIcon` at once. The menu bar's Extensions menu keeps the manifest's action icon+ (blue) after `setIcon`. Drawn 16 pt (32 px) in the top bar.+- Tooltip: none on a pinned extension button after 8 s of hover (Back shows "Go back ⌘[" within 3 s), so+ `setTitle` shows nowhere there. The Site Control Center tile's tooltip is the extension's name.+- Badge: Chromium's IconWithBadgeImageSource at half size, its 28 pt icon area centred on the 16 pt icon. "7" is+ 7 × 7 pt and "42" 8 × 7 pt, right-aligned 1 pt in from the icon's bottom right. "1234" is 14 × 7 pt, centred+ (20+ in Chromium's units). A 0.5 pt ring is cut out of the icon around the badge. Text is white or Google+ Grey 900 by contrast unless `setBadgeTextColor` set one. A transparent `setBadgeTextColor` is refused and keeps+ the old colour. With no colour set, the badge is #282828 in dark mode (Chromium's neutral container; light mode+ not seen). The tile in the Site Control Center carries the same badge; the menu doesn't. Text widths match SF+ bold at optical size 22–26 (CoreText's own 9 pt instance makes "42" a pixel wider).+- Custom icons: Arc has none, so Cra's toolbar icon styles (#9) stay toolbar-only.+- Cra: `extensions-action-updates.patch` reports icon, title, badge text (or the declarativeNetRequest count), badge+ and text colour. `ExtensionBadge` (CraCore) lays the badge out; `ExtensionStore.badged` draws it into the icon.+ Captured side by side with the same probe, Cra matches Arc's five states to the pixel (text ±1 px antialiasing).diff --git a/scripts/cef-patches/extensions-action-updates.patch b/scripts/cef-patches/extensions-action-updates.patchindex f08ebe1..a695772 100644--- a/scripts/cef-patches/extensions-action-updates.patch+++ b/scripts/cef-patches/extensions-action-updates.patch@@ -51,7 +51,7 @@ diff --git a/chrome/browser/devtools/protocol/extensions_handler.cc b/chrome/bronamespace {-@@ -160,8 +172,185 @@+@@ -160,7 +172,194 @@return result;}@@ -142,7 +142,7 @@ diff --git a/chrome/browser/devtools/protocol/extensions_handler.cc b/chrome/bro+ action_watches_.clear();+ profile_manager_observation_.Reset();+}-+++// Observes `profile`'s actions and reports their tab-independent state.+void ExtensionsHandler::WatchActions(Profile* profile) {+ extensions::ExtensionActionDispatcher* dispatcher =@@ -206,21 +206,30 @@ diff --git a/chrome/browser/devtools/protocol/extensions_handler.cc b/chrome/bro+ : action.GetDeclarativeIcon(tab_id));+ const std::string title =+ !for_tab || action.HasTitle(tab_id) ? action.GetTitle(tab_id) : "";++ // A tab's badge is its own text, else the declarativeNetRequest action++ // count when the extension asked for it.+ const std::string badge_text =-+ !for_tab || action.HasBadgeText(tab_id)-+ ? action.GetExplicitlySetBadgeText(tab_id)++ !for_tab ? action.GetExplicitlySetBadgeText(tab_id)++ : action.HasBadgeText(tab_id) || action.HasDNRActionCount(tab_id)++ ? action.GetDisplayBadgeText(tab_id)+ : "";-+ std::string badge_color;-+ if (!for_tab || action.HasBadgeBackgroundColor(tab_id)) {-+ const SkColor color = action.GetBadgeBackgroundColor(tab_id);-+ badge_color = base::StringPrintf(-+ "#%02X%02X%02X%02X", SkColorGetR(color), SkColorGetG(color),-+ SkColorGetB(color), SkColorGetA(color));-+ }-+ const std::string state =-+ icon + "\n" + title + "\n" + badge_text + "\n" + badge_color;-+ const bool empty =-+ icon.empty() && title.empty() && badge_text.empty() && badge_color.empty();++ auto hex = [](SkColor color) {++ return base::StringPrintf("#%02X%02X%02X%02X", SkColorGetR(color),++ SkColorGetG(color), SkColorGetB(color),++ SkColorGetA(color));++ };++ const std::string badge_color =++ !for_tab || action.HasBadgeBackgroundColor(tab_id)++ ? hex(action.GetBadgeBackgroundColor(tab_id))++ : "";++ const std::string badge_text_color =++ !for_tab || action.HasBadgeTextColor(tab_id)++ ? hex(action.GetBadgeTextColor(tab_id))++ : "";++ const std::string state = icon + "\n" + title + "\n" + badge_text + "\n" +++ badge_color + "\n" + badge_text_color;++ const bool empty = icon.empty() && title.empty() && badge_text.empty() &&++ badge_color.empty() && badge_text_color.empty();+ auto it = reported_actions_.find(key);+ if (it == reported_actions_.end() ? (empty && for_tab) : it->second == state) {+ return;@@ -231,13 +240,13 @@ diff --git a/chrome/browser/devtools/protocol/extensions_handler.cc b/chrome/bro+ reported_actions_[key] = state;+ }+ frontend_->ActionUpdated(action.extension_id(), profile, icon, title,-+ badge_text, badge_color, std::move(target_id));++ badge_text, badge_color, badge_text_color,++ std::move(target_id));+}-++protocol::DispatchResponse ExtensionsHandler::TriggerAction(const std::string& extension_id,- const std::string& target_id) {-@@ -219,6 +408,9 @@+@@ -219,6 +418,9 @@: target_id_(target_id),allow_loading_extensions_(allow_loading_extensions) {protocol::Extensions::Dispatcher::wire(dispatcher, this);@@ -318,7 +327,7 @@ diff --git a/chrome/browser/devtools/protocol/extensions_handler.h b/chrome/browdiff --git a/third_party/blink/public/devtools_protocol/domains/Extensions.pdl b/third_party/blink/public/devtools_protocol/domains/Extensions.pdl--- a/third_party/blink/public/devtools_protocol/domains/Extensions.pdl+++ b/third_party/blink/public/devtools_protocol/domains/Extensions.pdl-@@ -22,6 +22,32 @@+@@ -22,6 +22,34 @@# A tab target ID to trigger the default extension action on.string targetId@@ -344,6 +353,8 @@ diff --git a/third_party/blink/public/devtools_protocol/domains/Extensions.pdl b+ string badgeText+ # Badge background as #RRGGBBAA.+ string badgeColor++ # Badge text colour (chrome.action.setBadgeTextColor) as #RRGGBBAA.++ string badgeTextColor+ # Page target of the tab the change is for; absent for the+ # tab-independent state.+ optional string targetIddiff --git a/scripts/fetch-cef.sh b/scripts/fetch-cef.shindex 79f3fd0..0529a7e 100755--- a/scripts/fetch-cef.sh+++ b/scripts/fetch-cef.sh@@ -13,7 +13,7 @@ CEF_VERSION="${CEF_VERSION:-156.0.15+gcf671c0+chromium-156.0.8078.80}"ARCH="${CEF_ARCH:-macosarm64}"NAME="cef_binary_${CEF_VERSION}_${ARCH}_minimal"# Bump the suffix (codecs2, …) when the build changes but CEF_VERSION does not.-CEF_RELEASE="${CEF_RELEASE:-cef-${CEF_VERSION%%+*}-codecs6}"+CEF_RELEASE="${CEF_RELEASE:-cef-${CEF_VERSION%%+*}-codecs7}"URL="${CEF_URL:-https://github.com/VictorKildahl/cra/releases/download/${CEF_RELEASE}/cef_binary_${ARCH}_minimal.tar.bz2}"mkdir -p vendor