Renderer components — reuse layers, no duplication, directory structure. A repository rule for apps/ui/src/renderer/**; read it before editing a file there.
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Rule Renderer Components?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/geniro-io-rule-renderer-components)
---
name: rule-renderer-components
description: "Renderer components — reuse layers, no duplication, directory structure. A repository rule for apps/ui/src/renderer/**; read it before editing a file there."
---
<!-- GENERATED by scripts/sync-agent-rules.mjs from .claude/rules/renderer-components.md. DO NOT EDIT: edit the source, then run `pnpm sync:agent-rules`. -->
# Renderer components — reuse & structure
Every styled element goes through the layers in order: token → primitive → shared component → feature screen. Never duplicate a component or pattern.
## Layers
1. Token — see `renderer-design-system.md`.
2. Primitive in `components/ui/`: token-driven, shadcn-v4 style (`data-slot`, `cva` variants, `cn()`).
3. App-level shared component in `components/`, composed from primitives.
4. Feature screen: one directory per screen (`chats/`, `settings/`, `teams/`, …). App shell (`App.tsx`, `main.tsx`) and daemon clients sit at the renderer root: REST through `createDaemonApis(handle)` (`daemon-api.ts`) over the generated `autogenerated/`, WS through `daemon-client.ts`.
## Reuse
- Before adding UI, browse `components/ui/` and `components/` for an existing piece.
- A pattern that appears in a second place becomes a shared component, imported everywhere.
- New primitive → `components/ui/`; app-specific composition → `components/`; feature-only pieces stay in the feature directory.
- Import directly (`./ui/button`); no barrel `index.ts` files.
- Screens are layout + state wiring; visual building blocks come from the shared layers.
- Every component in `components/` and `components/ui/` gets a co-located `*.stories.tsx` in the same commit (enforced by `components/catalog-coverage.spec.ts`; how to write one is in `renderer-stories.md`).
## The one home for…
- Control-chip look: `chip`. `look` picks the sheet's shape: `flat` (no ground until hover), `h` (the chips tone), `pill` (the composer's "where" pill), `suggestion` (a fast action). `select`'s `ghost` variant is built from it; a trailing `ChipChevron` marks a picker, so never put one on a static chip.
- A row of items on one centre line: `ui/row.tsx` (`Row`, and `RowText` for a text that gives way with an ellipsis). Never a row of its own with a vertical margin on an item.
- A label: `ui/tag.tsx` (`Tag`): `neutral` (the chips tone, secondary text), `type` (a 6px dot in its hue on the hue's soft fill: memory types), `kind` (an icon in its hue on the soft fill: change kinds). There is no `Badge`.
- A warning that needs the user, as a label: `warn-pill` (`WarnPill`). A waiting count: `count-badge` (`CountBadge`, 16px, the rail's and tab bar's 15). A key: `ui/kbd.tsx` (`Kbd`, `line` or `tone`).
- A chat's or a thread's state as a glyph and a word: `state-mark` (`StateMark`; `RunStatusIcon` draws its glyphs). A state as a 6px dot and a word: `status-dot` (`StatusDot`).
- "Needs you" on a row or a card: `attention-bar` (`AttentionBar`), a straight 3px bar inset from the corners, never a coloured edge that follows a radius.
- A search box: `SearchField` (`search-panel.tsx`).
- A page's header band (46px: its title, parents, save state and actions): `page-header` (`PageHeader`; `onBack` makes the first parent a press back and draws a phone ‹; `titleLead` stands before the title, as a project's colour dot). Whether an edit is saved: `save-state` (`SaveState`: Saved, Saving…, a chat changing it with Open chat, Not saved with Retry — and `errorReason` after a dash when the page knows why — Changed elsewhere with Reload, each with its glyph), whose width is reserved.
- A library of cards (teams, projects): `library-card` (`LibraryCard` in `LIBRARY_GRID_CLASS`: a top row with its pill or tag, the ⋯ taking that slot on hover, a title, two lines of description, an optional `meter` row, a footer). A member as a row of a block: `member-row` (`MemberRow`, inside a `SettingsList` with `overflow-hidden`). A page's named section: `SettingsGroup` over a `SettingsList` or `SettingsPanel`, on every page, not only Settings.
- A panel at a page's right edge: `side-sheet` (`SideSheet`): `over` slides over the page, `beside` stands in its row so the page narrows (a member, a task: 420px, a resize handle when the user may widen it); its head takes an avatar, a sub line, actions, a pinned banner and a `topBar` row above the title; a `phoneBar` makes it a full-screen page with a ‹ bar on a phone. A phone's sheet from the bottom edge, and a select's phone menu: `ui/bottom-sheet.tsx` (`BottomSheet`, `BottomSheetOptions`). A surface kept mounted while it leaves: `ui/use-presence.ts`.
- A placeholder while something loads: `ui/skeleton.tsx` (`Skeleton`), static at the final size. A region that opens and closes in place: `ui/expand.tsx` (`Expand`).
- A row of tabs: `tab-strip` (`TabStrip`, tonal, with counts).
- Dropdowns: `select`, never a native `<select>` (its macOS menu ignores tokens and is invisible to the DOM). Pass `groups`, not `<option>` children; tests open `[data-menu-trigger]` and read `[role="option"]`.
- Always-visible mutually exclusive options: `segmented-control` — only when the choice is the screen's subject. A filter that narrows what is already shown, with a count on each, is `quick-filters` (`QuickFilters`); one without counts goes behind a trigger (`Menu`).
- Images the user looks at: `image-viewer` (built on `dialog`, which portals every dialog to the body). Use `ZoomableImage`; a caller that controls which picture shows renders `ImageViewer` with `ZOOMABLE_TRIGGER_CLASS` on its opener. A bare `<img>` is only for chrome. Never add a second lightbox.
- Command output: `ansi-text` over the `ansi.ts` parser. Colours come from `--ansi-*` tokens (brightness → `--ansi-bright-*`), never from the stream or computed in TypeScript.
- Pickable answer options: `option-list`, whose `arity` (`many` / `one` / `none`) decides the drawing. Never `chip` (labels can be sentences).
- Dismissible error strip: `error-banner`. `error-text` alone is for a form field, where typing clears it.
- Clipboard: `copy-button`, which owns the write and the copied feedback.
- One primary action with choices of what it does (a save with its target): `split-button`. Picking from its menu changes the button; only the labelled half acts. Never a full-width select beside a second filled button.
- "There is nothing here": `empty-state` (`EmptyState`: centred, a 14/600 title, a 13px line, at most one action).
- Asking before an action: a modal question, `confirm-dialog` — or `confirm-action-button`, the button that opens one and runs the action from it. Never a second press on the same button for a new surface.
- A card that is clickable takes its hover from `card-hover.ts` (`NAV_CARD_CLASS` on a `NavListItem` card, `CARD_BUTTON_CLASS` on a card that is itself the button): a background tint only, never a translate, a shadow or a ring change; never restate it.
- A long free text in a header or row: `clamped-text` (`ClampedText`), which folds it and offers Show more only when it overflows.
- A panel opened by hovering (a submenu, a `hover-popover`, a menu a hover reveals): `use-pointer-grace` (`usePointerGrace`) keeps it while the pointer travels to it and closes it once the pointer strays or stops short. Never a close timer of its own.
- Tooltips: a plain `title` attribute. `TooltipLayer` (`components/ui/tooltip.tsx`, mounted once in `boot-app.tsx`) draws every one in the design system instead of the OS; never build a per-control hover tip for plain text. A tip that holds controls or a reading is a `hover-popover`.
- Reaching an MCP listing: `mcp-dialog-button` (opens `mcp-section` in a `dialog`); its open state belongs to the caller, and `variant="none"` draws no trigger where another control on the surface opens it.
- Memoized callbacks: `use-latest-callback` (`useLatestCallback`), never `useCallback` (eslint bans it). A kept `useCallback` function holds its render's whole scope, which holds the other kept callbacks and their renders, so every earlier render stays in memory until the renderer runs out of heap. A `useMemo` whose value holds a function made inline is the same link: build that function with `useLatestCallback`.
- Remembering a boolean the user set: `use-persisted-flag`. Inside a chat thread use `chats/thread-ui-memory.ts` (`useThreadFlag` / `useThreadOverride` / `useThreadFlags`) instead, so the choice stays with that thread.
- Side-panel blocks and outward links: `panel-section` + `panel-link-row`.
- Sidebar rows: `nav-list-item`; set `suspendActivation` while a nested control owns the row's clicks and focus.
- Prompt-length fields: `expandable-textarea`, except where the surrounding component must close the field itself (its ⤢ modal cannot be dismissed from outside — see `chats/queued-strip.tsx`).
- Opening a long text in a window: `markdown-editor-dialog` (`MarkdownEditorDialog` to edit it, `MarkdownViewerDialog` for the same window locked). Never a second text window.
- A long text that is edited somewhere else (a team's text on a project's page, a shared stage text, a block another screen owns): `read-only-text` (`ReadOnlyText`), its first lines with Open full text into `MarkdownViewerDialog`. Never the whole text printed in full, and never a disabled or `inert` editor standing in for a read-only one. What this scope adds to that text is a field only once it holds text or its Add was pressed: the Add sits beside Open full text through `ReadOnlyText`'s `actions`, styled `TEXT_ACTION_CLASS`.
- A setting a narrower scope can override (a project over its team): `teams/overridable-row.tsx` (`OverridableRow`, `OverridableGroup`). The control stays live and changing it is the override; the row's tag then reads the scope's colour dot and name with a reset arrow back to the inherited value, a quiet Team tag before. Never a coloured edge, and never an Override button that unlocks a faded or `inert` control.
- A text that may run long on a card or row: `clamped-text`. A list that grows with use (history, devices, analyses) shows its newest few with Show all, or moves behind a button into a dialog; never every entry inline. The Show all press is `show-all` (`useShowAll` slices the list, `ShowAllButton` draws the press; `limit` 0 hides the list whole until asked for, `total` null when nobody counted it); a new list uses it rather than a toggle of its own.
- A settings page's named block: `settings-group` (`SettingsGroup`: its title row — 13/600, a count and the group's own actions at the right, and no "?"; the group's `hint` is the title's tooltip — over a `SettingsPanel`, the tonal block whose `SettingsPanelRow`s a hairline separates; no icon tile). `SettingsGroups` is the page column. A list too long for the rows' column is summed up in a row whose button opens it in a `dialog`. Every labelled setting carries a `hint` (its "?"), and every action button a `title` carrying the same text, in plain words: a row whose control is an action passes `action` and draws no "?". A setting row (`SettingsPanelRow`) is at least 44px, inline on a phone too; a segmented choice passes `layout="choice"` (beside its label on a desktop, under it on a phone); one that can show an error passes `error` (null while fine), which reserves its line.
## Daemon types
- Never restate a daemon wire type; import it from `autogenerated/`. `shared/contracts.ts` is Electron-internal and holds no daemon shapes, except the one twin recorded in `apps/ui/src/main/AGENTS.md` (`ShareDestination`).
- A renderer-only concept over daemon data is derived from a generated type (`TeamMeta = Pick<Team, …>`, `Pick<TeamMember, 'id'>`), so a daemon change surfaces as a type error. These derivations live in `teams/member-schema.ts` and `teams/team-doc.ts`.
## Test helpers
- A helper only specs use lives in `renderer/__tests__/`, never in a production directory such as `components/ui/`.
- `__tests__/stub-resize-observer.ts` is called by the specs that need it, not installed suite-wide — other specs rely on the global being absent.