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
Merge origin/main into the hub language fix (#705)
Claude8f206414f4cf
diff --cc windows/src/hub/shell.tsindex 6cd49939,1e4bd063..7d5ccaaa--- a/windows/src/hub/shell.ts+++ b/windows/src/hub/shell.ts@@@ -84,10 -94,17 +94,18 @@@ const DEFAULT_STATUS: FlowStatus =export async function startHub(root: HTMLElement, opts: HubOptions) {document.body.classList.add("hub-window");+ // The window is created hidden and only shown and hidden afterwards: its+ // canvases animate only while it is on screen (#792).+ await onEvent<boolean>("hub-visible", setWindowShown);+ 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 labels = 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;@@@ -160,21 -197,113 +198,117 @@@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[]) => {- groupsContainer.append(h("div", { class: "hub-group", text: title }));+ const heading = h("div", { class: "hub-group", text: title });- side.append(heading);++ groupsContainer.append(heading);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() }));+ const label = h("span", { text: p.title() });+ b.append(icon(p.icon), label);items.set(p.id, b);+ labels.set(p.id, label);- side.append(b);+ groupsContainer.append(b);}+ return heading;};group("Flow", FLOW_PAGES);- group(t("Notch"), NOTCH_PAGES);+ const notchGroup = 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 --cc windows/tests/hub.test.mjsindex c3502b15,00000000..403be05emode 100644,000000..100644--- a/windows/tests/hub.test.mjs+++ b/windows/tests/hub.test.mjs@@@ -1,133 -1,0 +1,135 @@@+// Language changes must update the existing sidebar as well as its page.+import { beforeEach, test } from "node:test";+import assert from "node:assert/strict";+import { registerHooks } from "node:module";+import { readFileSync } from "node:fs";+import { fileURLToPath } from "node:url";+import ts from "typescript";+import { installFakeDom } from "./fakedom.mjs";+import { calls, emit, sent } from "./tauri.mjs";++// The shell imports its stylesheet; layout is checked in the browser.+registerHooks({+ resolve(specifier, context, nextResolve) {+ if (specifier.endsWith(".css")) {+ return { url: new URL(specifier, context.parentURL).href, shortCircuit: true };+ }+ return nextResolve(specifier, context);+ },+ load(url, context, nextLoad) {+ if (url.endsWith(".css")) return { format: "module", source: "", shortCircuit: true };+ // The canvas helper has a parameter property beyond Node's type stripping.+ if (url.endsWith("/hub/hero.ts")) {+ const { outputText } = ts.transpileModule(readFileSync(fileURLToPath(url), "utf8"), {+ compilerOptions: { target: ts.ScriptTarget.ES2022, module: ts.ModuleKind.ESNext },+ });+ return { format: "module", source: outputText, shortCircuit: true };+ }+ return nextLoad(url, context);+ },+});++const dom = installFakeDom();+// Keep canvas animation asleep: these tests exercise the shell's DOM only.+document.visibilityState = "hidden";+document.addEventListener = () => {};+document.documentElement = { dataset: {} };+window.addEventListener = () => {};++const { h } = await import("../src/views/dom.ts");+const { onLanguageChange, setLanguage, t } = await import("../src/i18n/i18n.ts");+const { FLOW_PAGES, NOTCH_PAGES, startHub } = await import("../src/hub/shell.ts");+const pages = [...FLOW_PAGES, ...NOTCH_PAGES];+const settle = () => new Promise((resolve) => setImmediate(resolve));++beforeEach(() => {+ setLanguage("en");+ calls.length = 0;+});++async function openHub() {+ const root = dom.root();+ const hub = await startHub(root, {+ version: "test",+ flowPages: Object.fromEntries(FLOW_PAGES.map((page) => [page.id, (container) => {+ container.append(h("h1", { text: page.title() }));+ }])),+ renderNotch: async () => {},+ });++ // The fake DOM keeps no input value: the settings search field starts empty.++ for (const input of root.find(".hub-search-input")) input.value = "";+ // The settings entry point wires language changes to this public method.+ const off = onLanguageChange(() => hub.redraw());+ return { root, hub, off, buttons: root.find(".hub-item") };+}++test("language redraw relabels sidebar nodes and preserves selection and navigation", async () => {+ const { root, hub, off, buttons } = await openHub();+ try {+ const logo = root.find(".hub-brand")[0].find("CANVAS")[0];+ const labels = buttons.map((button) => button.find("SPAN")[0]);+ const groups = root.find(".hub-group");+ buttons[FLOW_PAGES.length].fire("click");+ await settle();+ assert.equal(hub.current(), "general");+ assert.equal(root.find("H1")[0].textContent, "General");+ calls.length = 0;++ for (const language of ["fr", "ar", "en"]) {+ setLanguage(language);+ await settle();+ assert.deepEqual(root.find(".hub-item"), buttons, "keep the existing buttons");+ assert.deepEqual(buttons.map((button) => button.find("SPAN")[0]), labels);+ assert.deepEqual(buttons.map((button) => button.textContent), pages.map((page) => page.title()));+ assert.equal(groups[0].textContent, "Flow");+ assert.equal(groups[1].textContent, t("Notch"));+ assert.equal(root.find(".hub-status")[0].textContent, t("Dictation is off"));+ assert.equal(root.find(".hub-brand")[0].find("CANVAS")[0], logo);+ assert.equal(hub.current(), "general");+ assert.deepEqual(buttons.filter((button) => button.classList.contains("on")), [buttons[FLOW_PAGES.length]]);+ assert.equal(root.find("H1")[0].textContent, t("General"));+ assert.equal(document.documentElement.dataset.dir, language === "ar" ? "rtl" : "ltr");+ }+ assert.deepEqual(calls, [], "redrawing must not save settings or request data");+ buttons[0].fire("click");+ await settle();+ assert.equal(hub.current(), "dictation", "existing click listeners still work");+ } finally {+ off();+ }+});++test("language redraw retains the latest dictation state and key in the status line", async () => {+ const { root, off } = await openHub();+ try {+ const status = root.find(".hub-status")[0];+ emit("flow-prefs", { enabled: true, key: "right_ctrl" });+ emit("speech-models", { parakeet: { state: "ready" } });+ const english = status.textContent;+ assert.match(english, /^Ready · hold /);+ calls.length = 0;+ setLanguage("fr");+ await settle();+ assert.notEqual(status.textContent, english);+ assert.equal(status.textContent, "Prête · maintiens Ctrl de droite");+ setLanguage("en");+ await settle();+ assert.equal(status.textContent, english);+ assert.deepEqual(sent("flow_set_prefs"), []);+ assert.deepEqual(calls, []);+ } finally {+ off();+ }+});++test("the sidebar uses the selected language on its first render", async () => {+ setLanguage("es");+ const { root, off, buttons } = await openHub();+ try {+ assert.deepEqual(buttons.map((button) => button.textContent), pages.map((page) => page.title()));+ assert.equal(root.find(".hub-group")[1].textContent, t("Notch"));+ assert.equal(root.find(".hub-status")[0].textContent, t("Dictation is off"));+ } finally {+ off();+ }+});