The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
feat(desktop): appearance-settings slot and the app's swatch grid for plugins
tobenwarrior8d71403fface
diff --git a/apps/desktop/src/app/settings/appearance-contrib.test.tsx b/apps/desktop/src/app/settings/appearance-contrib.test.tsxnew file mode 100644index 00000000000..9eb8f355bb7--- /dev/null+++ b/apps/desktop/src/app/settings/appearance-contrib.test.tsx@@ -0,0 +1,66 @@+// @vitest-environment jsdom+import { act, cleanup, render, screen } from '@testing-library/react'+import { afterEach, describe, expect, it, vi } from 'vitest'++import { registry } from '@/contrib/registry'++import { APPEARANCE_AREAS, AppearanceExtraSlot } from './appearance-contrib'++const disposers: Array<() => void> = []++afterEach(() => {+ cleanup()+ disposers.splice(0).forEach(dispose => dispose())+})++describe('AppearanceExtraSlot', () => {+ it('renders nothing when empty, then mounts a late registration in place', () => {+ const { container, unmount } = render(<AppearanceExtraSlot />)++ expect(container.firstChild).toBeNull()+ unmount()++ act(() => {+ disposers.push(+ registry.register({+ area: APPEARANCE_AREAS.extra,+ id: 'extra-controls',+ render: () => <span>Extra controls</span>,+ source: 'disk'+ })+ )+ })++ render(<AppearanceExtraSlot />)++ expect(screen.getByText('Extra controls')).toBeTruthy()++ act(() => {+ disposers.splice(0).forEach(dispose => dispose())+ })++ expect(screen.queryByText('Extra controls')).toBeNull()+ })++ it('contains a throwing contribution instead of taking the page down', () => {+ vi.spyOn(console, 'error').mockImplementation(() => undefined)++ act(() => {+ disposers.push(+ registry.register({+ area: APPEARANCE_AREAS.extra,+ id: 'broken-extra',+ render: () => {+ throw new Error('broken appearance contribution')+ },+ source: 'disk'+ })+ )+ })++ render(<AppearanceExtraSlot />)++ // The boundary's inline fallback names the failed contribution.+ expect(screen.getByRole('button', { name: 'broken-extra' })).toBeTruthy()+ })+})diff --git a/apps/desktop/src/app/settings/appearance-contrib.tsx b/apps/desktop/src/app/settings/appearance-contrib.tsxnew file mode 100644index 00000000000..78064146908--- /dev/null+++ b/apps/desktop/src/app/settings/appearance-contrib.tsx@@ -0,0 +1,37 @@+import { useContributions } from '@/contrib'+import { ContribBoundary, ContribRender } from '@/contrib/react/boundary'++/**+ * Appearance settings' plugin seam — a render area at the END of the+ * Appearance page, so a plugin adds its own controls (session-colour rules,+ * theme extras) with the app's own primitives instead of injecting nodes into+ * the page and driving its widgets through React internals.+ *+ * The app's swatch grid (`ColorSwatches`, exported from the SDK) is the+ * sanctioned control for colour picking: it renders the same grid the profile+ * rail and project dialog use, with the plugin's own `onChange`.+ */+export const APPEARANCE_AREAS = {+ /** Appended to the Appearance settings page, after the built-in rows. */+ extra: 'appearance.extra'+} as const++/** Mounts every `appearance.extra` registration (own error boundary each, so a+ * broken contribution degrades to an inline error instead of a dead page). */+export function AppearanceExtraSlot() {+ const contributions = useContributions(APPEARANCE_AREAS.extra)++ if (contributions.length === 0) {+ return null+ }++ return (+ <>+ {contributions.map(contribution => (+ <ContribBoundary id={contribution.id} key={`${contribution.source ?? 'core'}:${contribution.id}`} variant="chip">+ {contribution.render && <ContribRender render={contribution.render} />}+ </ContribBoundary>+ ))}+ </>+ )+}diff --git a/apps/desktop/src/app/settings/appearance-settings.tsx b/apps/desktop/src/app/settings/appearance-settings.tsxindex c7f8a53f575..95d6b98e902 100644--- a/apps/desktop/src/app/settings/appearance-settings.tsx+++ b/apps/desktop/src/app/settings/appearance-settings.tsx@@ -73,6 +73,7 @@ import { $marketplaceInstalls, isUserTheme, removeUserTheme } from '@/themes/useimport { setHermesConfigCache, useHermesConfigRecord } from '../hooks/use-config-record'+import { AppearanceExtraSlot } from './appearance-contrib'import type { AppearanceSubpageId } from './appearance-subpages'import { ChatFontSetting } from './chat-font-setting'import { MODE_OPTIONS } from './constants'@@ -1050,6 +1051,11 @@ export function AppearanceSettings({ subpage }: AppearanceSettingsProps = {}) {<PetSettings /></div>)}++ {/* Plugin-provided appearance controls — the sanctioned seam for a+ plugin that used to inject nodes into this page. Not a setting+ section: the subpage filter above does not gate it. */}+ <AppearanceExtraSlot /></SettingsContent>)}diff --git a/apps/desktop/src/components/ui/color-swatches.tsx b/apps/desktop/src/components/ui/color-swatches.tsxindex b3c7ec84e79..c58c4feda64 100644--- a/apps/desktop/src/components/ui/color-swatches.tsx+++ b/apps/desktop/src/components/ui/color-swatches.tsx@@ -1,6 +1,6 @@import { Codicon } from './codicon'-interface ColorSwatchesProps {+export interface ColorSwatchesProps {swatches: readonly string[]value: null | stringonChange: (color: null | string) => voiddiff --git a/apps/desktop/src/sdk/index.ts b/apps/desktop/src/sdk/index.tsindex ca2b981dfca..4b7b599c073 100644--- a/apps/desktop/src/sdk/index.ts+++ b/apps/desktop/src/sdk/index.ts@@ -1670,6 +1670,12 @@ export {type SidebarNavContribution,WORKSPACE_PAGE_HEADER_AREA} from '@/app/routes'+/** Appearance settings' plugin seam: register a render contribution at+ * `APPEARANCE_AREAS.extra` to add controls at the end of the Appearance page.+ * `ColorSwatches` is the app's own swatch grid (profile rail / project dialog+ * look) — use it for colour picking instead of driving app widgets through+ * React internals; pair it with `host.sessions.setColor` for session colours. */+export { APPEARANCE_AREAS } from '@/app/settings/appearance-contrib'/** THE settings rows: `ListRow` is label + description with the control beside* it (wide) or under it (narrow); `ToggleRow` is the one on/off row — a Switch,@@ -1717,7 +1723,7 @@ export { Codicon } from '@/components/ui/codicon'* deterministic color". Feed it `PROFILE_SWATCHES` so a hand-picked color* shares the generated palette's saturation and lightness; a bespoke grid of* literal hex drifts off-theme the moment the palette moves. */-export { ColorSwatches } from '@/components/ui/color-swatches'+export { ColorSwatches, type ColorSwatchesProps } from '@/components/ui/color-swatches'export { ConfirmDialog } from '@/components/ui/confirm-dialog'export {ContextMenu,diff --git a/website/docs/developer-guide/desktop-plugin-sdk.md b/website/docs/developer-guide/desktop-plugin-sdk.mdindex 261766a7865..704e8056ea2 100644--- a/website/docs/developer-guide/desktop-plugin-sdk.md+++ b/website/docs/developer-guide/desktop-plugin-sdk.md@@ -223,6 +223,7 @@ Import the area constants from the SDK; each area has its own `data` payload.| Keybind | `KEYBINDS_AREA` | `data: KeybindContribution` || Theme | `THEMES_AREA` | `data` as a `DesktopTheme` || Composer | `COMPOSER_AREAS.*` | render slots, or middleware / attachment providers |+| Appearance settings | `APPEARANCE_AREAS.extra` | `render` — controls appended to Settings → Appearance |### Panes@@ -636,6 +637,15 @@ register(ctx) {The reasoning-pill visibility CSS the plugin also injected has no hook; it isonly needed if the app ever hides that label at narrow widths.+### Appearance settings++`APPEARANCE_AREAS.extra` renders contributions at the end of **Settings →+Appearance**. For colour picking, use the app's own swatch grid —+`ColorSwatches` renders exactly what the profile rail and project dialog render,+with your own `onChange`; pair it with `host.sessions.setColor(id, color)` for+session colours — instead of injecting nodes into the page or driving app+widgets through React internals.+### Transcript directives — inline components the model addresses`TRANSCRIPT_DIRECTIVE_AREA` makes the transcript itself a contribution area.