Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/desktop/src/design.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ const PILL_ALLOWED: [file: string, part: string, why: string][] = [
"a glyph in the machine icon picker; its fill marks the one chosen",
],
["ui/ShortcutSettings.tsx", "recording ?", "the keycap button; its fill marks recording"],
["ui/Settings.tsx", "aria-current={s.id === section", "a settings section row"],
["ui/SettingsSectionList.tsx", "aria-current={current", "a settings section row"],
];

/**
Expand Down
5 changes: 5 additions & 0 deletions apps/desktop/src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,11 @@
}

/* Centered lanes (Settings) reserve equal gutter on both sides so floating headers stay aligned. */
@utility gutter-stable {
overflow-y: hidden;
scrollbar-gutter: stable;
}

@utility scroll-stable-both {
overflow-y: auto;
scrollbar-gutter: stable both-edges;
Expand Down
15 changes: 10 additions & 5 deletions apps/desktop/src/ui/Capabilities.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { failureSummary, mcpCopy, runOnMachines, secretTargetReason } from "../s
import { machineRequest, useLoadScopeSettings, useScope } from "../state/settingsScope";
import { askConfirm, errorText, toast, useApp } from "../state/store";
import { createSkillWithAgent } from "../state/threadOpen";
import { Fold } from "./Fold";
import { ChevronRight, Copy, Ellipsis, FolderOpen, Pencil, RefreshCw, Search } from "./icons";
import { cardInset, cx, MenuContent, menuItem, noTextHelpers, Spinner, Switch, Tooltip } from "./primitives";
import { SettingsScopeBar } from "./SettingsScope";
Expand Down Expand Up @@ -461,7 +462,9 @@ function McpSection({
}
footer={data.configPath ? `Saved in ${data.configPath}` : undefined}
>
{adding && <AddServer run={run} onDone={() => setAdding(false)} />}
<Fold open={adding}>
<AddServer run={run} onDone={() => setAdding(false)} />
</Fold>
{shown.length === 0 && !adding && (
<Row
title={filter ? "No matching servers" : "No MCP servers"}
Expand Down Expand Up @@ -664,8 +667,8 @@ function McpRow({
) : null}
</div>
</div>
{open && (
<div className="rc-expand flex flex-col gap-3 px-4 pb-3 pl-10">
<Fold open={open}>
<div className="flex flex-col gap-3 px-4 pb-3 pl-10">
<dl className="grid grid-cols-[88px_1fr] gap-x-3 gap-y-1 text-callout">
<dt className="text-fg-faint">Command</dt>
<dd className="selectable m-0 truncate font-mono text-fg-muted" title={s.target}>
Expand Down Expand Up @@ -728,7 +731,7 @@ function McpRow({
</Action>
)}
</div>
)}
</Fold>
</div>
);
}
Expand Down Expand Up @@ -844,7 +847,9 @@ function SkillsSection({
</div>
}
/>
{creating && <NewSkill onDone={() => setCreating(false)} />}
<Fold open={creating}>
<NewSkill onDone={() => setCreating(false)} />
</Fold>
{groups.length === 0 && (
<Group>
<Row title={filter ? "No matching skills" : "No skills yet"} />
Expand Down
61 changes: 61 additions & 0 deletions apps/desktop/src/ui/Fold.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import { type ReactNode, useEffect, useState } from "react";
import { cx } from "./primitives";

/**
* Rows that unfold with a height transition and fold back before they unmount. Folded rows are
* not rendered at all, so a long list costs nothing until opened. Opening waits two frames, so
* the folded state is painted before the unfold starts; the clip lifts, and a closed fold
* unmounts, when its height transition ends. An open fold is not clipped, so a dragged row can
* travel past its last row.
*/
/** When a fold settles even if no `transitionend` arrives (a hidden parent, a toggle mid-frame). */
const FOLD_SETTLE_MS = 400;

export function Fold({
open,
children,
className,
}: {
open: boolean;
children: ReactNode;
className?: string;
}) {
const [mounted, setMounted] = useState(open);
const [shown, setShown] = useState(open);
const [still, setStill] = useState(open);
useEffect(() => {
if (open) {
setMounted(true);
let frame = requestAnimationFrame(() => {
frame = requestAnimationFrame(() => setShown(true));
});
const settle = setTimeout(() => setStill(true), FOLD_SETTLE_MS);
return () => {
cancelAnimationFrame(frame);
clearTimeout(settle);
};
}
setStill(false);
setShown(false);
const settle = setTimeout(() => setMounted(false), FOLD_SETTLE_MS);
return () => clearTimeout(settle);
}, [open]);
if (!mounted) return null;
return (
<div
data-fold={shown ? "open" : "closed"}
className={cx(
"grid transition-[grid-template-rows,opacity] duration-200 ease-snappy",
!still && "overflow-hidden",
)}
style={{ gridTemplateRows: shown ? "1fr" : "0fr", opacity: shown ? 1 : 0 }}
onTransitionEnd={(e) => {
if (e.target !== e.currentTarget || e.propertyName !== "grid-template-rows") return;
if (open) setStill(true);
else setMounted(false);
}}
>
<div className={cx("min-h-0", !still && "overflow-hidden", className)}>{children}</div>
</div>
);
}
5 changes: 3 additions & 2 deletions apps/desktop/src/ui/Harnesses.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ import {
useApp,
} from "../state/store";
import { HarnessCommandFields } from "./AddHarness";
import { Fold } from "./Fold";
import { HarnessIcon } from "./HarnessIcon";
import { Check, ChevronRight, Minus, Plus, RefreshCw, X } from "./icons";
import { CopyButton } from "./Markdown";
Expand Down Expand Up @@ -581,7 +582,7 @@ export function HarnessCard({ harness }: { harness: Harness }) {
detail={result ? result.text : harness.error}
/>
)}
{open && (
<Fold open={open}>
<div className="ml-11 flex flex-col gap-4 pb-1">
{hasAccounts && <AccountsList harness={harness} />}
<section className="flex flex-col gap-2">
Expand Down Expand Up @@ -642,7 +643,7 @@ export function HarnessCard({ harness }: { harness: Harness }) {
</button>
)}
</div>
)}
</Fold>
</div>
);
}
Expand Down
103 changes: 39 additions & 64 deletions apps/desktop/src/ui/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ const StatisticsPage = lazy(() => import("./StatisticsPage").then((m) => ({ defa

import { refreshServerService, useMachines } from "../state/machines";
import { useSettingsAttention } from "../state/settingsAttention";
import { type SettingsNavPage, SettingsSectionList } from "./SettingsSectionList";
import { type SettingEntry, searchSettings } from "./settingsIndex";
import {
Action,
Expand All @@ -141,11 +142,7 @@ import {

const UsagePage = lazy(() => import("./UsagePage").then((m) => ({ default: m.UsagePage })));

interface Page {
id: SettingsSection;
label: string;
icon: typeof Gear;
}
type Page = SettingsNavPage;

/**
* The nav, top to bottom: pages, then groups of pages under a heading. One
Expand Down Expand Up @@ -970,36 +967,38 @@ export function SettingsNav() {
data-focus-area="sections"
className="rc-in flex h-full min-h-0 flex-col gap-3 px-3 pb-3 outline-none"
>
<div className="flex h-8 shrink-0 items-center gap-2 rounded-md bg-fill-subtle px-2 text-body focus-within:bg-fill">
<Search size={16} className="shrink-0 text-fg-faint" />
<input
ref={field}
value={query}
onChange={(e) => {
setQuery(e.target.value);
setActive(0);
}}
onKeyDown={onFieldKey}
placeholder="Search settings"
aria-label="Search settings"
{...noTextHelpers}
className="min-w-0 flex-1 bg-transparent font-medium text-fg outline-none placeholder:text-fg-muted"
/>
{query ? (
<button
type="button"
aria-label="Clear search"
onClick={() => {
clear();
field.current?.focus();
<div className="gutter-stable shrink-0">
<div className="flex h-8 items-center gap-2 rounded-lg bg-fill-subtle px-2 text-body focus-within:bg-fill">
<Search size={16} className="shrink-0 text-fg-faint" />
<input
ref={field}
value={query}
onChange={(e) => {
setQuery(e.target.value);
setActive(0);
}}
className="flex size-4 shrink-0 items-center justify-center rounded-xs text-fg-faint hover:text-fg"
>
<X size={12} strokeWidth={2.5} />
</button>
) : (
<Kbd>/</Kbd>
)}
onKeyDown={onFieldKey}
placeholder="Search settings"
aria-label="Search settings"
{...noTextHelpers}
className="min-w-0 flex-1 bg-transparent font-medium text-fg outline-none placeholder:text-fg-muted"
/>
{query ? (
<button
type="button"
aria-label="Clear search"
onClick={() => {
clear();
field.current?.focus();
}}
className="flex size-4 shrink-0 items-center justify-center rounded-xs text-fg-faint hover:text-fg"
>
<X size={12} strokeWidth={2.5} />
</button>
) : (
<Kbd>/</Kbd>
)}
</div>
</div>
<div ref={resultsScroll} className="scroll-stable flex min-h-0 flex-1 flex-col gap-4 pb-1">
{query.trim() ? (
Expand Down Expand Up @@ -1044,36 +1043,12 @@ export function SettingsNav() {
<p className="px-2 py-1.5 text-caption text-fg-muted">Nothing matches “{query.trim()}”.</p>
)
) : (
NAV.map((group) => (
<div key={group.heading ?? group.pages[0]?.id} className="flex flex-col gap-1">
{group.heading && (
<div className="px-2 pb-0.5 font-medium text-callout text-fg-muted">{group.heading}</div>
)}
{group.pages.map((s) => (
<button
key={s.id}
type="button"
aria-current={s.id === section ? "page" : undefined}
aria-description={attention[s.id]}
onClick={() => openSettings(s.id)}
className={cx(
"flex h-8 items-center gap-2 rounded-md px-2 text-left font-medium text-body",
s.id === section ? "bg-fill text-fg" : "text-fg-muted hover:bg-fill hover:text-fg",
)}
>
<s.icon size={16} strokeWidth={1.85} className="shrink-0" />
<span className="min-w-0 flex-1 truncate">{s.label}</span>
{attention[s.id] && (
<span
data-testid={`settings-attention-${s.id}`}
title={attention[s.id]}
className="size-1.5 shrink-0 rounded-full bg-warning"
/>
)}
</button>
))}
</div>
))
<SettingsSectionList
groups={NAV}
section={section}
attention={attention}
onOpen={(id) => openSettings(id)}
/>
)}
</div>
</nav>
Expand Down
95 changes: 95 additions & 0 deletions apps/desktop/src/ui/SettingsSectionList.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
import { type ComponentType, useLayoutEffect, useRef, useState } from "react";
import type { SettingsSection } from "../state/appState";
import { cx } from "./primitives";

export interface SettingsNavPage {
id: SettingsSection;
label: string;
icon: ComponentType<{ size?: number; strokeWidth?: number; className?: string }>;
}

export interface SettingsNavGroup {
heading?: string;
pages: SettingsNavPage[];
}

interface Highlight {
top: number;
height: number;
ready: boolean;
}

/**
* The Settings pages, grouped under their headings. The open page's fill is one shared pill that
* glides to the page picked next (200ms `--ease-snappy`, transform only), so the eye follows the
* move instead of seeing one row go dark and another light up.
*/
export function SettingsSectionList({
groups,
section,
attention,
onOpen,
}: {
groups: SettingsNavGroup[];
section: SettingsSection;
attention: Partial<Record<SettingsSection, string>>;
onOpen: (id: SettingsSection) => void;
}) {
const list = useRef<HTMLDivElement>(null);
const [highlight, setHighlight] = useState<Highlight | null>(null);
useLayoutEffect(() => {
const row = list.current?.querySelector<HTMLElement>(`[data-section="${section}"]`);
if (!row) return setHighlight(null);
setHighlight((prev) => ({ top: row.offsetTop, height: row.offsetHeight, ready: prev !== null }));
}, [section]);
return (
<div ref={list} className="relative flex flex-col gap-4">
{highlight && (
<span
aria-hidden
data-testid="settings-nav-highlight"
className={cx(
"pointer-events-none absolute inset-x-0 top-0 rounded-lg bg-fill",
highlight.ready && "transition-transform duration-200 ease-snappy",
)}
style={{ height: highlight.height, transform: `translateY(${highlight.top}px)` }}
/>
)}
{groups.map((group) => (
<div key={group.heading ?? group.pages[0]?.id} className="flex flex-col gap-1">
{group.heading && (
<div className="px-2 pb-0.5 font-medium text-callout text-fg-muted">{group.heading}</div>
)}
{group.pages.map((s) => {
const current = s.id === section;
return (
<button
key={s.id}
type="button"
data-section={s.id}
aria-current={current ? "page" : undefined}
aria-description={attention[s.id]}
onClick={() => onOpen(s.id)}
className={cx(
"relative flex h-8 items-center gap-2 rounded-lg px-2 text-left font-medium text-body",
current ? "text-fg" : "text-fg-muted hover:bg-fill-subtle hover:text-fg",
current && !highlight && "bg-fill",
)}
>
<s.icon size={16} strokeWidth={1.85} className="shrink-0" />
<span className="min-w-0 flex-1 truncate">{s.label}</span>
{attention[s.id] && (
<span
data-testid={`settings-attention-${s.id}`}
title={attention[s.id]}
className="size-1.5 shrink-0 rounded-full bg-warning"
/>
)}
</button>
);
})}
</div>
))}
</div>
);
}
Loading
Loading