> Every Taji docs page as Markdown: https://docs.taji.is/llms.txt

# The window's UI

The rules a change to `ui/`, `window/`, `packages/` or `plugins/*/ui` works to: what the window may compute, the tokens, the kit's parts, accessibility and copy. Source of truth: `packages/kit/tokens.css` and the kit's components; held by `ui/src/patterns.test.ts`, `ui/src/tokens.test.ts`, `ui/src/reach.test.ts`, `ui/src/boundaries.test.ts`, `ui/src/roles.test.ts` and `ui/src/raw.test.ts`. [`AGENTS.md`](https://github.com/TajiAI/Taji/blob/main/AGENTS.md) maps the directories and the window gates. In each table the last column names what holds a rule; "review" means no test does, so a reviewer does.

## What the window computes

| Rule | Held by |
|---|---|
| It draws; the kernel computes: a price, P&L, greek, breakeven, yield, rank or filter result is a wire field ([0001](https://github.com/TajiAI/Taji/blob/main/docs/decisions/0001-kernel-computes.md)). The window keeps layout, axis ticks, scaling, formatting and shown sums. A domain formula in `ui/src` is a review defect, save a drawing's live in-drag tags. A streaming price's tick cue compares consecutive served lasts on the client: display, not a wire figure | review |
| A cross-account total is the kernel's `totals`, `Partial` (`packages/kit/book/AccountFace.tsx`) when it leaves an account out; buying power is never summed | `ui/src/accounts/accounts.render.test.tsx` |
| A view change (focus, selection, a toggle) goes through `act` (`packages/plugin/state/act.ts`): painted in the cache before posting, rolled back if refused. What must wait for the kernel (an order, the vault, a link) is a bare verb | review |
| No source reads a provider's own keys (`raw` off a data row) | `ui/src/raw.test.ts` |
| A pane's UI imports only its folder, `@taji/plugin`, the kit and shared dependencies, never another plugin ([window half](https://docs.taji.is/plugins/window.md)) | `ui/src/boundaries.test.ts` |

## Scene first

1. Add or change a scene in `ui/mock/app/scenes.ts`.
2. Run `pnpm --filter @taji/ui mock:app` and open `localhost:7793/app/?scene=<id>`.
3. Build the pane against that scene (`ui/src/connections/` for a full-window page).
4. Check: `bash engine/crates/taji/scripts/ui_gate.sh`.

## Tokens

| Subject | Rule | Held by |
|---|---|---|
| Theme | One dark theme, `:root` (neutral grey grounds, `--up`/`--down` performance). The accent, Buy's colour, is gold, sky, iris or graphite (`data-accent`); `.warm` (the gate, the welcome) keeps its own palette | `ui/src/tokens.test.ts` |
| Literals | Colour, type, radius, duration and shadow are `tokens.css` tokens, never literals; structural sizes are literal | `ui/src/patterns.test.ts` |
| Fonts | Geist (`--sans`) and, for code and keys, Geist Mono (`--mono`), self-hosted in `packages/kit/fonts.css`; every number tabular; base 14px | `packages/kit/fonts.test.ts` (tabular) |
| Type | `--fs-page-*` for a surface read at arm's length (the welcome, Connections, any full-window page), `--fs-micro` to `--fs-figure` (11px floor) in the shell's chrome | review |
| Icons | Two families, both `currentColor`: the chrome's `lucide-react`, 16px, stroke 1.75; the chart's drawing strip, TradingView's 28px and 1.5 stroke for parity | review |
| Components | A component does one job with few controls | review |
| Selected fill | A selected, current, pressed or checked row never fills with `--accent-soft` | `ui/src/patterns.test.ts` |
| Disabled | A disabled control's opacity is `.4`; the chart's controls (`chart/`) use `.5` | `ui/src/patterns.test.ts` |
| Surfaces | No `glass-panel` class | `ui/src/patterns.test.ts` |
| Chords | A chord is read from the shortcut table (`packages/kit/shell/shortcuts.ts`), never written as a modifier glyph, a literal `kbd` or a literal hint; every row is hinted by a control unless it is marked `unhinted` | `ui/src/patterns.test.ts` |
| Animation | `motion` (`motion/react`), never a hand-rolled spring, easing or tween | `ui/src/patterns.test.ts` (a numeric `duration`) |
| Tailwind | Utilities only, `tw:`-prefixed, the conversation's assistant-ui kit's alone | review |

## Parts

Use the kit's part (liquikit: `packages/kit/liquikit/`); a hand-rolled twin is a review defect. `ui/src/patterns.test.ts` greps the `title=`, `ChevronDown` and class-string rows and lists the exceptions. A kit part's change handler is `onValueChange`, its test id `eid`.

| For | Use |
|---|---|
| Menu, list, popover, dialog | `packages/kit/ui/Pop.tsx`; a dialog `packages/kit/ui/Float.tsx` |
| Confirm, quit | `Alert` (`packages/kit/ui/Alert.tsx`) on `Float`, Keep focused |
| On the phone, a menu of many acts, a form, a confirm | `PhoneSheet` (`packages/kit/ui/Sheet.tsx`); `OrderConfirm` (`packages/kit/trade/Confirm.tsx`) draws one itself |
| Pick one value | `Dropdown` (`packages/kit/ui/Select.tsx`), its trigger `.select`, never `ChevronDown` |
| One of two to five words | `Segmented` (`packages/kit/ui/Segmented.tsx`) with `usePicked` (`packages/kit/ui/picked.ts`) |
| A page's sections | `TabBar` (`packages/kit/ui/TabBar.tsx`) |
| On or off | `packages/kit/ui/Switch.tsx` |
| Button | `Act` (`packages/kit/ui/Act.tsx`), `variant` `safe`, `danger` or `prominent` (at most once per surface), never a class string; or liquikit `Button` |
| Icon-only button | `IconAct` (`packages/kit/ui/IconAct.tsx`) with `aria-label` and `data-tip` |
| Tooltip, a disabled act's reason | `data-tip` (`packages/kit/shell/Tip.tsx`), not `title=` |
| Record table | `packages/kit/table/Table.tsx` |
| A read pending, under the heads | `p.pending-line` with `role="status"` (`packages/kit/base.css`), one line |
| A streaming price's up or down cue | `Tick` (`packages/kit/ui/Tick.tsx`) around its words |
| An account named | `AccountFace` (`packages/kit/book/AccountFace.tsx`): the brokerage's mark, name and tail; `AccountShort` where the surface says the stage; `AccountAt` in a confirm; never a tail alone |

## Accessibility

| Rule | Held by |
|---|---|
| Pointer focus draws nothing. Keyboard focus is a 3px `--focus-ring` (the accent at 70%) outline, offset 1px, on the control, never a wrapper (`packages/kit/base.css`); a field's moves its border | `ui/src/tokens.test.ts` (the ring's contrast) |
| A role promises its keys: a listbox, tree, grid or menu item moves by arrow keys, or is a button or table | `ui/src/roles.test.ts` |
| `--ink-2` reads at 4.5:1 on the surfaces `ui/src/tokens.test.ts` lists, and `prefers-contrast: more` raises each colour it sets | `ui/src/tokens.test.ts` |
| Overlay sentences are at least `--fs-ui`, in `--ink` or `--ink-2`, never `--ink-3`; `--fs-dense` only for a one-line caption, quiet act, key hint or a well's mono text | `ui/src/reach.test.ts` (the overlay sheets it lists) |
| `prefers-reduced-motion` gets the end state, under `MotionConfig reducedMotion="user"` (`packages/plugin/realm.tsx`); a tick cue keeps its ink, unfaded | review |
| `prefers-reduced-transparency` makes glass solid | `ui/src/reach.test.ts`, `mock:app:reach` |
| Forced colours drop box-shadows: a shadow-only edge or state gets a system-colour outline; `forced-color-adjust: none` only on swatches | `ui/src/patterns.test.ts` (the shadow half) |
| A `useSyncExternalStore`'s `subscribe` is a module-scope function or a `useCallback` on its key, never an inline literal, which React resubscribes every render | `ui/src/patterns.test.ts` |
| On a coarse pointer a target is 44px and 8px from the next (16px beside a commit) and an input 16px or more; `useCompact` (`packages/kit/shell/compact.ts`) swaps the frame for the phone's (a touch screen under 700px wide, or a phone on its side no taller than 500px). | `mock:app:reach` (`ui/mock/app/reach.ts`) on every scene with `touch` (the targets); review (the input) |

## Copy

Say what the user gets in their words, not how Taji is built: "Seal your vault", not "Argon2id". Say "device", never "Mac". One line per idea; cut a sentence that loses nothing. Held by review.

## See also

- [A plugin's window half](https://docs.taji.is/plugins/window.md): the contract a plugin's frame draws to.
- [Testing](https://docs.taji.is/contribute/testing.md): which checks a window change needs.
- [Decision 0001](https://github.com/TajiAI/Taji/blob/main/docs/decisions/0001-kernel-computes.md): the kernel computes, clients draw.
