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 Gmail and Live Calendar on Google Calendar favorites
Victor32caaf812b5b
diff --git a/Packages/CraCore/Sources/CraCore/CalendarPreview.swift b/Packages/CraCore/Sources/CraCore/CalendarPreview.swiftnew file mode 100644index 0000000..f565040--- /dev/null+++ b/Packages/CraCore/Sources/CraCore/CalendarPreview.swift@@ -0,0 +1,257 @@+import Foundation++/// Arc's Live Calendar for a Google Calendar favorite (Arc 1.172.1, Victor's signed-in Arc, 8 Nov+/// 2026): hovering the tile shows today as a timeline card, the tile counts down to the next+/// meeting, and a link to join it shows shortly before it starts. Arc reads the calendar with a+/// hidden page (its LiveCalendarClient); in 1.172.1 that page no longer reads and Arc says+/// "Failed to update", so Cra reads the events the way Google's own Calendar embed does: a hidden+/// `calendar.google.com/calendar/u/<n>/embed` page asks the Calendar API through the page's own+/// signed-in client (`gapi.client`) for the primary calendar. Nothing leaves the Mac but that+/// request to Google, made by the space's own sign-in.+public enum CalendarPreview {+ public struct Event: Equatable, Sendable {+ public var title: String+ public var start: Date+ public var end: Date+ public var allDay: Bool+ /// The video call to join (Meet, Zoom, Teams…), when the event has one.+ public var meetingURL: String?+ /// The event in Google Calendar.+ public var link: String?++ public init(title: String, start: Date, end: Date, allDay: Bool = false, meetingURL: String? = nil, link: String? = nil) {+ (self.title, self.start, self.end, self.allDay, self.meetingURL, self.link) = (title, start, end, allDay, meetingURL, link)+ }+ }++ public enum Fetch: Equatable, Sendable {+ case events([Event])+ /// The calendar answered that nobody is signed in (Arc's CalendarPreviewLoginView).+ case signedOut+ case failed+ }++ // MARK: The favorite++ public static func isCalendar(_ url: String) -> Bool {+ URL(string: url)?.host == "calendar.google.com"+ }++ /// The hidden page for the favorite's account (u/0 unless the favorite names another).+ public static func embedURL(for favorite: String) -> String? {+ guard let u = URL(string: favorite), u.host == "calendar.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://calendar.google.com/calendar/u/\(account)/embed"+ }++ /// Arc's + on the card: a new event in the favorite's account.+ public static func newEventURL(for favorite: String) -> String? {+ embedURL(for: favorite).map { $0.replacingOccurrences(of: "/embed", with: "/r/eventedit") }+ }++ // MARK: Reading++ /// Run in the hidden embed page (awaits a promise, returns a JSON string): today and tomorrow+ /// of the primary calendar, once the page's client is ready.+ public static func fetchScript(from: Date, to: Date) -> String {+ let iso = ISO8601DateFormatter()+ return """+ new Promise(done => {+ const started = Date.now();+ const ask = () => {+ const c = window.gapi && gapi.client && gapi.client.request;+ if (!c) { if (Date.now() - started > 15000) done(JSON.stringify({error: 'no client'})); else setTimeout(ask, 100); return; }+ gapi.client.request({path: 'https://clients6.google.com/calendar/v3/calendars/primary/events',+ params: {singleEvents: true, orderBy: 'startTime', maxResults: 100, timeMin: '\(iso.string(from: from))', timeMax: '\(iso.string(from: to))'}})+ .then(r => done(JSON.stringify({items: r.result.items || []})),+ e => done(JSON.stringify({error: 'status', status: (e && e.status) || 0})));+ };+ ask();+ })+ """+ }++ /// The script's answer. 401/403 mean the space isn't signed in to Google.+ public static func parse(_ json: String) -> Fetch {+ guard let object = try? JSONSerialization.jsonObject(with: Data(json.utf8)) as? [String: Any] else { return .failed }+ if object["error"] != nil {+ let status = object["status"] as? Int ?? 0+ return status == 401 || status == 403 ? .signedOut : .failed+ }+ guard let items = object["items"] as? [[String: Any]] else { return .failed }+ return .events(items.compactMap(event))+ }++ private static func event(_ item: [String: Any]) -> Event? {+ if item["status"] as? String == "cancelled" { return nil }+ // Declined invitations stay off the card, as in Google Calendar's own day view.+ if let people = item["attendees"] as? [[String: Any]],+ people.contains(where: { $0["self"] as? Bool == true && $0["responseStatus"] as? String == "declined" }) { return nil }+ guard let start = item["start"] as? [String: Any], let end = item["end"] as? [String: Any] else { return nil }+ let allDay = start["date"] != nil+ guard let s = time(start), let e = time(end) else { return nil }+ return Event(title: (item["summary"] as? String) ?? "(No title)", start: s, end: max(e, s), allDay: allDay,+ meetingURL: meetingURL(in: item), link: item["htmlLink"] as? String)+ }++ private static func time(_ field: [String: Any]) -> Date? {+ if let s = field["dateTime"] as? String { return ISO8601DateFormatter().date(from: s) }+ if let s = field["date"] as? String {+ let f = DateFormatter()+ f.locale = Locale(identifier: "en_US_POSIX")+ f.dateFormat = "yyyy-MM-dd"+ return f.date(from: s)+ }+ return nil+ }++ /// The call: the event's Meet link, its conference's video entry, else a known meeting+ /// address in its location or notes.+ static func meetingURL(in item: [String: Any]) -> String? {+ if let meet = item["hangoutLink"] as? String { return meet }+ if let points = (item["conferenceData"] as? [String: Any])?["entryPoints"] as? [[String: Any]],+ let video = points.first(where: { $0["entryPointType"] as? String == "video" })?["uri"] as? String { return video }+ for text in [item["location"], item["description"]].compactMap({ $0 as? String }) {+ if let url = meetingAddress(in: text) { return url }+ }+ return nil+ }++ private static let meetingHosts = ["meet.google.com", "zoom.us", "teams.microsoft.com", "teams.live.com", "whereby.com", "webex.com", "around.co"]++ static func meetingAddress(in text: String) -> String? {+ guard let detector = try? NSDataDetector(types: NSTextCheckingResult.CheckingType.link.rawValue) else { return nil }+ for match in detector.matches(in: text, range: NSRange(text.startIndex..., in: text)) {+ guard let url = match.url, let host = url.host?.lowercased(), url.scheme?.hasPrefix("http") == true else { continue }+ if meetingHosts.contains(where: { host == $0 || host.hasSuffix("." + $0) }) { return url.absoluteString }+ }+ return nil+ }++ // MARK: The card++ /// Arc's hour labels ("8 AM", "12 PM"), in English whatever the Mac's clock says.+ public static func hourLabel(_ hour: Int) -> String {+ let h = hour % 12 == 0 ? 12 : hour % 12+ return "\(h) \(hour % 24 < 12 ? "AM" : "PM")"+ }++ /// Where the card scrolls to: the current hour's line 13 pt under the top, as in Arc.+ public static func initialScroll(now: Date, calendar: Calendar = .current, hourHeight: CGFloat) -> CGFloat {+ let hour = calendar.component(.hour, from: now)+ return max(0, CGFloat(hour) * hourHeight - 13)+ }++ /// A timed event on the day's timeline: points from the top of midnight, its width share and+ /// column (Arc's CalendarLayout: events that overlap share the row side by side).+ public struct Placement: Equatable, Sendable {+ public var event: Event+ public var top: CGFloat+ public var height: CGFloat+ public var column: Int+ public var columns: Int+ }++ public static func layout(_ events: [Event], day: Date, calendar: Calendar = .current, hourHeight: CGFloat, minHeight: CGFloat = 18) -> [Placement] {+ let dayStart = calendar.startOfDay(for: day)+ guard let dayEnd = calendar.date(byAdding: .day, value: 1, to: dayStart) else { return [] }+ let timed = events.filter { !$0.allDay && $0.end > dayStart && $0.start < dayEnd }+ .sorted { ($0.start, $1.end) < ($1.start, $0.end) }+ func y(_ d: Date) -> CGFloat { CGFloat(min(max(d, dayStart), dayEnd).timeIntervalSince(dayStart) / 3600) * hourHeight }++ var out: [Placement] = []+ var group: [Placement] = []+ var groupEnd: CGFloat = -1+ var columnEnds: [CGFloat] = []+ func close() {+ let n = columnEnds.count+ out += group.map { var p = $0; p.columns = n; return p }+ group = []; columnEnds = []+ }+ for e in timed {+ let top = y(e.start), height = max(minHeight, y(e.end) - top)+ if top >= groupEnd { close() }+ let column = columnEnds.firstIndex { $0 <= top } ?? columnEnds.count+ if column == columnEnds.count { columnEnds.append(top + height) } else { columnEnds[column] = top + height }+ group.append(Placement(event: e, top: top, height: height, column: column, columns: 1))+ groupEnd = max(groupEnd, top + height)+ }+ close()+ return out+ }++ // MARK: Meetings++ /// Arc's Show Next Meeting Link (Never, On Start, Two Minutes Before (its default), Five, Ten).+ public enum LinkTiming: String, Codable, CaseIterable, Sendable {+ case never, onStart, twoMinutes, fiveMinutes, tenMinutes++ public var title: String {+ switch self {+ case .never: return "Never"+ case .onStart: return "On Start"+ case .twoMinutes: return "Two Minutes Before"+ case .fiveMinutes: return "Five Minutes Before"+ case .tenMinutes: return "Ten Minutes Before"+ }+ }++ public var lead: TimeInterval? {+ switch self {+ case .never: return nil+ case .onStart: return 0+ case .twoMinutes: return 120+ case .fiveMinutes: return 300+ case .tenMinutes: return 600+ }+ }+ }++ /// The meeting whose link shows now: the soonest call that starts within the lead time and+ /// hasn't ended, skipping ones the person dismissed.+ public static func meetingToJoin(in events: [Event], now: Date, timing: LinkTiming, dismissed: Set<String> = []) -> Event? {+ guard let lead = timing.lead else { return nil }+ return events.filter { $0.meetingURL != nil && !$0.allDay && !dismissed.contains(key($0)) }+ .filter { now >= $0.start.addingTimeInterval(-lead) && now < $0.end }+ .min { $0.start < $1.start }+ }++ /// For the Join command: the call that is on now, else the next one today.+ public static func nextCall(in events: [Event], now: Date, calendar: Calendar = .current) -> Event? {+ let calls = events.filter { $0.meetingURL != nil && !$0.allDay && $0.end > now }+ if let current = calls.filter({ $0.start <= now }).min(by: { $0.start < $1.start }) { return current }+ return calls.filter { calendar.isDate($0.start, inSameDayAs: now) }.min { $0.start < $1.start }+ }++ /// Show Time to Next Meeting: the tile's countdown to the next timed event within the hour+ /// ("12m", "Now" while it runs), nil when none is near.+ public static func timeToNext(in events: [Event], now: Date) -> String? {+ let timed = events.filter { !$0.allDay && $0.end > now }+ if timed.contains(where: { $0.start <= now && $0.meetingURL != nil }) { return "Now" }+ guard let next = timed.filter({ $0.start > now }).min(by: { $0.start < $1.start }) else { return nil }+ let minutes = Int(ceil(next.start.timeIntervalSince(now) / 60))+ return minutes <= 60 ? "\(minutes)m" : nil+ }++ /// Identifies an event for dismissal (title and start).+ public static func key(_ e: Event) -> String { "\(e.title)|\(e.start.timeIntervalSince1970)" }++ /// "9:10 – 9:30" in the Mac's own clock style.+ public static func timeRange(_ e: Event, locale: Locale = .current) -> String {+ let f = DateFormatter()+ f.locale = locale+ f.timeStyle = .short+ f.dateStyle = .none+ return "\(f.string(from: e.start)) – \(f.string(from: e.end))"+ }++ /// The gear menu's "Last fetch: …" line ("Just now", "5 min ago").+ public static func lastFetch(_ date: Date?, now: Date) -> String {+ guard let date else { return "Last fetch: Never" }+ let s = Int(now.timeIntervalSince(date))+ if s < 60 { return "Last fetch: Just now" }+ if s < 3600 { return "Last fetch: \(s / 60) min ago" }+ return "Last fetch: \(s / 3600) h ago"+ }+}diff --git a/Packages/CraCore/Sources/CraCore/FavoritePreviewMetrics.swift b/Packages/CraCore/Sources/CraCore/FavoritePreviewMetrics.swiftnew file mode 100644index 0000000..ad7e5e6--- /dev/null+++ b/Packages/CraCore/Sources/CraCore/FavoritePreviewMetrics.swift@@ -0,0 +1,37 @@+import Foundation++/// Arc's Previews card beside a favorite (Gmail, Calendar), measured at 2x and 60 fps on Victor's+/// signed-in Arc 1.172.1, 8 Nov 2026.+public enum FavoritePreviewMetrics {+ /// The card: 238 pt wide, at most 270 pt tall; longer content scrolls under it.+ public static let width: CGFloat = 238+ public static let maxHeight: CGFloat = 270+ /// A mail row: 84 pt with a 1 pt line under it, its text 11 pt in from the card's edges.+ public static let mailRowHeight: CGFloat = 84+ public static let inset: CGFloat = 11+ /// The pointer's row: a lighter rounded card, 3 pt in from the row.+ public static let hoverInset: CGFloat = 3+ /// The round buttons at the bottom right (Gmail's +; Calendar's gear and +).+ public static let buttonSize: CGFloat = 32+ public static let buttonInset: CGFloat = 9.5+ public static let buttonGap: CGFloat = 8+ /// The Calendar card: 255 pt tall, an hour 42 pt with its label at the top left, events from+ /// 42 pt in (where the now line starts) to 5 pt from the right edge.+ public static let calendarHeight: CGFloat = 255+ public static let hourHeight: CGFloat = 42+ public static let eventsLeft: CGFloat = 42+ public static let eventsRight: CGFloat = 5+}++/// How Arc's Previews card comes and goes (60 fps capture, 8 Nov 2026): it shows about 0.25 s after+/// the pointer lands on the tile (once the content is in hand), grows from about 80 % while it+/// fades in over some 4 frames, and when the pointer leaves both the tile and the card, it waits+/// about 0.15 s, then fades out, shrinking a little, over about 4 frames.+public enum FavoritePreviewMotion {+ public static let showDelay: TimeInterval = 0.25+ public static let openScale: CGFloat = 0.8+ public static let openDuration: TimeInterval = 0.075+ public static let closeDelay: TimeInterval = 0.15+ public static let closeScale: CGFloat = 0.95+ public static let closeDuration: TimeInterval = 0.07+}diff --git a/Packages/CraCore/Sources/CraCore/GmailPreview.swift b/Packages/CraCore/Sources/CraCore/GmailPreview.swiftindex 6e5754b..00a65b6 100644--- a/Packages/CraCore/Sources/CraCore/GmailPreview.swift+++ b/Packages/CraCore/Sources/CraCore/GmailPreview.swift@@ -8,7 +8,14 @@ public enum GmailPreview {public struct Mail: Equatable, Sendable {public var from: Stringpublic var subject: String- public init(from: String, subject: String) { (self.from, self.subject) = (from, subject) }+ /// The feed's opening lines of the mail, under the subject in Arc's card.+ public var snippet: String+ public var received: Date?+ /// The mail in Gmail (the feed's alternate link).+ public var link: String?+ public init(from: String, subject: String, snippet: String = "", received: Date? = nil, link: String? = nil) {+ (self.from, self.subject, self.snippet, self.received, self.link) = (from, subject, snippet, received, link)+ }}public struct Inbox: Equatable, Sendable {@@ -28,8 +35,9 @@ public enum GmailPreview {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? {+ /// The feed's unread count and its newest mails, at most `limit` (the feed holds 20; Arc's card+ /// scrolls through them).+ public static func parse(_ xml: String, limit: Int = 20) -> Inbox? {guard xml.contains("<feed") else { return nil }let count = Int(first("fullcount", in: xml) ?? "") ?? 0var mails: [Mail] = []@@ -37,12 +45,46 @@ public enum GmailPreview {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) ?? "")))+ mails.append(Mail(from: unescape(author), subject: unescape(first("title", in: entry) ?? ""),+ snippet: unescape(first("summary", in: entry) ?? ""),+ received: (first("issued", in: entry) ?? first("modified", in: entry)).flatMap(date),+ link: href(in: entry).map(unescape)))rest = rest[end.upperBound...]}return Inbox(unread: count, mails: mails)}+ /// Arc's age of a mail in the card: "50s", "2m", "3h", then days.+ public static func age(of date: Date, now: Date) -> String {+ let s = max(0, Int(now.timeIntervalSince(date)))+ switch s {+ case ..<60: return "\(s)s"+ case ..<3600: return "\(s / 60)m"+ case ..<86400: return "\(s / 3600)h"+ default: return "\(s / 86400)d"+ }+ }++ /// Arc's + on the card: a new mail in the favorite's account.+ public static func composeURL(for favorite: String) -> String? {+ guard let feed = feedURL(for: favorite) else { return nil }+ return feed.replacingOccurrences(of: "/feed/atom", with: "/#inbox?compose=new")+ }++ private static func date(_ s: String) -> Date? {+ let f = ISO8601DateFormatter()+ if let d = f.date(from: s) { return d }+ f.formatOptions = [.withInternetDateTime, .withFractionalSeconds]+ return f.date(from: s)+ }++ private static func href(in entry: String) -> String? {+ guard let link = entry.range(of: "<link"), let end = entry.range(of: ">", range: link.upperBound..<entry.endIndex),+ let h = entry.range(of: "href=\"", range: link.upperBound..<end.lowerBound),+ let q = entry.range(of: "\"", range: h.upperBound..<end.lowerBound) else { return nil }+ return String(entry[h.upperBound..<q.lowerBound])+ }+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])diff --git a/Packages/CraCore/Sources/CraCore/SidebarModel.swift b/Packages/CraCore/Sources/CraCore/SidebarModel.swiftindex 34a4d19..06f0ed0 100644--- a/Packages/CraCore/Sources/CraCore/SidebarModel.swift+++ b/Packages/CraCore/Sources/CraCore/SidebarModel.swift@@ -536,6 +536,15 @@ public struct AppSettings: Codable, Equatable {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 Live Calendar on a Google Calendar favorite (the favorite's menu ▸ Live Calendar), on+ /// until "Disable Live Calendar".+ public var liveCalendar: Bool = true+ /// Live Calendar ▸ Show Hover Preview: today's timeline when the pointer rests on the tile.+ public var calendarHoverPreview: Bool = true+ /// Live Calendar ▸ Show Time to Next Meeting: the tile counts down to it.+ public var calendarTimeToNextMeeting: Bool = true+ /// Live Calendar ▸ Show Next Meeting Link, Two Minutes Before in Arc.+ public var calendarMeetingLink: CalendarPreview.LinkTiming = .twoMinutes/// 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@@ -752,6 +761,10 @@ extension AppSettings {pageTopWindowDrag = try c.decodeIfPresent(Bool.self, forKey: .pageTopWindowDrag) ?? trueboostsEnabled = try c.decodeIfPresent(Bool.self, forKey: .boostsEnabled) ?? truefavoritePreviews = try c.decodeIfPresent(Bool.self, forKey: .favoritePreviews) ?? true+ liveCalendar = try c.decodeIfPresent(Bool.self, forKey: .liveCalendar) ?? true+ calendarHoverPreview = try c.decodeIfPresent(Bool.self, forKey: .calendarHoverPreview) ?? true+ calendarTimeToNextMeeting = try c.decodeIfPresent(Bool.self, forKey: .calendarTimeToNextMeeting) ?? true+ calendarMeetingLink = (try? c.decodeIfPresent(CalendarPreview.LinkTiming.self, forKey: .calendarMeetingLink)) ?? .twoMinutessearchSuggestions = 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/CalendarPreviewTests.swift b/Packages/CraCore/Tests/CraCoreTests/CalendarPreviewTests.swiftnew file mode 100644index 0000000..da8b0cc--- /dev/null+++ b/Packages/CraCore/Tests/CraCoreTests/CalendarPreviewTests.swift@@ -0,0 +1,130 @@+import CraCore+import Foundation+import Testing++/// Arc's Live Calendar on a Google Calendar favorite, read through the Calendar embed's client.+struct CalendarPreviewTests {+ static let utc: Calendar = {+ var c = Calendar(identifier: .gregorian)+ c.timeZone = TimeZone(identifier: "UTC")!+ return c+ }()++ static func at(_ h: Int, _ m: Int = 0) -> Date {+ utc.date(from: DateComponents(year: 2026, month: 11, day: 8, hour: h, minute: m))!+ }++ /// The answer Google gave the embed's client on 8 Nov 2026 (one Meet event), trimmed.+ static let answer = """+ {"items":[{"summary":"Cra preview test","start":{"dateTime":"2026-11-08T09:10:00+01:00"},"end":{"dateTime":"2026-11-08T09:30:00+01:00"},+ "hangoutLink":"https://meet.google.com/ope-ucwb-mfe","conferenceData":{"entryPoints":[{"entryPointType":"video","uri":"https://meet.google.com/ope-ucwb-mfe"}]},+ "htmlLink":"https://www.google.com/calendar/event?eid=abc"},+ {"summary":"Holiday","start":{"date":"2026-11-09"},"end":{"date":"2026-11-10"}},+ {"summary":"Declined","start":{"dateTime":"2026-11-08T12:00:00Z"},"end":{"dateTime":"2026-11-08T13:00:00Z"},"attendees":[{"self":true,"responseStatus":"declined"}]},+ {"status":"cancelled","summary":"Gone","start":{"dateTime":"2026-11-08T12:00:00Z"},"end":{"dateTime":"2026-11-08T13:00:00Z"}},+ {"summary":"Zoom sync","location":"https://us02web.zoom.us/j/123?pwd=x","start":{"dateTime":"2026-11-08T14:00:00Z"},"end":{"dateTime":"2026-11-08T14:30:00Z"}},+ {"start":{"dateTime":"2026-11-08T15:00:00Z"},"end":{"dateTime":"2026-11-08T15:15:00Z"},"description":"no call here, see https://example.com"}]}+ """++ @Test func readsTheEventsAndTheirCalls() throws {+ guard case .events(let events) = CalendarPreview.parse(Self.answer) else { Issue.record("no events"); return }+ #expect(events.map(\.title) == ["Cra preview test", "Holiday", "Zoom sync", "(No title)"])+ let meet = try #require(events.first)+ #expect(meet.start == Self.at(8, 10))+ #expect(meet.end == Self.at(8, 30))+ #expect(meet.meetingURL == "https://meet.google.com/ope-ucwb-mfe")+ #expect(meet.link == "https://www.google.com/calendar/event?eid=abc")+ #expect(events[1].allDay)+ #expect(events[2].meetingURL == "https://us02web.zoom.us/j/123?pwd=x")+ #expect(events[3].meetingURL == nil)+ }++ @Test func aSignedOutCalendarAsksToSignIn() {+ #expect(CalendarPreview.parse(#"{"error":"status","status":401}"#) == .signedOut)+ #expect(CalendarPreview.parse(#"{"error":"no client"}"#) == .failed)+ #expect(CalendarPreview.parse("not json") == .failed)+ }++ @Test(arguments: [("https://calendar.google.com/calendar/u/0/r", "https://calendar.google.com/calendar/u/0/embed"),+ ("https://calendar.google.com/calendar/u/2/r/week", "https://calendar.google.com/calendar/u/2/embed"),+ ("https://calendar.google.com/", "https://calendar.google.com/calendar/u/0/embed")])+ func theHiddenPageOfTheFavoritesAccount(favorite: String, embed: String) {+ #expect(CalendarPreview.embedURL(for: favorite) == embed)+ #expect(CalendarPreview.isCalendar(favorite))+ }++ @Test func otherSitesAreNoCalendar() {+ #expect(CalendarPreview.embedURL(for: "https://mail.google.com/mail/u/0/") == nil)+ #expect(!CalendarPreview.isCalendar("https://example.com/calendar"))+ #expect(CalendarPreview.newEventURL(for: "https://calendar.google.com/calendar/u/1/r") == "https://calendar.google.com/calendar/u/1/r/eventedit")+ }++ /// Arc's labels on 8 Nov 2026 read "8 AM" … "12 PM" … "1 PM" on a Mac with a 24-hour clock.+ @Test func hourLabelsLikeArc() {+ #expect([0, 8, 11, 12, 13, 23].map(CalendarPreview.hourLabel) == ["12 AM", "8 AM", "11 AM", "12 PM", "1 PM", "11 PM"])+ }++ @Test func theCardOpensAtTheCurrentHour() {+ let morning = CalendarPreview.initialScroll(now: Self.at(8, 32), calendar: Self.utc, hourHeight: 42)+ let midnight = CalendarPreview.initialScroll(now: Self.at(0, 5), calendar: Self.utc, hourHeight: 42)+ #expect(morning == 323)+ #expect(midnight == 0)+ }++ @Test func overlappingEventsShareTheRow() {+ let a = CalendarPreview.Event(title: "A", start: Self.at(9), end: Self.at(10))+ let b = CalendarPreview.Event(title: "B", start: Self.at(9, 30), end: Self.at(11))+ let c = CalendarPreview.Event(title: "C", start: Self.at(10), end: Self.at(10, 30))+ let d = CalendarPreview.Event(title: "D", start: Self.at(13), end: Self.at(13, 5))+ let allDay = CalendarPreview.Event(title: "Holiday", start: Self.at(0), end: Self.at(23), allDay: true)+ let placed = CalendarPreview.layout([d, c, b, a, allDay], day: Self.at(12), calendar: Self.utc, hourHeight: 42)+ #expect(placed.map(\.event.title) == ["A", "B", "C", "D"])+ #expect(placed.map(\.column) == [0, 1, 0, 0])+ #expect(placed.map(\.columns) == [2, 2, 2, 1])+ #expect(placed[0].top == 9 * 42 && placed[0].height == 42)+ #expect(placed[3].height == 18, "a five-minute event keeps a readable height")+ }++ static let meeting = CalendarPreview.Event(title: "Standup", start: at(9), end: at(9, 15), meetingURL: "https://meet.google.com/x")++ /// Arc's default is Two Minutes Before; the link stays until the meeting ends.+ @Test func theJoinLinkShowsAtTheChosenLead() {+ let events = [Self.meeting]+ #expect(CalendarPreview.meetingToJoin(in: events, now: Self.at(8, 57), timing: .twoMinutes) == nil)+ #expect(CalendarPreview.meetingToJoin(in: events, now: Self.at(8, 58), timing: .twoMinutes) == Self.meeting)+ #expect(CalendarPreview.meetingToJoin(in: events, now: Self.at(8, 55), timing: .fiveMinutes) == Self.meeting)+ #expect(CalendarPreview.meetingToJoin(in: events, now: Self.at(8, 59), timing: .onStart) == nil)+ #expect(CalendarPreview.meetingToJoin(in: events, now: Self.at(9, 14), timing: .onStart) == Self.meeting)+ #expect(CalendarPreview.meetingToJoin(in: events, now: Self.at(9, 15), timing: .tenMinutes) == nil)+ #expect(CalendarPreview.meetingToJoin(in: events, now: Self.at(9), timing: .never) == nil)+ #expect(CalendarPreview.meetingToJoin(in: events, now: Self.at(9), timing: .twoMinutes, dismissed: [CalendarPreview.key(Self.meeting)]) == nil)+ }++ @Test func theJoinCommandTakesTheCallOnNowElseTheNextToday() {+ let later = CalendarPreview.Event(title: "Review", start: Self.at(14), end: Self.at(15), meetingURL: "https://zoom.us/j/1")+ let tomorrow = CalendarPreview.Event(title: "Tomorrow", start: Self.at(9).addingTimeInterval(86400), end: Self.at(10).addingTimeInterval(86400), meetingURL: "https://zoom.us/j/2")+ #expect(CalendarPreview.nextCall(in: [later, Self.meeting], now: Self.at(9, 5), calendar: Self.utc) == Self.meeting)+ #expect(CalendarPreview.nextCall(in: [later, Self.meeting], now: Self.at(10), calendar: Self.utc) == later)+ #expect(CalendarPreview.nextCall(in: [tomorrow], now: Self.at(10), calendar: Self.utc) == nil)+ }++ @Test func theTileCountsDownToTheNextMeeting() {+ let lunch = CalendarPreview.Event(title: "Lunch", start: Self.at(12), end: Self.at(13))+ #expect(CalendarPreview.timeToNext(in: [Self.meeting, lunch], now: Self.at(8, 48)) == "12m")+ #expect(CalendarPreview.timeToNext(in: [Self.meeting, lunch], now: Self.at(9, 5)) == "Now")+ #expect(CalendarPreview.timeToNext(in: [Self.meeting, lunch], now: Self.at(10)) == nil, "lunch is two hours away")+ #expect(CalendarPreview.timeToNext(in: [Self.meeting, lunch], now: Self.at(11, 0)) == "60m")+ }++ @Test func theGearMenusLastFetch() {+ #expect(CalendarPreview.lastFetch(Self.at(9), now: Self.at(9, 0)) == "Last fetch: Just now")+ #expect(CalendarPreview.lastFetch(Self.at(9), now: Self.at(9, 5)) == "Last fetch: 5 min ago")+ #expect(CalendarPreview.lastFetch(nil, now: Self.at(9)) == "Last fetch: Never")+ }++ @Test func theScriptAsksForThePrimaryCalendar() {+ let js = CalendarPreview.fetchScript(from: Self.at(0), to: Self.at(23))+ #expect(js.contains("calendars/primary/events"))+ #expect(js.contains("2026-11-08T00:00:00Z"))+ }+}diff --git a/Packages/CraCore/Tests/CraCoreTests/GmailPreviewTests.swift b/Packages/CraCore/Tests/CraCoreTests/GmailPreviewTests.swiftindex 614e5e6..05a7030 100644--- a/Packages/CraCore/Tests/CraCoreTests/GmailPreviewTests.swift+++ b/Packages/CraCore/Tests/CraCoreTests/GmailPreviewTests.swift@@ -1,4 +1,5 @@import CraCore+import Foundationimport Testing/// Arc's Previews for a Gmail favorite, from Gmail's Atom feed of unread mail.@@ -12,7 +13,40 @@ struct GmailPreviewTests {@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")])+ #expect(inbox?.mails.map(\.from) == ["Ada Lovelace", "Billing"])+ #expect(inbox?.mails.map(\.subject) == ["Lunch & plans", "Invoice #42"])+ }++ /// Arc's card row: sender and age, subject, then the feed's opening lines; a click opens the mail.+ @Test func readsEachMailsSnippetTimeAndLink() throws {+ let feed = """+ <feed><fullcount>1</fullcount><entry><title>Run failed: CI</title><summary>CI workflow run CI: No jobs were run & more</summary>+ <link rel="alternate" href="https://mail.google.com/mail/u/[email protected]&message_id=19a&view=conv&extsrc=atom" type="text/html" />+ <modified>2026-11-08T07:31:00Z</modified><issued>2026-11-08T07:30:00Z</issued><author><name>Victor</name></author></entry></feed>+ """+ let mail = try #require(GmailPreview.parse(feed)?.mails.first)+ #expect(mail.snippet == "CI workflow run CI: No jobs were run & more")+ #expect(mail.received == Date(timeIntervalSince1970: 1_794_123_000))+ #expect(mail.link == "https://mail.google.com/mail/u/[email protected]&message_id=19a&view=conv&extsrc=atom")+ }++ @Test func listsTheWholeFeed() {+ let entries = (1...20).map { "<entry><title>\($0)</title><author><name>S</name></author></entry>" }.joined()+ #expect(GmailPreview.parse("<feed><fullcount>31</fullcount>\(entries)</feed>")?.mails.count == 20)+ }++ /// The ages Arc printed on 8 Nov 2026: "50s", "1m", "3h", "10h".+ static let ages: [(Double, String)] = [(50, "50s"), (61, "1m"), (10_859, "3h"), (36_000, "10h"), (172_805, "2d"), (-5, "0s")]++ @Test(arguments: ages)+ func agesLikeArc(seconds: Double, label: String) {+ let now = Date(timeIntervalSince1970: 1_000_000)+ #expect(GmailPreview.age(of: now.addingTimeInterval(-seconds), now: now) == label)+ }++ @Test func composesInTheFavoritesAccount() {+ #expect(GmailPreview.composeURL(for: "https://mail.google.com/mail/u/1/#inbox") == "https://mail.google.com/mail/u/1/#inbox?compose=new")+ #expect(GmailPreview.composeURL(for: "https://example.com/") == nil)}@Test func anEmptyInboxIsArcsExhale() {diff --git a/Sources/Cra/App/AppDelegate.swift b/Sources/Cra/App/AppDelegate.swiftindex e4c81f8..d7eabc6 100644--- a/Sources/Cra/App/AppDelegate.swift+++ b/Sources/Cra/App/AppDelegate.swift@@ -900,7 +900,11 @@ 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 }+ if let n = dict["gmailPreview"].flatMap(Int.init), let w = main.window { FavoritePreviewCard.shared.demoGmail(unread: n, in: w); return }+ // calendarPreview=1: the Calendar favorite's card for a sample day (a call in 90 s).+ if dict["calendarPreview"] != nil, let w = main.window { FavoritePreviewCard.shared.demoCalendar(in: w); return }+ // previewDismiss=1: the card goes, as when the pointer leaves it.+ if dict["previewDismiss"] != nil { FavoritePreviewCard.shared.dismiss(animated: false); 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 }// boostPick=1|0|copyThis|copyRelated|zapRelated: the code panel's eyedropper on (the@@ -1278,6 +1282,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSMenuItemValidation {case "editSpace", "deleteSpace", "nextSpace", "previousSpace", "manageSpaces", "changeProfile": return !main.isStandalone// A Blank Window has no favorites or pinned section to put a tab in (Arc).case "favoriteTab", "newFolder", "newGitHubLiveFolder", "resetTab": return !main.isBlank+ case "joinNextMeeting": return LiveCalendarClient.shared.nextCall()?.meetingURL != nilcase "closeLittleWindows": return !littleWindows.isEmptycase let id? where id.hasPrefix("moveTabToSpace"):guard let n = Int(id.dropFirst(14)), n >= 1, n <= store.spaceOrder.count else { return false }@@ -1515,6 +1520,8 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSMenuItemValidation {case "pinTab": if let c = current, !main.isBlank { store.togglePinned(c) }case "favoriteTab":if let c = current, !main.isBlank { store.isFavorite(c) ? store.removeFromFavorites(c) : store.addToFavorites(c) }+ case "joinNextMeeting":+ if let url = LiveCalendarClient.shared.nextCall()?.meetingURL { main.sidebarActions.openURL(url) } else { NSSound.beep() }// A pane has no row of its own: its split's name is edited.case "renameTab": main.sidebarUI.renamingID = current.map { store.splitContaining($0)?.id ?? $0 }case "duplicateTab": if let c = current { store.duplicateTab(c) }diff --git a/Sources/Cra/App/KeyBindings.swift b/Sources/Cra/App/KeyBindings.swiftindex 838f1b6..17b2996 100644--- a/Sources/Cra/App/KeyBindings.swift+++ b/Sources/Cra/App/KeyBindings.swift@@ -221,6 +221,10 @@ final class KeyBindingRegistry {KeyAction(id: "recentTabBackward", name: "Previous Recent Tab", section: .tabs, shortcuts: [Shortcut(Shortcut.tab, [.control, .shift])], inCommandBar: false),KeyAction(id: "clearToday", name: "Clear Today", section: .tabs, shortcuts: [Shortcut("k", cmdShift)], triggers: ["clear", "tidy"]),KeyAction(id: "favoriteTab", name: "Add to Favorites", section: .tabs, shortcuts: [], triggers: ["favorite", "top app"]),+ // Arc's Join Meeting ⌃⌘J (Settings ▸ Shortcuts; the command bar's "Join next video conference"):+ // the call from a Calendar favorite's Live Calendar.+ KeyAction(id: "joinNextMeeting", name: "Join Meeting", section: .none, shortcuts: [Shortcut("j", [.control, .command])],+ triggers: ["join", "meeting", "video call", "join next video conference"]),KeyAction(id: "renameTab", name: "Rename Tab…", section: .tabs, shortcuts: [], triggers: ["rename"]),KeyAction(id: "duplicateTab", name: "Duplicate Tab", section: .tabs, shortcuts: [], triggers: ["duplicate"]),KeyAction(id: "resetTab", name: "Reset Pinned Tab", section: .tabs, shortcuts: [], triggers: ["reset", "home"]),diff --git a/Sources/Cra/Services/LiveCalendarClient.swift b/Sources/Cra/Services/LiveCalendarClient.swiftnew file mode 100644index 0000000..93ac4bf--- /dev/null+++ b/Sources/Cra/Services/LiveCalendarClient.swift@@ -0,0 +1,199 @@+import AppKit+import CraCEF++/// Arc's LiveCalendarClient for a Google Calendar favorite: a hidden page in the favorite's own+/// profile reads today's events (CalendarPreview.fetchScript), then closes ("Live Calendar+/// timeout reached; tearing down" after 25 s). The card, the tile's countdown and the Join link+/// read `state(for:)`; `changed` tells them when it moves.+@MainActor+final class LiveCalendarClient {+ static let shared = LiveCalendarClient()+ static let changed = Notification.Name("CraLiveCalendarChanged")++ struct State: Equatable {+ var events: [CalendarPreview.Event] = []+ var signedOut = false+ var failed = false+ var fetched: Date?+ }++ private(set) var states: [String: State] = [:]+ /// Meetings whose Join link was closed (CalendarPreview.key).+ private(set) var dismissed: Set<String> = []+ private var running: [String: HiddenPage] = [:]+ private var waiting: [String: [() -> Void]] = [:]+ private var timer: Timer?+ /// Calendar favorites seen lately (key → favorite URL and profile), refreshed by the timer.+ private var watched: [String: (favorite: String, profile: String?)] = [:]++ private static func key(_ embed: String, _ profile: String?) -> String { embed + "|" + (profile ?? "") }++ func state(for favorite: String, profilePath: String?) -> State? {+ CalendarPreview.embedURL(for: favorite).flatMap { states[Self.key($0, profilePath)] }+ }++ /// A Calendar favorite is in a sidebar: keep its events fresh (every 5 minutes, as the+ /// countdown and Join link need them without a hover).+ func watch(favorite: String, profilePath: String?) {+ guard let embed = CalendarPreview.embedURL(for: favorite) else { return }+ let k = Self.key(embed, profilePath)+ guard watched[k] == nil else { return }+ watched[k] = (favorite, profilePath)+ refresh(favorite: favorite, profilePath: profilePath, ifOlderThan: 60)+ if timer == nil {+ // Every 30 s the countdown and the Join link move on; every 5 min the events are read again.+ var ticks = 0+ let t = Timer(timeInterval: 30, repeats: true) { _ in+ MainActor.assumeIsolated {+ let s = LiveCalendarClient.shared+ ticks += 1+ if ticks % 10 == 0 { for w in s.watched.values { s.refresh(favorite: w.favorite, profilePath: w.profile) } }+ NotificationCenter.default.post(name: LiveCalendarClient.changed, object: nil)+ }+ }+ RunLoop.main.add(t, forMode: .common)+ timer = t+ }+ }++ /// Arc's "Join next video conference" command: the call on now, else the next one today,+ /// from any watched Calendar favorite.+ func nextCall(now: Date = Date()) -> CalendarPreview.Event? {+ let all = watched.keys.compactMap { states[$0]?.events }.flatMap { $0 }+ return CalendarPreview.nextCall(in: all, now: now)+ }++ func dismiss(_ e: CalendarPreview.Event) {+ dismissed.insert(CalendarPreview.key(e))+ NotificationCenter.default.post(name: Self.changed, object: nil)+ }++ /// Reads the favorite's calendar unless it was read within `age` seconds; `then` runs once+ /// there is an answer (or none in 25 s).+ func refresh(favorite: String, profilePath: String?, ifOlderThan age: TimeInterval = 0, then: (() -> Void)? = nil) {+ guard let embed = CalendarPreview.embedURL(for: favorite) else { then?(); return }+ let k = Self.key(embed, profilePath)+ if age > 0, let f = states[k]?.fetched, Date().timeIntervalSince(f) < age { then?(); return }+ if let then { waiting[k, default: []].append(then) }+ guard running[k] == nil else { return }+ let now = Date(), cal = Calendar.current+ let from = cal.startOfDay(for: now)+ let to = cal.date(byAdding: .day, value: 2, to: from) ?? now.addingTimeInterval(2 * 86400)+ CraLog.note("live calendar fetch begins (\(profilePath == nil ? "default profile" : "space profile"))")+ running[k] = HiddenPage(url: embed, profilePath: profilePath, script: CalendarPreview.fetchScript(from: from, to: to)) { [weak self] answer in+ self?.finish(k, answer.map(CalendarPreview.parse) ?? .failed)+ }+ }++ private func finish(_ k: String, _ fetch: CalendarPreview.Fetch) {+ running[k]?.close()+ running[k] = nil+ var s = states[k] ?? State()+ switch fetch {+ case .events(let events): s = State(events: events, fetched: Date())+ case .signedOut: s.signedOut = true; s.failed = false; s.events = []; s.fetched = Date()+ case .failed: s.failed = true+ }+ states[k] = s+ CraLog.note("live calendar fetch complete: \(s.signedOut ? "signed out" : s.failed ? "failed" : "\(s.events.count) events")")+ NotificationCenter.default.post(name: Self.changed, object: nil)+ for run in waiting.removeValue(forKey: k) ?? [] { run() }+ }++ /// Testing without a sign-in (cra://debug?calendarPreview=…): the events as if fetched.+ func setDemo(_ events: [CalendarPreview.Event], favorite: String, profilePath: String?) {+ guard let embed = CalendarPreview.embedURL(for: favorite) else { return }+ states[Self.key(embed, profilePath)] = State(events: events, fetched: Date())+ dismissed = []+ NotificationCenter.default.post(name: Self.changed, object: nil)+ }+}++/// A page no one sees: loads `url` in the profile, runs `script` (a promise of a string) once the+/// page committed, answers once, and is closed by its owner.+@MainActor+private final class HiddenPage: NSObject, @preconcurrency CraBrowserDelegate {+ private var browser: CraBrowser?+ private let script: String+ private var answer: ((String?) -> Void)?+ private var poll: Timer?++ init(url: String, profilePath: String?, script: String, answer: @escaping (String?) -> Void) {+ self.script = script+ self.answer = answer+ super.init()+ browser = CraBrowser(frame: NSRect(x: 0, y: 0, width: 800, height: 600), url: url, delegate: self, incognito: false, profilePath: profilePath)+ if let w = browser?.hostWindow { hide(w) }+ let started = Date()+ let t = Timer(timeInterval: 0.25, repeats: true) { [weak self] _ in+ MainActor.assumeIsolated {+ guard let self, let b = self.browser else { return }+ if Date().timeIntervalSince(started) > 25 { self.reply(nil); return }+ guard b.isCreated, b.hasCommittedLoad, !b.isLoading else { return }+ self.poll?.invalidate()+ self.poll = nil+ self.run(in: b)+ }+ }+ RunLoop.main.add(t, forMode: .common)+ poll = t+ }++ private func run(in b: CraBrowser) {+ let body = try? JSONSerialization.data(withJSONObject: ["expression": script, "awaitPromise": true, "returnByValue": true])+ b.sendDevToolsMethod("Runtime.evaluate", params: body.flatMap { String(data: $0, encoding: .utf8) } ?? "{}") { [weak self] result, _ in+ let value = result.flatMap { r -> String? in+ guard let json = try? JSONSerialization.jsonObject(with: Data(r.utf8)) as? [String: Any] else { return nil }+ return (json["result"] as? [String: Any])?["value"] as? String+ }+ DispatchQueue.main.async { self?.reply(value) }+ }+ }++ private func reply(_ value: String?) {+ poll?.invalidate()+ poll = nil+ let a = answer+ answer = nil+ a?(value)+ }++ func close() {+ poll?.invalidate()+ poll = nil+ answer = nil+ if let w = browser?.hostWindow { w.orderOut(nil) }+ browser?.close()+ browser = nil+ }++ private func hide(_ w: NSWindow) {+ w.alphaValue = 0+ w.ignoresMouseEvents = true+ w.orderOut(nil)+ }++ func browser(_ browser: CraBrowser, didChangeTitle title: String) {}+ func browser(_ browser: CraBrowser, didChangeURL url: String) {}+ func browser(_ browser: CraBrowser, didChangeLoading loading: Bool, canGoBack: Bool, canGoForward: Bool) {}+ func browser(_ browser: CraBrowser, didChangeProgress progress: Double) {}+ func browser(_ browser: CraBrowser, didFinishLoadingURL url: String, title: String, statusCode: Int) {}+ func browser(_ browser: CraBrowser, didLoadFavicon image: NSImage, forURL iconURL: String) {}+ func browser(_ browser: CraBrowser, didChangeStatusMessage message: String) {}+ func browser(_ browser: CraBrowser, didReportThemeColor hex: String) {}+ func browser(_ browser: CraBrowser, didChangeFullscreen fullscreen: Bool) {}+ func browser(_ browser: CraBrowser, requestsNewTabWithURL url: String, inBackground background: Bool) {}+ func browser(_ browser: CraBrowser, popupHostForURL url: String, inBackground background: Bool) -> CraBrowser? { nil }+ func devToolsHostView(for browser: CraBrowser) -> NSView? { nil }+ func browser(_ browser: CraBrowser, didCreateDevToolsView view: NSView) {}+ func browserDidCloseDevTools(_ browser: CraBrowser) {}+ func browser(_ browser: CraBrowser, didCreateHostWindow window: NSWindow) { hide(window) }+ func browser(_ browser: CraBrowser, devToolsPageBounds bounds: NSRect) {}+ func browser(_ browser: CraBrowser, devToolsDocked docked: Bool) {}+ func browser(_ browser: CraBrowser, handleKeyEvent event: NSEvent) -> Bool { false }+ func browser(_ browser: CraBrowser, handleUnhandledKeyEvent event: NSEvent) -> Bool { false }+ func browser(_ browser: CraBrowser, didUpdateDownload download: CraDownloadInfo) {}+ func browser(_ browser: CraBrowser, requestsPermissionForOrigin origin: String, kinds: UInt, completion: @escaping (Bool) -> Void) { completion(false) }+ func browserDidReceiveFocus(_ browser: CraBrowser) {}+ func browserDidClose(_ browser: CraBrowser) {}+}diff --git a/Sources/Cra/UI/Sidebar/FavoritePreviewCard.swift b/Sources/Cra/UI/Sidebar/FavoritePreviewCard.swiftnew file mode 100644index 0000000..83522a0--- /dev/null+++ b/Sources/Cra/UI/Sidebar/FavoritePreviewCard.swift@@ -0,0 +1,723 @@+import AppKit+import CraCEF+import SwiftUI++/// Arc's Previews card beside a Gmail or Google Calendar favorite (Arc 1.172.1, measured on+/// Victor's signed-in Arc, 8 Nov 2026; CraCore FavoritePreviewMetrics and FavoritePreviewMotion).+/// It shows a moment after the pointer lands on a tile that isn't the open tab, takes the pointer+/// (rows light up, a click opens the mail or event in the favorite), and goes once the pointer has+/// left both the tile and the card. Gmail's card lists the unread mail with a + for a new one;+/// Calendar's is today's timeline with a gear (Last fetch, Refresh, Disable Live Calendar) and a +.+@MainActor+final class FavoritePreviewCard {+ static let shared = FavoritePreviewCard()++ /// The favorite the pointer is on, and what its card can do.+ struct Target {+ var favorite: String+ var profilePath: String?+ /// Loads a URL in the favorite (and selects it).+ var open: (String) -> Void+ /// Opens a URL in a new tab (Join).+ var openNewTab: (String) -> Void+ var disableLiveCalendar: () -> Void = {}+ }++ private var panel: PreviewPanel?+ private weak var tile: NSView?+ private var target: Target?+ private var showWork: DispatchWorkItem?+ private var closeWork: DispatchWorkItem?+ private var wantsShow = false+ private var inbox: [String: GmailPreview.Inbox] = [:]+ private var observer: NSObjectProtocol?++ private init() {+ observer = NotificationCenter.default.addObserver(forName: LiveCalendarClient.changed, object: nil, queue: .main) { _ in+ MainActor.assumeIsolated { FavoritePreviewCard.shared.contentChanged() }+ }+ }++ // MARK: Pointer++ func hover(_ tile: NSView, target: Target) {+ closeWork?.cancel()+ if self.tile === tile, panel != nil { return }+ if panel != nil { dismiss(animated: false) }+ self.tile = tile+ self.target = target+ wantsShow = false+ showWork?.cancel()+ if let feed = GmailPreview.feedURL(for: target.favorite) {+ fetchMail(feed, profilePath: target.profilePath, for: tile)+ } else if CalendarPreview.isCalendar(target.favorite) {+ LiveCalendarClient.shared.refresh(favorite: target.favorite, profilePath: target.profilePath, ifOlderThan: 60)+ }+ let work = DispatchWorkItem { [weak self, weak tile] in+ guard let self, let tile, self.tile === tile, tile.window != nil else { return }+ self.wantsShow = true+ self.showIfReady()+ }+ showWork = work+ DispatchQueue.main.asyncAfter(deadline: .now() + FavoritePreviewMotion.showDelay, execute: work)+ }++ func leave(_ tile: NSView) {+ guard self.tile === tile else { return }+ showWork?.cancel()+ scheduleClose()+ }++ /// The tile was clicked, or its window went: the card goes at once.+ func cancel(_ tile: NSView) {+ guard self.tile === tile else { return }+ dismiss(animated: false)+ }++ fileprivate func pointerEnteredCard() { closeWork?.cancel() }+ fileprivate func pointerLeftCard() { scheduleClose() }++ private func scheduleClose() {+ closeWork?.cancel()+ let work = DispatchWorkItem { [weak self] in+ guard let self else { return }+ let p = NSEvent.mouseLocation+ if let panel = self.panel, panel.frame.contains(p), panel.cardFrame.contains(p) { return }+ if let tile = self.tile, let w = tile.window, w.convertToScreen(tile.convert(tile.bounds, to: nil)).contains(p) { return }+ self.dismiss(animated: true)+ }+ closeWork = work+ DispatchQueue.main.asyncAfter(deadline: .now() + FavoritePreviewMotion.closeDelay, execute: work)+ }++ func dismiss(animated: Bool) {+ showWork?.cancel()+ closeWork?.cancel()+ wantsShow = false+ tile = nil+ target = nil+ guard let p = panel else { return }+ panel = nil+ p.close(animated: animated)+ }++ // MARK: Content++ private func fetchMail(_ feed: String, profilePath: String?, for tile: NSView) {+ CraCEFRuntime.fetchURL(feed, headers: nil, profilePath: profilePath) { status, _, _, body in+ MainActor.assumeIsolated {+ // Arc shows its "exhale" card whenever it has no unread mail to list, signed out+ // included (seen on a space with no Google sign-in, 7 Nov 2026).+ let parsed = status == 200 ? GmailPreview.parse(body) : nil+ let key = feed + "|" + (profilePath ?? "")+ let new = parsed ?? self.inbox[key] ?? GmailPreview.Inbox(unread: 0, mails: [])+ self.inbox[key] = new+ guard self.tile === tile else { return }+ if self.panel != nil { self.refreshPanel() } else { self.showIfReady() }+ }+ }+ }++ private func contentChanged() {+ guard let target, CalendarPreview.isCalendar(target.favorite) else { return }+ if panel != nil { refreshPanel() } else { showIfReady() }+ }++ private func content() -> AnyView? {+ guard let target else { return nil }+ if let feed = GmailPreview.feedURL(for: target.favorite) {+ guard let inbox = inbox[feed + "|" + (target.profilePath ?? "")] else { return nil }+ return AnyView(GmailPreviewView(inbox: inbox, now: Date(), open: { [weak self] in self?.open($0) },+ compose: { [weak self] in GmailPreview.composeURL(for: target.favorite).map { self?.open($0) } }))+ }+ if CalendarPreview.isCalendar(target.favorite) {+ let state = LiveCalendarClient.shared.state(for: target.favorite, profilePath: target.profilePath)+ // Arc's card shows its timeline whether or not the fetch worked; Cra waits for a first answer.+ guard let state else { return nil }+ return AnyView(CalendarPreviewView(state: state, now: Date(), actions: calendarActions(target)))+ }+ return nil+ }++ private func calendarActions(_ target: Target) -> CalendarPreviewView.Actions {+ CalendarPreviewView.Actions(+ open: { [weak self] in self?.open($0) },+ join: { [weak self] url in self?.dismiss(animated: false); target.openNewTab(url) },+ newEvent: { [weak self] in CalendarPreview.newEventURL(for: target.favorite).map { self?.open($0) } },+ gear: { [weak self] point in self?.gearMenu(target, at: point) },+ signIn: { [weak self] in self?.open(target.favorite) })+ }++ private func open(_ url: String) {+ let t = target+ dismiss(animated: false)+ t?.open(url)+ }++ /// Arc's gear on the Calendar card: Last fetch, Refresh, then Disable Live Calendar.+ private func gearMenu(_ target: Target, at point: CGPoint) {+ guard let panel else { return }+ let m = NSMenu()+ m.autoenablesItems = false+ let fetched = LiveCalendarClient.shared.state(for: target.favorite, profilePath: target.profilePath)?.fetched+ MenuItems.add(m, CalendarPreview.lastFetch(fetched, now: Date()), enabled: false) {}+ MenuItems.add(m, "Refresh") { LiveCalendarClient.shared.refresh(favorite: target.favorite, profilePath: target.profilePath) }+ m.addItem(.separator())+ MenuItems.add(m, "Disable Live Calendar") { [weak self] in+ self?.dismiss(animated: false)+ target.disableLiveCalendar()+ }+ guard let view = panel.contentView else { return }+ // The menu holds the pointer: keep the card while it is up.+ closeWork?.cancel()+ m.popUp(positioning: nil, at: view.convert(point, from: nil), in: view)+ scheduleClose()+ }++ private func showIfReady() {+ guard wantsShow, panel == nil, let tile, let window = tile.window, let view = content() else { return }+ let p = PreviewPanel(content: view)+ let t = window.convertToScreen(tile.convert(tile.bounds, to: nil))+ // Arc: the card's left edge 4 pt in from the tile's right edge, its top 3.5 pt above the tile's bottom.+ p.place(cardTopLeft: NSPoint(x: t.maxX - 4, y: t.minY + 3.5))+ window.addChildWindow(p, ordered: .above)+ p.open()+ panel = p+ }++ private func refreshPanel() {+ guard let panel, let view = content() else { return }+ panel.replace(view)+ }++ // MARK: Testing++ /// cra://debug?gmailPreview=<unread>: the card for a sample inbox where Arc's 264 pt sidebar+ /// has its fourth favorite tile.+ func demoGmail(unread: Int, in window: NSWindow) {+ let now = Date()+ let mails = (0..<min(unread, 20)).map {+ GmailPreview.Mail(from: "Sender \($0 + 1)", subject: "Subject line \($0 + 1)", snippet: "The first lines of mail \($0 + 1), long enough to run onto a second line of the card.",+ received: now.addingTimeInterval(-Double($0 + 1) * 2400))+ }+ let favorite = "https://mail.google.com/mail/u/0/"+ inbox[GmailPreview.feedURL(for: favorite)! + "|"] = GmailPreview.Inbox(unread: unread, mails: mails)+ demo(favorite, in: window)+ }++ /// cra://debug?calendarPreview=1: today's card with a meeting starting in 90 s and two+ /// overlapping events, as if fetched.+ func demoCalendar(in window: NSWindow) {+ let favorite = "https://calendar.google.com/calendar/u/0/r"+ let now = Date()+ let events = [+ CalendarPreview.Event(title: "Design review", start: now.addingTimeInterval(90), end: now.addingTimeInterval(90 + 1800),+ meetingURL: "https://meet.google.com/cra-demo"),+ CalendarPreview.Event(title: "Lunch", start: now.addingTimeInterval(7200), end: now.addingTimeInterval(9000)),+ CalendarPreview.Event(title: "Call with Ada", start: now.addingTimeInterval(7800), end: now.addingTimeInterval(9600),+ meetingURL: "https://zoom.us/j/1"),+ ]+ LiveCalendarClient.shared.setDemo(events, favorite: favorite, profilePath: nil)+ demo(favorite, in: window)+ }++ private func demo(_ favorite: String, in window: NSWindow) {+ guard let content = window.contentView else { return }+ dismiss(animated: false)+ let anchor = NSView(frame: NSRect(x: 200, y: content.bounds.height - 44 - 47, width: 56, height: 47))+ content.addSubview(anchor)+ tile = anchor+ target = Target(favorite: favorite, profilePath: nil, open: { CraLog.note("preview opens \($0)") },+ openNewTab: { CraLog.note("preview joins \($0)") })+ wantsShow = true+ showIfReady()+ anchor.removeFromSuperview()+ CraLog.note("preview card shown: \(panel.map { "\(Int($0.cardFrame.width))x\(Int($0.cardFrame.height))" } ?? "none")")+ }+}++// MARK: - Join reminder++/// Live Calendar's Show Next Meeting Link: from the chosen lead (Arc's default, two minutes+/// before) until the call ends, a card beside the Calendar favorite names the meeting with a Join+/// button and a close button (Arc's LiveCalendarReminder; its look isn't visible in Arc 1.172.1,+/// whose calendar no longer reads, so the card is Cra's, in the preview card's style).+@MainActor+final class MeetingReminder {+ static let shared = MeetingReminder()+ private var panel: PreviewPanel?+ private var shown: String?++ func update(tile: NSView, favorite: String?, events: [CalendarPreview.Event], timing: CalendarPreview.LinkTiming, join: @escaping (String) -> Void) {+ let meeting = favorite == nil ? nil : CalendarPreview.meetingToJoin(in: events, now: Date(), timing: timing,+ dismissed: LiveCalendarClient.shared.dismissed)+ guard let meeting, let url = meeting.meetingURL, let window = tile.window, window.isVisible else {+ if meeting == nil { close() }+ return+ }+ let key = CalendarPreview.key(meeting)+ let view = AnyView(MeetingReminderView(event: meeting, now: Date(),+ join: { [weak self] in self?.close(); LiveCalendarClient.shared.dismiss(meeting); join(url) },+ dismiss: { [weak self] in self?.close(); LiveCalendarClient.shared.dismiss(meeting) }))+ if let panel, shown == key { panel.replace(view); return }+ close()+ let p = PreviewPanel(content: view)+ let t = window.convertToScreen(tile.convert(tile.bounds, to: nil))+ p.place(cardTopLeft: NSPoint(x: t.maxX - 4, y: t.minY + 3.5))+ window.addChildWindow(p, ordered: .above)+ p.open()+ panel = p+ shown = key+ CraLog.note("meeting link shown: \(meeting.title)")+ }++ func close() {+ panel?.close(animated: true)+ panel = nil+ shown = nil+ }+}++private struct MeetingReminderView: View {+ let event: CalendarPreview.Event+ let now: Date+ let join: () -> Void+ let dismiss: () -> Void++ private var when: String {+ let s = Int(event.start.timeIntervalSince(now))+ if s <= 0 { return "Now · " + CalendarPreview.timeRange(event) }+ return "In \(max(1, Int(ceil(Double(s) / 60)))) min · " + CalendarPreview.timeRange(event)+ }++ var body: some View {+ CardStyle.card(+ HStack(spacing: 10) {+ VStack(alignment: .leading, spacing: 2) {+ Text(event.title).font(.system(size: 13, weight: .semibold)).foregroundStyle(CardStyle.text).lineLimit(1)+ Text(when).font(.system(size: 11)).foregroundStyle(CardStyle.secondary).lineLimit(1)+ }+ Spacer(minLength: 0)+ Text("Join").font(.system(size: 12, weight: .semibold))+ .padding(.horizontal, 12).padding(.vertical, 5)+ .background(Capsule().fill(CalendarPreviewView.nowColor))+ .foregroundStyle(.black.opacity(0.85))+ .contentShape(Capsule())+ .onTapGesture(perform: join)+ .accessibilityAddTraits(.isButton)+ Image(systemName: "xmark").font(.system(size: 10, weight: .bold)).foregroundStyle(CardStyle.secondary)+ .frame(width: 18, height: 18).contentShape(Rectangle())+ .onTapGesture(perform: dismiss)+ .accessibilityLabel("Dismiss")+ .accessibilityAddTraits(.isButton)+ }+ .padding(.horizontal, FavoritePreviewMetrics.inset).padding(.vertical, 10)+ .frame(width: FavoritePreviewMetrics.width))+ }+}++// MARK: - Panel++/// The card's window: no key, no title, the card inset by room for its shadow; it scales and+/// fades as Arc's does (the window's own shadow couldn't follow the scale, so the card draws one).+private final class PreviewPanel: NSPanel {+ static let margin: CGFloat = 24+ private let card = NSView()+ private var host: NSHostingView<AnyView>++ init(content: AnyView) {+ host = FirstMouseHostingView(rootView: content)+ super.init(contentRect: .zero, styleMask: [.borderless, .nonactivatingPanel], backing: .buffered, defer: false)+ backgroundColor = .clear+ isOpaque = false+ hasShadow = false+ level = .floating+ acceptsMouseMovedEvents = true+ becomesKeyOnlyIfNeeded = true+ animationBehavior = .none+ let root = TrackingView()+ root.wantsLayer = true+ contentView = root+ card.wantsLayer = true+ card.layer?.shadowColor = NSColor.black.cgColor+ card.layer?.shadowOpacity = 0.35+ card.layer?.shadowRadius = 10+ card.layer?.shadowOffset = CGSize(width: 0, height: -4)+ root.addSubview(card)+ card.addSubview(host)+ fit()+ }++ override var canBecomeKey: Bool { false }+ override var canBecomeMain: Bool { false }++ /// The card on screen (the window is larger, for the shadow).+ var cardFrame: NSRect { frame.insetBy(dx: Self.margin, dy: Self.margin) }++ private func fit() {+ let size = host.fittingSize+ let m = Self.margin+ setContentSize(NSSize(width: size.width + 2 * m, height: size.height + 2 * m))+ card.frame = NSRect(x: m, y: m, width: size.width, height: size.height)+ host.frame = card.bounds+ card.layer?.shadowPath = CGPath(roundedRect: card.bounds, cornerWidth: 10, cornerHeight: 10, transform: nil)+ (contentView as? TrackingView)?.cardRect = card.frame+ }++ func place(cardTopLeft p: NSPoint) {+ setFrameTopLeftPoint(NSPoint(x: p.x - Self.margin, y: p.y + Self.margin))+ }++ func replace(_ view: AnyView) {+ let top = NSPoint(x: frame.minX, y: frame.maxY)+ host.rootView = view+ fit()+ setFrameTopLeftPoint(top)+ }++ /// Arc's opening: from about 80 % about a point near the tile, fading in, some 4 frames.+ func open() {+ orderFront(nil)+ guard let layer = card.layer else { return }+ setAnchor(layer)+ let fade = CABasicAnimation(keyPath: "opacity")+ fade.fromValue = 0+ fade.toValue = 1+ var animations: [CAAnimation] = [fade]+ if !NSWorkspace.shared.accessibilityDisplayShouldReduceMotion {+ let grow = CABasicAnimation(keyPath: "transform.scale")+ grow.fromValue = FavoritePreviewMotion.openScale+ grow.toValue = 1+ animations.append(grow)+ }+ let group = CAAnimationGroup()+ group.animations = animations+ group.duration = FavoritePreviewMotion.openDuration+ group.timingFunction = CAMediaTimingFunction(name: .easeOut)+ layer.add(group, forKey: "open")+ }++ func close(animated: Bool) {+ parent?.removeChildWindow(self)+ guard animated, let layer = card.layer else { orderOut(nil); return }+ setAnchor(layer)+ CATransaction.begin()+ CATransaction.setCompletionBlock { [weak self] in self?.orderOut(nil) }+ let fade = CABasicAnimation(keyPath: "opacity")+ fade.fromValue = 1+ fade.toValue = 0+ let shrink = CABasicAnimation(keyPath: "transform.scale")+ shrink.fromValue = 1+ shrink.toValue = NSWorkspace.shared.accessibilityDisplayShouldReduceMotion ? 1 : FavoritePreviewMotion.closeScale+ let group = CAAnimationGroup()+ group.animations = [fade, shrink]+ group.duration = FavoritePreviewMotion.closeDuration+ group.timingFunction = CAMediaTimingFunction(name: .easeIn)+ group.fillMode = .forwards+ group.isRemovedOnCompletion = false+ layer.add(group, forKey: "close")+ CATransaction.commit()+ }++ /// The scale's fixed point: a third of the way in, near the top (measured from Arc's frames).+ private func setAnchor(_ layer: CALayer) {+ let anchor = CGPoint(x: 0.33, y: 0.86)+ let f = card.frame+ layer.anchorPoint = anchor+ layer.position = CGPoint(x: f.minX + anchor.x * f.width, y: f.minY + anchor.y * f.height)+ }+}++/// Clicks in the card act at once, though its window never becomes key (Arc's+/// HostingViewAcceptingFirstMouse).+private final class FirstMouseHostingView: NSHostingView<AnyView> {+ override func acceptsFirstMouse(for event: NSEvent?) -> Bool { true }+}++/// Tells the card's controller when the pointer comes onto the card and leaves it.+private final class TrackingView: NSView {+ var cardRect: NSRect = .zero { didSet { updateTrackingAreas() } }++ override func updateTrackingAreas() {+ super.updateTrackingAreas()+ for t in trackingAreas where t.owner === self { removeTrackingArea(t) }+ addTrackingArea(NSTrackingArea(rect: cardRect, options: [.mouseEnteredAndExited, .activeAlways], owner: self, userInfo: nil))+ }++ override func mouseEntered(with event: NSEvent) { MainActor.assumeIsolated { FavoritePreviewCard.shared.pointerEnteredCard() } }+ override func mouseExited(with event: NSEvent) { MainActor.assumeIsolated { FavoritePreviewCard.shared.pointerLeftCard() } }+}++// MARK: - Views++private enum CardStyle {+ static let fill = Color(red: 25 / 255, green: 24 / 255, blue: 23 / 255)+ static let edge = Color(red: 63 / 255, green: 62 / 255, blue: 60 / 255)+ static let line = Color.white.opacity(0.08)+ static let text = Color.white.opacity(0.9)+ static let secondary = Color.white.opacity(0.5)+ static let hover = Color.white.opacity(0.07)++ static func card<V: View>(_ v: V) -> some View {+ v.background(RoundedRectangle(cornerRadius: 10, style: .continuous).fill(fill))+ .clipShape(RoundedRectangle(cornerRadius: 10, style: .continuous))+ .overlay(RoundedRectangle(cornerRadius: 10, style: .continuous).strokeBorder(edge, lineWidth: 1))+ }+}++/// Arc's round buttons at the card's bottom right: 32 pt, dark with a light rim (+), or lighter (gear).+private struct RoundButton: View {+ let symbol: String+ var light = false+ var label: String+ let run: (CGPoint) -> Void+ @State private var hovered = false++ var body: some View {+ GeometryReader { g in+ Circle()+ .fill(light ? Color.white.opacity(hovered ? 0.3 : 0.24) : Color(white: hovered ? 0.2 : 0.14))+ .overlay(Circle().strokeBorder(Color.white.opacity(light ? 0 : 0.14), lineWidth: 1))+ .overlay(Image(systemName: symbol).font(.system(size: 15, weight: .semibold)).foregroundStyle(CardStyle.text))+ .shadow(color: .black.opacity(0.35), radius: 4, y: 1)+ .contentShape(Circle())+ .onHover { hovered = $0 }+ .onTapGesture {+ let f = g.frame(in: .global)+ run(CGPoint(x: f.midX, y: f.maxY))+ }+ }+ .frame(width: FavoritePreviewMetrics.buttonSize, height: FavoritePreviewMetrics.buttonSize)+ .accessibilityElement()+ .accessibilityLabel(label)+ .accessibilityAddTraits(.isButton)+ }+}++private struct GmailPreviewView: View {+ let inbox: GmailPreview.Inbox+ let now: Date+ let open: (String) -> Void+ let compose: () -> Void++ var body: some View {+ if inbox.mails.isEmpty { empty } else { list }+ }++ /// Arc's "exhale" card (docs/screenshots/arc-gmail-preview-empty.png): 240 pt wide, the line+ /// centred 23.5 pt down, the leaf 38.5 pt, the card 62.5 pt tall.+ private var empty: some View {+ CardStyle.card(+ VStack(spacing: -2) {+ Text(GmailPreview.emptyText).font(.system(size: 13)).multilineTextAlignment(.center)+ Text("🍃").font(.system(size: 14))+ }+ .foregroundStyle(.white.opacity(0.78))+ .padding(.vertical, 15.5).padding(.horizontal, 16)+ .frame(width: 240))+ }++ private var list: some View {+ let rowStep = FavoritePreviewMetrics.mailRowHeight + 1+ let height = min(CGFloat(inbox.mails.count) * rowStep - 1, FavoritePreviewMetrics.maxHeight)+ return CardStyle.card(+ ZStack(alignment: .bottomTrailing) {+ ScrollView(.vertical, showsIndicators: false) {+ VStack(spacing: 0) {+ ForEach(Array(inbox.mails.enumerated()), id: \.offset) { i, mail in+ if i > 0 { Rectangle().fill(CardStyle.line).frame(height: 1) }+ MailRow(mail: mail, now: now) { mail.link.map(open) }+ }+ }+ }+ RoundButton(symbol: "plus", label: "New Email") { _ in compose() }+ .padding(FavoritePreviewMetrics.buttonInset)+ }+ .frame(width: FavoritePreviewMetrics.width, height: height))+ }+}++/// Arc's mail row: sender and age, the subject, two lines of the mail, 11 pt in.+private struct MailRow: View {+ let mail: GmailPreview.Mail+ let now: Date+ let open: () -> Void+ @State private var hovered = false++ var body: some View {+ VStack(alignment: .leading, spacing: 0) {+ HStack(alignment: .firstTextBaseline, spacing: 6) {+ Text(mail.from).font(.system(size: 13, weight: .semibold)).lineLimit(1)+ Spacer(minLength: 0)+ if let r = mail.received { Text(GmailPreview.age(of: r, now: now)).font(.system(size: 13)) }+ }+ .foregroundStyle(CardStyle.text)+ Text(mail.subject).font(.system(size: 13)).foregroundStyle(CardStyle.text).lineLimit(1)+ Text(mail.snippet).font(.system(size: 12)).foregroundStyle(CardStyle.secondary).lineLimit(2)+ .fixedSize(horizontal: false, vertical: true)+ }+ .padding(.horizontal, FavoritePreviewMetrics.inset)+ .padding(.top, 8.5)+ .frame(maxWidth: .infinity, minHeight: FavoritePreviewMetrics.mailRowHeight, maxHeight: FavoritePreviewMetrics.mailRowHeight, alignment: .topLeading)+ .background {+ if hovered {+ RoundedRectangle(cornerRadius: 7, style: .continuous).fill(CardStyle.hover).padding(FavoritePreviewMetrics.hoverInset)+ }+ }+ .contentShape(Rectangle())+ .onHover { hovered = $0 }+ .onTapGesture(perform: open)+ .accessibilityElement(children: .combine)+ .accessibilityAddTraits(.isButton)+ }+}++/// Arc's Calendar card: today from the current hour, an hour per 42 pt with its label at the top+/// left, a cream now line with a dot, the events in columns where they overlap, and the gear and+/// + at the bottom right.+struct CalendarPreviewView: View {+ struct Actions {+ var open: (String) -> Void+ var join: (String) -> Void+ var newEvent: () -> Void+ var gear: (CGPoint) -> Void+ var signIn: () -> Void+ }++ let state: LiveCalendarClient.State+ let now: Date+ let actions: Actions++ static let nowColor = Color(red: 1, green: 0.94, blue: 0.78)++ var body: some View {+ if state.signedOut { signIn } else { timeline }+ }++ /// Arc's CalendarPreviewLoginView: a sign-in, in the card's style.+ private var signIn: some View {+ CardStyle.card(+ VStack(spacing: 8) {+ Text("Sign in to Google Calendar to see today's meetings here.")+ .font(.system(size: 13)).multilineTextAlignment(.center).foregroundStyle(.white.opacity(0.78))+ Button("Sign In", action: actions.signIn).buttonStyle(.borderedProminent).controlSize(.small)+ }+ .padding(.vertical, 14).padding(.horizontal, 16)+ .frame(width: FavoritePreviewMetrics.width))+ }++ private var timeline: some View {+ let hour = FavoritePreviewMetrics.hourHeight+ let placed = CalendarPreview.layout(state.events, day: now, hourHeight: hour)+ return CardStyle.card(+ ZStack(alignment: .bottomTrailing) {+ ScrollViewReader { scroller in+ ScrollView(.vertical, showsIndicators: false) {+ ZStack(alignment: .topLeading) {+ VStack(spacing: 0) {+ ForEach(0..<24, id: \.self) { h in+ VStack(alignment: .leading, spacing: 0) {+ Rectangle().fill(CardStyle.line).frame(height: 1)+ Text(CalendarPreview.hourLabel(h)).font(.system(size: 11)).foregroundStyle(CardStyle.secondary)+ .padding(.leading, 5).padding(.top, 3)+ Spacer(minLength: 0)+ }+ .frame(height: hour)+ .id(h)+ }+ }+ GeometryReader { g in+ let width = g.size.width - FavoritePreviewMetrics.eventsLeft - FavoritePreviewMetrics.eventsRight+ // The now line under the events, so it never runs through a title; its dot stays clear of them.+ nowLine(width: g.size.width).offset(y: nowY(hour) - 3)+ ForEach(Array(placed.enumerated()), id: \.offset) { _, p in+ let w = width / CGFloat(p.columns)+ EventBlock(event: p.event, now: now, compact: p.height < 30, join: actions.join, open: actions.open)+ .frame(width: max(0, w - 2), height: max(0, p.height - 2), alignment: .topLeading)+ .clipped()+ .offset(x: FavoritePreviewMetrics.eventsLeft + CGFloat(p.column) * w, y: p.top + 1)+ }+ }+ }+ .frame(height: 24 * hour)+ .background(GeometryReader { _ in Color.clear.onAppear { scrollToNow(scroller) } })+ }+ }+ HStack(spacing: FavoritePreviewMetrics.buttonGap) {+ RoundButton(symbol: "gearshape.fill", light: true, label: "Calendar Settings", run: actions.gear)+ RoundButton(symbol: "plus", label: "New Event") { _ in actions.newEvent() }+ }+ .padding(FavoritePreviewMetrics.buttonInset)+ }+ .frame(width: FavoritePreviewMetrics.width, height: FavoritePreviewMetrics.calendarHeight))+ }++ private func nowY(_ hour: CGFloat) -> CGFloat {+ CGFloat(now.timeIntervalSince(Calendar.current.startOfDay(for: now)) / 3600) * hour+ }++ private func nowLine(width: CGFloat) -> some View {+ HStack(spacing: 0) {+ Circle().fill(Self.nowColor).frame(width: 6, height: 6)+ Rectangle().fill(Self.nowColor).frame(height: 1.5)+ }+ .padding(.leading, FavoritePreviewMetrics.eventsLeft - 3)+ .padding(.trailing, FavoritePreviewMetrics.eventsRight)+ .frame(width: width, height: 6)+ }++ /// The current hour's line 13 pt under the card's top, as Arc opens it.+ private func scrollToNow(_ scroller: ScrollViewProxy) {+ let h = Calendar.current.component(.hour, from: now)+ let anchor = UnitPoint(x: 0, y: 13 / FavoritePreviewMetrics.calendarHeight)+ DispatchQueue.main.async { scroller.scrollTo(h, anchor: anchor) }+ }+}++/// An event on the timeline: its title and time; a call has a Join button.+private struct EventBlock: View {+ let event: CalendarPreview.Event+ let now: Date+ /// Under half an hour: the title and start on one line.+ let compact: Bool+ let join: (String) -> Void+ let open: (String) -> Void+ @State private var hovered = false++ var body: some View {+ let past = event.end <= now+ HStack(alignment: compact ? .center : .top, spacing: 4) {+ if compact {+ (Text(event.title).font(.system(size: 11, weight: .semibold))+ + Text(" " + CalendarPreview.timeRange(event)).font(.system(size: 10)).foregroundColor(.white.opacity(0.6)))+ .lineLimit(1)+ } else {+ VStack(alignment: .leading, spacing: 1) {+ Text(event.title).font(.system(size: 11, weight: .semibold)).lineLimit(1)+ Text(CalendarPreview.timeRange(event)).font(.system(size: 10)).foregroundStyle(.white.opacity(0.6)).lineLimit(1)+ }+ }+ Spacer(minLength: 0)+ if let url = event.meetingURL, !past {+ Text("Join").font(.system(size: 10, weight: .semibold))+ .padding(.horizontal, 6).padding(.vertical, compact ? 0 : 2)+ .background(Capsule().fill(CalendarPreviewView.nowColor))+ .foregroundStyle(.black.opacity(0.85))+ .contentShape(Capsule())+ .onTapGesture { join(url) }+ .accessibilityAddTraits(.isButton)+ }+ }+ .foregroundStyle(CardStyle.text)+ .padding(.horizontal, 5).padding(.vertical, compact ? 0 : 3)+ .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: compact ? .leading : .topLeading)+ // Opaque, over the hour lines and the now line.+ .background(RoundedRectangle(cornerRadius: 5, style: .continuous).fill(Color(white: hovered ? 0.27 : 0.22)))+ .opacity(past ? 0.55 : 1)+ .clipped()+ .contentShape(Rectangle())+ .onHover { hovered = $0 }+ .onTapGesture { event.link.map(open) }+ .accessibilityElement(children: .combine)+ }+}diff --git a/Sources/Cra/UI/Sidebar/GmailPreviewCard.swift b/Sources/Cra/UI/Sidebar/GmailPreviewCard.swiftdeleted file mode 100644index 0247976..0000000--- a/Sources/Cra/UI/Sidebar/GmailPreviewCard.swift+++ /dev/null@@ -1,103 +0,0 @@-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 }- // Arc shows its "exhale" card whenever it has no unread mail to list, signed out- // included (seen on a space with no Google sign-in, 7 Nov 2026).- let inbox = status == 200 ? GmailPreview.parse(body) : nil- self.show(inbox ?? GmailPreview.Inbox(unread: 0, mails: []), 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 3d153f0..2526338 100644--- a/Sources/Cra/UI/Sidebar/List/SpaceColumnView.swift+++ b/Sources/Cra/UI/Sidebar/List/SpaceColumnView.swift@@ -1122,6 +1122,9 @@ final class FavoriteTileView: NSView, ArcTooltipTarget, NSDraggingSource {/// Cuts a split's tile into its cells.private let cutMask = CAShapeLayer()private let unreadDot = CALayer()+ /// Live Calendar's Show Time to Next Meeting ("12m", "Now") at the tile's top right.+ private let countdown = CATextLayer()+ nonisolated(unsafe) private var calendarObserver: NSObjectProtocol?private var focusRing: FocusRingLayer?private var model: FavoriteTileModel?private var palette: SpacePalette?@@ -1144,12 +1147,25 @@ final class FavoriteTileView: NSView, ArcTooltipTarget, NSDraggingSource {cutMask.fillRule = .evenOddunreadDot.cornerRadius = 3layer?.addSublayer(unreadDot)+ countdown.fontSize = 9+ countdown.font = NSFont.systemFont(ofSize: 9, weight: .semibold)+ countdown.alignmentMode = .right+ countdown.contentsScale = 2+ countdown.isHidden = true+ layer?.addSublayer(countdown)+ calendarObserver = NotificationCenter.default.addObserver(forName: LiveCalendarClient.changed, object: nil, queue: .main) { [weak self] _ in+ MainActor.assumeIsolated { self?.calendarChanged() }+ }setAccessibilityElement(true)setAccessibilityRole(.button)}required init?(coder: NSCoder) { fatalError() }+ deinit {+ if let o = calendarObserver { NotificationCenter.default.removeObserver(o) }+ }+override var isFlipped: Bool { true }override var mouseDownCanMoveWindow: Bool { false }@@ -1165,6 +1181,9 @@ final class FavoriteTileView: NSView, ArcTooltipTarget, NSDraggingSource {while favicons.count > m.cells.count { favicons.removeLast().removeFromSuperview() }// Arc 1.171: the open split's tile is one selected tile; the cut shows while it is closed.layer?.mask = m.cells.count > 1 && !m.selected ? cutMask : nil+ if let url = liveCalendarURL, let store = grid?.store {+ LiveCalendarClient.shared.watch(favorite: url, profilePath: store.profilePath(item: itemID))+ }refresh()}@@ -1195,6 +1214,10 @@ final class FavoriteTileView: NSView, ArcTooltipTarget, NSDraggingSource {for (f, c) in zip(favicons, m.cells) { f.show(c.icon, flip: c.icon != nil && c.glyphDark == dark, colors: faviconColors) }unreadDot.isHidden = !(m.unread && !m.selected)unreadDot.backgroundColor = (m.tileColor == nil ? colors.textPrimary : (dark ? NSColor.white : NSColor.black)).withAlphaComponent(0.6).cgColor+ let ink = (m.tileColor == nil ? colors.textPrimary : (dark ? NSColor.white : NSColor.black)).withAlphaComponent(0.7)+ countdown.string = countdownText.map { NSAttributedString(string: $0, attributes: [.font: NSFont.systemFont(ofSize: 9, weight: .semibold), .foregroundColor: ink]) }+ countdown.isHidden = countdownText == nil+ if countdownText != nil { unreadDot.isHidden = true }if m.focus != (focusRing != nil) {if m.focus {let r = FocusRingLayer(radius: FavoriteTileMetrics.corner)@@ -1231,6 +1254,7 @@ final class FavoriteTileView: NSView, ArcTooltipTarget, NSDraggingSource {cutMask.path = path}unreadDot.frame = CGRect(x: bounds.width - 5 - 6, y: 5, width: 6, height: 6)+ countdown.frame = CGRect(x: 4, y: 3, width: bounds.width - 9, height: 12)focusRing?.frame = boundsCATransaction.commit()}@@ -1262,7 +1286,7 @@ final class FavoriteTileView: NSView, ArcTooltipTarget, NSDraggingSource {hovering = truetrackPointer(event)if let url = previewURL, let store = grid?.store {- GmailPreviewCard.shared.hover(self, favoriteURL: url, profilePath: store.profilePath(item: itemID))+ FavoritePreviewCard.shared.hover(self, target: previewTarget(url, store: store))}}override func mouseMoved(with event: NSEvent) { trackPointer(event) }@@ -1270,17 +1294,62 @@ final class FavoriteTileView: NSView, ArcTooltipTarget, NSDraggingSource {hovering = falsehoveredCell = nilArcTooltipController.shared.mouseExited(self)- GmailPreviewCard.shared.leave(self)+ FavoritePreviewCard.shared.leave(self)}- /// A Gmail favorite with Previews on: Arc shows its unread mail instead of the name tooltip.+ /// A Gmail favorite with Previews on, or a Calendar favorite with Live Calendar's hover+ /// preview: Arc shows the card instead of the name tooltip, and none on the open tab.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 }+ guard let store = grid?.store, model?.selected != true, model?.cells.count == 1, let url = store.item(itemID)?.tab?.url else { return nil }+ if GmailPreview.feedURL(for: url) != nil { return store.settings.favoritePreviews ? url : nil }+ if CalendarPreview.isCalendar(url) { return store.settings.liveCalendar && store.settings.calendarHoverPreview ? url : nil }+ return nil+ }++ /// The favorite's Google Calendar address while Live Calendar is on for it.+ private var liveCalendarURL: String? {+ guard let store = grid?.store, store.settings.liveCalendar, let url = store.item(itemID)?.tab?.url,+ CalendarPreview.isCalendar(url) else { return nil }return url}- override func mouseDown(with event: NSEvent) { press = event }+ private var calendarEvents: [CalendarPreview.Event] {+ guard let url = liveCalendarURL, let store = grid?.store else { return [] }+ return LiveCalendarClient.shared.state(for: url, profilePath: store.profilePath(item: itemID))?.events ?? []+ }++ private var countdownText: String? {+ guard let store = grid?.store, store.settings.calendarTimeToNextMeeting, liveCalendarURL != nil else { return nil }+ return CalendarPreview.timeToNext(in: calendarEvents, now: Date())+ }++ private func previewTarget(_ url: String, store: SidebarStore) -> FavoritePreviewCard.Target {+ let id = itemID+ return FavoritePreviewCard.Target(+ favorite: url, profilePath: store.profilePath(item: id),+ open: { [weak self] u in self?.openInFavorite(u) },+ openNewTab: { [weak grid] u in grid?.actions.openURL(u) },+ disableLiveCalendar: { store.settings.liveCalendar = false })+ }++ /// A mail, event or new draft from the card: the favorite opens on it.+ private func openInFavorite(_ url: String) {+ guard let grid else { return }+ grid.store.selectTab(itemID, window: grid.ui.windowID)+ (window?.windowController as? MainWindowController)?.loadInSelectedTab(url)+ }++ private func calendarChanged() {+ guard liveCalendarURL != nil else { return }+ refresh()+ MeetingReminder.shared.update(tile: self, favorite: liveCalendarURL, events: calendarEvents,+ timing: grid?.store.settings.calendarMeetingLink ?? .twoMinutes) { [weak grid] in grid?.actions.openURL($0) }+ }++ override func mouseDown(with event: NSEvent) {+ FavoritePreviewCard.shared.cancel(self)+ press = event+ }override func mouseDragged(with event: NSEvent) {guard let p = press, let grid else { return }guard hypot(event.locationInWindow.x - p.locationInWindow.x, event.locationInWindow.y - p.locationInWindow.y) > 3 else { return }@@ -1364,6 +1433,10 @@ final class FavoriteTileView: NSView, ArcTooltipTarget, NSDraggingSource {let tileColor = item.tab?.tileColorlet m = NSMenu()m.autoenablesItems = false+ if let url = item.tab?.url, CalendarPreview.isCalendar(url) {+ Self.liveCalendarMenu(m, url: url, profilePath: store.profilePath(item: id), store: store)+ m.addItem(.separator())+ }MenuItems.add(m, action: "favoriteTab", title: Self.removeTitle(id, store)) { store.removeFromFavorites(id) }MenuItems.add(m, action: "renameTab", title: "Rename…") { ui.renamingID = id }if let t = item.tab, t.liveItemURL == nil {@@ -1407,6 +1480,35 @@ final class FavoriteTileView: NSView, ArcTooltipTarget, NSDraggingSource {return m}+ /// Arc 1.172.1's Live Calendar ▸ at the top of a Calendar favorite's menu: the last fetch,+ /// Refresh, then ✓Show Hover Preview, ✓Show Time to Next Meeting and Show Next Meeting Link ▸+ /// (Never … Ten Minutes Before). With Live Calendar off it offers to turn it back on.+ private static func liveCalendarMenu(_ m: NSMenu, url: String, profilePath: String?, store: SidebarStore) {+ let sub = MenuItems.submenu(m, "Live Calendar")+ m.items.last?.image = NSImage(systemSymbolName: "calendar", accessibilityDescription: nil)+ guard store.settings.liveCalendar else {+ MenuItems.add(sub, "Enable Live Calendar") { store.settings.liveCalendar = true }+ return+ }+ let state = LiveCalendarClient.shared.state(for: url, profilePath: profilePath)+ let status = state?.failed == true ? "Failed to update" : state?.signedOut == true ? "Not signed in" : CalendarPreview.lastFetch(state?.fetched, now: Date())+ MenuItems.add(sub, status, enabled: false) {}+ MenuItems.add(sub, "Refresh") { LiveCalendarClient.shared.refresh(favorite: url, profilePath: profilePath) }+ sub.addItem(.separator())+ MenuItems.add(sub, "Show Hover Preview", on: store.settings.calendarHoverPreview) { store.settings.calendarHoverPreview.toggle() }+ MenuItems.add(sub, "Show Time to Next Meeting", on: store.settings.calendarTimeToNextMeeting) {+ store.settings.calendarTimeToNextMeeting.toggle()+ NotificationCenter.default.post(name: LiveCalendarClient.changed, object: nil)+ }+ let link = MenuItems.submenu(sub, "Show Next Meeting Link")+ for t in CalendarPreview.LinkTiming.allCases {+ MenuItems.add(link, t.title, on: store.settings.calendarMeetingLink == t) {+ store.settings.calendarMeetingLink = t+ NotificationCenter.default.post(name: LiveCalendarClient.changed, object: nil)+ }+ }+ }+/// Shared favorites (#154) take Arc's words: Remove Favorite deletes the favorite.private static func removeTitle(_ id: UUID, _ store: SidebarStore) -> String {store.profileList(ofItem: id) == nil ? "Remove from Favorites" : "Remove Favorite"diff --git a/Tests/Scenarios/favorite-previews.scenario b/Tests/Scenarios/favorite-previews.scenarionew file mode 100644index 0000000..64aaec4--- /dev/null+++ b/Tests/Scenarios/favorite-previews.scenario@@ -0,0 +1,16 @@+# Arc's Previews beside a Gmail or Google Calendar favorite (docs/arc-parity.md "Previews, measured"):+# Gmail's card lists the unread mail, 84 pt rows to at most 270 pt with a +; with none it is Arc's+# "exhale" card. Calendar's card is today's 255 pt timeline with the gear and +.+budget rss=700 stalls50=10+cra://debug?gmailPreview=3+expect-log preview card shown: 238x254$+cra://debug?previewDismiss=1+cra://debug?gmailPreview=9+expect-log preview card shown: 238x270$+cra://debug?previewDismiss=1+cra://debug?gmailPreview=0+expect-log preview card shown: 240x6[0-9]$+cra://debug?previewDismiss=1+cra://debug?calendarPreview=1+expect-log preview card shown: 238x255$+cra://debug?previewDismiss=1diff --git a/docs/arc-parity.md b/docs/arc-parity.mdindex f68d7c6..d20671f 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… | 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. Arc shows the empty card when it has no mail to list, signed out too. Calendar not measured: the Victor space has no Google sign-in, so Arc has no events to preview. |-| Join Meeting ⌃⌘J | Shortcuts | missing | Needs Calendar previews, which need a space signed in to Google Calendar to measure. |+| Previews (Gmail, Calendar on Favorites) | Settings ▸ General ▸ Previews Settings…, a Calendar favorite's menu ▸ Live Calendar | done | Gmail: the unread mail from Gmail's Atom feed (the space's own sign-in) in Arc's card, rows, + and motion, measured on Victor's signed-in Arc 8 Nov. Calendar: Arc's timeline card, gear menu, Live Calendar ▸ submenu, tile countdown and meeting link; events read through Google's Calendar embed (Arc's own fetch says "Failed to update" in 1.172.1). See "Previews, measured". |+| Join Meeting ⌃⌘J | Shortcuts | done | The call on now, else the next one today, from a Live Calendar favorite. || 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: Gmail done, Tabs pane; Block Cookie Banners done, under Privacy) |+| General | (Previews: Gmail done, Tabs pane; Live Calendar in the Calendar favorite's menu, as in Arc; 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) |@@ -133,7 +133,12 @@ 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).+- Previews for a Gmail favorite: unread mail in Arc's card on hover (Settings ▸ Tabs); 8 Nov: Arc's full card+ (sender, age, subject, two lines, scrolling past 270 pt, + for a new mail, rows open the mail) and its motion.+- Live Calendar on a Google Calendar favorite (8 Nov, Victor's choice: a working version, as Arc's no longer reads):+ today's timeline on hover, the gear's Last fetch / Refresh / Disable Live Calendar, the favorite's Live Calendar ▸+ submenu (Show Hover Preview, Show Time to Next Meeting, Show Next Meeting Link ▸ Never … Ten Minutes Before), the+ tile's countdown, a Join card from two minutes before a call, and Join Meeting ⌃⌘J.- 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).@@ -170,6 +175,24 @@ in this sweep (Essential Shortcuts window, Library pages).Hide Developer Tools", and an arrow.clockwise "Refresh this Page" (Cra shows it for JS, which runs on load). Delete asks "Delete this Boost?" in Arc'sdialog. Reference captures: docs/screenshots/arc-boost-*.png.+## Previews, measured (Arc 1.172.1, Victor's signed-in Arc, 8 Nov 2026)++- Hovering a favorite that isn't the open tab shows the card about 0.25 s after the tile lights up (once the content is+ in hand; the first Gmail fetch took ~0.85 s); it grows from about 80 % and fades in over some 4 frames at 60 fps+ (opacity .21/.47/.76/.95/1). The pointer can move onto the card; once it has left tile and card, the card waits+ ~0.17 s and fades out, shrinking a little, over ~4 frames. Cra measured the same way: 0.28 s, .14/.29/.82/.97/1,+ 0.15 s (CraCore FavoritePreviewMotion).+- Gmail: 238 pt wide, at most 270 pt (the fourth row peeks), rows 84 pt with 1 pt lines, 11 pt insets; sender semibold+ 13 and its age ("50s", "1m", "3h"), subject 13, two grey lines 12; the pointer's row a lighter card 3 pt in; a 32 pt ++ 9.5 pt from the bottom right. The card refreshes in place when mail arrives.+- Calendar: 238 × 255 pt, an hour 42 pt with "8 AM" (English, whatever the Mac's clock) at the top left, the current+ hour's line 13 pt under the top, a cream now line with a dot from 42 pt in, a filled gear and a + at the bottom right.+ Gear: "Last fetch: Just now" (dimmed), Refresh, Disable Live Calendar. The favorite's menu starts with Live Calendar ▸:+ status, Refresh, ✓Show Hover Preview, ✓Show Time to Next Meeting, Show Next Meeting Link ▸ Never / On Start /+ ✓Two Minutes Before / Five / Ten. Arc's LiveCalendarClient (a hidden browser) says "Failed to update" for a calendar+ with events, so its event blocks, countdown and meeting link couldn't be seen: Cra's are its own, in the card's style.+ Cra reads the primary calendar the way Google's Calendar embed does (a hidden `calendar/u/<n>/embed` page asks the+ Calendar API through the page's own signed-in client), every 5 minutes and on hover when older than a minute.+## Left for later, and why-- Calendar previews and Join Meeting: Arc shows them for a Google Calendar favorite in a space signed in to Google; Victor's Arc has neither (checked 7 Nov: calendar.google.com shows the signed-out landing page). Signing in to his accounts is his to do.