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.
Arc parity: Previews for a Gmail favorite (its unread mail on hover)
Victor06366ad8b065
diff --git a/Packages/CraCore/Sources/CraCore/GmailPreview.swift b/Packages/CraCore/Sources/CraCore/GmailPreview.swiftnew file mode 100644index 0000000..6e5754b--- /dev/null+++ b/Packages/CraCore/Sources/CraCore/GmailPreview.swift@@ -0,0 +1,55 @@+import Foundation++/// Arc's Previews (Settings ▸ General ▸ Previews; Arc 1.172.1, hovered on Victor's Gmail favorite,+/// 7 Nov 2026): hovering a Gmail favorite shows its unread mail in a dark card under the tile+/// instead of the name tooltip, "No unread emails, you can exhale! 🍃" when there is none. Cra reads+/// Gmail's Atom feed of the inbox's unread mail with the space's own sign-in; nothing else is asked.+public enum GmailPreview {+ public struct Mail: Equatable, Sendable {+ public var from: String+ public var subject: String+ public init(from: String, subject: String) { (self.from, self.subject) = (from, subject) }+ }++ public struct Inbox: Equatable, Sendable {+ public var unread: Int+ public var mails: [Mail]+ public init(unread: Int, mails: [Mail]) { (self.unread, self.mails) = (unread, mails) }+ }++ /// Arc's line for an inbox with nothing unread.+ public static let emptyText = "No unread emails, you can exhale!"++ /// The feed for a Gmail favorite's account (u/0 unless the favorite names another).+ public static func feedURL(for favorite: String) -> String? {+ guard let u = URL(string: favorite), u.host == "mail.google.com" else { return nil }+ let parts = u.path.split(separator: "/")+ let account = parts.firstIndex(of: "u").flatMap { parts.indices.contains($0 + 1) ? String(parts[$0 + 1]) : nil } ?? "0"+ return "https://mail.google.com/mail/u/\(account)/feed/atom"+ }++ /// The feed's unread count and its newest mails (sender, subject), at most `limit`.+ public static func parse(_ xml: String, limit: Int = 5) -> Inbox? {+ guard xml.contains("<feed") else { return nil }+ let count = Int(first("fullcount", in: xml) ?? "") ?? 0+ var mails: [Mail] = []+ var rest = Substring(xml)+ while mails.count < limit, let start = rest.range(of: "<entry>"), let end = rest.range(of: "</entry>", range: start.upperBound..<rest.endIndex) {+ let entry = String(rest[start.upperBound..<end.lowerBound])+ let author = first("author", in: entry).flatMap { first("name", in: $0) } ?? ""+ mails.append(Mail(from: unescape(author), subject: unescape(first("title", in: entry) ?? "")))+ rest = rest[end.upperBound...]+ }+ return Inbox(unread: count, mails: mails)+ }++ private static func first(_ tag: String, in s: String) -> String? {+ guard let a = s.range(of: "<\(tag)>"), let b = s.range(of: "</\(tag)>", range: a.upperBound..<s.endIndex) else { return nil }+ return String(s[a.upperBound..<b.lowerBound])+ }++ private static func unescape(_ s: String) -> String {+ s.replacingOccurrences(of: "&", with: "&").replacingOccurrences(of: "<", with: "<").replacingOccurrences(of: ">", with: ">")+ .replacingOccurrences(of: """, with: "\"").replacingOccurrences(of: "'", with: "'")+ }+}diff --git a/Packages/CraCore/Sources/CraCore/SidebarModel.swift b/Packages/CraCore/Sources/CraCore/SidebarModel.swiftindex f6763bc..34a4d19 100644--- a/Packages/CraCore/Sources/CraCore/SidebarModel.swift+++ b/Packages/CraCore/Sources/CraCore/SidebarModel.swift@@ -534,6 +534,8 @@ public struct AppSettings: Codable, Equatable {public var pageTopWindowDrag: Bool = true/// Arc's Settings ▸ Advanced "Enable Boosts on websites you visit", on by default.public var boostsEnabled: Bool = true+ /// Arc's Settings ▸ General ▸ Previews: hovering a Gmail favorite shows its unread mail.+ public var favoritePreviews: Bool = true/// Arc's searchSuggestEnabled: the command bar asks the search engine for suggestions/// as you type and fills its rows with them.public var searchSuggestions: Bool = true@@ -749,6 +751,7 @@ extension AppSettings {allowAppleEventsJavaScript = try c.decodeIfPresent(Bool.self, forKey: .allowAppleEventsJavaScript) ?? falsepageTopWindowDrag = try c.decodeIfPresent(Bool.self, forKey: .pageTopWindowDrag) ?? trueboostsEnabled = try c.decodeIfPresent(Bool.self, forKey: .boostsEnabled) ?? true+ favoritePreviews = try c.decodeIfPresent(Bool.self, forKey: .favoritePreviews) ?? truesearchSuggestions = try c.decodeIfPresent(Bool.self, forKey: .searchSuggestions) ?? trueshowSpaceHeaderOnSingleSpace = try c.decodeIfPresent(Bool.self, forKey: .showSpaceHeaderOnSingleSpace) ?? truesharedFavorites = try c.decodeIfPresent(Bool.self, forKey: .sharedFavorites) ?? falsediff --git a/Packages/CraCore/Tests/CraCoreTests/GmailPreviewTests.swift b/Packages/CraCore/Tests/CraCoreTests/GmailPreviewTests.swiftnew file mode 100644index 0000000..614e5e6--- /dev/null+++ b/Packages/CraCore/Tests/CraCoreTests/GmailPreviewTests.swift@@ -0,0 +1,38 @@+import CraCore+import Testing++/// Arc's Previews for a Gmail favorite, from Gmail's Atom feed of unread mail.+struct GmailPreviewTests {+ static let feed = """+ <?xml version="1.0" encoding="UTF-8"?><feed version="0.3" xmlns="http://purl.org/atom/ns#"><title>Gmail - Inbox</title>+ <fullcount>2</fullcount><entry><title>Lunch & plans</title><summary>…</summary><author><name>Ada Lovelace</name><email>[email protected]</email></author></entry>+ <entry><title>Invoice #42</title><author><name>Billing</name></author></entry></feed>+ """++ @Test func readsTheUnreadMail() {+ let inbox = GmailPreview.parse(Self.feed)+ #expect(inbox?.unread == 2)+ #expect(inbox?.mails == [.init(from: "Ada Lovelace", subject: "Lunch & plans"), .init(from: "Billing", subject: "Invoice #42")])+ }++ @Test func anEmptyInboxIsArcsExhale() {+ let inbox = GmailPreview.parse(#"<feed><fullcount>0</fullcount></feed>"#)+ #expect(inbox == .init(unread: 0, mails: []))+ #expect(GmailPreview.emptyText == "No unread emails, you can exhale!")+ }++ @Test func aSignInPageIsNoFeed() {+ #expect(GmailPreview.parse("<html><body>Sign in</body></html>") == nil)+ }++ @Test(arguments: [("https://mail.google.com/mail/u/0/#inbox", "https://mail.google.com/mail/u/0/feed/atom"),+ ("https://mail.google.com/mail/u/2/", "https://mail.google.com/mail/u/2/feed/atom"),+ ("https://mail.google.com/", "https://mail.google.com/mail/u/0/feed/atom")])+ func theFeedOfTheFavoritesAccount(favorite: String, feed: String) {+ #expect(GmailPreview.feedURL(for: favorite) == feed)+ }++ @Test func otherSitesHaveNone() {+ #expect(GmailPreview.feedURL(for: "https://www.youtube.com/") == nil)+ }+}diff --git a/Sources/Cra/App/AppDelegate.swift b/Sources/Cra/App/AppDelegate.swiftindex 70039a3..4bcad47 100644--- a/Sources/Cra/App/AppDelegate.swift+++ b/Sources/Cra/App/AppDelegate.swift@@ -898,6 +898,8 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSMenuItemValidation {}return}+ // gmailPreview=<unread>: the Gmail favorite's preview card for a sample inbox.+ if let n = dict["gmailPreview"].flatMap(Int.init), let w = main.window { GmailPreviewCard.shared.demo(unread: n, in: w); return }// boostZap=1|0: Boost editor's Zap on or off for the open page.if let z = dict["boostZap"] { main.debugZap(z == "1"); return }// captureToEasel=1: the page's screenshot, then the capture menu's New Easel.diff --git a/Sources/Cra/UI/Settings/TabsPane.swift b/Sources/Cra/UI/Settings/TabsPane.swiftindex 6a1c457..2eb99f5 100644--- a/Sources/Cra/UI/Settings/TabsPane.swift+++ b/Sources/Cra/UI/Settings/TabsPane.swift@@ -14,6 +14,8 @@ struct TabsPane: View {SettingsCheckbox(title: "Show the New Tab button above tabs", isOn: $store.settings.newTabButtonAtTop)SettingsCheckbox(title: "Haptic feedback when reordering tabs", isOn: $store.settings.hapticFeedbackOnReorder)SettingsCheckbox(title: "Preview a folder’s tabs when hovering over it", isOn: $store.settings.folderPreviews)+ // Arc: Settings ▸ General ▸ Previews (Gmail's unread mail on its favorite).+ SettingsCheckbox(title: "Preview unread Gmail when hovering its favorite", isOn: $store.settings.favoritePreviews)SettingsCheckbox(title: "Show toolbar above the page", isOn: $store.settings.showToolbar)SettingsCheckbox(title: "Pages fill the window edge to edge", isOn: $store.settings.edgeToEdgeContent)SettingsCheckbox(title: "Enable Picture in Picture when you leave a video tab", isOn: $store.settings.autoPictureInPicture)diff --git a/Sources/Cra/UI/Sidebar/GmailPreviewCard.swift b/Sources/Cra/UI/Sidebar/GmailPreviewCard.swiftnew file mode 100644index 0000000..655efe6--- /dev/null+++ b/Sources/Cra/UI/Sidebar/GmailPreviewCard.swift@@ -0,0 +1,102 @@+import AppKit+import CraCEF+import SwiftUI++/// Arc's Previews card for a Gmail favorite (Arc 1.172.1, measured at 2x on Victor's Arc, 7 Nov 2026;+/// docs/screenshots/arc-gmail-preview-empty.png): 240 pt wide, #191817 with a 1 pt #3F3E3C edge and+/// 10 pt corners, its left edge 4 pt in from the tile's right edge and its top 3.5 pt above the tile's+/// bottom; the text centred, "No unread emails, you can exhale!" and a leaf when there is none.+@MainActor+final class GmailPreviewCard {+ static let shared = GmailPreviewCard()+ private var panel: NSPanel?+ private var pending: DispatchWorkItem?+ private weak var tile: NSView?++ /// Hovering a Gmail tile: after a moment, its unread mail beside it.+ func hover(_ tile: NSView, favoriteURL: String, profilePath: String?) {+ guard let feed = GmailPreview.feedURL(for: favoriteURL) else { return }+ self.tile = tile+ pending?.cancel()+ let work = DispatchWorkItem { [weak self, weak tile] in+ CraCEFRuntime.fetchURL(feed, headers: nil, profilePath: profilePath) { status, _, _, body in+ MainActor.assumeIsolated {+ guard let self, let tile, self.tile === tile, tile.window != nil else { return }+ // Signed out: Gmail answers with its sign-in page, and Arc shows nothing.+ guard status == 200, let inbox = GmailPreview.parse(body) else { return }+ self.show(inbox, by: tile)+ }+ }+ }+ pending = work+ DispatchQueue.main.asyncAfter(deadline: .now() + 0.45, execute: work)+ }++ func leave(_ tile: NSView) {+ guard self.tile === tile else { return }+ pending?.cancel()+ pending = nil+ self.tile = nil+ panel?.parent?.removeChildWindow(panel!)+ panel?.orderOut(nil)+ panel = nil+ }++ /// Testing without a Gmail sign-in (cra://debug?gmailPreview=<unread>): the card for a sample+ /// inbox, where it would hang under the fourth favorite tile of Arc's 264 pt sidebar.+ func demo(unread: Int, in window: NSWindow) {+ guard let content = window.contentView else { return }+ let anchor = NSView(frame: NSRect(x: 200, y: content.bounds.height - 44 - 47, width: 56, height: 47))+ content.addSubview(anchor)+ let mails = (0..<min(unread, 5)).map { GmailPreview.Mail(from: "Sender \($0 + 1)", subject: "Subject line \($0 + 1)") }+ show(GmailPreview.Inbox(unread: unread, mails: mails), by: anchor)+ anchor.removeFromSuperview()+ }++ private func show(_ inbox: GmailPreview.Inbox, by tile: NSView) {+ guard let window = tile.window else { return }+ panel?.orderOut(nil)+ let host = NSHostingView(rootView: GmailPreviewView(inbox: inbox))+ let size = host.fittingSize+ let p = NSPanel(contentRect: NSRect(origin: .zero, size: size), styleMask: [.borderless, .nonactivatingPanel], backing: .buffered, defer: false)+ p.backgroundColor = .clear+ p.isOpaque = false+ p.hasShadow = true+ p.ignoresMouseEvents = true+ p.level = .floating+ p.contentView = host+ let t = window.convertToScreen(tile.convert(tile.bounds, to: nil))+ p.setFrameOrigin(NSPoint(x: t.maxX - 4, y: t.minY + 3.5 - size.height))+ window.addChildWindow(p, ordered: .above)+ p.orderFront(nil)+ panel = p+ }+}++private struct GmailPreviewView: View {+ let inbox: GmailPreview.Inbox++ var body: some View {+ VStack(alignment: inbox.mails.isEmpty ? .center : .leading, spacing: inbox.mails.isEmpty ? -2 : 8) {+ if inbox.mails.isEmpty {+ // Arc: the line centred 23.5 pt down, the leaf 38.5 pt, the card 62.5 pt tall.+ Text(GmailPreview.emptyText).font(.system(size: 13)).multilineTextAlignment(.center)+ Text("🍃").font(.system(size: 14))+ } else {+ Text(inbox.unread == 1 ? "1 unread email" : "\(inbox.unread) unread emails")+ .font(.system(size: 11, weight: .semibold)).foregroundStyle(.white.opacity(0.5))+ ForEach(Array(inbox.mails.enumerated()), id: \.offset) { _, mail in+ VStack(alignment: .leading, spacing: 2) {+ Text(mail.from).font(.system(size: 13, weight: .semibold)).lineLimit(1)+ Text(mail.subject).font(.system(size: 12)).foregroundStyle(.white.opacity(0.6)).lineLimit(1)+ }+ }+ }+ }+ .foregroundStyle(.white.opacity(inbox.mails.isEmpty ? 0.78 : 0.88))+ .padding(.vertical, inbox.mails.isEmpty ? 15.5 : 12).padding(.horizontal, 16)+ .frame(width: 240, alignment: inbox.mails.isEmpty ? .center : .leading)+ .background(RoundedRectangle(cornerRadius: 10, style: .continuous).fill(Color(red: 25 / 255, green: 24 / 255, blue: 23 / 255)))+ .overlay(RoundedRectangle(cornerRadius: 10, style: .continuous).strokeBorder(Color(red: 63 / 255, green: 62 / 255, blue: 60 / 255), lineWidth: 1))+ }+}diff --git a/Sources/Cra/UI/Sidebar/List/SpaceColumnView.swift b/Sources/Cra/UI/Sidebar/List/SpaceColumnView.swiftindex 069a421..3d153f0 100644--- a/Sources/Cra/UI/Sidebar/List/SpaceColumnView.swift+++ b/Sources/Cra/UI/Sidebar/List/SpaceColumnView.swift@@ -1258,9 +1258,27 @@ final class FavoriteTileView: NSView, ArcTooltipTarget, NSDraggingSource {ArcTooltipController.shared.mouseMoved(in: self)}- override func mouseEntered(with event: NSEvent) { hovering = true; trackPointer(event) }+ override func mouseEntered(with event: NSEvent) {+ hovering = true+ trackPointer(event)+ if let url = previewURL, let store = grid?.store {+ GmailPreviewCard.shared.hover(self, favoriteURL: url, profilePath: store.profilePath(item: itemID))+ }+ }override func mouseMoved(with event: NSEvent) { trackPointer(event) }- override func mouseExited(with event: NSEvent) { hovering = false; hoveredCell = nil; ArcTooltipController.shared.mouseExited(self) }+ override func mouseExited(with event: NSEvent) {+ hovering = false+ hoveredCell = nil+ ArcTooltipController.shared.mouseExited(self)+ GmailPreviewCard.shared.leave(self)+ }++ /// A Gmail favorite with Previews on: Arc shows its unread mail instead of the name tooltip.+ private var previewURL: String? {+ guard let store = grid?.store, store.settings.favoritePreviews, let url = store.item(itemID)?.tab?.url,+ GmailPreview.feedURL(for: url) != nil else { return nil }+ return url+ }override func mouseDown(with event: NSEvent) { press = event }override func mouseDragged(with event: NSEvent) {@@ -1420,7 +1438,7 @@ final class FavoriteTileView: NSView, ArcTooltipTarget, NSDraggingSource {// ArcTooltipTarget: the title by the pointer.var text: String {- guard let m = model else { return "" }+ guard let m = model, previewURL == nil else { return "" }if let i = hoveredCell, m.cells.count > 1, m.cells.indices.contains(i) { return m.cells[i].title }return m.title}diff --git a/docs/arc-parity.md b/docs/arc-parity.mdindex 04d2274..18e9c5e 100644--- a/docs/arc-parity.md+++ b/docs/arc-parity.md@@ -34,8 +34,8 @@ or Arc-only service), per CONTRIBUTING.md.| Restore windows from previous session | Settings ▸ Advanced | done | Settings ▸ Advanced; off keeps the window in use last. || Block Cookie Banners | Settings ▸ General | done | Settings ▸ Privacy; hides the common consent managers' banners (CookieBanners), off by default as in Arc. || Archive Little Arcs after | Settings ▸ Links (6 hours default) | done | Settings ▸ Tabs ▸ Links; a Little Window left alone that long closes into the archive. |-| Previews (Gmail, Calendar on Favorites) | Settings ▸ General ▸ Previews Settings… | missing | Fetches through the browser session; nothing leaves the Mac. |-| Join Meeting ⌃⌘J | Shortcuts | missing | Needs calendar previews first. |+| Previews (Gmail, Calendar on Favorites) | Settings ▸ General ▸ Previews Settings… | partial | Gmail done: hovering a Gmail favorite shows its unread mail from Gmail's Atom feed (the space's own sign-in), Arc's card and empty state measured on Victor's Arc. Calendar not measured: Victor has no Calendar favorite. |+| Join Meeting ⌃⌘J | Shortcuts | missing | Needs Calendar previews, which couldn't be measured (no Calendar favorite in Victor's Arc). || Troubleshooting menu | Help ▸ Troubleshooting: Record Trace, Open Task Manager, Reveal Arc Data, Copy Arc Info | done | Export Diagnostics…, Open Task Manager (Chrome's), Reveal Cra Data, Copy Cra Info; Record Trace is Arc-internal. || Help menu | Getting Started, Release Notes, Contact the Team, Visit Help Center, Restore Data | partial | || Ad blocker upsell card, Sync, Account, Membership card, Share Arc, Sign Out, Send to Dia, Share Space | | *skip* | Account/cloud. |@@ -83,7 +83,7 @@ gains "New Profile".| Arc tab | Rows Cra lacks ||---|---|-| General | Previews Settings… (Block Cookie Banners done, under Privacy) |+| General | (Previews: Gmail done, Tabs pane; Block Cookie Banners done, under Privacy) || Profiles | "New documents" app (Arc's Notes/Easels); Privacy, Passwords, Credit Cards and Notifications done || Links | "Open Little Arc when clicking on links with ⌥⌘ held"; Archive Little Windows after done || Advanced | Shared Quotes (arc.net) (the rest done) |@@ -126,6 +126,7 @@ in this sweep (Essential Shortcuts window, Library pages).measured live in Arc (names, #RRGGBBAA format, no trace in the page's markup) and fitted to thesemantic palette Arc stores per space.- Edit ▸ Find ▸ Use Selection to Find and Jump to Selection (⌘J).+- Previews for a Gmail favorite: unread mail in Arc's card on hover (Settings ▸ Tabs).- Boosts: New Boost, the editor, Zap, CSS/JS code, Library ▸ Boosts, Window ▸ View Boosts…, the Advanced switch.- Window dragging from the top of webpages (Victor's choice, 7 Nov: on, as in Arc).- AppleScript, Arc's dictionary (Victor's choice, 7 Nov: like Arc, JavaScript off by default).@@ -160,4 +161,4 @@ in this sweep (Essential Shortcuts window, Library pages).## Left for later, and why-- Previews and Join Meeting: not started (they need a live Google session in Arc to measure).+- Calendar previews and Join Meeting: Arc shows them for a Google Calendar favorite, which Victor's Arc doesn't have.diff --git a/docs/screenshots/arc-gmail-preview-empty.png b/docs/screenshots/arc-gmail-preview-empty.pngnew file mode 100644index 0000000..834c608Binary files /dev/null and b/docs/screenshots/arc-gmail-preview-empty.png differ