Skip to content

armgit / cra

Public Imported from GitHub
0

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.

Settings ▸ Max, as Arc's: Tidy Tabs with its picture, and how to turn on Apple Intelligence

Victor3e9cc2b12896
diff --git a/Sources/Cra/App/AppDelegate.swift b/Sources/Cra/App/AppDelegate.swift
index bf61a7f..80415db 100644
--- a/Sources/Cra/App/AppDelegate.swift
+++ b/Sources/Cra/App/AppDelegate.swift
@@ -612,6 +612,12 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSMenuItemValidation {
// tidy: the divider's Tidy on the window's space, without hovering it; undoTidy: ⌘Z's.
if dict["tidy"] != nil { TidyTabsService.shared.tidy(store.focusedSpace(window: main.windowID).id, store: store); return }
if dict["undoTidy"] != nil { _ = store.undoTidy(); return }
+ // settingsPane=max: Settings opened on that pane.
+ if let p = dict["settingsPane"].flatMap(SettingsPane.init(rawValue:)) {
+ showSettingsWindow()
+ settingsController?.show(p)
+ return
+ }
// Scenario hooks (scripts/scenario.sh): what a journey needs without a pointer.
if dict["checkStore"] != nil { logSidebarProblems(); return }
// A main-thread stall of this many milliseconds, for the performance recorder's tests.
diff --git a/Sources/Cra/Services/TidyTabsService.swift b/Sources/Cra/Services/TidyTabsService.swift
index 4d285f6..b9fc60f 100644
--- a/Sources/Cra/Services/TidyTabsService.swift
+++ b/Sources/Cra/Services/TidyTabsService.swift
@@ -13,11 +13,39 @@ import FoundationModels
final class TidyTabsService {
static let shared = TidyTabsService()
- /// Whether the system model can run now. Read again when Cra comes to the front, so turning
- /// Apple Intelligence on in System Settings shows the button without a relaunch.
- private(set) var modelAvailable = false
- /// Why not, for Settings (nil while available).
- private(set) var unavailableReason: String? = "Needs macOS 26 and Apple Intelligence."
+ /// Where Apple Intelligence stands on this Mac, as Settings explains it.
+ enum Status: Equatable {
+ case available
+ /// Off in System Settings ▸ Apple Intelligence & Siri.
+ case off
+ /// On, with the model still downloading.
+ case preparing
+ /// An Intel Mac, or one Apple Intelligence doesn't support.
+ case ineligible
+ /// macOS 15 or earlier: no FoundationModels.
+ case needsNewerMacOS
+ case unavailable
+
+ /// What Settings ▸ Max says under its features.
+ var explanation: String {
+ switch self {
+ case .available: return "Max features run on Apple Intelligence on this Mac. Nothing is sent anywhere."
+ case .off: return "Max features run on Apple Intelligence, which is off on this Mac."
+ case .preparing: return "Apple Intelligence is still downloading. Max features turn on once it’s ready."
+ case .ineligible: return "Max features run on Apple Intelligence, which needs a Mac with Apple silicon."
+ case .needsNewerMacOS: return "Max features run on Apple Intelligence, which needs macOS 26 or later."
+ case .unavailable: return "Apple Intelligence isn’t available right now."
+ }
+ }
+
+ /// Whether System Settings can fix it.
+ var canOpenSettings: Bool { self == .off || self == .preparing || self == .unavailable }
+ }
+
+ /// Read again when Cra comes to the front and while Settings shows it, so turning Apple
+ /// Intelligence on in System Settings shows the button without a relaunch.
+ private(set) var status: Status = .needsNewerMacOS
+ var modelAvailable: Bool { status == .available }
@ObservationIgnored private var activation: NSObjectProtocol?
@@ -29,33 +57,39 @@ final class TidyTabsService {
}
func refresh() {
- // A test copy can stand in a fixed model (CRA_TIDY_FAKE_MODEL=1) where Apple Intelligence is off.
- if Self.fakeModel {
- set(available: true, reason: nil)
- return
+ let now = Self.currentStatus()
+ if now != status { status = now }
+ }
+
+ private static func currentStatus() -> Status {
+ // A test copy can stand in a fixed model (CRA_TIDY_FAKE_MODEL=1) where Apple Intelligence is off,
+ // or show Settings as a Mac without it would (=off, =preparing, =ineligible).
+ switch ProcessInfo.processInfo.environment["CRA_TIDY_FAKE_MODEL"] {
+ case "1": return .available
+ case "off": return .off
+ case "preparing": return .preparing
+ case "ineligible": return .ineligible
+ default: break
}
#if canImport(FoundationModels)
if #available(macOS 26.0, *) {
switch SystemLanguageModel.default.availability {
- case .available: set(available: true, reason: nil)
- case .unavailable(.appleIntelligenceNotEnabled):
- set(available: false, reason: "Turn on Apple Intelligence in System Settings to use it.")
- case .unavailable(.deviceNotEligible):
- set(available: false, reason: "This Mac can’t run Apple Intelligence.")
- case .unavailable(.modelNotReady):
- set(available: false, reason: "Apple Intelligence is still getting ready.")
- case .unavailable:
- set(available: false, reason: "Apple Intelligence isn’t available right now.")
+ case .available: return .available
+ case .unavailable(.appleIntelligenceNotEnabled): return .off
+ case .unavailable(.modelNotReady): return .preparing
+ case .unavailable(.deviceNotEligible): return .ineligible
+ case .unavailable: return .unavailable
}
- return
}
#endif
- set(available: false, reason: "Needs macOS 26 and Apple Intelligence.")
+ return .needsNewerMacOS
}
- private func set(available: Bool, reason: String?) {
- if modelAvailable != available { modelAvailable = available }
- if unavailableReason != reason { unavailableReason = reason }
+ /// System Settings ▸ Apple Intelligence & Siri (the Siri-Settings extension's pane).
+ static let systemSettingsURL = URL(string: "x-apple.systempreferences:com.apple.Siri-Settings.extension")!
+
+ func openSystemSettings() {
+ NSWorkspace.shared.open(Self.systemSettingsURL)
}
/// Whether the divider may show Tidy for this space now.
diff --git a/Sources/Cra/UI/Settings/MaxPane.swift b/Sources/Cra/UI/Settings/MaxPane.swift
new file mode 100644
index 0000000..fa69f9b
--- /dev/null
+++ b/Sources/Cra/UI/Settings/MaxPane.swift
@@ -0,0 +1,144 @@
+import AppKit
+import SwiftUI
+
+/// Arc's Max pane (Arc 1.171, Settings ▸ Max): one card, a row per feature with a picture in a
+/// white frame, its name, what it does and a switch, and a line under the card about where the
+/// data goes. Cra's features run on the Mac's own Apple Intelligence model, so that line says
+/// nothing leaves the Mac, or, while Apple Intelligence can't run, why and how to turn it on.
+struct MaxPane: View {
+ @Environment(SidebarStore.self) private var store
+ private var service: TidyTabsService { TidyTabsService.shared }
+
+ var body: some View {
+ @Bindable var store = store
+ let available = service.status == .available
+ SettingsCardPane {
+ MaxCard {
+ MaxFeatureRow(title: "Tidy Tabs", isOn: $store.settings.tidyTabs, enabled: available) {
+ TidyTabsPicture()
+ } description: {
+ Text("Press the \(Image(nsImage: BroomGlyph.image).renderingMode(.template)) icon to let your Sidebar organize itself whenever you have six or more Today Tabs.")
+ }
+ }
+ MaxFooter(status: service.status) { service.openSystemSettings() }
+ .padding(.top, 14)
+ }
+ // Coming back from System Settings brings Cra to the front, which reads the status again;
+ // a model still downloading gets there without that.
+ .task {
+ while !Task.isCancelled {
+ service.refresh()
+ try? await Task.sleep(for: .seconds(3))
+ }
+ }
+ }
+}
+
+/// The card around Max's rows: a hairline border on a lighter fill, rows split by hairlines.
+struct MaxCard<Content: View>: View {
+ @ViewBuilder let content: Content
+ @Environment(\.colorScheme) private var scheme
+
+ var body: some View {
+ VStack(spacing: 0) { content }
+ .frame(maxWidth: .infinity)
+ .background(RoundedRectangle(cornerRadius: SettingsMetrics.cardCorner, style: .continuous)
+ .fill(scheme == .dark ? Color.white.opacity(0.04) : Color.white.opacity(0.6)))
+ .overlay(RoundedRectangle(cornerRadius: SettingsMetrics.cardCorner, style: .continuous)
+ .strokeBorder(Color.primary.opacity(0.1), lineWidth: 1))
+ }
+}
+
+/// One Max feature: picture, name over description, switch. Off while Apple Intelligence can't run.
+struct MaxFeatureRow<Picture: View, Description: View>: View {
+ let title: String
+ @Binding var isOn: Bool
+ var enabled = true
+ @ViewBuilder let picture: Picture
+ @ViewBuilder let description: Description
+
+ var body: some View {
+ HStack(alignment: .center, spacing: 14) {
+ MaxPictureFrame { picture }
+ VStack(alignment: .leading, spacing: 4) {
+ Text(title).font(.system(size: 14))
+ description
+ .font(.system(size: 12)).foregroundStyle(.secondary)
+ .fixedSize(horizontal: false, vertical: true)
+ }
+ Spacer(minLength: 8)
+ Toggle(title, isOn: Binding(get: { isOn && enabled }, set: { isOn = $0 }))
+ .toggleStyle(.switch).labelsHidden()
+ .disabled(!enabled)
+ }
+ .padding(10)
+ }
+}
+
+/// Arc frames each picture in white: 3 pt round a tile with 6 pt corners.
+private struct MaxPictureFrame<Content: View>: View {
+ @ViewBuilder let content: Content
+ var body: some View {
+ content
+ .frame(width: 88, height: 56)
+ .clipShape(RoundedRectangle(cornerRadius: 5, style: .continuous))
+ .padding(3)
+ .background(RoundedRectangle(cornerRadius: 8, style: .continuous).fill(Color.white))
+ .accessibilityHidden(true)
+ }
+}
+
+/// Under the card, where Arc says Max sends data to its AI partners: what runs where, or why it
+/// can't and the way to System Settings ▸ Apple Intelligence & Siri.
+private struct MaxFooter: View {
+ let status: TidyTabsService.Status
+ let openSettings: () -> Void
+
+ var body: some View {
+ VStack(spacing: 3) {
+ Text(status.explanation)
+ .font(.system(size: 12)).foregroundStyle(.secondary)
+ .multilineTextAlignment(.center)
+ .fixedSize(horizontal: false, vertical: true)
+ if status.canOpenSettings {
+ Button(action: openSettings) {
+ Text("Turn on Apple Intelligence in System Settings").font(.system(size: 12)).underline()
+ }
+ .buttonStyle(.link)
+ }
+ }
+ .frame(maxWidth: .infinity)
+ }
+}
+
+/// Arc's Tidy Tabs picture: the squiggle, the broom and a ✕ on lavender.
+private struct TidyTabsPicture: View {
+ private let ink = Color(red: 0.55, green: 0.52, blue: 0.72)
+ var body: some View {
+ ZStack {
+ Color(red: 0.84, green: 0.82, blue: 0.96)
+ HStack(spacing: 5) {
+ Squiggle()
+ .stroke(Color(red: 0.70, green: 0.67, blue: 0.90), style: StrokeStyle(lineWidth: 1.1, lineCap: .round))
+ .frame(width: 40, height: 5)
+ Image(nsImage: BroomGlyph.image).renderingMode(.template).foregroundStyle(ink)
+ Image(systemName: "xmark").font(.system(size: 9, weight: .semibold)).foregroundStyle(ink)
+ }
+ .offset(x: -2)
+ }
+ }
+}
+
+private struct Squiggle: Shape {
+ func path(in r: CGRect) -> Path {
+ var p = Path()
+ let period: CGFloat = 9
+ p.move(to: CGPoint(x: r.minX, y: r.midY))
+ var x: CGFloat = 0
+ while x <= r.width {
+ p.addLine(to: CGPoint(x: r.minX + x, y: r.midY + r.height / 2 * sin(2 * .pi * x / period)))
+ x += 0.5
+ }
+ return p
+ }
+}
diff --git a/Sources/Cra/UI/Settings/SettingsWindowController.swift b/Sources/Cra/UI/Settings/SettingsWindowController.swift
index 8a618a8..8ebe44f 100644
--- a/Sources/Cra/UI/Settings/SettingsWindowController.swift
+++ b/Sources/Cra/UI/Settings/SettingsWindowController.swift
@@ -12,15 +12,17 @@ struct SettingsActions {
/// The panes in Dia's Settings sidebar (Dia 1.54.2: Account, Tabs, Privacy, Profiles, Skills,
/// Apps, Shortcuts, Advanced). Cra has no account or AI skills/apps; General
-/// (system integration) and Extensions take rows instead.
+/// (system integration) and Extensions take rows instead. Max is Arc's Max pane, for the
+/// features Cra runs on the Mac's own Apple Intelligence model.
enum SettingsPane: String, CaseIterable, Identifiable {
- case general, tabs, privacy, profiles, extensions, shortcuts, performance, advanced
+ case general, tabs, max, privacy, profiles, extensions, shortcuts, performance, advanced
var id: String { rawValue }
var title: String {
switch self {
case .general: return "General"
case .tabs: return "Tabs"
+ case .max: return "Max"
case .privacy: return "Privacy"
case .profiles: return "Profiles"
case .extensions: return "Extensions"
@@ -35,6 +37,8 @@ enum SettingsPane: String, CaseIterable, Identifiable {
switch self {
case .general: return "gearshape"
case .tabs: return "square.on.square"
+ // macOS 15.1 added Apple's mark; before it, sparkles.
+ case .max: return NSImage(systemSymbolName: "apple.intelligence", accessibilityDescription: nil) != nil ? "apple.intelligence" : "sparkles"
case .privacy: return "hand.raised"
case .profiles: return "person"
case .extensions: return "puzzlepiece.extension"
@@ -83,6 +87,8 @@ final class SettingsNavigation {
final class SettingsWindowController: NSWindowController, NSToolbarDelegate {
private let nav = SettingsNavigation()
+ func show(_ pane: SettingsPane) { nav.show(pane) }
+
init(store: SidebarStore, bindings: KeyBindingRegistry, actions: SettingsActions) {
let window = NSWindow(contentRect: NSRect(origin: .zero, size: SettingsMetrics.windowSize),
styleMask: [.titled, .closable, .fullSizeContentView], backing: .buffered, defer: false)
@@ -238,6 +244,7 @@ struct SettingsContent: View {
switch nav.pane {
case .general: GeneralPane()
case .tabs: TabsPane()
+ case .max: MaxPane()
case .privacy: PrivacyPane(actions: actions)
case .profiles: ProfilesPane(actions: actions)
case .extensions: ExtensionsPane(actions: actions)
diff --git a/Sources/Cra/UI/Settings/TabsPane.swift b/Sources/Cra/UI/Settings/TabsPane.swift
index fe82cfe..a16d25b 100644
--- a/Sources/Cra/UI/Settings/TabsPane.swift
+++ b/Sources/Cra/UI/Settings/TabsPane.swift
@@ -71,12 +71,6 @@ struct TabsPane: View {
isOn: $store.settings.tabSleepOnMemoryPressure)
Text(tabSleepNote).font(.system(size: 11)).foregroundStyle(.secondary)
.fixedSize(horizontal: false, vertical: true)
- // Arc Max's Tidy Tabs, on the Mac's own model.
- SettingsCheckbox(title: "Show Tidy to sort Today tabs into groups", isOn: $store.settings.tidyTabs)
- .disabled(!tidy.modelAvailable)
- Text(tidy.unavailableReason ?? "Uses Apple Intelligence on this Mac. Nothing leaves it.")
- .font(.system(size: 11)).foregroundStyle(.secondary)
- .fixedSize(horizontal: false, vertical: true)
}
}
.sheet(isPresented: $showsAirTrafficControl) {
@@ -85,7 +79,6 @@ struct TabsPane: View {
}
@State private var showsAirTrafficControl = false
- private var tidy: TidyTabsService { TidyTabsService.shared }
/// Says what a forced-out tab costs, and which tabs stay, before the user finds out.
private var tabSleepNote: String {
diff --git a/docs/development.md b/docs/development.md
index 8b36dd1..c518874 100644
--- a/docs/development.md
+++ b/docs/development.md
@@ -157,8 +157,10 @@ Measure them with `sample <pid> 6 1` and compare the main thread's busy time bet
Tidy Tabs needs Apple Intelligence. `CRA_TIDY_FAKE_MODEL=1` stands in a model that groups by
site (after a 1.6 s pause), so a test instance on any Mac shows the button, the squiggle and the
-groups; `cra://debug?tidy=1` runs Tidy on the window's space without hovering the divider and
-`cra://debug?undoTidy=1` is ⌘Z's undo.
+groups; `CRA_TIDY_FAKE_MODEL=off` (or `preparing`, `ineligible`) shows Settings ▸ Max as a Mac
+without Apple Intelligence would. `cra://debug?tidy=1` runs Tidy on the window's space without
+hovering the divider, `cra://debug?undoTidy=1` is ⌘Z's undo and `cra://debug?settingsPane=max`
+opens Settings on a pane.
`cra://debug?menuAt=315,24` opens the menu a click at that window point would open (the
developer-mode ⌄ here), and `&button=right` the context menu, a tab row's for instance.