A tiny friend in your Mac's notch and on your iPhone that keeps an eye on your AI coding agents: Claude Code, Codex, Cursor, Gemini CLI, Antigravity and more. Approve from the notch or your Lock Screen.
Swift ai-agentsanthropicantigravityclaudeclaude-codecodexcursordynamic-islandgemini-cliiosiphonlinuxmacosmacos-appmenubar-appnotchopen-sourceswiftswiftuiwindows
Settings search in the Coucou window
Claudee3c821b7b2dc
diff --git a/.github/workflows/build.yml b/.github/workflows/build.ymlindex 65abf50d..95d48041 100644--- a/.github/workflows/build.yml+++ b/.github/workflows/build.yml@@ -51,6 +51,9 @@ jobs:- name: Test Mail triage (rules, banned words, VIPs, search)run: bash scripts/test-mail-triage.sh+ - name: Test the settings search (accents, words, labels)+ run: bash scripts/test-settings-search.sh+- name: Test Flow dictation keysrun: bash scripts/test-flow-keys.shdiff --git a/NotchBuddy/Resources/Localizable.xcstrings b/NotchBuddy/Resources/Localizable.xcstringsindex 66f7b1aa..4dc6df79 100644--- a/NotchBuddy/Resources/Localizable.xcstrings+++ b/NotchBuddy/Resources/Localizable.xcstrings@@ -35036,6 +35036,208 @@}}},+ "hub.search.placeholder" : {+ "extractionState" : "manual",+ "localizations" : {+ "ar" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "البحث في الإعدادات"+ }+ },+ "bn" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "সেটিংস খুঁজুন"+ }+ },+ "de" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Einstellungen suchen"+ }+ },+ "en" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Search settings"+ }+ },+ "es" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Buscar un ajuste"+ }+ },+ "fr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Rechercher un réglage"+ }+ },+ "hi" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "सेटिंग खोजें"+ }+ },+ "id" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Cari pengaturan"+ }+ },+ "ja" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "設定を検索"+ }+ },+ "ko" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "설정 검색"+ }+ },+ "pt-BR" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Buscar ajustes"+ }+ },+ "ru" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Поиск настроек"+ }+ },+ "th" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "ค้นหาการตั้งค่า"+ }+ },+ "tr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Ayarlarda ara"+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "搜索设置"+ }+ },+ "zh-Hant" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "搜尋設定"+ }+ }+ }+ },+ "hub.search.none" : {+ "extractionState" : "manual",+ "localizations" : {+ "ar" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "لم يُعثر على أي إعداد"+ }+ },+ "bn" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "কোনো সেটিং পাওয়া যায়নি"+ }+ },+ "de" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Keine Einstellung gefunden"+ }+ },+ "en" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "No setting found"+ }+ },+ "es" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Ningún ajuste encontrado"+ }+ },+ "fr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Aucun réglage trouvé"+ }+ },+ "hi" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "कोई सेटिंग नहीं मिली"+ }+ },+ "id" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Pengaturan tidak ditemukan"+ }+ },+ "ja" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "該当する設定はありません"+ }+ },+ "ko" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "찾은 설정이 없어요"+ }+ },+ "pt-BR" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Nenhum ajuste encontrado"+ }+ },+ "ru" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Настройка не найдена"+ }+ },+ "th" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "ไม่พบการตั้งค่า"+ }+ },+ "tr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Ayar bulunamadı"+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "未找到设置"+ }+ },+ "zh-Hant" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "找不到設定"+ }+ }+ }+ },"hub.section.notch" : {"extractionState" : "manual","localizations" : {diff --git a/NotchBuddy/Sources/App/FlowHub.swift b/NotchBuddy/Sources/App/FlowHub.swiftindex 7489572d..26af1479 100644--- a/NotchBuddy/Sources/App/FlowHub.swift+++ b/NotchBuddy/Sources/App/FlowHub.swift@@ -264,6 +264,7 @@ struct FlowHubView: View {private struct HubSidebar: View {@ObservedObject var router: HubRouter@ObservedObject private var flow = FlowDictation.shared+ @ObservedObject private var search = SettingsSearch.sharedvar body: some View {VStack(alignment: .leading, spacing: 3) {@@ -278,23 +279,30 @@ private struct HubSidebar: View {.padding(.horizontal, 8)// Halfway between the window's buttons and "FLOW"..padding(.top, 25)- .padding(.bottom, 31)+ .padding(.bottom, 16)++ HubSearchField()+ .padding(.bottom, 14)ScrollView {- VStack(alignment: .leading, spacing: 2) {- HubSidebarHeader(text: "Flow")- ForEach(HubPage.flowPages) { page in- HubSidebarItem(page: page, selected: router.page == page) { router.page = page }- }- HubSidebarHeader(text: String(localized: "hub.section.notch"))- .padding(.top, 14)- ForEach(HubPage.notchPages) { page in- HubSidebarItem(page: page, selected: router.page == page) { router.page = page }- }- HubSidebarHeader(text: "Mail")- .padding(.top, 14)- ForEach(HubPage.mailPages) { page in- HubSidebarItem(page: page, selected: router.page == page) { router.page = page }+ if !search.query.trimmingCharacters(in: .whitespaces).isEmpty {+ HubSearchResults(router: router)+ } else {+ VStack(alignment: .leading, spacing: 2) {+ HubSidebarHeader(text: "Flow")+ ForEach(HubPage.flowPages) { page in+ HubSidebarItem(page: page, selected: router.page == page) { router.page = page }+ }+ HubSidebarHeader(text: String(localized: "hub.section.notch"))+ .padding(.top, 14)+ ForEach(HubPage.notchPages) { page in+ HubSidebarItem(page: page, selected: router.page == page) { router.page = page }+ }+ HubSidebarHeader(text: "Mail")+ .padding(.top, 14)+ ForEach(HubPage.mailPages) { page in+ HubSidebarItem(page: page, selected: router.page == page) { router.page = page }+ }}}}@@ -403,17 +411,20 @@ struct HubPageScaffold<Trailing: View, Content: View>: View {@Environment(\.hubPage) private var pagevar body: some View {- ScrollView {- VStack(alignment: .leading, spacing: 22) {- HubHero(page: page, title: title, subtitle: subtitle, trailing: trailing)- content()+ ScrollViewReader { proxy in+ ScrollView {+ VStack(alignment: .leading, spacing: 22) {+ HubHero(page: page, title: title, subtitle: subtitle, trailing: trailing)+ content()+ }+ .padding(.horizontal, 28)+ .padding(.top, 24)+ .padding(.bottom, 28)+ .frame(maxWidth: 1100, alignment: .leading)}- .padding(.horizontal, 28)- .padding(.top, 24)- .padding(.bottom, 28)- .frame(maxWidth: 1100, alignment: .leading)+ .scrollIndicators(.automatic)+ .settingsSearchScroll(proxy)}- .scrollIndicators(.automatic)}}diff --git a/NotchBuddy/Sources/App/FlowHubSettings.swift b/NotchBuddy/Sources/App/FlowHubSettings.swiftindex ac9b49d8..3d072a09 100644--- a/NotchBuddy/Sources/App/FlowHubSettings.swift+++ b/NotchBuddy/Sources/App/FlowHubSettings.swift@@ -14,6 +14,7 @@ struct HubSettingsPage: View {var body: some View {HubPageScaffold(title: String(localized: "hub.page.settings")) {HubLabel(String(localized: "hub.settings.keys"))+ .settingsHeading("flow.keys")HubCard {HubRow(title: String(localized: "flow.enable")) {Toggle("", isOn: $flow.isEnabled).toggleStyle(.switch).labelsHidden()@@ -51,8 +52,10 @@ struct HubSettingsPage: View {HubKeyCap(text: String(localized: "hub.key-esc"))}}+ .settingsAnchor("flow.keys", cornerRadius: 14)HubLabel(String(localized: "flow.ai.title"))+ .settingsHeading("flow.ai")HubCard {HubRow(title: String(localized: "flow.prompt-mode"), detail: String(localized: "flow.prompt-mode-detail")) {Toggle("", isOn: $store.promptMode)@@ -94,8 +97,10 @@ struct HubSettingsPage: View {.foregroundColor(HubTheme.secondary).fixedSize(horizontal: false, vertical: true)}+ .settingsAnchor("flow.ai", cornerRadius: 14)HubLabel(String(localized: "hub.settings.permission"))+ .settingsHeading("flow.permission")HubCard {if flow.trusted {Label(String(localized: "flow.access-ok"), systemImage: "checkmark.circle.fill")@@ -110,13 +115,17 @@ struct HubSettingsPage: View {.buttonStyle(HubButtonStyle(primary: true))}}+ .settingsAnchor("flow.permission", cornerRadius: 14)HubLabel(String(localized: "hub.settings.recognition"))+ .settingsHeading("flow.recognition")HubCard {HubRecognitionSettings(language: $language)}+ .settingsAnchor("flow.recognition", cornerRadius: 14)HubLabel(String(localized: "hub.page.notes"))+ .settingsHeading("flow.summary")HubCard {HubSummaryEnginePicker()Text("notes.engine-detail")@@ -129,8 +138,10 @@ struct HubSettingsPage: View {.foregroundColor(HubTheme.secondary).fixedSize(horizontal: false, vertical: true)}+ .settingsAnchor("flow.summary", cornerRadius: 14)HubLabel(String(localized: "hub.settings.app"))+ .settingsHeading("flow.app")HubCard {HubRow(title: String(localized: "hub.settings.dock"), detail: String(localized: "hub.settings.dock-detail")) {Toggle("", isOn: Binding(get: { showInDock }, set: { showInDock = $0; FlowHubController.showInDock = $0 }))@@ -144,8 +155,10 @@ struct HubSettingsPage: View {.labelsHidden()}}+ .settingsAnchor("flow.app", cornerRadius: 14)HubLabel(String(localized: "hub.settings.privacy"))+ .settingsHeading("flow.privacy")HubCard {HubRow(title: String(localized: "hub.settings.keep")) {Picker("", selection: $store.keepDays) {@@ -170,6 +183,7 @@ struct HubSettingsPage: View {.foregroundColor(HubTheme.secondary).fixedSize(horizontal: false, vertical: true)}+ .settingsAnchor("flow.privacy", cornerRadius: 14)}.onAppear { flow.recheckTrust() }.alert(String(localized: "hub.settings.clear-all-confirm"), isPresented: $confirmClear) {diff --git a/NotchBuddy/Sources/App/MailHubPages.swift b/NotchBuddy/Sources/App/MailHubPages.swiftindex 227ec568..8dcb5b11 100644--- a/NotchBuddy/Sources/App/MailHubPages.swift+++ b/NotchBuddy/Sources/App/MailHubPages.swift@@ -47,6 +47,7 @@ struct HubMailOverviewPage: View {}}}+ .settingsAnchor("mail.autosort", cornerRadius: 14)let today = store.todayHStack(spacing: 12) {diff --git a/NotchBuddy/Sources/App/SettingsSearch.swift b/NotchBuddy/Sources/App/SettingsSearch.swiftnew file mode 100644index 00000000..08f57e48--- /dev/null+++ b/NotchBuddy/Sources/App/SettingsSearch.swift@@ -0,0 +1,332 @@+import SwiftUI++#if !APPSTORE++// Search in the Coucou window: every setting of Flow, the notch and Mail, by its words in+// the app's language. A result opens its page, scrolls to its box and makes it glow.+//+// The index lists each box (a GroupBox of Settings, a card of a Flow or Mail page) with the+// labels inside it, by their catalog keys: what is searched is exactly what is shown. A box+// is found by its anchor (`.settingsAnchor("…")` on the view).++struct SettingsSearchEntry: Identifiable, Sendable {+ /// The box's anchor, unique.+ let id: String+ let page: HubPage+ /// The box's title (a catalog key, or a name that is never translated).+ let title: String+ /// The labels inside the box (catalog keys).+ let terms: [String]+}++/// A result: the box, and the label that matched when it isn't the title.+struct SettingsSearchHit: Identifiable {+ let entry: SettingsSearchEntry+ let label: String?+ var id: String { entry.id + "|" + (label ?? "") }+}++@MainActor+final class SettingsSearch: ObservableObject {+ static let shared = SettingsSearch()++ @Published var query = ""+ /// The box to show, and a fresh token each time it is asked (the same box twice glows twice).+ @Published private(set) var target: String?+ @Published private(set) var token = UUID()+ /// The last box opened from the results (its row stays selected).+ @Published private(set) var shown: String?++ /// The words of the app's language for a key (names stay as they are).+ nonisolated static func text(_ key: String) -> String {+ NSLocalizedString(key, comment: "")+ }++ func results() -> [SettingsSearchHit] {+ let words = SettingsSearchMatch.words(query)+ guard !words.isEmpty else { return [] }+ // The boxes named by the words first, then the settings inside the others.+ var boxes: [SettingsSearchHit] = []+ var labels: [SettingsSearchHit] = []+ for entry in Self.entries {+ switch SettingsSearchMatch.match(words, title: Self.text(entry.title), page: entry.page.title,+ labels: entry.terms.map(Self.text)) {+ case .box?: boxes.append(SettingsSearchHit(entry: entry, label: nil))+ case .label(let label)?: labels.append(SettingsSearchHit(entry: entry, label: label))+ case nil: break+ }+ }+ return Array((boxes + labels).prefix(30))+ }++ /// Opens the box's page; the page scrolls to the box and makes it glow.+ func reveal(_ entry: SettingsSearchEntry) {+ FlowHubController.shared.router.page = entry.page+ target = entry.id+ shown = entry.id+ let mine = UUID()+ token = mine+ // Once shown, the box is no longer asked for: coming back to its page later doesn't+ // scroll or glow again.+ DispatchQueue.main.asyncAfter(deadline: .now() + 2.5) { [weak self] in+ guard let self, self.token == mine else { return }+ self.target = nil+ }+ }++ // MARK: - The index++ static let entries: [SettingsSearchEntry] = {+ func e(_ id: String, _ page: HubPage, _ title: String, _ terms: [String] = []) -> SettingsSearchEntry {+ SettingsSearchEntry(id: id, page: page, title: title, terms: terms)+ }+ var list = [+ // Flow+ e("flow.history", .dictation, "hub.history", ["hub.page.dictation"]),+ e("flow.notes", .notes, "hub.page.notes", ["notes.live", "notes.key-points"]),+ e("flow.insights", .insights, "hub.page.insights"),+ e("flow.dictionary", .dictionary, "hub.page.dictionary", ["hub.replacements"]),+ e("flow.snippets", .snippets, "hub.page.snippets"),+ e("flow.styles", .styles, "hub.page.styles", ["hub.cleanup", "hub.style-default", "hub.style-apps"]),+ e("flow.keys", .settings, "hub.settings.keys",+ ["flow.enable", "hub.settings.hold", "flow.edge", "hub.settings.handsfree", "hub.settings.paste-again", "hub.settings.cancel"]),+ e("flow.ai", .settings, "flow.ai.title", ["flow.prompt-mode", "flow.translate"]),+ e("flow.permission", .settings, "hub.settings.permission", ["flow.accessibility-open"]),+ e("flow.recognition", .settings, "hub.settings.recognition", ["Dictation language"]),+ e("flow.summary", .settings, "hub.page.notes", ["notes.engine"]),+ e("flow.app", .settings, "hub.settings.app", ["hub.settings.dock", "hub.settings.open-at-launch"]),+ e("flow.privacy", .settings, "hub.settings.privacy", ["hub.settings.keep"]),+ // Notch → General+ e("general.demo", .general, "demo.groupbox.title"),+ e("general.sound", .general, "Sound", ["Enable sounds", "Volume", "Open sounds folder", "Reload sounds"]),+ e("general.behavior", .general, "Behavior", ["Open on hover", "Close after", "Hide after", "alerts.all-pills"]),+ e("general.display", .general, "Display", ["Show Mochi on", "Screen with the notch", "Main screen (menu bar)", "Follow the mouse"]),+ e("general.vitals", .general, "vitals.title", ["vitals.toggle"]),+ e("general.hotkey", .general, "Hotkey", ["Show island with shortcut", "Shortcut"]),+ e("general.startup", .general, "Startup", ["Launch at Mac startup"]),+ e("general.update", .general, "update.settings.title"),+ e("general.recap", .general, "Weekly recap",+ ["Keep a history of my coding sessions", "Hide project names in shared images", "Clear history"]),+ e("general.language", .general, "Language", ["Restart Coucou"]),+ e("general.iphone", .general, "iPhone", ["iphone.sync.toggle", "iphone.live-activity.toggle", "iphone.instruction.toggle"]),+ // Notch → Active pills, Agents, Chat, Integrations+ e("pills.main", .pills, "settings.main-pill", ["Active pills"]),+ e("agents.claude", .agents, "hooks.claude-code.title",+ ["Answer questions and permissions from terminal sessions in the notch"]),+ e("agents.claude-desktop", .agents, "claude-desktop.chat.title"),+ e("agents.gemini", .agents, "hooks.gemini.title"),+ e("agents.antigravity", .agents, "hooks.antigravity.title"),+ e("agents.codex", .agents, "hooks.codex.title"),+ e("agents.copilot", .agents, "hooks.copilot.title"),+ e("agents.muse", .agents, "hooks.muse.title"),+ e("agents.opencode", .agents, "plugin.opencode.title"),+ e("agents.amp", .agents, "plugin.amp.title"),+ e("agents.hermes", .agents, "plugin.hermes.title", ["plugin.hermes.approvals"]),+ e("agents.plan", .agents, "plan.title", ["plan.show-in-notch", "Show Codex plan in the notch"]),+ e("chat.subscriptions", .chat, "chat.subscriptions.title", ["chat.subscriptions.use"]),+ e("chat.anthropic", .chat, "chat.anthropic-api.title", ["chat.model", "Anthropic", "Claude"]),+ e("chat.others", .chat, "chat.other-providers.title", ["Google AI", "OpenAI", "DeepSeek", "Gemini"]),+ e("chat.local", .chat, "chat.local.title", ["Ollama", "LM Studio"]),+ e("integrations.all", .integrations, "Integrations",+ ["Stripe", "GitHub", "Vercel", "n8n", "Notion", "Resend", "Cal.com", "WhatsApp", "Spotify", "Crypto",+ "crypto.exchange", "crypto.currency"]),+ // Notch → Voice, Shortcuts+ e("voice.wake", .voice, "«\u{202F}OK Coucou\u{202F}» — voice wake word", ["Enable voice command", "Request permissions"]),+ e("voice.language", .voice, "Language", ["voice.listen-language", "voice.language"]),+ e("voice.tts", .voice, "voice.tts-engine", ["voice.tts-gender", "voice.tts-test"]),+ e("voice.history", .voice, "voice.history-title"),+ e("shortcuts.global", .shortcuts, "shortcut.group.global"),+ e("shortcuts.island", .shortcuts, "shortcut.group.island"),+ e("mail.autosort", .mailOverview, "hub.mail.autosort", ["hub.mail.journal", "hub.mail.sent", "hub.mail.undo"]),+ e("mail.rules", .mailRules, "hub.mail.rules", ["hub.mail.field.sender", "hub.mail.field.subject", "hub.mail.do.junk"]),+ e("mail.banned", .mailBanned, "hub.mail.banned"),+ e("mail.vip", .mailVIP, "hub.mail.vip"),+ ]+ #if !PHONE_LINK+ list.removeAll { $0.id == "general.iphone" }+ #endif+ return list+ }()+}++// MARK: - Anchors++private struct SettingsAnchor: ViewModifier {+ let anchor: String+ let cornerRadius: CGFloat+ @ObservedObject private var search = SettingsSearch.shared+ @State private var glow = false++ func body(content: Content) -> some View {+ content+ .id(anchor)+ .overlay(+ RoundedRectangle(cornerRadius: cornerRadius, style: .continuous)+ .stroke(HubTheme.accent, lineWidth: 2)+ .shadow(color: HubTheme.accent.opacity(0.6), radius: 8)+ .opacity(glow ? 1 : 0)+ .allowsHitTesting(false)+ )+ .onChange(of: search.token) { _, _ in flashIfMine() }+ .onAppear { flashIfMine() }+ }++ private func flashIfMine() {+ guard search.target == anchor else { return }+ withAnimation(.easeOut(duration: 0.25).delay(0.25)) { glow = true }+ DispatchQueue.main.asyncAfter(deadline: .now() + 1.9) {+ withAnimation(.easeIn(duration: 0.6)) { glow = false }+ }+ }+}++/// Scrolls a page's ScrollView to the box the search asked for.+private struct SettingsSearchScroller: ViewModifier {+ let proxy: ScrollViewProxy+ @ObservedObject private var search = SettingsSearch.shared++ func body(content: Content) -> some View {+ content+ .onChange(of: search.token) { _, _ in scroll() }+ .onAppear { scroll() }+ }++ private func scroll() {+ guard let target = search.target else { return }+ // After the page is laid out.+ DispatchQueue.main.asyncAfter(deadline: .now() + 0.12) {+ withAnimation(.easeInOut(duration: 0.35)) {+ proxy.scrollTo(target, anchor: .top)+ // A card with its title above it: the title too (a no-op where there is none).+ proxy.scrollTo(target + "#label", anchor: .top)+ }+ }+ }+}++// MARK: - The sidebar's field and results++struct HubSearchField: View {+ @ObservedObject private var search = SettingsSearch.shared+ @FocusState private var focused: Bool++ var body: some View {+ HStack(spacing: 7) {+ Image(systemName: "magnifyingglass")+ .font(.system(size: 12, weight: .medium))+ .foregroundColor(HubTheme.muted)+ TextField(String(localized: "hub.search.placeholder"), text: $search.query)+ .textFieldStyle(.plain)+ .font(.system(size: 13))+ .focused($focused)+ .onExitCommand { search.query = "" }+ // Return opens the first result.+ .onSubmit { if let first = search.results().first { search.reveal(first.entry) } }+ if !search.query.isEmpty {+ Button { search.query = "" } label: {+ Image(systemName: "xmark.circle.fill")+ .font(.system(size: 11))+ .foregroundColor(HubTheme.muted)+ }+ .buttonStyle(.plain)+ .help(String(localized: "Close"))+ }+ }+ .padding(.horizontal, 10)+ .frame(height: 32)+ .background(RoundedRectangle(cornerRadius: 9).fill(HubTheme.card))+ .overlay(RoundedRectangle(cornerRadius: 9).strokeBorder(focused ? HubTheme.accent.opacity(0.6) : Color.white.opacity(0.07)))+ }+}++/// What the search found, in place of the pages while something is typed.+struct HubSearchResults: View {+ @ObservedObject private var search = SettingsSearch.shared+ @ObservedObject var router: HubRouter++ var body: some View {+ let hits = search.results()+ VStack(alignment: .leading, spacing: 2) {+ if hits.isEmpty {+ Text("hub.search.none")+ .font(.system(size: 12.5))+ .foregroundColor(HubTheme.muted)+ .padding(.horizontal, 10)+ .padding(.top, 6)+ }+ ForEach(hits) { hit in+ HubSearchRow(hit: hit, selected: search.shown == hit.entry.id && router.page == hit.entry.page) {+ search.reveal(hit.entry)+ }+ }+ }+ }+}++private struct HubSearchRow: View {+ let hit: SettingsSearchHit+ let selected: Bool+ let action: () -> Void+ @State private var hover = false++ var body: some View {+ Button(action: action) {+ HStack(alignment: .top, spacing: 10) {+ Image(systemName: hit.entry.page.symbol)+ .font(.system(size: 13, weight: .medium))+ .frame(width: 20)+ .padding(.top, 1)+ VStack(alignment: .leading, spacing: 2) {+ Text(hit.label ?? SettingsSearch.text(hit.entry.title))+ .font(.system(size: 13, weight: .medium))+ .foregroundColor(HubTheme.text)+ .lineLimit(2)+ .multilineTextAlignment(.leading)+ Text(hit.label == nil+ ? hit.entry.page.title+ : hit.entry.page.title + " › " + SettingsSearch.text(hit.entry.title))+ .font(.system(size: 11))+ .foregroundColor(HubTheme.muted)+ .lineLimit(1)+ }+ Spacer(minLength: 0)+ }+ .foregroundColor(Color(hex: "#B7BBC2"))+ .padding(.horizontal, 10)+ .padding(.vertical, 6)+ .background(RoundedRectangle(cornerRadius: 9)+ .fill(Color.white.opacity(selected ? 0.08 : (hover ? 0.04 : 0))))+ .contentShape(Rectangle())+ }+ .buttonStyle(.plain)+ .onHover { hover = $0 }+ }+}+#endif++// The App Store build has no Coucou window: its boxes are never searched.+extension View {+ /// A box the search of the Coucou window can find (SettingsSearch.entries).+ func settingsAnchor(_ id: String, cornerRadius: CGFloat = 8) -> some View {+ #if APPSTORE+ self+ #else+ modifier(SettingsAnchor(anchor: id, cornerRadius: cornerRadius))+ #endif+ }++ /// The small title above a box anchored `id`: the search scrolls to it, so it stays in view.+ func settingsHeading(_ id: String) -> some View {+ self.id(id + "#label")+ }++ /// Scrolls to the box the search asked for (inside a ScrollViewReader).+ func settingsSearchScroll(_ proxy: ScrollViewProxy) -> some View {+ #if APPSTORE+ self+ #else+ modifier(SettingsSearchScroller(proxy: proxy))+ #endif+ }+}diff --git a/NotchBuddy/Sources/App/SettingsSearchMatch.swift b/NotchBuddy/Sources/App/SettingsSearchMatch.swiftnew file mode 100644index 00000000..d2709db9--- /dev/null+++ b/NotchBuddy/Sources/App/SettingsSearchMatch.swift@@ -0,0 +1,41 @@+import Foundation++/// How the search of the Coucou window matches a box (pure, tested by scripts/test-settings-search.sh).+///+/// Every word typed must be somewhere in the box: its title, its page or one of its labels,+/// whatever the case and the accents ("reglage" finds "Réglage"), and a piece of a word is+/// enough ("volu" finds "Volume").+enum SettingsSearchMatch: Equatable {+ /// The box itself: the words are all in its title or its page.+ case box+ /// A setting inside the box: the label the words point at.+ case label(String)++ static func normalize(_ s: String) -> String {+ s.folding(options: [.caseInsensitive, .diacriticInsensitive, .widthInsensitive], locale: Locale(identifier: "en_US_POSIX"))+ .trimmingCharacters(in: .whitespacesAndNewlines)+ }++ /// The words of a query, normalized.+ static func words(_ query: String) -> [String] {+ query.split(whereSeparator: { $0.isWhitespace }).map { normalize(String($0)) }.filter { !$0.isEmpty }+ }++ /// nil when the box doesn't have every word.+ static func match(_ words: [String], title: String, page: String, labels: [String]) -> SettingsSearchMatch? {+ guard !words.isEmpty else { return nil }+ let head = normalize(title + " " + page)+ let texts = labels.map(normalize)+ let all = ([head] + texts).joined(separator: " ")+ guard words.allSatisfy({ all.contains($0) }) else { return nil }+ if words.allSatisfy({ head.contains($0) }) { return .box }+ // The label with the most of the words, the first one when tied.+ var best: (index: Int, count: Int)?+ for (i, text) in texts.enumerated() {+ let count = words.filter { text.contains($0) }.count+ if count > 0, count > (best?.count ?? 0) { best = (i, count) }+ }+ guard let best else { return .box }+ return .label(labels[best.index])+ }+}diff --git a/NotchBuddy/Sources/App/SettingsView.swift b/NotchBuddy/Sources/App/SettingsView.swiftindex f4a3ac6b..bf10fbd8 100644--- a/NotchBuddy/Sources/App/SettingsView.swift+++ b/NotchBuddy/Sources/App/SettingsView.swift@@ -216,14 +216,17 @@ struct SettingsView: View {.padding(.top, 20).padding(.bottom, 12)}- ScrollView {- VStack(alignment: .leading, spacing: 18) {- sectionContent+ ScrollViewReader { proxy in+ ScrollView {+ VStack(alignment: .leading, spacing: 18) {+ sectionContent+ }+ .padding(.horizontal, embeddedSection == nil ? 20 : 28)+ .padding(.top, embeddedSection == nil ? 0 : 20)+ .padding(.bottom, 16)+ .frame(maxWidth: embeddedSection == nil ? .infinity : 1100, alignment: .leading)}- .padding(.horizontal, embeddedSection == nil ? 20 : 28)- .padding(.top, embeddedSection == nil ? 0 : 20)- .padding(.bottom, 16)- .frame(maxWidth: embeddedSection == nil ? .infinity : 1100, alignment: .leading)+ .settingsSearchScroll(proxy)}if !statusMessage.isEmpty {Divider()@@ -305,6 +308,7 @@ struct SettingsView: View {}.padding(6)}+ .settingsAnchor("general.demo")GroupBox("Sound") {VStack(alignment: .leading, spacing: 10) {@@ -339,6 +343,7 @@ struct SettingsView: View {}.padding(6)}+ .settingsAnchor("general.sound")GroupBox("Behavior") {VStack(alignment: .leading, spacing: 10) {@@ -363,6 +368,7 @@ struct SettingsView: View {}.padding(6)}+ .settingsAnchor("general.behavior")GroupBox("Display") {VStack(alignment: .leading, spacing: 10) {@@ -392,6 +398,7 @@ struct SettingsView: View {refreshConnectedScreens()}}+ .settingsAnchor("general.display")GroupBox(String(localized: "vitals.title")) {VStack(alignment: .leading, spacing: 10) {@@ -405,6 +412,7 @@ struct SettingsView: View {}.padding(6)}+ .settingsAnchor("general.vitals")GroupBox("Hotkey") {VStack(alignment: .leading, spacing: 10) {@@ -433,15 +441,18 @@ struct SettingsView: View {}.padding(6)}+ .settingsAnchor("general.hotkey")GroupBox("Startup") {Toggle("Launch at Mac startup", isOn: $launchAtStartup).onChange(of: launchAtStartup) { _, on in toggleStartup(on) }.padding(6)}+ .settingsAnchor("general.startup")#if !APPSTOREUpdateSettingsSection()+ .settingsAnchor("general.update")#endifGroupBox(String(localized: "Weekly recap")) {@@ -457,6 +468,7 @@ struct SettingsView: View {}.padding(6)}+ .settingsAnchor("general.recap")GroupBox(String(localized: "Language")) {VStack(alignment: .leading, spacing: 10) {@@ -507,6 +519,7 @@ struct SettingsView: View {}.padding(6)}+ .settingsAnchor("general.language")#if PHONE_LINKGroupBox("iPhone") {@@ -536,6 +549,7 @@ struct SettingsView: View {}.padding(6)}+ .settingsAnchor("general.iphone")#endif}@@ -583,6 +597,7 @@ struct SettingsView: View {}.padding(6)}+ .settingsAnchor("pills.main")}// MARK: - Agents section@@ -653,9 +668,11 @@ struct SettingsView: View {}.padding(6)}+ .settingsAnchor("agents.claude")#if !APPSTOREClaudeDesktopChatSettingsSection()+ .settingsAnchor("agents.claude-desktop")GroupBox(String(localized: "hooks.gemini.title")) {VStack(alignment: .leading, spacing: 10) {@@ -689,6 +706,7 @@ struct SettingsView: View {}.padding(6)}+ .settingsAnchor("agents.gemini")GroupBox(String(localized: "hooks.antigravity.title")) {VStack(alignment: .leading, spacing: 10) {@@ -722,6 +740,7 @@ struct SettingsView: View {}.padding(6)}+ .settingsAnchor("agents.antigravity")GroupBox(String(localized: "hooks.codex.title")) {VStack(alignment: .leading, spacing: 10) {@@ -755,6 +774,7 @@ struct SettingsView: View {}.padding(6)}+ .settingsAnchor("agents.codex")GroupBox(String(localized: "hooks.copilot.title")) {VStack(alignment: .leading, spacing: 10) {@@ -788,6 +808,7 @@ struct SettingsView: View {}.padding(6)}+ .settingsAnchor("agents.copilot")GroupBox(String(localized: "hooks.muse.title")) {VStack(alignment: .leading, spacing: 10) {@@ -821,6 +842,7 @@ struct SettingsView: View {}.padding(6)}+ .settingsAnchor("agents.muse")GroupBox(String(localized: "plugin.opencode.title")) {VStack(alignment: .leading, spacing: 10) {@@ -854,6 +876,7 @@ struct SettingsView: View {}.padding(6)}+ .settingsAnchor("agents.opencode")GroupBox(String(localized: "plugin.amp.title")) {VStack(alignment: .leading, spacing: 10) {@@ -887,6 +910,7 @@ struct SettingsView: View {}.padding(6)}+ .settingsAnchor("agents.amp")GroupBox(String(localized: "plugin.hermes.title")) {VStack(alignment: .leading, spacing: 10) {@@ -959,6 +983,7 @@ struct SettingsView: View {}.padding(6)}+ .settingsAnchor("agents.hermes")#if !APPSTORE.task(id: hermesPluginInstalled) {guard hermesPluginInstalled else { hermesSupportsApprovals = false; return }@@ -1038,6 +1063,7 @@ struct SettingsView: View {}.padding(6)}+ .settingsAnchor("agents.plan")#endif}@@ -1107,6 +1133,7 @@ struct SettingsView: View {.padding(6).id(cliScan)}+ .settingsAnchor("chat.subscriptions").onAppear { CLILocator.shared.refresh() }.onReceive(NotificationCenter.default.publisher(for: CLILocator.changed)) { _ in cliScan += 1 }#endif@@ -1150,6 +1177,7 @@ struct SettingsView: View {}.padding(6)}+ .settingsAnchor("chat.anthropic")GroupBox(String(localized: "chat.other-providers.title")) {VStack(alignment: .leading, spacing: 12) {@@ -1227,6 +1255,7 @@ struct SettingsView: View {}.padding(.vertical, 4)}+ .settingsAnchor("chat.others")GroupBox(String(localized: "chat.local.title")) {VStack(alignment: .leading, spacing: 12) {@@ -1304,6 +1333,7 @@ struct SettingsView: View {}.padding(.vertical, 4)}+ .settingsAnchor("chat.local")}// MARK: - Integrations section@@ -1456,6 +1486,7 @@ struct SettingsView: View {}.padding(6)}+ .settingsAnchor("integrations.all")}// MARK: - Voice section@@ -1536,6 +1567,7 @@ struct SettingsView: View {}.padding(6)}+ .settingsAnchor("voice.wake").onAppear {voicePermissionsGranted = VoiceSettings.micStatus == .granted&& VoiceSettings.speechStatus == .granted@@ -1574,6 +1606,7 @@ struct SettingsView: View {}.padding(6)}+ .settingsAnchor("voice.language")GroupBox(String(localized: "voice.tts-engine")) {VStack(alignment: .leading, spacing: 10) {@@ -1641,6 +1674,7 @@ struct SettingsView: View {}.padding(6)}+ .settingsAnchor("voice.tts")}#if !APPSTORE@@ -1695,6 +1729,7 @@ struct SettingsView: View {}.padding(6)}+ .settingsAnchor("voice.history")}}}diff --git a/NotchBuddy/Sources/App/ShortcutsSettingsView.swift b/NotchBuddy/Sources/App/ShortcutsSettingsView.swiftindex 71c9f30e..a68c55a1 100644--- a/NotchBuddy/Sources/App/ShortcutsSettingsView.swift+++ b/NotchBuddy/Sources/App/ShortcutsSettingsView.swift@@ -44,6 +44,7 @@ struct ShortcutsSettingsView: View {}.padding(6)}+ .settingsAnchor("shortcuts.global")}/// Shortcuts listed here. The App Store build hides the ones it can't run.@@ -124,6 +125,7 @@ struct ShortcutsSettingsView: View {}.padding(6)}+ .settingsAnchor("shortcuts.island")}// MARK: - Bindingsdiff --git a/scripts/test-settings-search.sh b/scripts/test-settings-search.shnew file mode 100755index 00000000..e53ad693--- /dev/null+++ b/scripts/test-settings-search.sh@@ -0,0 +1,9 @@+#!/usr/bin/env bash+set -euo pipefail+cd "$(dirname "$0")/.."+TEST_DIR="$(mktemp -d "${TMPDIR:-/tmp}/coucou-settings-search.XXXXXX")"+trap 'rm -rf "$TEST_DIR"' EXIT+swiftc -swift-version 6 -strict-concurrency=complete \+ NotchBuddy/Sources/App/SettingsSearchMatch.swift \+ tests/SettingsSearchTests.swift -o "$TEST_DIR/settings-search-tests"+"$TEST_DIR/settings-search-tests"diff --git a/tests/SettingsSearchTests.swift b/tests/SettingsSearchTests.swiftnew file mode 100644index 00000000..ff111b89--- /dev/null+++ b/tests/SettingsSearchTests.swift@@ -0,0 +1,30 @@+import Foundation++@main+enum SettingsSearchTests {+ static func main() {+ let w = SettingsSearchMatch.words+ precondition(w(" Réglage SON ") == ["reglage", "son"])+ precondition(w(" ").isEmpty)++ let sound = (title: "Son", page: "Général", labels: ["Activer les sons", "Volume", "Ouvrir le dossier des sons"])+ func m(_ q: String) -> SettingsSearchMatch? {+ SettingsSearchMatch.match(w(q), title: sound.title, page: sound.page, labels: sound.labels)+ }+ // The box by its title or its page, whatever the accents and the case.+ precondition(m("son") == .box)+ precondition(m("GENERAL") == .box)+ precondition(m("général son") == .box)+ // A setting inside it.+ precondition(m("volu") == .label("Volume"))+ precondition(m("dossier") == .label("Ouvrir le dossier des sons"))+ // Every word somewhere; the label with most of them.+ precondition(m("ouvrir dossier son") == .label("Ouvrir le dossier des sons"))+ precondition(m("volume general") == .label("Volume"))+ // Not there.+ precondition(m("micro") == nil)+ precondition(m("volume micro") == nil, "every word must be found")+ precondition(m("") == nil)+ print("SettingsSearch tests: all passed")+ }+}diff --git a/windows/src/i18n/strings.json b/windows/src/i18n/strings.jsonindex 32324a0d..297fef53 100644--- a/windows/src/i18n/strings.json+++ b/windows/src/i18n/strings.json@@ -5822,6 +5822,21 @@"ko": "아직 규칙이 없습니다. 예: 보낸 사람에 ‘newsletter’가 있으면 정크로 이동.","ja": "ルールはまだありません。例:差出人に「newsletter」を含む場合、迷惑メールへ移動。"},+ "No setting found": {+ "zh-Hans": "未找到设置",+ "hi": "कोई सेटिंग नहीं मिली",+ "es": "Ningún ajuste encontrado",+ "ar": "لم يُعثر على أي إعداد",+ "fr": "Aucun réglage trouvé",+ "bn": "কোনো সেটিং পাওয়া যায়নি",+ "pt-BR": "Nenhum ajuste encontrado",+ "ru": "Настройка не найдена",+ "id": "Pengaturan tidak ditemukan",+ "de": "Keine Einstellung gefunden",+ "tr": "Ayar bulunamadı",+ "ko": "찾은 설정이 없어요",+ "ja": "該当する設定はありません"+ },"No snippet yet. Your booking link, your signature, your address: say a few words, get the whole text.": {"zh-Hans": "还没有片段。你的预约链接、签名、地址:说几个字,就能得到整段文字。","hi": "अभी कोई स्निपेट नहीं। आपका बुकिंग लिंक, हस्ताक्षर, पता: कुछ शब्द बोलें, पूरा टेक्स्ट पाएँ।",@@ -8342,6 +8357,21 @@"ko": "받아쓰기 검색","ja": "口述を検索"},+ "Search settings": {+ "zh-Hans": "搜索设置",+ "hi": "सेटिंग खोजें",+ "es": "Buscar un ajuste",+ "ar": "البحث في الإعدادات",+ "fr": "Rechercher un réglage",+ "bn": "সেটিংস খুঁজুন",+ "pt-BR": "Buscar ajustes",+ "ru": "Поиск настроек",+ "id": "Cari pengaturan",+ "de": "Einstellungen suchen",+ "tr": "Ayarlarda ara",+ "ko": "설정 검색",+ "ja": "設定を検索"+ },"Searches": {"zh-Hans": "搜索","hi": "खोजता है",