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
feat(windows): settings search in the Coucou window (#996)
Ohualtex074ce9babbe9
diff --git a/windows/src/hub/hub.css b/windows/src/hub/hub.cssindex 13a7873a..7ef8c06a 100644--- a/windows/src/hub/hub.css+++ b/windows/src/hub/hub.css@@ -56,6 +56,165 @@ body.hub-window {height: 28px;}+/* ── Settings search field & results ── */+.hub-search {+ display: flex;+ align-items: center;+ gap: 7px;+ height: 32px;+ padding: 0 10px;+ margin: 0 4px 10px;+ background: var(--hub-card);+ border-radius: 9px;+ border: 1px solid rgba(255, 255, 255, 0.07);+ box-sizing: border-box;+}++.hub-search:focus-within {+ border-color: rgba(110, 86, 207, 0.6);+}++.hub-search svg.hub-search-icon {+ width: 13px;+ height: 13px;+ flex: 0 0 13px;+ fill: none;+ stroke: var(--hub-muted);+ stroke-width: 1.8;+ stroke-linecap: round;+ stroke-linejoin: round;+}++.hub-search-input {+ flex: 1;+ min-width: 0;+ border: none;+ background: transparent;+ color: var(--hub-text);+ font: 400 13px var(--font);+ outline: none;+ padding: 0;+}++.hub-search-input::placeholder {+ color: var(--hub-muted);+}++.hub-search-clear {+ display: flex;+ align-items: center;+ justify-content: center;+ width: 16px;+ height: 16px;+ padding: 0;+ border: none;+ background: transparent;+ color: var(--hub-muted);+ cursor: pointer;+ border-radius: 50%;+}++.hub-search-clear:hover {+ color: var(--hub-text);+}++.hub-search-clear svg {+ width: 11px;+ height: 11px;+ fill: none;+ stroke: currentColor;+ stroke-width: 2;+}++.hub-search-empty {+ font-size: 12.5px;+ color: var(--hub-muted);+ padding: 8px 10px;+}++.hub-search-results {+ display: flex;+ flex-direction: column;+ gap: 2px;+}++.hub-search-row {+ display: flex;+ align-items: flex-start;+ gap: 10px;+ width: 100%;+ padding: 6px 10px;+ background: transparent;+ border: none;+ border-radius: 9px;+ color: #b7bbc2;+ text-align: start;+ cursor: pointer;+ box-sizing: border-box;+ transition: background 0.12s ease;+}++.hub-search-row:hover {+ background: rgba(255, 255, 255, 0.04);+}++.hub-search-row.on {+ background: rgba(255, 255, 255, 0.08);+ color: var(--hub-text);+}++.hub-search-row svg {+ width: 15px;+ height: 15px;+ flex: 0 0 15px;+ margin-top: 2px;+ fill: none;+ stroke: currentColor;+ stroke-width: 1.7;+}++.hub-search-row-text {+ display: flex;+ flex-direction: column;+ gap: 2px;+ min-width: 0;+ flex: 1;+}++.hub-search-row-title {+ font: 500 13px var(--font);+ color: var(--hub-text);+ line-height: 1.3;+}++.hub-search-row-subtitle {+ font: 400 11px var(--font);+ color: var(--hub-muted);+ white-space: nowrap;+ overflow: hidden;+ text-overflow: ellipsis;+}++/* Card anchor glow */+@keyframes hub-card-glow {+ 0% {+ box-shadow: 0 0 0 0 transparent;+ }+ 30% {+ box-shadow: 0 0 0 2px var(--hub-accent, #6e56cf), 0 0 16px rgba(110, 86, 207, 0.6);+ }+ 75% {+ box-shadow: 0 0 0 2px var(--hub-accent, #6e56cf), 0 0 16px rgba(110, 86, 207, 0.6);+ }+ 100% {+ box-shadow: 0 0 0 0 transparent;+ }+}++.hub-card-glowing {+ animation: hub-card-glow 2.2s cubic-bezier(0.16, 1, 0.3, 1) forwards !important;+}+.hub-group {font: 700 10.5px var(--font);letter-spacing: 0.12em;diff --git a/windows/src/hub/pages/dictation.ts b/windows/src/hub/pages/dictation.tsindex 43932d1b..23f74f3d 100644--- a/windows/src/hub/pages/dictation.ts+++ b/windows/src/hub/pages/dictation.ts@@ -94,6 +94,7 @@ export async function dictationPage(page: HTMLElement, ctx: HubContext) {h("div", { class: "hub-history-head" }, label(t("History")), search),list,);+ left.dataset.anchor = "flow.history";const right = h("div", { style: "display:flex;flex-direction:column;gap:14px" }, numbers(stats), promo(ctx));page.append(h("div", { class: "hub-columns" }, left, right));draw();diff --git a/windows/src/hub/pages/flowsettings.ts b/windows/src/hub/pages/flowsettings.tsindex f195ba55..25ef2a0d 100644--- a/windows/src/hub/pages/flowsettings.ts+++ b/windows/src/hub/pages/flowsettings.ts@@ -7,7 +7,7 @@ import { t } from "../../i18n/i18n";import { onEvent } from "../../core/bridge";import { FlowBridge, type Edge, type FlowKey, type ModelsStatus } from "../../core/flow";import type { HubContext } from "../shell";-import { button, card, divider, keyKeycap, keycap, label, number, row, segmented, select, toggle } from "../ui";+import { anchor, button, card, divider, keyKeycap, keycap, label, number, row, segmented, select, toggle } from "../ui";/** Download / progress / installed, for the voice model. Redraws itself. */export function modelsControl(ctx: HubContext, onReady?: () => void): HTMLElement {@@ -93,35 +93,35 @@ export async function flowSettingsPage(page: HTMLElement, ctx: HubContext) {} else if (status.keys !== "ok") {keysCard.append(h("div", { class: "hub-warn", text: t("Coucou can't watch the keyboard here: use the pill's microphone to dictate.") }));}- page.append(keysCard);+ page.append(anchor("flow.keys", keysCard));// ── Microphone ──page.append(label(t("Microphone")));const mics: [string, string][] = [["", t("System default")], ...status.mics.map((m): [string, string] => [m.name, m.name])];if (prefs.mic && !mics.some(([id]) => id === prefs.mic)) mics.push([prefs.mic, prefs.mic]);- page.append(card(row(t("Microphone"), t("The one Coucou listens to for dictation and calls."), select(mics, prefs.mic, (mic) => void ctx.setPrefs((p) => (p.mic = mic))))));+ page.append(anchor("flow.permission", card(row(t("Microphone"), t("The one Coucou listens to for dictation and calls."), select(mics, prefs.mic, (mic) => void ctx.setPrefs((p) => (p.mic = mic)))))));// ── Recognition ──page.append(label(t("Recognition")));- page.append(card(+ page.append(anchor("flow.recognition", card(row(t("Parakeet, on your computer"), t("The most accurate, offline, 25 languages. Downloaded once (about {0} MB).", { 0: number(status.models.downloadMb) }), modelsControl(ctx)),h("div", { class: "hub-note", text: t("Your voice never leaves this computer: Parakeet turns it into text here, and the recording is dropped as soon as it is pasted.") }),- ));+ )));// ── Notetaker ──page.append(label(t("Notetaker")));- page.append(card(+ page.append(anchor("flow.summary", card(row(t("Summaries"), null, select([["claude", t("Claude (your key)")], ["off", t("No summary")]], prefs.summaryEngine, (engine) => void ctx.setPrefs((p) => (p.summaryEngine = engine)))),h("div", { class: "hub-note", text: t("With Claude, the transcript (never the audio) goes to Anthropic with your key from Notch → Chat.") }),divider(),h("div", { class: "hub-note", text: t("Everything stays on this computer. Tell the people in the call that you are recording.") }),- ));+ )));// ── App ──page.append(label(t("App")));- page.append(card(+ page.append(anchor("flow.app", card(row(t("Open this window when you open Coucou"), t("Not when Coucou starts with the computer."), toggle(prefs.openAtLaunch, (on) => void ctx.setPrefs((p) => (p.openAtLaunch = on)))),- ));+ )));// ── Privacy ──page.append(label(t("Privacy")));@@ -145,10 +145,10 @@ export async function flowSettingsPage(page: HTMLElement, ctx: HubContext) {);};erase();- page.append(card(+ page.append(anchor("flow.privacy", card(row(t("Keep the history"), null, select(keep, String(prefs.keepDays), (v) => void ctx.setPrefs((p) => (p.keepDays = Number(v))))),divider(),confirmRow,h("div", { class: "hub-note", text: t("The history, the statistics and your notes stay on this computer, in Coucou's folder. Dictations are never saved as audio; a call's audio is deleted as soon as its transcript is written.") }),- ));+ )));}diff --git a/windows/src/hub/pages/insights.ts b/windows/src/hub/pages/insights.tsindex a0c1f2c4..1adcc2d4 100644--- a/windows/src/hub/pages/insights.ts+++ b/windows/src/hub/pages/insights.ts@@ -20,6 +20,7 @@ export async function insightsPage(page: HTMLElement, ctx: HubContext) {const stats: FlowStats | null = await FlowBridge.stats();let period: Period = "month";const body = h("div", { style: "display:flex;flex-direction:column;gap:14px" });+ body.dataset.anchor = "flow.insights";const picker = segmented<Period>([["week", t("Week")], ["month", t("Month")], ["all", t("All")]], period, (p) => {period = p;draw();diff --git a/windows/src/hub/pages/mail.ts b/windows/src/hub/pages/mail.tsindex e62b66db..3e1d2a76 100644--- a/windows/src/hub/pages/mail.ts+++ b/windows/src/hub/pages/mail.ts@@ -71,6 +71,7 @@ export async function mailOverviewPage(page: HTMLElement, ctx: HubContext) {} else if (!view.outlookOpen) {sortCard.append(divider(), h("div", { class: "hub-note", text: t("Outlook is closed: nothing is sorted until it is open.") }));}+ sortCard.dataset.anchor = "mail.autosort";page.append(sortCard);const stat = (value: number, text: string, color: string) =>@@ -179,6 +180,7 @@ export async function mailRulesPage(page: HTMLElement, ctx: HubContext) {));const list = card();+ list.dataset.anchor = "mail.rules";page.append(list);const drawRules = () => {clear(list);@@ -242,7 +244,9 @@ function chipsPage(chips.append(h("span", { class: "hub-chip" }, h("span", { text: w }), remove));}};- page.append(card(h("div", { class: "hub-row" }, field, button(t("Add"), add, "primary")), chips));+ const chipsCard = card(h("div", { class: "hub-row" }, field, button(t("Add"), add, "primary")), chips);+ chipsCard.dataset.anchor = id === "mailBanned" ? "mail.banned" : "mail.vip";+ page.append(chipsCard);draw();}diff --git a/windows/src/hub/pages/notes.ts b/windows/src/hub/pages/notes.tsindex 099556c7..1585a9c9 100644--- a/windows/src/hub/pages/notes.ts+++ b/windows/src/hub/pages/notes.ts@@ -35,7 +35,9 @@ export async function notesPage(page: HTMLElement, ctx: HubContext) {const listEl = h("div", { class: "hub-notes-list" });const detail = h("div", { class: "hub-note-detail" });- page.append(h("div", { class: "hub-notes" }, listEl, detail));+ const notesContainer = h("div", { class: "hub-notes" }, listEl, detail);+ notesContainer.dataset.anchor = "flow.notes";+ page.append(notesContainer);const reload = async () => {state = (await FlowBridge.notes()) ?? state;diff --git a/windows/src/hub/pages/styles.ts b/windows/src/hub/pages/styles.tsindex 16996abc..ad494522 100644--- a/windows/src/hub/pages/styles.ts+++ b/windows/src/hub/pages/styles.ts@@ -41,7 +41,7 @@ export async function stylesPage(page: HTMLElement, ctx: HubContext) {const keyNote = h("div", { class: "hub-warn", text: t("The clean-up uses your Claude key. Add it in Notch → Chat.") });keyNote.style.display = status.hasClaudeKey ? "none" : "";const defaultRow = row(t("Other apps"), null, select(styleOptions(), status.prefs.defaultStyle, (style) => void ctx.setPrefs((p) => (p.defaultStyle = style))));- page.append(card(+ const stylesCard = card(row(t("Clean up with Claude"), t("Removes the “um”, the repeats and the corrections you made while speaking, and fixes the punctuation."),toggle(status.prefs.cleanup, (on) => {void ctx.setPrefs((p) => (p.cleanup = on));@@ -51,7 +51,9 @@ export async function stylesPage(page: HTMLElement, ctx: HubContext) {divider(),defaultRow,h("div", { class: "hub-note", text: t("With the clean-up on, the text (never your voice) goes to Anthropic with your Claude key. Off, everything stays on this computer.") }),- ));+ );+ stylesCard.dataset.anchor = "flow.styles";+ page.append(stylesCard);// "Add an app": the apps with a window right now.const add = h("select", { class: "hub-select" }) as HTMLSelectElement;diff --git a/windows/src/hub/pages/words.ts b/windows/src/hub/pages/words.tsindex d5515ebd..8ea0db71 100644--- a/windows/src/hub/pages/words.ts+++ b/windows/src/hub/pages/words.ts@@ -54,7 +54,9 @@ export async function dictionaryPage(page: HTMLElement, ctx: HubContext) {}};wordInput.style.flex = "1";- page.append(card(h("div", { class: "hub-row" }, wordInput, button(t("Add"), addWord, "primary")), chips));+ const wordsCard = card(h("div", { class: "hub-row" }, wordInput, button(t("Add"), addWord, "primary")), chips);+ wordsCard.dataset.anchor = "flow.dictionary";+ page.append(wordsCard);drawWords();// ── Replacements ──@@ -129,6 +131,7 @@ export async function snippetsPage(page: HTMLElement, ctx: HubContext) {const list = h("div", {});const listCard = card(list);+ listCard.dataset.anchor = "flow.snippets";page.append(listCard);const draw = () => {clear(list);diff --git a/windows/src/hub/search.ts b/windows/src/hub/search.tsnew file mode 100644index 00000000..481477fd--- /dev/null+++ b/windows/src/hub/search.ts@@ -0,0 +1,184 @@+// Settings search in the Coucou window: matches every setting of Flow,+// Notch and Mail in the app's language, whatever the accents and case.+// Port of SettingsSearch.swift and SettingsSearchMatch.swift.++import { t } from "../i18n/i18n";+import type { PageId } from "./shell";++export interface SettingsSearchEntry {+ /** The box's anchor, unique. */+ id: string;+ page: PageId;+ /** The box's title (catalog key, or a name that is never translated). */+ title: string;+ /** The labels inside the box (catalog keys). */+ terms: string[];+}++export interface SettingsSearchHit {+ entry: SettingsSearchEntry;+ label?: string;+ id: string;+}++export type MatchResult =+ | { kind: "box" }+ | { kind: "label"; label: string };++/**+ * Normalizes a string for searching: case-insensitive, diacritic/accent-insensitive,+ * trimmed of leading/trailing whitespace.+ */+export function normalize(s: string): string {+ return s+ .normalize("NFD")+ .replace(/[\u0300-\u036f]/g, "")+ .toLowerCase()+ .trim();+}++/**+ * The words of a query, normalized.+ */+export function words(query: string): string[] {+ return query+ .split(/\s+/)+ .map(normalize)+ .filter((w) => w.length > 0);+}++/**+ * Matches a list of query words against a box's title, page and inner labels.+ * Returns null when the box doesn't have every word.+ */+export function match(+ wordList: string[],+ title: string,+ page: string,+ labels: string[]+): MatchResult | null {+ if (wordList.length === 0) return null;+ const head = normalize(title + " " + page);+ const texts = labels.map(normalize);+ const all = [head, ...texts].join(" ");+ if (!wordList.every((w) => all.includes(w))) return null;+ if (wordList.every((w) => head.includes(w))) return { kind: "box" };++ // The label with the most of the words, the first one when tied.+ let bestIndex = -1;+ let bestCount = 0;+ for (let i = 0; i < texts.length; i++) {+ const text = texts[i];+ const count = wordList.filter((w) => text.includes(w)).length;+ if (count > 0 && count > bestCount) {+ bestIndex = i;+ bestCount = count;+ }+ }++ if (bestIndex < 0) return { kind: "box" };+ return { kind: "label", label: labels[bestIndex] };+}++export const SETTINGS_ENTRIES: SettingsSearchEntry[] = [+ // Flow+ { id: "flow.history", page: "dictation", title: "hub.history", terms: ["hub.page.dictation"] },+ { id: "flow.notes", page: "notes", title: "hub.page.notes", terms: ["notes.live", "notes.key-points"] },+ { id: "flow.insights", page: "insights", title: "hub.page.insights", terms: [] },+ { id: "flow.dictionary", page: "dictionary", title: "hub.page.dictionary", terms: ["hub.replacements"] },+ { id: "flow.snippets", page: "snippets", title: "hub.page.snippets", terms: [] },+ { id: "flow.styles", page: "styles", title: "hub.page.styles", terms: ["hub.cleanup", "hub.style-default", "hub.style-apps"] },+ {+ id: "flow.keys",+ page: "flowsettings",+ title: "hub.settings.keys",+ terms: ["flow.enable", "hub.settings.hold", "flow.edge", "hub.settings.handsfree", "hub.settings.paste-again", "hub.settings.cancel"],+ },+ { id: "flow.ai", page: "flowsettings", title: "flow.ai.title", terms: ["flow.prompt-mode", "flow.translate"] },+ { id: "flow.permission", page: "flowsettings", title: "hub.settings.permission", terms: ["flow.accessibility-open"] },+ { id: "flow.recognition", page: "flowsettings", title: "hub.settings.recognition", terms: ["Dictation language"] },+ { id: "flow.summary", page: "flowsettings", title: "hub.page.notes", terms: ["notes.engine"] },+ { id: "flow.app", page: "flowsettings", title: "hub.settings.app", terms: ["hub.settings.dock", "hub.settings.open-at-launch"] },+ { id: "flow.privacy", page: "flowsettings", title: "hub.settings.privacy", terms: ["hub.settings.keep"] },++ // Notch → General+ { id: "general.demo", page: "general", title: "demo.groupbox.title", terms: [] },+ { id: "general.sound", page: "general", title: "Sound", terms: ["Enable sounds", "Volume", "Open sounds folder", "Reload sounds"] },+ { id: "general.behavior", page: "general", title: "Behavior", terms: ["Open on hover", "Close after", "Hide after", "alerts.all-pills"] },+ { id: "general.display", page: "general", title: "Display", terms: ["Show Mochi on", "Screen with the notch", "Main screen (menu bar)", "Follow the mouse"] },+ { id: "general.vitals", page: "general", title: "vitals.title", terms: ["vitals.toggle"] },+ { id: "general.hotkey", page: "general", title: "Hotkey", terms: ["Show island with shortcut", "Shortcut"] },+ { id: "general.startup", page: "general", title: "Startup", terms: ["Launch at Mac startup"] },+ { id: "general.update", page: "general", title: "update.settings.title", terms: [] },+ { id: "general.recap", page: "general", title: "Weekly recap", terms: ["Keep a history of my coding sessions", "Hide project names in shared images", "Clear history"] },+ { id: "general.language", page: "general", title: "Language", terms: ["Restart Coucou"] },++ // Notch → Pills, Agents, Chat, Integrations, Phone, Voice, Shortcuts+ { id: "pills.main", page: "pills", title: "settings.main-pill", terms: ["Active pills"] },+ { id: "agents.claude", page: "agents", title: "hooks.claude-code.title", terms: ["Answer questions and permissions from terminal sessions in the notch"] },+ { id: "agents.claude-desktop", page: "agents", title: "claude-desktop.chat.title", terms: [] },+ { id: "agents.gemini", page: "agents", title: "hooks.gemini.title", terms: [] },+ { id: "agents.antigravity", page: "agents", title: "hooks.antigravity.title", terms: [] },+ { id: "agents.codex", page: "agents", title: "hooks.codex.title", terms: [] },+ { id: "agents.copilot", page: "agents", title: "hooks.copilot.title", terms: [] },+ { id: "agents.muse", page: "agents", title: "hooks.muse.title", terms: [] },+ { id: "agents.opencode", page: "agents", title: "plugin.opencode.title", terms: [] },+ { id: "agents.amp", page: "agents", title: "plugin.amp.title", terms: [] },+ { id: "agents.hermes", page: "agents", title: "plugin.hermes.title", terms: ["plugin.hermes.approvals"] },+ { id: "agents.plan", page: "agents", title: "plan.title", terms: ["plan.show-in-notch", "Show Codex plan in the notch"] },+ { id: "chat.subscriptions", page: "chat", title: "chat.subscriptions.title", terms: ["chat.subscriptions.use"] },+ { id: "chat.anthropic", page: "chat", title: "chat.anthropic-api.title", terms: ["chat.model", "Anthropic", "Claude"] },+ { id: "chat.others", page: "chat", title: "chat.other-providers.title", terms: ["Google AI", "OpenAI", "DeepSeek", "Gemini"] },+ { id: "chat.local", page: "chat", title: "chat.local.title", terms: ["Ollama", "LM Studio"] },+ {+ id: "integrations.all",+ page: "integrations",+ title: "Integrations",+ terms: [+ "Stripe", "GitHub", "Vercel", "n8n", "Notion", "Resend", "Cal.com", "WhatsApp", "Spotify", "Crypto",+ "Linear", "X", "YouTube", "Figma", "OpenWeather", "Railway", "Supabase", "Hugging Face", "Sentry", "PostHog", "Twilio",+ ],+ },+ { id: "phone.android", page: "phone", title: "phone.title", terms: ["phone.status", "phone.pairing", "phone.approvals"] },+ { id: "voice.wake", page: "voice", title: "«\u202FOK Coucou\u202F» — voice wake word", terms: ["Enable voice command", "Request permissions"] },+ { id: "voice.language", page: "voice", title: "Language", terms: ["voice.listen-language", "voice.language"] },+ { id: "voice.tts", page: "voice", title: "voice.tts-engine", terms: ["voice.tts-gender", "voice.tts-test"] },+ { id: "voice.history", page: "voice", title: "voice.history-title", terms: [] },+ { id: "shortcuts.global", page: "shortcuts", title: "shortcut.group.global", terms: [] },+ { id: "shortcuts.island", page: "shortcuts", title: "shortcut.group.island", terms: [] },++ { id: "mail.autosort", page: "mailOverview", title: "hub.mail.autosort", terms: ["hub.mail.journal", "hub.mail.sent", "hub.mail.undo"] },+ { id: "mail.rules", page: "mailRules", title: "hub.mail.rules", terms: ["hub.mail.field.sender", "hub.mail.field.subject", "hub.mail.do.junk"] },+ { id: "mail.banned", page: "mailBanned", title: "hub.mail.banned", terms: [] },+ { id: "mail.vip", page: "mailVIP", title: "hub.mail.vip", terms: [] },+];++/**+ * Searches the settings index given a query string and page title resolver.+ */+export function searchSettings(+ query: string,+ getPageTitle: (page: PageId) => string,+ entries: SettingsSearchEntry[] = SETTINGS_ENTRIES+): SettingsSearchHit[] {+ const qWords = words(query);+ if (qWords.length === 0) return [];+ const boxes: SettingsSearchHit[] = [];+ const labels: SettingsSearchHit[] = [];++ for (const entry of entries) {+ const titleText = t(entry.title);+ const pageText = getPageTitle(entry.page);+ const labelTexts = entry.terms.map((k) => t(k));+ const res = match(qWords, titleText, pageText, labelTexts);+ if (!res) continue;+ if (res.kind === "box") {+ boxes.push({ entry, id: entry.id });+ } else {+ labels.push({ entry, label: res.label, id: `${entry.id}|${res.label}` });+ }+ }++ return [...boxes, ...labels].slice(0, 30);+}diff --git a/windows/src/hub/shell.ts b/windows/src/hub/shell.tsindex 693d9082..1e4bd063 100644--- a/windows/src/hub/shell.ts+++ b/windows/src/hub/shell.ts@@ -5,11 +5,12 @@import "./hub.css";import { h, clear } from "../views/dom";-import { t } from "../i18n/i18n";+import { t, onLanguageChange } from "../i18n/i18n";import { onEvent } from "../core/bridge";import { FlowBridge, type FlowPrefs, type FlowStatus, type ModelsStatus } from "../core/flow";import { hero, liveMochi, setWindowShown } from "./hero";import { icon, keyLabel } from "./ui";+import { searchSettings, type SettingsSearchHit } from "./search";export type PageId =| "dictation" | "notes" | "insights" | "dictionary" | "snippets" | "styles" | "flowsettings"@@ -99,8 +100,11 @@ export async function startHub(root: HTMLElement, opts: HubOptions) {const shown = await FlowBridge.hubShown();if (shown !== null) setWindowShown(shown);let current: PageId = "dictation";+ let activeAnchor: string | null = null;+ let searchHits: SettingsSearchHit[] = [];let status: FlowStatus = (await FlowBridge.status()) ?? DEFAULT_STATUS;const items = new Map<PageId, HTMLElement>();+ const searchRows = new Map<string, HTMLElement>();const statusLine = h("div", { class: "hub-status" });const scroll = h("div", { class: "hub-scroll" });let rendering = 0;@@ -145,12 +149,20 @@ export async function startHub(root: HTMLElement, opts: HubOptions) {statusLine.append(h("i", { class: "dot", style: `background:${color}` }), h("span", { text }));}- async function show(page: PageId) {+ function updateSearchRowHighlights() {+ for (const [id, rowEl] of searchRows) {+ rowEl.classList.toggle("on", id === activeAnchor);+ }+ }++ async function show(page: PageId, targetAnchor?: string) {const def = ALL.find((p) => p.id === page) ?? FLOW_PAGES[0];ctx.onLeave?.();ctx.onLeave = undefined;current = def.id;+ activeAnchor = targetAnchor ?? null;for (const [id, el] of items) el.classList.toggle("on", id === current);+ updateSearchRowHighlights();const token = ++rendering;const page_ = h("div", { class: "hub-page" });const renderer = opts.flowPages[def.id];@@ -165,7 +177,19 @@ export async function startHub(root: HTMLElement, opts: HubOptions) {if (token !== rendering) return;clear(scroll);scroll.append(page_);- scroll.scrollTop = 0;+ if (targetAnchor) {+ const el = page_.querySelector(`[data-anchor="${targetAnchor}"]`) as HTMLElement | null;+ if (el) {+ el.scrollIntoView({ behavior: "smooth", block: "center" });+ el.classList.remove("hub-card-glowing");+ void el.offsetWidth;+ el.classList.add("hub-card-glowing");+ } else {+ scroll.scrollTop = 0;+ }+ } else {+ scroll.scrollTop = 0;+ }}// ── The sidebar ──@@ -173,18 +197,113 @@ export async function startHub(root: HTMLElement, opts: HubOptions) {const logo = h("canvas", {});side.append(h("div", { class: "hub-brand" }, logo, h("span", { text: "Coucou" })));liveMochi(logo as HTMLCanvasElement);++ // Settings search field+ const searchInput = h("input", {+ class: "hub-search-input",+ type: "text",+ placeholder: t("Search settings"),+ spellcheck: "false",+ }) as HTMLInputElement;++ const searchClear = h("button", {+ class: "hub-search-clear",+ title: t("Close"),+ style: "display:none",+ }, icon("x"));++ const searchBox = h("div", { class: "hub-search" },+ icon("search"),+ searchInput,+ searchClear,+ );+ searchBox.querySelector("svg")?.classList.add("hub-search-icon");+ side.append(searchBox);++ const groupsContainer = h("div", { class: "hub-groups" });+ const resultsContainer = h("div", { class: "hub-search-results", style: "display:none" });+ side.append(groupsContainer, resultsContainer);+const group = (title: string, pages: PageDef[]) => {- side.append(h("div", { class: "hub-group", text: title }));+ groupsContainer.append(h("div", { class: "hub-group", text: title }));for (const p of pages) {const b = h("button", { class: "hub-item", onclick: () => void show(p.id) });b.append(icon(p.icon), h("span", { text: p.title() }));items.set(p.id, b);- side.append(b);+ groupsContainer.append(b);}};group("Flow", FLOW_PAGES);group(t("Notch"), NOTCH_PAGES);if (status.platform === "windows") group("Mail", MAIL_PAGES);++ function renderSearchResults() {+ clear(resultsContainer);+ searchRows.clear();+ const query = searchInput.value.trim();+ if (!query) {+ searchClear.style.display = "none";+ resultsContainer.style.display = "none";+ groupsContainer.style.display = "";+ searchHits = [];+ return;+ }+ searchClear.style.display = "";+ groupsContainer.style.display = "none";+ resultsContainer.style.display = "";+ searchHits = searchSettings(query, (pageId) => ALL.find((p) => p.id === pageId)?.title() ?? pageId);+ if (searchHits.length === 0) {+ resultsContainer.append(h("div", { class: "hub-search-empty", text: t("No setting found") }));+ return;+ }+ for (const hit of searchHits) {+ const pageDef = ALL.find((p) => p.id === hit.entry.page);+ const row = h("button", { class: "hub-search-row" });+ if (activeAnchor === hit.entry.id && current === hit.entry.page) {+ row.classList.add("on");+ }+ row.append(icon(pageDef?.icon ?? "sliders"));+ const textContainer = h("div", { class: "hub-search-row-text" });+ const rowTitle = h("div", { class: "hub-search-row-title", text: hit.label ?? t(hit.entry.title) });+ const rowSubtitle = h("div", {+ class: "hub-search-row-subtitle",+ text: hit.label+ ? `${pageDef?.title() ?? ""} › ${t(hit.entry.title)}`+ : (pageDef?.title() ?? ""),+ });+ textContainer.append(rowTitle, rowSubtitle);+ row.append(textContainer);+ row.addEventListener("click", () => {+ void show(hit.entry.page, hit.entry.id);+ });+ searchRows.set(hit.entry.id, row);+ resultsContainer.append(row);+ }+ }++ searchInput.addEventListener("input", renderSearchResults);+ searchInput.addEventListener("keydown", (e) => {+ if (e.key === "Escape") {+ searchInput.value = "";+ renderSearchResults();+ } else if (e.key === "Enter") {+ if (searchHits.length > 0) {+ void show(searchHits[0].entry.page, searchHits[0].entry.id);+ }+ }+ });++ searchClear.addEventListener("click", () => {+ searchInput.value = "";+ renderSearchResults();+ searchInput.focus();+ });++ onLanguageChange(() => {+ searchInput.placeholder = t("Search settings");+ if (searchInput.value.trim()) renderSearchResults();+ });+side.append(h("div", { class: "spacer" }), statusLine, h("div", { class: "hub-version", text: `Coucou ${opts.version}` }));clear(root);diff --git a/windows/src/hub/ui.ts b/windows/src/hub/ui.tsindex 47d715ae..12091c9a 100644--- a/windows/src/hub/ui.ts+++ b/windows/src/hub/ui.ts@@ -36,6 +36,7 @@ export const HUB_ICONS: Record<string, string> = {filter: "M4 7h16M7 12h10M10 17h4",nosign: "M12 3.5a8.5 8.5 0 1 0 0 17 8.5 8.5 0 0 0 0-17zM6 6l12 12",star: "M12 3.5l2.6 5.3 5.9.9-4.3 4.1 1 5.8L12 16.9l-5.2 2.7 1-5.8-4.3-4.1 5.9-.9z",+ search: "M10.5 3a7.5 7.5 0 0 1 5.96 12.06l4.24 4.24-1.4 1.4-4.24-4.24A7.5 7.5 0 1 1 10.5 3zm0 2a5.5 5.5 0 1 0 0 11 5.5 5.5 0 0 0 0-11z",};export function icon(name: string): SVGSVGElement {@@ -64,6 +65,12 @@ export function card(...children: (HTMLElement | null | false)[]): HTMLElement {return el;}+/** Sets a data-anchor on an element so settings search can scroll to it and glow. */+export function anchor<T extends HTMLElement>(id: string, el: T): T {+ el.dataset.anchor = id;+ return el;+}+export function divider(): HTMLElement {return h("div", { class: "hub-divider" });}diff --git a/windows/tests/settings_search.test.mjs b/windows/tests/settings_search.test.mjsnew file mode 100644index 00000000..94827add--- /dev/null+++ b/windows/tests/settings_search.test.mjs@@ -0,0 +1,94 @@+import test from "node:test";+import assert from "node:assert/strict";+import { normalize, words, match, searchSettings, SETTINGS_ENTRIES } from "../src/hub/search.ts";++test("SettingsSearch - words normalization and splitting", () => {+ assert.deepEqual(words(" Réglage SON "), ["reglage", "son"]);+ assert.deepEqual(words(" "), []);+ assert.deepEqual(words("général"), ["general"]);+ assert.deepEqual(words("Türkçe Ayarlar"), ["turkce", "ayarlar"]);+ assert.deepEqual(words("Häufige Fragen"), ["haufige", "fragen"]);+});++test("SettingsSearch - match against box, title, and labels (Mac contract parity)", () => {+ const sound = {+ title: "Son",+ page: "Général",+ labels: ["Activer les sons", "Volume", "Ouvrir le dossier des sons"],+ };++ const m = (q) => match(words(q), sound.title, sound.page, sound.labels);++ // The box by its title or its page, whatever the accents and the case.+ assert.deepEqual(m("son"), { kind: "box" });+ assert.deepEqual(m("GENERAL"), { kind: "box" });+ assert.deepEqual(m("général son"), { kind: "box" });++ // A setting inside it.+ assert.deepEqual(m("volu"), { kind: "label", label: "Volume" });+ assert.deepEqual(m("dossier"), { kind: "label", label: "Ouvrir le dossier des sons" });++ // Every word somewhere; the label with most of them.+ assert.deepEqual(m("ouvrir dossier son"), { kind: "label", label: "Ouvrir le dossier des sons" });+ assert.deepEqual(m("volume general"), { kind: "label", label: "Volume" });++ // Not there.+ assert.equal(m("micro"), null);+ assert.equal(m("volume micro"), null, "every word must be found");+ assert.equal(m(""), null);+});++test("SettingsSearch - searchSettings searches entries across Flow, Notch and Mail", () => {+ const pageTitles = {+ dictation: "Dictation",+ flowsettings: "Settings",+ general: "General",+ agents: "Agents",+ mailOverview: "Overview",+ mailRules: "Rules",+ mailBanned: "Banned words",+ mailVIP: "VIP",+ };+ const getPageTitle = (p) => pageTitles[p] ?? p;++ // Search by box name+ const resKeys = searchSettings("keys", getPageTitle);+ assert.ok(resKeys.length > 0);+ assert.ok(resKeys.some((h) => h.entry.id === "flow.keys"));++ // Search by term inside box+ const resHandsfree = searchSettings("handsfree", getPageTitle);+ assert.ok(resHandsfree.length > 0);+ assert.ok(resHandsfree.some((h) => h.entry.id === "flow.keys"));++ // Search by sound in general+ const resSound = searchSettings("sound", getPageTitle);+ assert.ok(resSound.some((h) => h.entry.id === "general.sound"));++ // Search Mail entries+ const resMail = searchSettings("rules", getPageTitle);+ assert.ok(resMail.some((h) => h.entry.id === "mail.rules"));++ const resBanned = searchSettings("banned", getPageTitle);+ assert.ok(resBanned.some((h) => h.entry.id === "mail.banned"));++ // Empty query returns empty array+ assert.deepEqual(searchSettings("", getPageTitle), []);+ assert.deepEqual(searchSettings(" ", getPageTitle), []);++ // Unknown query returns empty array+ assert.deepEqual(searchSettings("nonexistentgibberishqueryxyz", getPageTitle), []);+});++test("SettingsSearch - SETTINGS_ENTRIES integrity and completeness", () => {+ assert.ok(SETTINGS_ENTRIES.length >= 30, "must include complete set of hub settings");+ const ids = new Set();+ for (const entry of SETTINGS_ENTRIES) {+ assert.ok(entry.id, "every entry must have an id");+ assert.ok(!ids.has(entry.id), `duplicate entry id: ${entry.id}`);+ ids.add(entry.id);+ assert.ok(entry.page, `entry ${entry.id} must define a page`);+ assert.ok(entry.title, `entry ${entry.id} must define a title`);+ assert.ok(Array.isArray(entry.terms), `entry ${entry.id} must define terms array`);+ }+});