Skip to content

Soul-driven AI agent with permission-hardened tools, token budgets, and multi-channel access. Runs 24/7 from CLI, Telegram or More.

feat(desktop): notifications for needs-you and long tasks, with sounds and unread dots

Salman Qureshic51f167b301d
diff --git a/apps/desktop/src-tauri/capabilities/default.json b/apps/desktop/src-tauri/capabilities/default.json
index de64cd6e..65b964fc 100644
--- a/apps/desktop/src-tauri/capabilities/default.json
+++ b/apps/desktop/src-tauri/capabilities/default.json
@@ -13,6 +13,8 @@
"core:window:allow-minimize",
"core:window:allow-unminimize",
"core:window:allow-start-dragging",
+ "core:window:allow-request-user-attention",
+ "core:window:allow-set-badge-count",
"core:app:allow-version",
"core:app:allow-name",
"store:default",
diff --git a/apps/desktop/src/app/events.ts b/apps/desktop/src/app/events.ts
index 83e43879..4c65d2a8 100644
--- a/apps/desktop/src/app/events.ts
+++ b/apps/desktop/src/app/events.ts
@@ -13,6 +13,7 @@ import type { BotActivityEvent, ChatMessage, CodeMode, PendingPrompt } from "~/a
import { useBots, useChat, useRuntimeState, type AgentState } from "./store";
import { conversations, useCodeSessions, type ConversationStore, type Surface } from "./conversation";
import type { ArtifactRef } from "~/api/artifacts";
+import { useNotify } from "./notify/store";
export function useRuntimeEvents(enabled: boolean): void {
const chatId = conversations.chat((s) => s.activeId);
@@ -229,6 +230,17 @@ export async function openThread(surface: Surface, id: string | null): Promise<v
return;
}
store.getState().setLoading(true);
+ useNotify.getState().seen(id);
+ // Prompts still waiting here (asked while you were elsewhere, perhaps from a notification).
+ void http.get<{ prompts?: Array<Record<string, unknown>> }>(`/api/chat/pending?sessionId=${encodeURIComponent(id)}`)
+ .then((r) => {
+ if (store.getState().activeId !== id) return;
+ for (const p of r.prompts ?? []) {
+ const kind = p.type === "choice_prompt" ? "choice" : p.type === "permission_continue" ? "continue" : "permission";
+ store.getState().addPrompt(toPrompt(kind, p, String(p.prompt ?? p.question ?? "")));
+ }
+ })
+ .catch(() => { /* older Mercury */ });
// The plan Mercury was working through in this conversation, if any.
void http.get<{ plan: { steps: Array<{ label: string; status: "pending" | "active" | "done" }>; updatedAt: number } | null }>(`/api/chat/plan?sessionId=${encodeURIComponent(id)}`)
.then((r) => { if (store.getState().activeId === id && r.plan?.steps?.length) store.getState().setPlan(r.plan); })
diff --git a/apps/desktop/src/app/notify/notify.test.ts b/apps/desktop/src/app/notify/notify.test.ts
new file mode 100644
index 00000000..4b224453
--- /dev/null
+++ b/apps/desktop/src/app/notify/notify.test.ts
@@ -0,0 +1,74 @@
+import { beforeEach, describe, expect, it, vi } from "vitest";
+
+vi.mock("~/api/mercury", () => ({ chat: {} }));
+const played: string[] = [];
+vi.mock("./sounds", () => ({ playSound: (id: string) => played.push(id), SOUNDS: [], CUSTOM_MAX_BYTES: 1 }));
+
+const { handleActivity } = await import("./notify");
+const { useNotify, DEFAULT_PREFS, worthTelling } = await import("./store");
+const { conversations } = await import("../conversation");
+const { useUi } = await import("../store");
+const { useVoice } = await import("../voice");
+
+function reset() {
+ useNotify.setState({ prefs: { ...DEFAULT_PREFS, asked: true }, unread: {}, waiting: {}, alerts: [] });
+ conversations.chat.setState({ activeId: "open" });
+ useUi.setState({ view: "chat" });
+ useVoice.setState({ active: false });
+ played.length = 0;
+}
+
+describe("notifications", () => {
+ beforeEach(reset);
+
+ it("only long tasks are worth telling; failures always", () => {
+ expect(worthTelling("done", 5_000, DEFAULT_PREFS)).toBe(false);
+ expect(worthTelling("done", 31_000, DEFAULT_PREFS)).toBe(true);
+ expect(worthTelling("failed", 1_000, DEFAULT_PREFS)).toBe(true);
+ expect(worthTelling("done", 31_000, { ...DEFAULT_PREFS, done: false })).toBe(false);
+ });
+
+ it("a long task finishing elsewhere gets a blue dot and a sound", () => {
+ handleActivity({ kind: "done", sessionId: "other", title: "Research", ms: 45_000, preview: "Report ready" });
+ expect(useNotify.getState().unread.other).toBeTruthy();
+ expect(played).toEqual(["pop"]);
+ });
+
+ it("a quick reply elsewhere is marked new but stays quiet", () => {
+ handleActivity({ kind: "done", sessionId: "other", ms: 3_000 });
+ expect(useNotify.getState().unread.other).toBeTruthy();
+ expect(played).toEqual([]);
+ });
+
+ it("the conversation on screen is never marked new", () => {
+ handleActivity({ kind: "done", sessionId: "open", ms: 60_000 });
+ expect(useNotify.getState().unread.open).toBeUndefined();
+ });
+
+ it("needs-you marks the conversation until it's answered", () => {
+ handleActivity({ kind: "needs_you", sessionId: "other", id: "perm_1", prompt: "Run deploy?" });
+ expect(useNotify.getState().waiting.other).toBe("perm_1");
+ expect(played).toEqual(["pop"]);
+ handleActivity({ kind: "resolved", sessionId: "other", id: "perm_1" });
+ expect(useNotify.getState().waiting.other).toBeUndefined();
+ });
+
+ it("muted: no sound, but the dot still shows", () => {
+ useNotify.getState().setPrefs({ muted: true });
+ handleActivity({ kind: "done", sessionId: "other", ms: 90_000 });
+ expect(played).toEqual([]);
+ expect(useNotify.getState().unread.other).toBeTruthy();
+ });
+
+ it("stays quiet during a voice call", () => {
+ useVoice.setState({ active: true });
+ handleActivity({ kind: "needs_you", sessionId: "other", id: "p" });
+ expect(played).toEqual([]);
+ });
+
+ it("opening the conversation clears its dot", () => {
+ useNotify.getState().markUnread("x");
+ useNotify.getState().seen("x");
+ expect(useNotify.getState().unread.x).toBeUndefined();
+ });
+});
diff --git a/apps/desktop/src/app/notify/notify.ts b/apps/desktop/src/app/notify/notify.ts
new file mode 100644
index 00000000..49227fb7
--- /dev/null
+++ b/apps/desktop/src/app/notify/notify.ts
@@ -0,0 +1,222 @@
+/* ═══════════════════════════════════════════════════════════════
+ Notifications: when a conversation you're not looking at needs an
+ answer, or a long task finishes or fails, Mercury tells you.
+
+ Every alert is layered so it still lands when system notifications
+ are off or blocked (desktop can't even tell: the OS drops them
+ silently): the system banner, plus a sound, the Dock / taskbar badge
+ and bounce, the blue dot on the conversation, and an in-app alert
+ whenever the window is on screen.
+ ═══════════════════════════════════════════════════════════════ */
+
+import { useEffect } from "react";
+import { openStream } from "~/api/stream";
+import { isTauri } from "~/shell/tauri";
+import { conversations, useCodeSessions, type Surface } from "../conversation";
+import { useUi } from "../store";
+import { useVoice } from "../voice";
+import { playSound } from "./sounds";
+import { useNotify, worthTelling } from "./store";
+
+export interface ActivityEvent {
+ kind: "started" | "needs_you" | "resolved" | "done" | "stopped" | "failed";
+ sessionId: string;
+ title?: string;
+ id?: string;
+ prompt?: string;
+ ms?: number;
+ preview?: string;
+ message?: string;
+}
+
+/** Which surface a session belongs to. */
+export function surfaceOf(sessionId: string): Surface {
+ return useCodeSessions.getState().sessions.some((s) => s.id === sessionId) ? "code" : "chat";
+}
+
+/** The conversation is the one on screen (its surface shown, it open). */
+export function onScreen(sessionId: string): boolean {
+ const surface = surfaceOf(sessionId);
+ return useUi.getState().view === surface && conversations[surface].getState().activeId === sessionId;
+}
+
+function windowFocused(): boolean {
+ return typeof document !== "undefined" && document.visibilityState === "visible" && document.hasFocus();
+}
+
+/** Watching = on screen in a focused window: nothing to tell. */
+export function watching(sessionId: string): boolean {
+ return onScreen(sessionId) && windowFocused();
+}
+
+// ── system notifications ───────────────────────────────────────────
+
+export type Permission = "granted" | "denied" | "default" | "unsupported";
+
+/** Desktop always reports granted (the OS decides silently); the web reports the truth. */
+export async function permission(): Promise<Permission> {
+ if (isTauri) {
+ try { const { isPermissionGranted } = await import("@tauri-apps/plugin-notification"); return (await isPermissionGranted()) ? "granted" : "default"; } catch { return "unsupported"; }
+ }
+ if (typeof Notification === "undefined") return "unsupported";
+ return Notification.permission;
+}
+
+export async function askPermission(): Promise<Permission> {
+ if (isTauri) {
+ try { const { requestPermission } = await import("@tauri-apps/plugin-notification"); return await requestPermission(); } catch { return "unsupported"; }
+ }
+ if (typeof Notification === "undefined") return "unsupported";
+ try { return await Notification.requestPermission(); } catch { return "denied"; }
+}
+
+async function systemNotify(title: string, body: string): Promise<boolean> {
+ try {
+ if (isTauri) {
+ const { sendNotification } = await import("@tauri-apps/plugin-notification");
+ sendNotification({ title, body });
+ return true;
+ }
+ if (typeof Notification !== "undefined" && Notification.permission === "granted") {
+ const n = new Notification(title, { body, silent: true });
+ n.onclick = () => { window.focus(); n.close(); };
+ return true;
+ }
+ } catch { /* fall through to the other layers */ }
+ return false;
+}
+
+async function bounce(critical: boolean): Promise<void> {
+ if (!isTauri) return;
+ try {
+ const { getCurrentWindow, UserAttentionType } = await import("@tauri-apps/api/window");
+ await getCurrentWindow().requestUserAttention(critical ? UserAttentionType.Critical : UserAttentionType.Informational);
+ } catch { /* not every platform can */ }
+}
+
+async function setBadge(count: number): Promise<void> {
+ if (!isTauri) return;
+ try {
+ const { getCurrentWindow } = await import("@tauri-apps/api/window");
+ await getCurrentWindow().setBadgeCount(count > 0 ? count : undefined);
+ } catch { /* Windows has no badge count */ }
+}
+
+/** A notified conversation to offer when the window comes back. */
+let lastTold: { sessionId: string; at: number; kind: "needs" | "done" | "failed"; title: string; body: string } | null = null;
+
+export function sendTest(): void {
+ const { prefs, custom } = useNotify.getState();
+ if (!prefs.muted) playSound(prefs.sound, prefs.volume, custom?.url);
+ void systemNotify("Mercury", "Notifications are working. You'll hear this when a long task finishes.");
+ void bounce(false);
+}
+
+/** Tell the owner something, through every layer that applies. */
+function tell(kind: "needs" | "done" | "failed", sessionId: string, title: string, body: string): void {
+ const { prefs, custom, pushAlert } = useNotify.getState();
+ if (!prefs.muted) playSound(prefs.sound, prefs.volume, custom?.url);
+ const visible = typeof document !== "undefined" && document.visibilityState === "visible" && document.hasFocus();
+ if (visible) {
+ // The window is in front: an in-app alert is the right size.
+ pushAlert({ kind, title, body, sessionId });
+ return;
+ }
+ lastTold = { sessionId, at: Date.now(), kind, title, body };
+ if (prefs.system) void systemNotify(title, body);
+ void bounce(kind === "needs");
+}
+
+function label(e: ActivityEvent): string {
+ return (e.title || "").replace(/^Code · /, "").trim() || "A conversation";
+}
+
+export function handleActivity(e: ActivityEvent): void {
+ const n = useNotify.getState();
+ // On a call, Mercury is already talking to you.
+ if (useVoice.getState().active) return;
+ switch (e.kind) {
+ case "needs_you": {
+ n.markWaiting(e.sessionId, e.id ?? "");
+ if (watching(e.sessionId) || !n.prefs.needsYou) return;
+ tell("needs", e.sessionId, "Mercury needs you", `${label(e)}: ${e.prompt || "waiting for your answer"}`);
+ return;
+ }
+ case "resolved":
+ n.clearWaiting(e.sessionId, e.id);
+ return;
+ case "done":
+ case "failed": {
+ n.clearWaiting(e.sessionId);
+ if (!onScreen(e.sessionId)) n.markUnread(e.sessionId);
+ if (watching(e.sessionId) || !worthTelling(e.kind, e.ms ?? 0, n.prefs)) return;
+ if (e.kind === "done") tell("done", e.sessionId, `Done: ${label(e)}`, e.preview || "Mercury finished.");
+ else tell("failed", e.sessionId, `Stopped with an error: ${label(e)}`, e.message || "Something went wrong.");
+ // First long task: offer system notifications, once.
+ if (!n.prefs.asked) {
+ n.setPrefs({ asked: true });
+ void permission().then((p) => { if (p === "default") n.pushAlert({ kind: "ask", title: "Get a notification when long tasks finish?", body: "Mercury can tell you when it's done or needs you, even when the app is in the background." }); });
+ }
+ return;
+ }
+ case "stopped":
+ n.clearWaiting(e.sessionId);
+ return;
+ }
+}
+
+/** Open the conversation an alert is about. */
+export function openFromAlert(sessionId: string): void {
+ const surface = surfaceOf(sessionId);
+ useUi.getState().setView(surface);
+ void import("../events").then(({ openThread }) => openThread(surface, sessionId));
+}
+
+/** The activity stream, the badge, and the "you were notified" offer on return. */
+export function useNotifications(enabled: boolean): void {
+ useEffect(() => {
+ if (!enabled) return;
+ const stream = openStream("/api/chat/activity", {
+ onEvent: (event, raw) => {
+ if (event !== "activity") return;
+ try { handleActivity(JSON.parse(raw) as ActivityEvent); } catch { /* ignore a bad line */ }
+ },
+ });
+ return () => stream.close();
+ }, [enabled]);
+
+ // A conversation on screen has nothing new.
+ useEffect(() => {
+ const check = () => {
+ for (const s of ["chat", "code"] as const) {
+ const id = conversations[s].getState().activeId;
+ if (id && useUi.getState().view === s) useNotify.getState().seen(id);
+ }
+ };
+ check();
+ const offs = [useUi.subscribe(check), conversations.chat.subscribe(check), conversations.code.subscribe(check)];
+ return () => offs.forEach((off) => off());
+ }, []);
+
+ // Badge: conversations waiting on you plus ones with something new.
+ useEffect(() => {
+ const sync = () => {
+ const s = useNotify.getState();
+ void setBadge(s.prefs.badge ? Object.keys(s.waiting).length + Object.keys(s.unread).length : 0);
+ };
+ sync();
+ return useNotify.subscribe(sync);
+ }, []);
+
+ // Back in the window soon after a notification (perhaps by clicking it): offer to open it.
+ useEffect(() => {
+ const onFocus = () => {
+ const t = lastTold;
+ lastTold = null;
+ if (!t || Date.now() - t.at > 5 * 60_000 || onScreen(t.sessionId)) return;
+ useNotify.getState().pushAlert({ kind: t.kind, title: t.title, body: t.body, sessionId: t.sessionId });
+ };
+ window.addEventListener("focus", onFocus);
+ return () => window.removeEventListener("focus", onFocus);
+ }, []);
+}
diff --git a/apps/desktop/src/app/notify/sounds.ts b/apps/desktop/src/app/notify/sounds.ts
new file mode 100644
index 00000000..be9e2a8a
--- /dev/null
+++ b/apps/desktop/src/app/notify/sounds.ts
@@ -0,0 +1,122 @@
+/**
+ * Notification sounds: twelve short ones made with Web Audio (no files to
+ * ship, crisp at any volume), or the owner's own clip. Each is under a
+ * second and quiet by design: a nudge, not an alarm.
+ */
+
+export type SoundId = "pop" | "chime" | "ding" | "glass" | "bubble" | "tick" | "marimba" | "bell" | "blip" | "drop" | "pluck" | "twinkle" | "custom";
+
+export const SOUNDS: Array<{ id: Exclude<SoundId, "custom">; label: string }> = [
+ { id: "pop", label: "Pop" },
+ { id: "chime", label: "Chime" },
+ { id: "ding", label: "Ding" },
+ { id: "glass", label: "Glass" },
+ { id: "bubble", label: "Bubble" },
+ { id: "tick", label: "Tick" },
+ { id: "marimba", label: "Marimba" },
+ { id: "bell", label: "Bell" },
+ { id: "blip", label: "Blip" },
+ { id: "drop", label: "Drop" },
+ { id: "pluck", label: "Pluck" },
+ { id: "twinkle", label: "Twinkle" },
+];
+
+/** Own sounds are kept on this device; a short clip is plenty. */
+export const CUSTOM_MAX_BYTES = 1024 * 1024;
+
+let ctx: AudioContext | null = null;
+function audio(): AudioContext | null {
+ try {
+ ctx ??= new AudioContext();
+ if (ctx.state === "suspended") void ctx.resume();
+ return ctx;
+ } catch {
+ return null;
+ }
+}
+
+interface Tone {
+ type?: OscillatorType;
+ freq: number;
+ /** Glide to this frequency. */
+ to?: number;
+ at?: number;
+ dur: number;
+ gain?: number;
+ attack?: number;
+}
+
+function tones(list: Tone[], volume: number): void {
+ const a = audio();
+ if (!a) return;
+ const out = a.createGain();
+ out.gain.value = Math.max(0, Math.min(1, volume));
+ out.connect(a.destination);
+ const t0 = a.currentTime + 0.01;
+ for (const t of list) {
+ const o = a.createOscillator();
+ const g = a.createGain();
+ o.type = t.type ?? "sine";
+ const start = t0 + (t.at ?? 0);
+ const end = start + t.dur;
+ o.frequency.setValueAtTime(t.freq, start);
+ if (t.to) o.frequency.exponentialRampToValueAtTime(t.to, end);
+ const peak = t.gain ?? 0.35;
+ g.gain.setValueAtTime(0.0001, start);
+ g.gain.exponentialRampToValueAtTime(peak, start + (t.attack ?? 0.006));
+ g.gain.exponentialRampToValueAtTime(0.0001, end);
+ o.connect(g).connect(out);
+ o.start(start);
+ o.stop(end + 0.02);
+ }
+}
+
+function noiseTick(volume: number): void {
+ const a = audio();
+ if (!a) return;
+ const len = Math.floor(a.sampleRate * 0.03);
+ const buf = a.createBuffer(1, len, a.sampleRate);
+ const data = buf.getChannelData(0);
+ for (let i = 0; i < len; i++) data[i] = (Math.random() * 2 - 1) * (1 - i / len) ** 3;
+ const src = a.createBufferSource();
+ src.buffer = buf;
+ const band = a.createBiquadFilter();
+ band.type = "bandpass";
+ band.frequency.value = 3200;
+ band.Q.value = 1.2;
+ const g = a.createGain();
+ g.gain.value = Math.max(0, Math.min(1, volume)) * 0.9;
+ src.connect(band).connect(g).connect(a.destination);
+ src.start();
+}
+
+const RECIPES: Record<Exclude<SoundId, "custom">, (v: number) => void> = {
+ pop: (v) => tones([{ freq: 620, to: 190, dur: 0.09, gain: 0.5, attack: 0.003 }], v),
+ chime: (v) => tones([{ freq: 880, dur: 0.6, gain: 0.25 }, { freq: 1320, dur: 0.55, gain: 0.14, at: 0.01 }], v),
+ ding: (v) => tones([{ freq: 1046.5, dur: 0.5, gain: 0.3 }, { freq: 2093, dur: 0.3, gain: 0.08 }], v),
+ glass: (v) => tones([{ freq: 1567.98, dur: 0.38, gain: 0.2 }, { freq: 2349.3, dur: 0.3, gain: 0.12, at: 0.005 }, { freq: 1575, dur: 0.38, gain: 0.08 }], v),
+ bubble: (v) => tones([{ freq: 320, to: 940, dur: 0.12, gain: 0.4, attack: 0.004 }], v),
+ tick: (v) => noiseTick(v),
+ marimba: (v) => tones([{ freq: 523.25, dur: 0.32, gain: 0.4, attack: 0.002 }, { freq: 2093, dur: 0.06, gain: 0.12, attack: 0.001 }], v),
+ bell: (v) => tones([{ type: "triangle", freq: 660, dur: 0.9, gain: 0.3 }, { freq: 1650, dur: 0.5, gain: 0.1 }, { freq: 2475, dur: 0.25, gain: 0.05 }], v),
+ blip: (v) => tones([{ type: "square", freq: 880, dur: 0.06, gain: 0.08, attack: 0.002 }, { type: "square", freq: 1320, dur: 0.06, gain: 0.07, at: 0.07, attack: 0.002 }], v),
+ drop: (v) => tones([{ freq: 1250, to: 310, dur: 0.18, gain: 0.4, attack: 0.003 }], v),
+ pluck: (v) => tones([{ type: "triangle", freq: 392, dur: 0.3, gain: 0.45, attack: 0.002 }, { freq: 784, dur: 0.12, gain: 0.1, attack: 0.002 }], v),
+ twinkle: (v) => tones([{ freq: 1046.5, dur: 0.14, gain: 0.22 }, { freq: 1318.5, dur: 0.14, gain: 0.22, at: 0.08 }, { freq: 1568, dur: 0.3, gain: 0.22, at: 0.16 }], v),
+};
+
+/** Play a sound; a custom one plays from its data URL. Fails quietly (no audio device, autoplay rules). */
+export function playSound(id: SoundId, volume: number, customUrl?: string | null): void {
+ try {
+ if (id === "custom") {
+ if (!customUrl) return RECIPES.pop(volume);
+ const el = new Audio(customUrl);
+ el.volume = Math.max(0, Math.min(1, volume));
+ void el.play().catch(() => {});
+ return;
+ }
+ (RECIPES[id] ?? RECIPES.pop)(volume);
+ } catch {
+ /* sound is a nicety */
+ }
+}
diff --git a/apps/desktop/src/app/notify/store.ts b/apps/desktop/src/app/notify/store.ts
new file mode 100644
index 00000000..99a40d84
--- /dev/null
+++ b/apps/desktop/src/app/notify/store.ts
@@ -0,0 +1,99 @@
+import { create } from "zustand";
+import type { SoundId } from "./sounds";
+
+/**
+ * What notifies, and how: preferences (this device), which conversations
+ * have something new (the blue dot) or are waiting on you (amber), and the
+ * in-app alerts shown when system notifications are off or blocked.
+ */
+
+export interface NotifyPrefs {
+ /** System notifications, if the OS allows them. */
+ system: boolean;
+ needsYou: boolean;
+ done: boolean;
+ /** A finished task notifies only when it ran at least this long (seconds). */
+ doneAfterSec: number;
+ failed: boolean;
+ sound: SoundId;
+ volume: number;
+ muted: boolean;
+ /** Count on the Dock / taskbar icon. */
+ badge: boolean;
+ /** Asked once whether to turn system notifications on. */
+ asked: boolean;
+}
+
+export const DEFAULT_PREFS: NotifyPrefs = { system: true, needsYou: true, done: true, doneAfterSec: 30, failed: true, sound: "pop", volume: 0.6, muted: false, badge: true, asked: false };
+
+const PREFS_KEY = "mercury.notify.prefs.v1";
+const CUSTOM_KEY = "mercury.notify.customSound.v1";
+const SEEN_KEY = "mercury.notify.unread.v1";
+
+function read<T>(key: string, fallback: T): T {
+ try { const raw = localStorage.getItem(key); return raw ? (JSON.parse(raw) as T) : fallback; } catch { return fallback; }
+}
+function write(key: string, value: unknown): void {
+ try { if (value === null) localStorage.removeItem(key); else localStorage.setItem(key, JSON.stringify(value)); } catch { /* per-device nicety */ }
+}
+
+export interface CustomSound { name: string; url: string }
+
+export interface Alert {
+ id: string;
+ kind: "needs" | "done" | "failed" | "ask";
+ title: string;
+ body: string;
+ sessionId?: string;
+}
+
+interface NotifyState {
+ prefs: NotifyPrefs;
+ custom: CustomSound | null;
+ /** Conversations with a reply you haven't opened. */
+ unread: Record<string, number>;
+ /** Conversations waiting for your answer. */
+ waiting: Record<string, string>;
+ alerts: Alert[];
+ setPrefs(patch: Partial<NotifyPrefs>): void;
+ setCustom(c: CustomSound | null): void;
+ markUnread(id: string): void;
+ markWaiting(id: string, promptId: string): void;
+ clearWaiting(id: string, promptId?: string): void;
+ seen(id: string): void;
+ pushAlert(a: Omit<Alert, "id">): void;
+ dismiss(id: string): void;
+}
+
+export const useNotify = create<NotifyState>((set) => ({
+ prefs: { ...DEFAULT_PREFS, ...read<Partial<NotifyPrefs>>(PREFS_KEY, {}) },
+ custom: read<CustomSound | null>(CUSTOM_KEY, null),
+ unread: read<Record<string, number>>(SEEN_KEY, {}),
+ waiting: {},
+ alerts: [],
+ setPrefs: (patch) => set((s) => { const prefs = { ...s.prefs, ...patch }; write(PREFS_KEY, prefs); return { prefs }; }),
+ setCustom: (custom) => { write(CUSTOM_KEY, custom); set({ custom }); },
+ markUnread: (id) => set((s) => { const unread = { ...s.unread, [id]: Date.now() }; write(SEEN_KEY, unread); return { unread }; }),
+ markWaiting: (id, promptId) => set((s) => ({ waiting: { ...s.waiting, [id]: promptId } })),
+ clearWaiting: (id, promptId) => set((s) => {
+ if (!(id in s.waiting) || (promptId && s.waiting[id] !== promptId)) return s;
+ const waiting = { ...s.waiting };
+ delete waiting[id];
+ return { waiting };
+ }),
+ seen: (id) => set((s) => {
+ if (!(id in s.unread)) return s;
+ const unread = { ...s.unread };
+ delete unread[id];
+ write(SEEN_KEY, unread);
+ return { unread };
+ }),
+ pushAlert: (a) => set((s) => ({ alerts: [...s.alerts.filter((x) => !(a.sessionId && x.sessionId === a.sessionId && x.kind === a.kind)), { ...a, id: crypto.randomUUID() }].slice(-3) })),
+ dismiss: (id) => set((s) => ({ alerts: s.alerts.filter((a) => a.id !== id) })),
+}));
+
+/** Should a finished turn notify? Long ones only; failures always (when on). */
+export function worthTelling(kind: "done" | "failed", ms: number, prefs: NotifyPrefs): boolean {
+ if (kind === "failed") return prefs.failed;
+ return prefs.done && ms >= prefs.doneAfterSec * 1000;
+}
diff --git a/apps/desktop/src/components/Alerts.tsx b/apps/desktop/src/components/Alerts.tsx
new file mode 100644
index 00000000..31f08f54
--- /dev/null
+++ b/apps/desktop/src/components/Alerts.tsx
@@ -0,0 +1,60 @@
+import { AlertTriangle, BellRing, CheckCircle2, Hand, X } from "lucide-react";
+import { useEffect } from "react";
+import { askPermission, openFromAlert, sendTest } from "~/app/notify/notify";
+import { useNotify, type Alert } from "~/app/notify/store";
+import { cx } from "~/lib/cx";
+
+/**
+ * In-app alerts: what a notification would have said, shown inside the
+ * window (the window is in front, or system notifications are off). A
+ * "needs you" alert stays until handled; the rest fade after a while.
+ */
+
+const STAY_MS: Record<Alert["kind"], number | null> = { needs: null, ask: null, done: 9000, failed: 14000 };
+
+export function Alerts() {
+ const alerts = useNotify((s) => s.alerts);
+ if (!alerts.length) return null;
+ return (
+ <div className="pointer-events-none fixed right-4 top-12 z-[60] flex w-[340px] flex-col gap-2" aria-live="polite">
+ {alerts.map((a) => <AlertCard key={a.id} alert={a} />)}
+ </div>
+ );
+}
+
+function AlertCard({ alert: a }: { alert: Alert }) {
+ const dismiss = useNotify((s) => s.dismiss);
+ const setPrefs = useNotify((s) => s.setPrefs);
+ useEffect(() => {
+ const ms = STAY_MS[a.kind];
+ if (!ms) return;
+ const t = window.setTimeout(() => dismiss(a.id), ms);
+ return () => window.clearTimeout(t);
+ }, [a.id, a.kind, dismiss]);
+
+ const Icon = a.kind === "needs" ? Hand : a.kind === "failed" ? AlertTriangle : a.kind === "ask" ? BellRing : CheckCircle2;
+ const tone = a.kind === "needs" ? "text-amber" : a.kind === "failed" ? "text-red" : "text-accent";
+ return (
+ <div role={a.kind === "needs" ? "alert" : "status"} className="pointer-events-auto flex animate-fade-in gap-3 rounded-xl border border-line bg-surface/95 p-3 shadow-xl backdrop-blur">
+ <Icon size={18} className={cx("mt-0.5 shrink-0", tone)} aria-hidden="true" />
+ <div className="min-w-0 flex-1">
+ <div className="text-sm font-medium text-ink">{a.title}</div>
+ <p className="mt-0.5 line-clamp-2 text-sm text-ink2">{a.body}</p>
+ <div className="mt-2 flex gap-2">
+ {a.sessionId && (
+ <button onClick={() => { dismiss(a.id); openFromAlert(a.sessionId!); }} className="rounded-md bg-ink/[0.07] px-2.5 py-1 text-xs font-medium text-ink hover:bg-ink/[0.12]">
+ {a.kind === "needs" ? "Answer" : "Open"}
+ </button>
+ )}
+ {a.kind === "ask" && (
+ <>
+ <button onClick={() => { dismiss(a.id); setPrefs({ system: true }); void askPermission().then(() => sendTest()); }} className="rounded-md bg-accent px-2.5 py-1 text-xs font-medium text-on-accent hover:opacity-90">Turn on</button>
+ <button onClick={() => { dismiss(a.id); setPrefs({ system: false }); }} className="rounded-md px-2.5 py-1 text-xs text-ink3 hover:text-ink">Not now</button>
+ </>
+ )}
+ </div>
+ </div>
+ <button onClick={() => dismiss(a.id)} className="h-fit rounded p-0.5 text-ink4 hover:text-ink" aria-label="Dismiss"><X size={14} /></button>
+ </div>
+ );
+}
diff --git a/apps/desktop/src/layout/Rail.tsx b/apps/desktop/src/layout/Rail.tsx
index a9ee743d..ddbe2d2e 100644
--- a/apps/desktop/src/layout/Rail.tsx
+++ b/apps/desktop/src/layout/Rail.tsx
@@ -1,10 +1,12 @@
import { Bot, Brain, Code2, MessageSquare, Puzzle, Settings, Sparkles, Layers } from "lucide-react";
-import { useEffect } from "react";
+import { useEffect, useMemo } from "react";
import { cx } from "~/lib/cx";
import { useRuntimeState, useUi, type View } from "~/app/store";
import { Mark } from "~/components/Logo";
import { LABELS } from "~/components/indicators/StateOrb";
import { Tooltip } from "~/components/ui/Tooltip";
+import { useNotify } from "~/app/notify/store";
+import { useCodeSessions } from "~/app/conversation";
const ITEMS: Array<{ view: View; label: string; icon: typeof MessageSquare; key: string }> = [
{ view: "chat", label: "Chat", icon: MessageSquare, key: "1" },
@@ -27,6 +29,17 @@ export function Rail({ connectionName }: { connectionName: string }) {
const setView = useUi((s) => s.setView);
const agent = useRuntimeState((s) => s.agent);
const prompts = useRuntimeState((s) => s.prompts.length);
+ const unread = useNotify((s) => s.unread);
+ const waiting = useNotify((s) => s.waiting);
+ const codeIds = useCodeSessions((s) => s.sessions);
+ const dots = useMemo(() => {
+ const code = new Set(codeIds.map((c) => c.id));
+ const of = (ids: string[], surface: "chat" | "code") => ids.filter((id) => code.has(id) === (surface === "code")).length;
+ return {
+ chat: { waiting: of(Object.keys(waiting), "chat"), unread: of(Object.keys(unread), "chat") },
+ code: { waiting: of(Object.keys(waiting), "code"), unread: of(Object.keys(unread), "code") },
+ };
+ }, [unread, waiting, codeIds]);
useEffect(() => {
const onKey = (e: KeyboardEvent) => {
@@ -56,7 +69,13 @@ export function Rail({ connectionName }: { connectionName: string }) {
className={cx("relative flex h-9 w-9 items-center justify-center rounded-md transition-colors", view === v ? "bg-ink/[0.08] text-ink" : "text-ink3 hover:bg-ink/[0.05] hover:text-ink")}
>
<Icon size={18} strokeWidth={1.75} />
- {v === "chat" && prompts > 0 && <span className="absolute right-1.5 top-1.5 block h-1.5 w-1.5 rounded-full bg-amber" aria-label={`${prompts} waiting`} />}
+ {(v === "chat" || v === "code") && (() => {
+ const d = dots[v];
+ const wait = d.waiting + (v === "chat" ? prompts : 0);
+ if (wait > 0) return <span className="absolute right-1.5 top-1.5 block h-1.5 w-1.5 rounded-full bg-amber" aria-label={`${wait} waiting for you`} />;
+ if (d.unread > 0) return <span className="absolute right-1.5 top-1.5 block h-1.5 w-1.5 rounded-full bg-blue" aria-label={`${d.unread} with something new`} />;
+ return null;
+ })()}
</button>
</Tooltip>
))}
diff --git a/apps/desktop/src/layout/Workspace.tsx b/apps/desktop/src/layout/Workspace.tsx
index 616b28c2..a7efbcc4 100644
--- a/apps/desktop/src/layout/Workspace.tsx
+++ b/apps/desktop/src/layout/Workspace.tsx
@@ -21,6 +21,8 @@ import { ArtifactsView } from "~/views/artifacts/ArtifactsView";
import { ErrorBoundary } from "~/components/ErrorBoundary";
import { CloudBanner } from "~/views/settings/Cloud";
import { CallLayer } from "~/views/call/Call";
+import { useNotifications } from "~/app/notify/notify";
+import { Alerts } from "~/components/Alerts";
registerBuiltinStatusItems();
@@ -33,6 +35,7 @@ registerBuiltinStatusItems();
export function Workspace({ connection, health, onSwitchConnection }: { connection: Connection; health: HealthInfo; onSwitchConnection: () => void }) {
const view = useUi((s) => s.view);
useRuntimeEvents(true);
+ useNotifications(true);
usePulsePolling(connection.id);
useVoiceFeed(connection.id);
@@ -63,6 +66,7 @@ export function Workspace({ connection, health, onSwitchConnection }: { connecti
</div>
<StatusBar />
<CallLayer />
+ <Alerts />
</div>
);
}
diff --git a/apps/desktop/src/styles/tokens.css b/apps/desktop/src/styles/tokens.css
index 1c11a4fc..8858697f 100644
--- a/apps/desktop/src/styles/tokens.css
+++ b/apps/desktop/src/styles/tokens.css
@@ -19,6 +19,7 @@
--accent: 26 158 110; /* #1A9E6E */
--on-accent: 255 255 255;
--cyan: 14 124 140; /* #0E7C8C */
+ --blue: 37 99 235; /* #2563EB unread */
--amber: 183 121 31; /* #B7791F */
--red: 197 48 48; /* #C53030 */
--glow: 26 158 110;
@@ -37,6 +38,7 @@
--accent: 52 225 161; /* #34E1A1 */
--on-accent: 4 20 11;
--cyan: 127 216 232; /* #7FD8E8 */
+ --blue: 96 165 250; /* #60A5FA unread */
--amber: 245 196 81; /* #F5C451 */
--red: 255 107 107; /* #FF6B6B */
--glow: 52 225 161;
diff --git a/apps/desktop/src/views/chat/ThreadList.tsx b/apps/desktop/src/views/chat/ThreadList.tsx
index bb8362bf..0d8c7522 100644
--- a/apps/desktop/src/views/chat/ThreadList.tsx
+++ b/apps/desktop/src/views/chat/ThreadList.tsx
@@ -4,6 +4,7 @@ import { cx } from "~/lib/cx";
import * as api from "~/api/mercury";
import type { ChatThread } from "~/api/types";
import { refreshThreads } from "~/app/events";
+import { useNotify } from "~/app/notify/store";
const PAGE = 40;
@@ -23,6 +24,8 @@ export function ThreadList({ threads, activeId, onOpen, onNew, newLabel, searchL
/** Shown above the sessions (e.g. the live Optimus voice session). */
pinned?: React.ReactNode;
}) {
+ const unread = useNotify((s) => s.unread);
+ const waiting = useNotify((s) => s.waiting);
const [limit, setLimit] = useState(PAGE);
const [query, setQuery] = useState("");
const sentinel = useRef<HTMLDivElement>(null);
@@ -76,7 +79,12 @@ export function ThreadList({ threads, activeId, onOpen, onNew, newLabel, searchL
{list.map((t) => (
<div key={t.id} className={cx("group flex items-center rounded-lg", activeId === t.id ? "bg-ink/[0.07]" : "hover:bg-ink/[0.05]")}>
<button onClick={() => onOpen(t.id)} className="min-w-0 flex-1 px-3 py-2.5 text-left text-base" title={t.title || "Untitled"}>
- <span className={cx("block truncate", activeId === t.id ? "text-ink" : "text-ink2 group-hover:text-ink")}>{(t.title || "Untitled").replace(/^Code · /, "")}</span>
+ <span className="flex items-center gap-2">
+ <span className={cx("min-w-0 flex-1 truncate", activeId === t.id ? "text-ink" : unread[t.id] ? "font-medium text-ink" : "text-ink2 group-hover:text-ink")}>{(t.title || "Untitled").replace(/^Code · /, "")}</span>
+ {t.id in waiting
+ ? <span className="h-2 w-2 shrink-0 rounded-full bg-amber" aria-label="Waiting for you" title="Waiting for your answer" />
+ : unread[t.id] && activeId !== t.id ? <span className="h-2 w-2 shrink-0 rounded-full bg-blue" aria-label="New" title="Something new" /> : null}
+ </span>
{renderMeta?.(t)}
</button>
<button onClick={() => void remove(t)} className="mr-1 hidden rounded p-1 text-ink4 hover:text-red group-hover:block" aria-label="Delete thread">
diff --git a/apps/desktop/src/views/settings/Notifications.tsx b/apps/desktop/src/views/settings/Notifications.tsx
new file mode 100644
index 00000000..e534d511
--- /dev/null
+++ b/apps/desktop/src/views/settings/Notifications.tsx
@@ -0,0 +1,166 @@
+import { Check, ExternalLink, Play, Trash2, Upload, Volume2, VolumeX } from "lucide-react";
+import { useEffect, useRef, useState } from "react";
+import { askPermission, permission, sendTest, type Permission } from "~/app/notify/notify";
+import { CUSTOM_MAX_BYTES, playSound, SOUNDS, type SoundId } from "~/app/notify/sounds";
+import { useNotify } from "~/app/notify/store";
+import { Button } from "~/components/ui/Button";
+import { Switch } from "~/components/ui/Switch";
+import { Segmented } from "~/components/ui/bits";
+import { isTauri } from "~/shell/tauri";
+import { cx } from "~/lib/cx";
+
+/**
+ * Notifications: what tells you (needs an answer, a long task done or
+ * failed), how (system banner, sound, Dock badge), and the sound itself:
+ * twelve built in, or your own clip.
+ */
+
+const AFTER: Array<{ value: string; label: string }> = [
+ { value: "10", label: "10 s" }, { value: "30", label: "30 s" }, { value: "60", label: "1 min" }, { value: "120", label: "2 min" }, { value: "300", label: "5 min" },
+];
+
+async function systemSettingsUrl(): Promise<string | null> {
+ if (!isTauri) return null;
+ try {
+ const { platform } = await import("@tauri-apps/plugin-os");
+ const p = platform();
+ if (p === "macos") return "x-apple.systempreferences:com.apple.Notifications-Settings.extension";
+ if (p === "windows") return "ms-settings:notifications";
+ } catch { /* unknown platform */ }
+ return null;
+}
+
+export function NotificationsSettings() {
+ const prefs = useNotify((s) => s.prefs);
+ const custom = useNotify((s) => s.custom);
+ const setPrefs = useNotify((s) => s.setPrefs);
+ const setCustom = useNotify((s) => s.setCustom);
+ const [perm, setPerm] = useState<Permission | null>(null);
+ const [settingsUrl, setSettingsUrl] = useState<string | null>(null);
+ const [note, setNote] = useState<{ text: string; ok: boolean } | null>(null);
+ const file = useRef<HTMLInputElement>(null);
+
+ useEffect(() => { void permission().then(setPerm); void systemSettingsUrl().then(setSettingsUrl); }, []);
+
+ const pick = (id: SoundId) => { setPrefs({ sound: id }); playSound(id, prefs.volume, custom?.url); };
+
+ async function turnOn(v: boolean) {
+ setPrefs({ system: v });
+ if (v) setPerm(await askPermission());
+ }
+
+ function upload(f: File) {
+ setNote(null);
+ if (!f.type.startsWith("audio/")) return setNote({ text: "That isn't an audio file.", ok: false });
+ if (f.size > CUSTOM_MAX_BYTES) return setNote({ text: "Pick a clip under 1 MB (a second or two is plenty).", ok: false });
+ const r = new FileReader();
+ r.onload = () => {
+ const url = String(r.result);
+ setCustom({ name: f.name, url });
+ setPrefs({ sound: "custom" });
+ playSound("custom", prefs.volume, url);
+ setNote({ text: `Using ${f.name}.`, ok: true });
+ };
+ r.onerror = () => setNote({ text: "Couldn't read that file.", ok: false });
+ r.readAsDataURL(f);
+ }
+
+ return (
+ <div className="flex flex-col gap-6">
+ <p className="text-sm text-ink3">Mercury tells you when a conversation you're not looking at needs an answer, or when a long task finishes. Telegram, WhatsApp and other channels already notify you in their own apps.</p>
+
+ <section className="flex flex-col gap-3">
+ <h3 className="text-sm font-medium text-ink">System notifications</h3>
+ <div className="flex flex-col gap-3 rounded-lg border border-line bg-surface px-4 py-3">
+ <div className="flex items-center justify-between gap-4">
+ <div>
+ <div className="text-sm text-ink">Show notifications</div>
+ <div className="text-xs text-ink3">{perm === "denied" ? "Blocked. Allow them in your system settings, then try again." : perm === "unsupported" ? "Not available here; Mercury uses the sound, the badge and in-app alerts instead." : "A banner from your system, even when Mercury is in the background."}</div>
+ </div>
+ <Switch id="notify-system" checked={prefs.system && perm !== "denied"} onCheckedChange={(v) => void turnOn(v)} disabled={perm === "unsupported"} />
+ </div>
+ <div className="flex flex-wrap items-center gap-2">
+ <Button size="sm" variant="outline" onClick={() => { sendTest(); setNote({ text: "Test sent. No banner? Allow Mercury in your system's notification settings.", ok: true }); }}>Send a test</Button>
+ {settingsUrl && (
+ <Button size="sm" variant="ghost" onClick={() => void import("@tauri-apps/plugin-opener").then((m) => m.openUrl(settingsUrl)).catch(() => {})}>
+ <ExternalLink size={13} /> Open system notification settings
+ </Button>
+ )}
+ </div>
+ <p className="text-xs text-ink4">If banners are off or blocked, you still get the sound, a count on the app icon, a blue dot on the conversation, and an alert inside Mercury.</p>
+ </div>
+ </section>
+
+ <section className="flex flex-col gap-3">
+ <h3 className="text-sm font-medium text-ink">Tell me when</h3>
+ <div className="flex flex-col divide-y divide-line rounded-lg border border-line bg-surface">
+ <ToggleRow id="notify-needs" title="Mercury needs an answer" hint="An approval or a question in a conversation you're not looking at." checked={prefs.needsYou} onChange={(v) => setPrefs({ needsYou: v })} />
+ <div className="flex flex-col gap-2 px-4 py-3">
+ <div className="flex items-center justify-between gap-4">
+ <div>
+ <div className="text-sm text-ink">A task finishes</div>
+ <div className="text-xs text-ink3">Only tasks that ran at least this long, so quick replies stay quiet.</div>
+ </div>
+ <Switch id="notify-done" checked={prefs.done} onCheckedChange={(v) => setPrefs({ done: v })} />
+ </div>
+ {prefs.done && <Segmented value={String(prefs.doneAfterSec)} onChange={(v) => setPrefs({ doneAfterSec: Number(v) })} options={AFTER} />}
+ </div>
+ <ToggleRow id="notify-failed" title="A task stops with an error" checked={prefs.failed} onChange={(v) => setPrefs({ failed: v })} />
+ <ToggleRow id="notify-badge" title="Count on the app icon" hint="Conversations waiting for you or with something new." checked={prefs.badge} onChange={(v) => setPrefs({ badge: v })} />
+ </div>
+ </section>
+
+ <section className="flex flex-col gap-3">
+ <div className="flex items-center justify-between">
+ <h3 className="text-sm font-medium text-ink">Sound</h3>
+ <button onClick={() => setPrefs({ muted: !prefs.muted })} aria-pressed={prefs.muted} className="flex items-center gap-1.5 rounded-md px-2 py-1 text-xs text-ink3 hover:bg-ink/[0.05] hover:text-ink">
+ {prefs.muted ? <VolumeX size={14} /> : <Volume2 size={14} />}{prefs.muted ? "Muted" : "Mute"}
+ </button>
+ </div>
+ <div className={cx("flex flex-col gap-4 rounded-lg border border-line bg-surface px-4 py-4", prefs.muted && "opacity-50")}>
+ <label className="flex items-center gap-3 text-sm text-ink2">
+ <span className="w-16 shrink-0">Volume</span>
+ <input type="range" min={0} max={1} step={0.05} value={prefs.volume} onChange={(e) => setPrefs({ volume: Number(e.target.value) })} onMouseUp={() => playSound(prefs.sound, prefs.volume, custom?.url)} className="flex-1 accent-[rgb(var(--accent))]" aria-label="Volume" />
+ <span className="w-10 text-right font-mono text-xs text-ink3">{Math.round(prefs.volume * 100)}%</span>
+ </label>
+ <div className="grid grid-cols-3 gap-2" role="radiogroup" aria-label="Notification sound">
+ {SOUNDS.map((s) => (
+ <button key={s.id} role="radio" aria-checked={prefs.sound === s.id} onClick={() => pick(s.id)}
+ className={cx("flex h-10 items-center gap-2 rounded-lg border px-3 text-left text-sm", prefs.sound === s.id ? "border-accent/70 bg-accent/[0.08] text-ink" : "border-line text-ink2 hover:border-line-strong hover:text-ink")}>
+ {prefs.sound === s.id ? <Check size={14} className="shrink-0 text-accent" /> : <Play size={13} className="shrink-0 text-ink4" />}
+ <span className="flex-1">{s.label}</span>
+ {prefs.sound === s.id && <span className="text-2xs text-accent">Default</span>}
+ </button>
+ ))}
+ </div>
+ <div className="flex flex-wrap items-center gap-2 border-t border-line pt-3">
+ {custom ? (
+ <button role="radio" aria-checked={prefs.sound === "custom"} onClick={() => pick("custom")}
+ className={cx("flex h-10 min-w-0 flex-1 items-center gap-2 rounded-lg border px-3 text-left text-sm", prefs.sound === "custom" ? "border-accent/70 bg-accent/[0.08] text-ink" : "border-line text-ink2 hover:border-line-strong")}>
+ {prefs.sound === "custom" ? <Check size={14} className="shrink-0 text-accent" /> : <Play size={13} className="shrink-0 text-ink4" />}
+ <span className="min-w-0 flex-1 truncate">{custom.name}</span>
+ {prefs.sound === "custom" && <span className="text-2xs text-accent">Default</span>}
+ </button>
+ ) : <span className="flex-1 text-sm text-ink3">Or use your own sound.</span>}
+ <Button size="sm" variant="outline" onClick={() => file.current?.click()}><Upload size={13} /> {custom ? "Replace" : "Choose a file"}</Button>
+ {custom && <Button size="sm" variant="ghost" icon aria-label="Remove your sound" onClick={() => { setCustom(null); if (prefs.sound === "custom") setPrefs({ sound: "pop" }); }}><Trash2 size={14} /></Button>}
+ <input ref={file} type="file" accept="audio/*" className="hidden" onChange={(e) => { const f = e.target.files?.[0]; if (f) upload(f); e.target.value = ""; }} />
+ </div>
+ {note && <p className={cx("text-xs", note.ok ? "text-accent" : "text-red")}>{note.text}</p>}
+ </div>
+ </section>
+ </div>
+ );
+}
+
+function ToggleRow({ id, title, hint, checked, onChange }: { id: string; title: string; hint?: string; checked: boolean; onChange: (v: boolean) => void }) {
+ return (
+ <div className="flex items-center justify-between gap-4 px-4 py-3">
+ <div>
+ <div className="text-sm text-ink">{title}</div>
+ {hint && <div className="text-xs text-ink3">{hint}</div>}
+ </div>
+ <Switch id={id} checked={checked} onCheckedChange={onChange} />
+ </div>
+ );
+}
diff --git a/apps/desktop/src/views/settings/SettingsView.tsx b/apps/desktop/src/views/settings/SettingsView.tsx
index dc3a98da..9f55ebc7 100644
--- a/apps/desktop/src/views/settings/SettingsView.tsx
+++ b/apps/desktop/src/views/settings/SettingsView.tsx
@@ -1,4 +1,4 @@
-import { Activity, Boxes, Info, MessagesSquare, Mic, PanelBottom, Palette, Power, Server, Smartphone, UserRound } from "lucide-react";
+import { Activity, Boxes, Info, MessagesSquare, Mic, PanelBottom, Palette, Power, Server, Smartphone, UserRound, Bell } from "lucide-react";
import { useEffect, useState } from "react";
import { cx } from "~/lib/cx";
import { useUi } from "~/app/store";
@@ -19,17 +19,19 @@ import { ModelsSettings } from "./Models";
import { VoiceSettings } from "./Voice";
import { ChannelsSettings } from "./Channels";
import { isVisible, orderedIds, useContributions, type ContributionArea } from "~/extensions/registry";
+import { NotificationsSettings } from "./Notifications";
/**
* Settings: a section list on the left, one section on the right. Most-used
* first (Appearance), plain labels, every control explains itself in one line.
*/
-type Section = "profile" | "models" | "voice" | "channels" | "appearance" | "statusbar" | "analytics" | "connections" | "devices" | "startup" | "about";
+type Section = "profile" | "models" | "voice" | "notifications" | "channels" | "appearance" | "statusbar" | "analytics" | "connections" | "devices" | "startup" | "about";
const SECTIONS: Array<{ id: Section; label: string; icon: typeof Palette }> = [
{ id: "profile", label: "Profile", icon: UserRound },
{ id: "models", label: "Models", icon: Boxes },
{ id: "voice", label: "Voice", icon: Mic },
+ { id: "notifications", label: "Notifications", icon: Bell },
{ id: "channels", label: "Channels", icon: MessagesSquare },
{ id: "appearance", label: "Appearance", icon: Palette },
{ id: "statusbar", label: "Status bar", icon: PanelBottom },
@@ -71,6 +73,7 @@ export function SettingsView({ connection, health, onSwitchConnection }: { conne
{section === "profile" && <Profile />}
{section === "models" && <ModelsSettings />}
{section === "voice" && <VoiceSettings onOpenModels={() => setSection("models")} />}
+ {section === "notifications" && <NotificationsSettings />}
{section === "channels" && <ChannelsSettings />}
{section === "appearance" && <Appearance />}
{section === "statusbar" && <StatusBarSettings />}
diff --git a/apps/desktop/tailwind.config.js b/apps/desktop/tailwind.config.js
index 99c75b9f..98fceb28 100644
--- a/apps/desktop/tailwind.config.js
+++ b/apps/desktop/tailwind.config.js
@@ -21,6 +21,7 @@ export default {
accent: "rgb(var(--accent) / <alpha-value>)",
"on-accent": "rgb(var(--on-accent) / <alpha-value>)",
cyan: "rgb(var(--cyan) / <alpha-value>)",
+ blue: "rgb(var(--blue) / <alpha-value>)",
amber: "rgb(var(--amber) / <alpha-value>)",
red: "rgb(var(--red) / <alpha-value>)",
white: "#ffffff",