Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins
TypeScript ai-agentcoding-agentdesktop-appelectronglobali18nlocal-firstmcppipi-agentpi-desktoppluginsreactrusttypescript
feat(ui): add CheckboxGroup shared primitive for array multi-select
vastsa5ea714b43b5b
diff --git a/apps/desktop/src/AGENTS.md b/apps/desktop/src/AGENTS.mdindex 4b7ea3e05..4e3f66e82 100644--- a/apps/desktop/src/AGENTS.md+++ b/apps/desktop/src/AGENTS.md@@ -23,6 +23,7 @@ of any shared primitive is a spec violation.| Boolean toggle (switch) | `SettingsToggle` | `components/ui.tsx` || Multi-option segment | `SegmentedControl` | `components/ui.tsx` || Checkbox | `Checkbox` | `components/ui.tsx` |+| Checkbox group (array multi-select) | `CheckboxGroup` | `components/ui.tsx` || Native dropdown (non-Settings) | `Select` | `components/ui.tsx` || Settings dropdown | `SettingsMenuSelect` | `components/settings/SettingsMenuSelect.tsx` || Status badge | `Badge` | `components/ui.tsx` |diff --git a/apps/desktop/src/components/settings/ConfigSyncPage.tsx b/apps/desktop/src/components/settings/ConfigSyncPage.tsxindex 729f139c6..f23ff7c52 100644--- a/apps/desktop/src/components/settings/ConfigSyncPage.tsx+++ b/apps/desktop/src/components/settings/ConfigSyncPage.tsx@@ -10,7 +10,7 @@ import type {ConfigSyncState,} from "@pi-desktop/shared";import { api } from "../../lib/api";-import { Badge, Button, Field, Input, PasswordInput, SettingsToggle } from "../ui";+import { Badge, Button, Checkbox, Field, Input, PasswordInput, SettingsToggle } from "../ui";import { IconCloudDown, IconRefresh, IconShield, IconTrash } from "../icons";import { SettingsCard, SettingsRow } from "../../features/settings/primitives";import { configSyncProgressView } from "../../features/settings/config-sync-progress";@@ -683,46 +683,41 @@ export function ConfigSyncPage() {><div className="settings-config-sync-categories">{CATEGORIES.map((category) => (- <label key={category.id} className="settings-config-sync-category">- <input- type="checkbox"- checked={categories[category.id] !== false}- onChange={(event) =>- setSelection((current) => ({- ...current,- [category.id]: event.target.checked,- }))- }- />- <span>{t(category.label)}</span>- </label>- ))}- <label className="settings-config-sync-category">- <input- type="checkbox"- checked={selection.memory}+ <Checkbox+ key={category.id}+ className="settings-config-sync-category"+ checked={categories[category.id] !== false}onChange={(event) =>setSelection((current) => ({...current,- memory: event.target.checked,+ [category.id]: event.target.checked,}))}+ label={t(category.label)}/>- <span>{t("settings.configSync.categoryMemory")}</span>- </label>- <label className="settings-config-sync-category settings-config-sync-sensitive">- <input- type="checkbox"- checked={selection.credentials}- onChange={(event) =>- setSelection((current) => ({- ...current,- credentials: event.target.checked,- }))- }- />- <span>{t("settings.configSync.categoryCredentials")}</span>- </label>+ ))}+ <Checkbox+ className="settings-config-sync-category"+ checked={selection.memory}+ onChange={(event) =>+ setSelection((current) => ({+ ...current,+ memory: event.target.checked,+ }))+ }+ label={t("settings.configSync.categoryMemory")}+ />+ <Checkbox+ className="settings-config-sync-category settings-config-sync-sensitive"+ checked={selection.credentials}+ onChange={(event) =>+ setSelection((current) => ({+ ...current,+ credentials: event.target.checked,+ }))+ }+ label={t("settings.configSync.categoryCredentials")}+ /></div>{selection.credentials ? (<div className="settings-config-sync-warning">diff --git a/apps/desktop/src/components/ui.tsx b/apps/desktop/src/components/ui.tsxindex b4a0376fe..583d8d73b 100644--- a/apps/desktop/src/components/ui.tsx+++ b/apps/desktop/src/components/ui.tsx@@ -749,6 +749,54 @@ export function Checkbox({);}++export function CheckboxGroup<T extends string>({+ values,+ onChange,+ options,+ label,+ disabled,+ className,+ itemClassName,+ minSelected = 0,+}: {+ /** Currently selected values. */+ values: readonly T[];+ /** Called with the full updated selection. */+ onChange: (values: T[]) => void;+ options: readonly { readonly value: T; readonly label: ReactNode }[];+ /** Accessible group label. */+ label: string;+ disabled?: boolean;+ className?: string;+ itemClassName?: string;+ /** Prevent unchecking below this count (default 0 = no minimum). */+ minSelected?: number;+}) {+ const toggle = (value: T, on: boolean) => {+ const next = on+ ? [...values, value]+ : values.filter((v) => v !== value);+ if (next.length < minSelected) return;+ onChange(next);+ };++ return (+ <div className={cx("ui-checkbox-group", className)} role="group" aria-label={label}>+ {options.map((option) => (+ <Checkbox+ key={option.value}+ className={itemClassName}+ checked={values.includes(option.value)}+ disabled={disabled}+ onChange={(e) => toggle(option.value, e.target.checked)}+ label={option.label}+ />+ ))}+ </div>+ );+}+export function Badge({children,tone = "neutral",diff --git a/apps/desktop/src/features/settings/voice/VoiceSettingsSection.tsx b/apps/desktop/src/features/settings/voice/VoiceSettingsSection.tsxindex d1a0cbf4a..bb965767d 100644--- a/apps/desktop/src/features/settings/voice/VoiceSettingsSection.tsx+++ b/apps/desktop/src/features/settings/voice/VoiceSettingsSection.tsx@@ -6,7 +6,7 @@import { useCallback, useEffect, useState } from "react";import type { TFunction } from "i18next";import type { AppSettings } from "@pi-desktop/shared";-import { Button, Badge, Checkbox, SettingsToggle } from "../../../components/ui";+import { Button, Badge, CheckboxGroup, SettingsToggle } from "../../../components/ui";import { SettingsMenuSelect } from "../../../components/settings/SettingsMenuSelect";import { SettingsRow, SettingsCard } from "../primitives";import { voiceIpc } from "../../voice/voice-ipc";@@ -142,23 +142,21 @@ export function VoiceSettingsSection({</SettingsRow><SettingsRow title={t("settings.voiceLanguages")}>- <div className="voice-lang-checks">- {(["zh", "en", "ja", "ko"] as const).map((code) => (- <Checkbox- key={code}- className="voice-lang-label"- checked={voice.languages.includes(code)}- disabled={!voice.enabled}- onChange={(e) => {- const langs = e.target.checked- ? [...voice.languages, code]- : voice.languages.filter((l: string) => l !== code);- save({ languages: langs.length > 0 ? langs : [code] });- }}- label={({ zh: "中文", en: "English", ja: "日本語", ko: "한국어" } as const)[code]}- />- ))}- </div>+ <CheckboxGroup+ values={voice.languages}+ onChange={(langs) => save({ languages: langs })}+ options={[+ { value: "zh", label: "中文" },+ { value: "en", label: "English" },+ { value: "ja", label: "日本語" },+ { value: "ko", label: "한국어" },+ ]}+ label={t("settings.voiceLanguages")}+ disabled={!voice.enabled}+ className="voice-lang-checks"+ itemClassName="voice-lang-label"+ minSelected={1}+ /></SettingsRow><SettingsRow title={t("settings.voiceChineseVariant")}>diff --git a/docs/spec/04-ux/07-ui-design-system.md b/docs/spec/04-ux/07-ui-design-system.mdindex b2dd92524..30832c084 100644--- a/docs/spec/04-ux/07-ui-design-system.md+++ b/docs/spec/04-ux/07-ui-design-system.md@@ -1255,6 +1255,21 @@ Implementation: `components/ui.tsx → Checkbox`.Every standalone labeled checkbox **must** use `Checkbox`. Inline`<label><input type="checkbox"/>…</label>` is prohibited.+### 11.11b CheckboxGroup++Implementation: `components/ui.tsx → CheckboxGroup<T>`.++| Property | Value |+|---|---|+| CSS class | `.ui-checkbox-group` (container), items use `Checkbox` |+| Generic | `<T extends string>` for type-safe values/onChange |+| Props | `values: T[]`, `onChange(values: T[])`, `options: { value: T; label: ReactNode }[]`, `label`, `disabled`, `minSelected` |+| Minimum selection | `minSelected` (default 0) prevents unchecking below a threshold |++Use `CheckboxGroup` when a set of options maps to an array of selected+values (e.g. voice languages). For independent boolean fields with+heterogeneous state shapes, use individual `Checkbox` components.+### 11.12 SettingsMenuSelectImplementation: `components/settings/SettingsMenuSelect.tsx`.