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): Plugins, Skills and Settings follow the list-and-pane patterns

Salman Qureshi9002a89321f5
diff --git a/apps/desktop/src/components/ui/kit.tsx b/apps/desktop/src/components/ui/kit.tsx
new file mode 100644
index 00000000..442db9bb
--- /dev/null
+++ b/apps/desktop/src/components/ui/kit.tsx
@@ -0,0 +1,81 @@
+import { Search } from "lucide-react";
+import { useEffect, useRef, useState, type ReactNode } from "react";
+import { cx } from "~/lib/cx";
+import { Button, type ButtonProps } from "./Button";
+
+/* Shared pieces for list screens (Plugins, Skills, Settings). */
+
+export function SearchField({ value, onChange, placeholder, className }: { value: string; onChange: (v: string) => void; placeholder: string; className?: string }) {
+ return (
+ <label className={cx("flex h-9 items-center gap-2 rounded-lg border border-line bg-surface px-3 text-ink4 focus-within:border-line-strong", className)}>
+ <Search size={15} aria-hidden="true" />
+ <input value={value} onChange={(e) => onChange(e.target.value)} placeholder={placeholder} aria-label={placeholder} className="w-full bg-transparent text-sm text-ink placeholder:text-ink4" />
+ </label>
+ );
+}
+
+/** A tile with the item's initial on a tint chosen from its id: same item, same colour. */
+export function IconTile({ id, label, size = 40 }: { id: string; label: string; size?: number }) {
+ let h = 0;
+ for (let i = 0; i < id.length; i++) h = (h * 31 + id.charCodeAt(i)) >>> 0;
+ const hue = h % 360;
+ return (
+ <span
+ className="flex shrink-0 items-center justify-center rounded-xl font-semibold text-white"
+ style={{ width: size, height: size, fontSize: size * 0.42, background: `linear-gradient(135deg, hsl(${hue} 65% 58%), hsl(${(hue + 35) % 360} 70% 42%))` }}
+ aria-hidden="true"
+ >
+ {(label.trim()[0] ?? "?").toUpperCase()}
+ </span>
+ );
+}
+
+/** Destructive action in two clicks: "Remove" → "Remove? Yes". Resets after 4 s. */
+export function ConfirmButton({ children, confirmLabel = "Confirm", onConfirm, ...rest }: Omit<ButtonProps, "onClick"> & { confirmLabel?: string; onConfirm: () => void }) {
+ const [armed, setArmed] = useState(false);
+ const timer = useRef<ReturnType<typeof setTimeout> | null>(null);
+ useEffect(() => () => { if (timer.current) clearTimeout(timer.current); }, []);
+ return (
+ <Button
+ {...rest}
+ variant={armed ? "danger" : rest.variant ?? "ghost"}
+ onClick={() => {
+ if (armed) { setArmed(false); onConfirm(); return; }
+ setArmed(true);
+ timer.current = setTimeout(() => setArmed(false), 4000);
+ }}
+ >
+ {armed ? confirmLabel : children}
+ </Button>
+ );
+}
+
+/** Page header for list screens: title, count, controls on the right. */
+export function PageHeader({ title, meta, children }: { title: string; meta?: ReactNode; children?: ReactNode }) {
+ return (
+ <header className="flex h-[52px] shrink-0 items-center gap-3 border-b border-line px-5" data-tauri-drag-region>
+ <span className="text-base font-semibold text-ink">{title}</span>
+ {meta && <span className="text-sm text-ink3">{meta}</span>}
+ <div className="flex-1" />
+ {children}
+ </header>
+ );
+}
+
+/** One list row: tile, title + badges, description, actions on the right. */
+export function ItemRow({ tile, title, badges, description, footer, actions, tone }: { tile: ReactNode; title: ReactNode; badges?: ReactNode; description?: ReactNode; footer?: ReactNode; actions?: ReactNode; tone?: "warn" }) {
+ return (
+ <div className={cx("flex items-start gap-4 rounded-xl border bg-surface p-4 transition-colors hover:border-line-strong", tone === "warn" ? "border-amber/40" : "border-line")}>
+ {tile}
+ <div className="min-w-0 flex-1">
+ <div className="flex flex-wrap items-center gap-2">
+ <span className="text-base font-medium text-ink">{title}</span>
+ {badges}
+ </div>
+ {description && <p className="mt-1 line-clamp-2 text-sm text-ink3">{description}</p>}
+ {footer && <div className="mt-2">{footer}</div>}
+ </div>
+ {actions && <div className="flex shrink-0 items-center gap-2 self-center">{actions}</div>}
+ </div>
+ );
+}
diff --git a/apps/desktop/src/views/plugins/PluginsView.tsx b/apps/desktop/src/views/plugins/PluginsView.tsx
index 08859fa0..eac42577 100644
--- a/apps/desktop/src/views/plugins/PluginsView.tsx
+++ b/apps/desktop/src/views/plugins/PluginsView.tsx
@@ -5,12 +5,17 @@ import type { McpServer, PluginItem } from "~/api/types";
import { Button } from "~/components/ui/Button";
import { Switch } from "~/components/ui/Switch";
import { Badge, Empty, Mono, Segmented } from "~/components/ui/bits";
+import { ConfirmButton, IconTile, ItemRow, PageHeader, SearchField } from "~/components/ui/kit";
import { StateOrb } from "~/components/indicators/StateOrb";
import { Input } from "~/components/ui/Input";
type Tab = "installed" | "catalog" | "mcp";
-/** Plugins, the catalog, and MCP servers: three lists, one row style. */
+/**
+ * Plugins: installed, the catalog, MCP servers. One row style across all
+ * three; one primary action per row that names its state (Install,
+ * Installing…, Update); on/off separate from Remove, and Remove asks twice.
+ */
export function PluginsView() {
const [tab, setTab] = useState<Tab>("installed");
const [items, setItems] = useState<PluginItem[]>([]);
@@ -19,6 +24,8 @@ export function PluginsView() {
const [safeMode, setSafeMode] = useState(false);
const [catalogError, setCatalogError] = useState<string | null>(null);
const [loading, setLoading] = useState(false);
+ const [busy, setBusy] = useState<string | null>(null);
+ const [query, setQuery] = useState("");
const [source, setSource] = useState("");
const [note, setNote] = useState<string | null>(null);
@@ -43,84 +50,115 @@ export function PluginsView() {
}
useEffect(() => { void load(); }, []);
- const installed = useMemo(() => items.filter((p) => p.status !== "available"), [items]);
- const catalog = useMemo(() => items.filter((p) => p.status === "available"), [items]);
+ const q = query.trim().toLowerCase();
+ const match = (s: string) => !q || s.toLowerCase().includes(q);
+ const installed = useMemo(() => items.filter((p) => p.status !== "available" && match(`${p.name} ${p.description}`)), [items, q]);
+ const catalog = useMemo(() => items.filter((p) => p.status === "available" && match(`${p.name} ${p.description}`)), [items, q]);
+ const mcpShown = useMemo(() => servers.filter((s) => match(`${s.id} ${s.target}`)), [servers, q]);
+ const updates = items.filter((p) => p.status === "update-available").length;
- async function act(fn: () => Promise<unknown>, done?: string) {
+ async function act(key: string, fn: () => Promise<unknown>, done?: string) {
setNote(null);
+ setBusy(key);
try { await fn(); if (done) setNote(done); } catch (err) { setNote(err instanceof Error ? err.message : String(err)); }
+ setBusy(null);
void load();
}
return (
<div className="flex h-full min-h-0 flex-col">
- <header className="flex h-[52px] shrink-0 items-center gap-3 border-b border-line px-4" data-tauri-drag-region>
- <span className="text-sm font-medium text-ink">Plugins</span>
- <Segmented value={tab} onChange={setTab} options={[{ value: "installed", label: `Installed ${installed.length}` }, { value: "catalog", label: `Catalog ${catalog.length}` }, { value: "mcp", label: `MCP ${servers.length}` }]} />
+ <PageHeader title="Plugins" meta={updates > 0 ? `${updates} update${updates === 1 ? "" : "s"} available` : undefined}>
{safeMode && <Badge tone="amber">safe mode</Badge>}
- <div className="flex-1" />
- <Button variant="ghost" size="sm" icon onClick={() => void load(true)} loading={loading} aria-label="Refresh"><RefreshCw size={14} /></Button>
- </header>
+ <Button variant="ghost" size="sm" icon onClick={() => void load(true)} loading={loading} aria-label="Refresh"><RefreshCw size={15} /></Button>
+ </PageHeader>
<div className="min-h-0 flex-1 overflow-y-auto">
- <div className="mx-auto flex max-w-[760px] flex-col gap-2 px-6 py-5">
- {note && <p className="text-xs text-ink3">{note}</p>}
- {catalogError && tab === "catalog" && <p className="text-xs text-amber">Catalog: {catalogError}</p>}
+ <div className="mx-auto flex max-w-[820px] flex-col gap-3 px-8 py-6">
+ <div className="flex items-center gap-3">
+ <Segmented size="md" value={tab} onChange={setTab} options={[
+ { value: "installed", label: `Installed · ${items.filter((p) => p.status !== "available").length}` },
+ { value: "catalog", label: `Catalog · ${items.filter((p) => p.status === "available").length}` },
+ { value: "mcp", label: `MCP · ${servers.length}` },
+ ]} />
+ <SearchField value={query} onChange={setQuery} placeholder="Search plugins" className="ml-auto w-[260px]" />
+ </div>
- {tab === "installed" && (installed.length === 0 ? <Empty title="No plugins installed" body="Pick one from the catalog, or install from a path or URL below." /> : installed.map((p) => (
- <PluginRow key={p.id} p={p} onToggle={(v) => void act(() => (v ? api.plugins.enable(p.id) : api.plugins.disable(p.id)))} onUpdate={() => void act(() => api.plugins.update(p.id), "Updated.")} onRemove={() => void act(() => api.plugins.uninstall(p.id), "Removed.")} />
- )))}
+ {note && <p className="text-sm text-ink3">{note}</p>}
+ {catalogError && tab === "catalog" && <p className="text-sm text-amber">Catalog: {catalogError}</p>}
- {tab === "catalog" && (catalog.length === 0 ? <Empty title="Nothing new in the catalog" /> : catalog.map((p) => (
- <PluginRow key={p.id} p={p} onInstall={() => void act(() => api.plugins.install(p.id), "Installed.")} />
- )))}
+ {tab === "installed" && (installed.length === 0
+ ? <Empty title={q ? "No installed plugin matches" : "No plugins installed"} body={q ? undefined : "Browse the catalog, or install from a path or URL below."} />
+ : installed.map((p) => (
+ <PluginRow key={p.id} p={p} actions={
+ <>
+ {p.status === "update-available" && <Button size="sm" variant="primary" loading={busy === `u:${p.id}`} onClick={() => void act(`u:${p.id}`, () => api.plugins.update(p.id), `${p.name} updated.`)}>Update</Button>}
+ <Switch id={`plugin-${p.id}`} checked={p.enabled} onCheckedChange={(v) => void act(`t:${p.id}`, () => (v ? api.plugins.enable(p.id) : api.plugins.disable(p.id)))} label={p.enabled ? "On" : "Off"} />
+ <ConfirmButton size="sm" confirmLabel="Remove?" onConfirm={() => void act(`r:${p.id}`, () => api.plugins.uninstall(p.id), `${p.name} removed.`)}>Remove</ConfirmButton>
+ </>
+ } />
+ )))}
+
+ {tab === "catalog" && (catalog.length === 0
+ ? <Empty title={q ? "No catalog plugin matches" : "Nothing new in the catalog"} />
+ : catalog.map((p) => (
+ <PluginRow key={p.id} p={p} actions={
+ <Button size="sm" variant="outline" loading={busy === `i:${p.id}`} onClick={() => void act(`i:${p.id}`, () => api.plugins.install(p.id), `${p.name} installed.`)}>
+ {busy === `i:${p.id}` ? "Installing…" : "Install"}
+ </Button>
+ } />
+ )))}
{tab === "installed" && (
- <div className="mt-4 flex gap-2">
- <Input value={source} onChange={(e) => setSource(e.target.value)} placeholder="Install from a path, URL or catalog id…" mono />
- <Button variant="outline" disabled={!source.trim()} onClick={() => void act(() => api.plugins.install(source.trim()), "Installed.").then(() => setSource(""))}>Install</Button>
+ <div className="mt-3 flex gap-2">
+ <Input value={source} onChange={(e) => setSource(e.target.value)} placeholder="Install from a path, URL or catalog id…" mono className="h-10" />
+ <Button variant="outline" size="lg" disabled={!source.trim()} loading={busy === "src"} onClick={() => void act("src", () => api.plugins.install(source.trim()), "Installed.").then(() => setSource(""))}>Install</Button>
</div>
)}
- {tab === "mcp" && (!mcpAvailable ? <Empty title="MCP is not available on this runtime" body="Upgrade Mercury to 1.5 or newer." /> : servers.length === 0 ? <Empty title="No MCP servers" body="Add one with `mercury mcp add` on the runtime's machine." /> : servers.map((s) => <McpRow key={s.id} s={s} />))}
+ {tab === "mcp" && (!mcpAvailable
+ ? <Empty title="MCP is not available on this runtime" body="Upgrade Mercury to 1.5 or newer." />
+ : mcpShown.length === 0
+ ? <Empty title={q ? "No server matches" : "No MCP servers"} body={q ? undefined : "Add one with `mercury mcp add` on the runtime's machine."} />
+ : mcpShown.map((s) => <McpRow key={s.id} s={s} />))}
</div>
</div>
</div>
);
}
-function PluginRow({ p, onToggle, onUpdate, onRemove, onInstall }: { p: PluginItem; onToggle?: (v: boolean) => void; onUpdate?: () => void; onRemove?: () => void; onInstall?: () => void }) {
+function PluginRow({ p, actions }: { p: PluginItem; actions: React.ReactNode }) {
+ const problem = p.lastError || p.disabled?.message || p.incompatibleReason;
const state = p.status === "error" || p.disabled ? "needs-you" : p.running ? "working" : p.enabled ? "idle" : "offline";
return (
- <div className="flex items-start gap-3 rounded-lg border border-line bg-surface px-3.5 py-3">
- <StateOrb state={state} size={10} className="mt-[7px]" />
- <div className="min-w-0 flex-1">
- <div className="flex flex-wrap items-center gap-2">
- <span className="text-sm font-medium text-ink">{p.name}</span>
+ <ItemRow
+ tone={problem ? "warn" : undefined}
+ tile={<span className="relative"><IconTile id={p.id} label={p.name} />{p.status !== "available" && <StateOrb state={state} size={9} className="absolute -bottom-0.5 -right-0.5 rounded-full bg-surface p-[1.5px]" />}</span>}
+ title={p.name}
+ badges={
+ <>
<Mono>{p.installedVersion ?? p.latestVersion ?? ""}</Mono>
{p.tier === "official" && <Badge tone="accent">official</Badge>}
- {p.verified && <Badge>verified</Badge>}
- {p.status === "update-available" && <Badge tone="cyan">update {p.latestVersion}</Badge>}
+ {p.verified && p.tier !== "official" && <Badge>verified</Badge>}
+ {p.status === "update-available" && <Badge tone="cyan">{p.latestVersion} available</Badge>}
{p.status === "incompatible" && <Badge tone="amber">incompatible</Badge>}
{p.channel?.state && <Badge>{p.channel.type} · {p.channel.state}</Badge>}
- </div>
- <p className="mt-0.5 text-xs text-ink3">{p.description}</p>
- {(p.tools.length > 0 || p.commands.length > 0) && (
- <p className="mt-1 truncate font-mono text-2xs text-ink4">
- {p.tools.length > 0 && `${p.tools.length} tool${p.tools.length === 1 ? "" : "s"}`}
- {p.tools.length > 0 && p.commands.length > 0 && " · "}
- {p.commands.map((c) => `/${c}`).join(" ")}
- </p>
- )}
- {(p.lastError || p.disabled?.message || p.incompatibleReason) && <p className="mt-1 text-xs text-amber">{p.lastError || p.disabled?.message || p.incompatibleReason}</p>}
- </div>
- <div className="flex shrink-0 items-center gap-2">
- {onInstall && <Button size="sm" variant="outline" onClick={onInstall}>Install</Button>}
- {onUpdate && p.status === "update-available" && <Button size="sm" variant="outline" onClick={onUpdate}>Update</Button>}
- {onToggle && <Switch checked={p.enabled} onCheckedChange={onToggle} label={p.enabled ? "On" : "Off"} id={`plugin-${p.id}`} />}
- {onRemove && <Button size="sm" variant="ghost" onClick={onRemove}>Remove</Button>}
- </div>
- </div>
+ </>
+ }
+ description={p.description}
+ footer={
+ <>
+ {(p.tools.length > 0 || p.commands.length > 0) && (
+ <p className="truncate font-mono text-xs text-ink4">
+ {p.tools.length > 0 && `${p.tools.length} tool${p.tools.length === 1 ? "" : "s"}`}
+ {p.tools.length > 0 && p.commands.length > 0 && " · "}
+ {p.commands.map((c) => `/${c}`).join(" ")}
+ </p>
+ )}
+ {problem && <p className="mt-1 text-sm text-amber">{problem}</p>}
+ </>
+ }
+ actions={actions}
+ />
);
}
@@ -128,17 +166,13 @@ function McpRow({ s }: { s: McpServer }) {
const state = s.state === "connected" ? "idle" : s.state === "failed" ? "needs-you" : s.state === "disabled" ? "offline" : "thinking";
const allowed = s.tools.filter((t) => t.allowed !== false).length;
return (
- <div className="flex items-start gap-3 rounded-lg border border-line bg-surface px-3.5 py-3">
- <StateOrb state={state} size={10} className="mt-[7px]" />
- <div className="min-w-0 flex-1">
- <div className="flex flex-wrap items-center gap-2">
- <span className="text-sm font-medium text-ink">{s.id}</span>
- <Badge>{s.transport}</Badge>
- <Badge tone={s.state === "connected" ? "accent" : s.state === "failed" ? "red" : "neutral"}>{s.state}</Badge>
- </div>
- <Mono className="mt-0.5 block truncate">{s.target}</Mono>
- <p className="mt-1 text-xs text-ink3">{allowed} of {s.toolCount} tools allowed{s.error ? ` · ${s.error}` : ""}</p>
- </div>
- </div>
+ <ItemRow
+ tone={s.state === "failed" ? "warn" : undefined}
+ tile={<span className="relative"><IconTile id={s.id} label={s.id} /><StateOrb state={state} size={9} className="absolute -bottom-0.5 -right-0.5 rounded-full bg-surface p-[1.5px]" /></span>}
+ title={s.id}
+ badges={<><Badge>{s.transport}</Badge><Badge tone={s.state === "connected" ? "accent" : s.state === "failed" ? "red" : "neutral"}>{s.state}</Badge></>}
+ description={<Mono className="text-sm">{s.target}</Mono>}
+ footer={<p className="text-sm text-ink3">{allowed} of {s.toolCount} tools allowed{s.error ? ` · ${s.error}` : ""}</p>}
+ />
);
}
diff --git a/apps/desktop/src/views/settings/SettingsView.tsx b/apps/desktop/src/views/settings/SettingsView.tsx
index e2cb3605..c6bbc3ca 100644
--- a/apps/desktop/src/views/settings/SettingsView.tsx
+++ b/apps/desktop/src/views/settings/SettingsView.tsx
@@ -1,3 +1,4 @@
+import { Info, Palette, Power, Server, Smartphone } from "lucide-react";
import { useEffect, useState } from "react";
import { cx } from "~/lib/cx";
import * as api from "~/api/mercury";
@@ -7,25 +8,51 @@ import { useConnections, type Connection } from "~/shell/connections";
import { desktop, isTauri } from "~/shell/tauri";
import { Button } from "~/components/ui/Button";
import { Switch } from "~/components/ui/Switch";
-import { Badge, Mono, SectionTitle, Segmented } from "~/components/ui/bits";
+import { Badge, Mono, Segmented } from "~/components/ui/bits";
import { Dialog } from "~/components/ui/Dialog";
import { AddRemote } from "~/shell/AddRemote";
import { StateOrb } from "~/components/indicators/StateOrb";
-/** Settings: appearance, connections, this runtime's devices, start-up, about. */
+/**
+ * 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 = "appearance" | "connections" | "devices" | "startup" | "about";
+
+const SECTIONS: Array<{ id: Section; label: string; icon: typeof Palette }> = [
+ { id: "appearance", label: "Appearance", icon: Palette },
+ { id: "connections", label: "Connections", icon: Server },
+ { id: "devices", label: "Paired devices", icon: Smartphone },
+ { id: "startup", label: "Start-up", icon: Power },
+ { id: "about", label: "About", icon: Info },
+];
+
export function SettingsView({ connection, health, onSwitchConnection }: { connection: Connection; health: HealthInfo; onSwitchConnection: () => void }) {
+ const [section, setSection] = useState<Section>("appearance");
return (
- <div className="flex h-full min-h-0 flex-col">
- <header className="flex h-[52px] shrink-0 items-center px-4" data-tauri-drag-region>
- <span className="text-sm font-medium text-ink">Settings</span>
- </header>
+ <div className="flex h-full min-h-0">
+ <aside className="flex w-[240px] shrink-0 flex-col border-r border-line bg-soft">
+ <div className="flex h-[52px] shrink-0 items-center px-5" data-tauri-drag-region>
+ <span className="text-base font-semibold text-ink">Settings</span>
+ </div>
+ <nav className="flex flex-col gap-0.5 px-2" aria-label="Settings sections">
+ {SECTIONS.map(({ id, label, icon: Icon }) => (
+ <button key={id} onClick={() => setSection(id)} aria-current={section === id ? "page" : undefined}
+ className={cx("flex items-center gap-3 rounded-lg px-3 py-2.5 text-left text-base", section === id ? "bg-ink/[0.07] text-ink" : "text-ink2 hover:bg-ink/[0.05] hover:text-ink")}>
+ <Icon size={17} strokeWidth={1.75} aria-hidden="true" />
+ {label}
+ </button>
+ ))}
+ </nav>
+ </aside>
<div className="min-h-0 flex-1 overflow-y-auto">
- <div className="mx-auto flex max-w-[680px] flex-col gap-8 px-6 pb-10">
- <Appearance />
- <Connections current={connection} health={health} onSwitchConnection={onSwitchConnection} />
- <Devices current={connection} />
- <Startup />
- <About health={health} />
+ <div className="mx-auto flex max-w-[680px] flex-col gap-6 px-8 py-8">
+ <h1 className="text-xl font-semibold tracking-tight text-ink">{SECTIONS.find((s) => s.id === section)?.label}</h1>
+ {section === "appearance" && <Appearance />}
+ {section === "connections" && <Connections current={connection} health={health} onSwitchConnection={onSwitchConnection} />}
+ {section === "devices" && <Devices current={connection} />}
+ {section === "startup" && <Startup />}
+ {section === "about" && <About health={health} />}
</div>
</div>
</div>
@@ -40,17 +67,16 @@ function Appearance() {
const setTint = useTheme((s) => s.setTint);
return (
<section className="flex flex-col gap-3">
- <SectionTitle>Appearance</SectionTitle>
<div className="flex items-center justify-between rounded-lg border border-line bg-surface px-4 py-3">
<div>
- <div className="text-sm text-ink">Theme</div>
+ <div className="text-base text-ink">Theme</div>
<div className="text-xs text-ink3">Auto follows the system.</div>
</div>
<Segmented<ThemeMode> value={mode} onChange={setMode} options={[{ value: "light", label: "Light" }, { value: "dark", label: "Dark" }, { value: "system", label: "Auto" }]} />
</div>
<div className="flex items-center justify-between rounded-lg border border-line bg-surface px-4 py-3">
<div>
- <div className="text-sm text-ink">Tint</div>
+ <div className="text-base text-ink">Tint</div>
<div className="text-xs text-ink3">Only the accent changes. Amber and red stay what they mean.</div>
</div>
<div className="flex items-center gap-2">
@@ -78,7 +104,7 @@ function Connections({ current, health, onSwitchConnection }: { current: Connect
const [adding, setAdding] = useState(false);
return (
<section className="flex flex-col gap-3">
- <SectionTitle right={<Button size="sm" variant="outline" onClick={() => setAdding(true)}>Add connection</Button>}>Connections</SectionTitle>
+ <div className="flex justify-end"><Button size="md" variant="outline" onClick={() => setAdding(true)}>Add connection</Button></div>
<div className="overflow-hidden rounded-lg border border-line bg-surface">
{connections.map((c) => (
<div key={c.id} className="flex items-center gap-3 border-b border-line px-4 py-3 last:border-b-0">
@@ -117,10 +143,10 @@ function Devices({ current }: { current: Connection }) {
}
}
useEffect(() => { void load(); }, [current.id]);
- if (!supported) return null;
+ if (!supported) return <p className="text-sm text-ink3">This runtime does not support paired devices yet (needs Mercury 1.5).</p>;
return (
<section className="flex flex-col gap-3">
- <SectionTitle>Paired devices on {current.name}</SectionTitle>
+ <p className="text-sm text-ink3">Devices paired with {current.name}. Revoke one and it is signed out at once.</p>
<div className="overflow-hidden rounded-lg border border-line bg-surface">
{devices.length === 0 && <p className="px-4 py-3 text-xs text-ink4">No devices paired. This app attaches with the local token.</p>}
{devices.map((d) => (
@@ -147,10 +173,9 @@ function Startup() {
const m = await import("@tauri-apps/plugin-autostart");
try { await (v ? m.enable() : m.disable()); setEnabled(v); } catch { /* keep */ }
}
- if (enabled === null) return null;
+ if (enabled === null) return <p className="text-sm text-ink3">Available in the installed app.</p>;
return (
<section className="flex flex-col gap-3">
- <SectionTitle>Start-up</SectionTitle>
<div className="flex items-center justify-between rounded-lg border border-line bg-surface px-4 py-3">
<div>
<div className="text-sm text-ink">Open Mercury Desktop at login</div>
@@ -170,7 +195,6 @@ function About({ health }: { health: HealthInfo }) {
}, []);
return (
<section className="flex flex-col gap-3">
- <SectionTitle>About</SectionTitle>
<div className="rounded-lg border border-line bg-surface px-4 py-3 text-sm text-ink2">
<div className="flex items-center justify-between"><span>Mercury Desktop</span><Mono>{appVersion || "dev"}</Mono></div>
<div className="mt-1 flex items-center justify-between"><span>Runtime</span><Mono>{health.version} · API v{health.apiVersion ?? "?"}</Mono></div>
diff --git a/apps/desktop/src/views/skills/SkillsView.tsx b/apps/desktop/src/views/skills/SkillsView.tsx
index a7098689..a48f547e 100644
--- a/apps/desktop/src/views/skills/SkillsView.tsx
+++ b/apps/desktop/src/views/skills/SkillsView.tsx
@@ -1,17 +1,21 @@
import { RefreshCw } from "lucide-react";
-import { useEffect, useState } from "react";
+import { useEffect, useMemo, useState } from "react";
import * as api from "~/api/mercury";
import type { Skill } from "~/api/types";
import { Button } from "~/components/ui/Button";
import { Switch } from "~/components/ui/Switch";
-import { Empty, Mono } from "~/components/ui/bits";
+import { Empty, Mono, Segmented } from "~/components/ui/bits";
+import { ConfirmButton, IconTile, ItemRow, PageHeader, SearchField } from "~/components/ui/kit";
import { Input } from "~/components/ui/Input";
-/** Skills the runtime has loaded; each one on or off, plus install by registry id or URL. */
+/** Skills the runtime has loaded: search, filter by on/off, toggle, remove (asks twice), install. */
export function SkillsView() {
const [skills, setSkills] = useState<Skill[]>([]);
const [loading, setLoading] = useState(false);
+ const [query, setQuery] = useState("");
+ const [filter, setFilter] = useState<"all" | "on" | "off">("all");
const [source, setSource] = useState("");
+ const [busy, setBusy] = useState<string | null>(null);
const [note, setNote] = useState<string | null>(null);
async function load() {
@@ -21,48 +25,59 @@ export function SkillsView() {
}
useEffect(() => { void load(); }, []);
- async function act(fn: () => Promise<unknown>, done?: string) {
+ async function act(key: string, fn: () => Promise<unknown>, done?: string) {
setNote(null);
+ setBusy(key);
try { await fn(); if (done) setNote(done); } catch (err) { setNote(err instanceof Error ? err.message : String(err)); }
+ setBusy(null);
void load();
}
async function install() {
const s = source.trim();
if (!s) return;
- const isUrl = /^https?:\/\//i.test(s);
- await act(() => (isUrl ? api.skills.install(s) : api.skills.installFromRegistry(s)), "Installed.");
+ await act("install", () => (/^https?:\/\//i.test(s) ? api.skills.install(s) : api.skills.installFromRegistry(s)), "Installed.");
setSource("");
}
+ const q = query.trim().toLowerCase();
+ const shown = useMemo(() => skills
+ .filter((s) => filter === "all" || (filter === "on" ? s.active : !s.active))
+ .filter((s) => !q || `${s.name} ${s.description ?? ""}`.toLowerCase().includes(q))
+ .sort((a, b) => Number(b.active) - Number(a.active) || a.name.localeCompare(b.name)), [skills, filter, q]);
const active = skills.filter((s) => s.active).length;
return (
<div className="flex h-full min-h-0 flex-col">
- <header className="flex h-[52px] shrink-0 items-center gap-3 border-b border-line px-4" data-tauri-drag-region>
- <span className="text-sm font-medium text-ink">Skills</span>
- <span className="text-xs text-ink3">{active} of {skills.length} active</span>
- <div className="flex-1" />
- <Button variant="ghost" size="sm" icon onClick={() => void load()} loading={loading} aria-label="Refresh"><RefreshCw size={14} /></Button>
- </header>
+ <PageHeader title="Skills" meta={`${active} of ${skills.length} on`}>
+ <Button variant="ghost" size="sm" icon onClick={() => void load()} loading={loading} aria-label="Refresh"><RefreshCw size={15} /></Button>
+ </PageHeader>
<div className="min-h-0 flex-1 overflow-y-auto">
- <div className="mx-auto flex max-w-[760px] flex-col gap-2 px-6 py-5">
- {note && <p className="text-xs text-ink3">{note}</p>}
- {skills.length === 0 && !loading && <Empty title="No skills loaded" body="Install one by registry id or URL below, or let Mercury make its own." />}
- {skills.map((s) => (
- <div key={s.name} className="flex items-center gap-3 rounded-lg border border-line bg-surface px-3.5 py-2.5">
- <div className="min-w-0 flex-1">
- <div className="text-sm font-medium text-ink">{s.name}</div>
- {s.description && <p className="mt-0.5 text-xs text-ink3">{s.description}</p>}
- <Mono className="mt-0.5 block truncate">{s.path}</Mono>
- </div>
- <Switch id={`skill-${s.name}`} checked={s.active} onCheckedChange={(v) => void act(() => (v ? api.skills.activate(s.name) : api.skills.deactivate(s.name)))} label={s.active ? "On" : "Off"} />
- <Button size="sm" variant="ghost" onClick={() => void act(() => api.skills.remove(s.name), "Removed.")}>Remove</Button>
- </div>
+ <div className="mx-auto flex max-w-[820px] flex-col gap-3 px-8 py-6">
+ <div className="flex items-center gap-3">
+ <Segmented size="md" value={filter} onChange={setFilter} options={[{ value: "all", label: "All" }, { value: "on", label: "On" }, { value: "off", label: "Off" }]} />
+ <SearchField value={query} onChange={setQuery} placeholder="Search skills" className="ml-auto w-[260px]" />
+ </div>
+ {note && <p className="text-sm text-ink3">{note}</p>}
+ {shown.length === 0 && !loading && <Empty title={q || filter !== "all" ? "No skill matches" : "No skills loaded"} body={q || filter !== "all" ? undefined : "Install one by registry id or URL below, or let Mercury make its own."} />}
+ {shown.map((s) => (
+ <ItemRow
+ key={s.name}
+ tile={<IconTile id={s.name} label={s.name} />}
+ title={s.name}
+ description={s.description}
+ footer={<Mono className="block truncate">{s.path}</Mono>}
+ actions={
+ <>
+ <Switch id={`skill-${s.name}`} checked={s.active} onCheckedChange={(v) => void act(`t:${s.name}`, () => (v ? api.skills.activate(s.name) : api.skills.deactivate(s.name)))} label={s.active ? "On" : "Off"} />
+ <ConfirmButton size="sm" confirmLabel="Remove?" onConfirm={() => void act(`r:${s.name}`, () => api.skills.remove(s.name), `${s.name} removed.`)}>Remove</ConfirmButton>
+ </>
+ }
+ />
))}
- <div className="mt-4 flex gap-2">
- <Input value={source} onChange={(e) => setSource(e.target.value)} onKeyDown={(e) => { if (e.key === "Enter") void install(); }} placeholder="Registry id or URL…" mono />
- <Button variant="outline" disabled={!source.trim()} onClick={() => void install()}>Install</Button>
+ <div className="mt-3 flex gap-2">
+ <Input value={source} onChange={(e) => setSource(e.target.value)} onKeyDown={(e) => { if (e.key === "Enter") void install(); }} placeholder="Install by registry id or URL…" mono className="h-10" />
+ <Button variant="outline" size="lg" disabled={!source.trim()} loading={busy === "install"} onClick={() => void install()}>Install</Button>
</div>
</div>
</div>