This document is the source of truth for visual work in Happy (2). The product is a desktop application. Design for its desktop window and do not introduce mobile breakpoints, touch-only behavior, or mobile substitutes.
The design system is implemented by happy-desktop-ui. Its component workbench is the
blueprint: run it through Portless with pnpm blueprint.
This is the first principle and it is not negotiable. An element that the person is not moving never changes position, except by one deliberate glide to its new slot. Nothing moves after a drop settles. Confirmations and echoes never move anything.
- An element nobody is holding moves only while an animation is carrying it. It never appears somewhere else from one frame to the next.
- Each move is one glide, in one direction, that ends somewhere new. An element never snaps ahead and glides back, never reverses mid-glide, and never moves twice for one change. A move that is refused or put back glides back once, from wherever it stands.
- A dropped element lands where it was let go. The slot the drop previews is the slot it ends in, and the neighbours that made room for it stay there.
- No two resting elements overlap, and once settled there are no gaps that were not there before.
- The server's confirmation, an echo of the person's own change, another author writing back the same content, and a background batch that renames or marks rows move nothing. A render that changes no order moves no box.
The sidebar enforces this with a seeded chaos test,
packages/happy-desktop-ui/src/Sidebar.chaos.test.tsx, in Chromium, Firefox and
WebKit. It drags random rows, sections, separators, Search and Create at random
speeds, delivers replies late, twice, out of order, refused or not at all,
injects name batches mid-drag and after the drop, and checks every element's
box on every frame. A shorter run in the real app is the gym's sidebar-drag
workload (happy-desktop-gym/sources/electron/sidebarDragChaos.ts). Any surface
that rearranges content proves the same property the same way: per-frame boxes,
not end states.
Every visual element must be a reusable happy-desktop-ui component before it is used
by the main app. This applies to small primitives such as Box, Button, Icon, and
Avatar and to product-sized structures such as a rail, sidebar, title bar,
inspector, editor shell, or dialog.
A happy-desktop-ui component must:
- render in isolation without an application store, router, API client, IPC bridge, authentication context, or knowledge of a product route;
- receive all content, state, variants, dimensions, accessibility labels, and event handlers through props;
- make its visual states directly renderable by a test or blueprint fixture;
- expose stable elements or parts where their geometry needs to be measured;
- remain useful anywhere the same visual contract is needed, not just at the call site that caused it to be created.
The main app is glue and state management. It may load data, own stores, select
the current route, translate product data into component props, and handle
component callbacks. It must not define visual components, component-local
styling systems, icons, or alternate copies of happy-desktop-ui components. If the
app needs a new visual element, implement and prove it in happy-desktop-ui, add it to
the blueprint, and then import it into the app.
Keep product decisions out of the component. For example, a rail may accept
items, the selected item ID, optional slots, and an onItemSelect callback. It
must not read the app's feature store or navigate by itself.
Happy (2) follows the original Happy app's desktop, neutral visual language.
It uses the system appearance automatically by default: light mode has white
and #f5f5f5 grouped surfaces with black primary actions; dark mode has a
#1e1e1e grouped root, #212121 primary surfaces, and black primary actions. A product surface may offer a
controlled light/dark override only through the reusable happy-desktop-ui theme
scope, such as the compact appearance control in the feature rail. The override
must affect one stable application tree and remain fully keyboard accessible; it
must not create a duplicate themed tree or introduce component-specific colors.
Happy teal communicates general interactive
and link states; system blue remains the info colour for the original controls
that use it. System green, orange, and red carry success, warning, and
destructive meaning. The tokens live in
packages/happy-desktop-ui/src/theme.css and are the only source of color and
typography in the system. Its color roles are flattened directly from
~/Developer/happy/packages/happy-app/sources/theme.ts and retain Happy's
role names (for example var(--surface), var(--groupped-background), and
var(--text-link)); there are no Happy (2) color aliases or base palette
tokens. A raw hex value in component CSS is a defect.
Core values (see theme.css for the full set):
| Token group | Light / dark values |
|---|---|
| Surfaces | chrome #fff / #212121, app #f5f5f5 / #1e1e1e, surface #fff / #212121, raised #f8f8f8 / #171717, inset #f5f5f5 / #303030, code #f6f8fa / #161b22 |
| Hairlines | #eaeaea / #292929 |
| Text | #000 / #fff, secondary #49454f / #cac4d0 |
| Interactive/link | teal #2baccc in both schemes; original system-blue controls use #007aff / #0a84ff |
| Primary action | black with white text in both schemes |
| Semantics | green #34c759 / #32d74b, orange #ff9500 / #ff9f0a, red #ff3b30 / #ff453a |
| Type | UI "happy Figtree" (Figtree variable), code "happy Mono" (JetBrains Mono variable) |
| Radii | controls 6 px, content 8 px, cards 10 px, large shells 14 px, pills 999 |
Text colors are solid (not alpha) so rendering tests can assert exact rgb()
values in every engine. The prefers-color-scheme media query is the default
runtime selector. ThemeScope applies .happy-theme-light,
.happy-theme-dark, or .happy-theme-midnight to a single stable product tree
when the user selects an explicit appearance; the same classes remain available
for deterministic blueprint and test fixtures. Midnight is the dark palette
taken down to a neutral near-black (#0b0b0b app, #121212 surface) with a
white primary action. The custom appearance is one of those three classes plus
the person's customTheme.colors values from ~/.happy/desktop/config.json, declared on the
same scope element (see docs/custom-theme.md); it is the only place colors
outside theme.css reach the product, and only through the closed role list
in happy-desktop-state. Permission (permission-*), error-box (box-error-*),
and warning-box (box-warning-*) roles cannot be overridden. Invalid roles are
ignored individually; valid roles still apply. The complete config is watched
live, with per-field fallback and unknown fields preserved on writes. Avatar tone names resolve to solid, direct Happy
roles; product code never passes raw CSS colors or utility classes for identity.
Use a 4 px foundational grid. Prefer 8 px increments for spacing and 16 px increments for larger layout rhythm. One-pixel rules and intentional optical corrections are exceptions, not reasons to abandon the grid.
The blueprint background uses a 16 px minor grid and an 80 px major grid. It is a measurement surface, not decoration: specimen edges, rulers, and annotations should make declared dimensions easy to inspect.
Current reference dimensions are:
| Element | Reference dimension |
|---|---|
| Design reference window | 1280 × 800 px |
| Electron minimum window | 760 × 670 px |
| App title/navigation row | 56 px high |
| Feature rail | 64 px wide |
| Standard sidebar | clamp(250px, 30vw, 360px) |
| Inspector sidebar | clamp(250px, 30vw, 360px) |
| Main content shell inset | none; flat shared surfaces |
| Main content shell radius | 0 px; panels meet on hairlines |
| Content column | 880 px, centred; 16 px gutter |
| Surface header row | 56 px high |
| Section toolbar | 48 px high |
| Small button | 28 px high |
| Medium button | 36 px high |
| Large button | 44 px high |
| Modal dialog widths | 360 / 480 / 640 (small/med/lg) |
| Modal frame (height cap) | 280 / 560 / 720 (small/med/lg) |
| Modal overlay gutter | 24 px safe-area around the card |
| Blueprint toolbar | 42 px high |
| Blueprint specimen grid | 16 px minor / 80 px major |
The surface header row is the 56 px context strip at the top of a main
surface or a side panel: PanelHeader, InfoPanel, and ThreadPanel all use
it so a surface's header and its side panels line up on one baseline. The reusable
SURFACE_HEADER_HEIGHT constant is the single source of truth; a panel that
composes Toolbar for its header passes this height. The bare Toolbar default
(48 px) is the lighter section toolbar used inside a page body (admin tables,
settings sections), not at the top of a surface.
The content column is the one width the main lane is read at. A chat's
transcript and composer, and every page that takes the lane — the feed,
artifacts and an artifact's page, the inbox, settings, a Surface — read down a
column --happy-content-measure (880 px) wide, centred in the lane, so moving
between them never moves what is being read. A lane narrower than that is the
column. A page's own content, and the title and controls of its header, sit
--happy-content-gutter (16 px) inside the column's edges; a band that spans
the lane, such as a header or a bar with a rule under it, puts its content
there with padding-inline: var(--happy-content-inline). Never anchor a page's
column to the lane's leading edge, and never invent a page measure of its own.
Something deliberately narrower — a form, a card, an empty state — sits inside
the centred column, not against the lane's edge. A document read on its own
(--happy-document-measure) is the column widened by its larger text inset, so
its text stands where every other page's content does; an artifact's web page
is centred on that same measure unless it declares
<meta name="happy-page-width" content="full"> (see artifactPageHost.ts).
The exceptions take the whole lane because they are two-dimensional rather than
read down a column: a calendar's grid of days, a dashboard such as the system
monitor (which keeps a wider column of its own), pictures, video, PDFs, code
and diffs, terminals, and web pages that are not artifacts.
These are defaults and existing contracts, not permission to make every layout
fixed-size. The navigation and inspector use the same 30vw clamp as the
reference Happy desktop app rather than a fixed desktop-only width. Components
may accept explicit numeric or percentage dimensions when their purpose requires
them. Prefer integer CSS-pixel positions and sizes.
At the required 2× device scale, important edges must land on physical pixel
boundaries so one-pixel borders do not become blurry.
Equal DOM bounds or equal integrated pixel coverage do not prove equal stroke weight. Compare the perpendicular painted width, full pixel profile, and peak contrast of equal-role rules at different positions and zoom levels, including terminal and intermediate tree branches. Tree stems and horizontal branches have the same painted thickness and peak contrast against the same local background; verify both perpendicular orientations, rather than inferring stem weight from branch measurements. Every connector that belongs to a carried object remains visible from the first lifted commit through travel, holding, drop, and the end of settling. A remaining parent's connector must also retain its intended visible connection when one of its children moves. Inspect native-resolution captures and use integer nearest-neighbor enlargement for thin-ink comparisons: resizing a video or screenshot can itself make equal strokes appear uneven. Motion evidence must assert the intended movement and state change. Its measured coordinates and captured pixels must describe the same verified pose; labels or stationary frames do not establish that a moving interface renders correctly.
Every moving, resized, or transformed piece of custom UI has this contract, including text, font icons, existing sanctioned SVG artwork, controls, and compound components. Its internal geometry, alignment, glyph size, and visual weight stay consistent across supported desktop widths, zoom, and display scales. Let content adapt to a sensible window or sidebar width without imposing an unnecessary minimum or introducing a mobile layout.
Measure and move geometry in one coherent coordinate space, normally viewport
CSS pixels from getBoundingClientRect(). Preserve fractional measurements;
mixing rounded offset* values with fractional bounds, or discarding a small
settle delta, can create a visible jump at another zoom. A carried item or subtree
moves as one object through pickup, travel, release, and settling. If paint needs
alignment, apply a shared correction at its root rather than independently
rounding its children. A semantic change of parent or indentation begins at the
drop, rather than distorting the object under the pointer.
One owner paints each shared stroke or edge. Equal roles retain their intended CSS thickness and perceived weight at every supported position. The carried surface, its content, and its connectors compose above stationary peers for the whole motion; its opaque backing covers row gaps and remains independent of a shadow fade or a child's opacity until settling completes. A fading lift must also leave settled content and connectors visible when a drop needs no animation and its carried state clears immediately.
Existing sanctioned SVG artwork declares its viewport, painted bounds, and stroke
behavior under supported scaling. Do not impose a global non-scaling-stroke
rule: artwork may intentionally scale as a whole. These motion requirements do
not change the font icon system or open a new SVG icon path.
Verify representative narrow and wide desktop layouts, including odd sidebar widths, at native 80%, 100%, 125%, and 150% zoom. Use the actual component and handlers: prove the intended root moves, its descendants retain their relative geometry, the callback and resulting order are correct, and returning restores the expected order. Compare native painted profiles through the relevant states, including the first lifted commit and the carried surface after its shadow has faded. Record each stem's identity and nonzero geometry, and compare its native perpendicular pixel profile and peak contrast with horizontal branches against their local background in that same pose. A visible branch, a later held frame, or a correctly ranked DOM node alone does not prove continuous stem visibility. These are verification requirements, not permission to add tests without a request.
Do not make dimensions accidental. If a component promises a size, its border,
padding, content, and box-sizing must resolve to that size. Test fixed,
content-sized, percentage, full-width, nested, and constrained-container cases
as applicable.
Every modal-class surface uses one of three widths and one of three sanctioned
placements. The Modal card is small (360), medium (480), or large (640):
confirmations and pickers are small, forms are medium, and content-heavy
detail is large. It never sets its own position, scrim, or stacking — it is
hosted by ModalOverlay, the single backdrop that fixes to the app window,
dims with --happy-scrim at --happy-z-overlay, and keeps a 24 px minimum
safe-area gutter. The dim covers the whole window, the connection rail
included: ModalOverlay hangs itself on the shell's cover lane (WindowCover),
so a dialog needs no wrapper to reach the rail. The default center placement
is for dialogs and forms. The top placement is only for transient type-ahead surfaces, never forms; it uses
an adaptive top gutter of
min(128px, max(24px, calc(100cqh - 485px))) so the card sits 128 px from the
top both in the 1280 × 800 design reference and at the actual 760 × 670
Electron minimum. The fill placement drops the gutter and gives the whole
window to one immersive surface that paints its own background over the
dim. It is not a third way to show a card: use it only where looking at
something is a mode the window enters rather than a panel floating above the
app, which today means Lightbox alone. Such a surface owns its own way out —
Escape, an explicit close control, and a click on its own empty background —
because there is no exposed backdrop left to click. Application code composes
ModalOverlay around a Modal, Lightbox, editor panel, or type-ahead
instead of hand-rolling per-view scrims. Wire its onDismiss to close on a
backdrop click; omit it for a surface that must not be lost to a stray click,
such as an editor holding unsaved work.
A dialog's header and button row do not move while it is open.
- Every step of a flow shows in the same
Modal, at one width. - A dialog is as tall as its content. One whose height can change while it is
open uses
frame="anchored"withanchorHeight, the height of the tallest view its flow shows. The top edge is set once, so that view would be centred, and holds; only the bottom edge moves. WithoutanchorHeightthe size's frame (280 / 560 / 720) stands in and the body scrolls past it; with it, the body scrolls once the card reaches the window's gutter. AModalwithout aframeis centred on its own height and must not change height while open. - A switch that swaps the fields under it is a segmented control at the top of the body. Switching is not a step and brings no Back.
- A list and the form a row opens share one card; the form takes
onBackto the list. - A different width or frame partway through a flow needs the person's OK.
- No card inside the card: a note or group of rows in a dialog is an unfilled
frame with a 1 px divider border and 12 px corners, like
HappyAgentUserInputPromptvariant="card". - The header's 28 px leading slot holds one of
icon,leading, or theonBackchevron, built alike, so swapping them moves nothing. Back isonBack, never a footer button. - Close stays for the whole flow;
busydisables close and back in place. - The button row holds only what moves the dialog forward: the primary at the trailing edge, at most one secondary beside it. A dialog with a close button has no Cancel, except a confirmation, where Cancel is one of its answers.
- A button's label does not change while its action runs;
loadingshows the work. In a framed dialog footer buttons are at least 112 px wide. - A button that leaves the app shows
open-externalafter its words (trailingIcon).
Use flexbox for layout almost all of the time. It is the default tool for every row, column, toolbar, list, stack, and centered box in the system. Reach for another mechanism only when the layout genuinely cannot be expressed with flexbox at all — a true two-dimensional grid of related tracks (a real media grid, a data table's cells) is the main legitimate case for CSS Grid. Even then, prefer flexbox for the one-dimensional parts.
The one layout this rule does not govern is a present_files layout tree drawn
by MediaTree: its grid, flex, and sizing are the agent's, written in the
protocol's CSS subset. Those style values are an approved exception to typed
end-to-end data. They travel as normalized CSS text under a closed set of
keys, and each one is checked again with the protocol's grammar
(mediaLayoutStyleValue) in mediaLayoutProject before React sees it. They
always render inside .happy-media-tree's contained, clipped box.
Do not use floats, inline-block spacing hacks, layout tables, or manual
absolute positioning for layouts that flexbox handles; absolute positioning is
reserved for overlays, popovers, and badges that intentionally leave the flow.
Do not reach for Grid merely to center a single child — a one-item flex container
(display: flex; align-items: center; justify-content: center) is the standard
centering box.
Whenever component CSS deliberately uses a non-flex mechanism to arrange multiple children, put a comment immediately beside that rule or declaration explaining the concrete geometry that flexbox cannot express. This applies to Grid, absolute positioning used for layout, table layout, and any other alternative. A distant design note or an implicit visual argument is not a justification. Ordinary text flow and the internal display mode of a leaf glyph or control do not need a comment because they are not arranging a component's children.
ESLint enforces this contract in production CSS and inline JSX through
happy-layout/use-flex-layout. An exception must target exactly one
declaration and carry a concrete explanation of the geometry, for example:
/* eslint-disable-next-line happy-layout/use-flex-layout -- Two-dimensional media matrix with equal row and column tracks. */
display: grid;File-wide and block-wide disables are forbidden. The companion
happy-layout/require-layout-exception-reason rule rejects non-local or
unexplained suppressions.
The flex parent owns the spacing between its immediate visual children through
gap or row-gap/column-gap. Reusable children such as buttons, banners,
fields, cards, and list rows must not create external margins to separate
themselves from unknown siblings. Do not simulate sibling spacing with spacer
elements, adjacent-sibling selectors, :first-child/:last-child margin
exceptions, or margins that depend on whether an optional child exists.
Conditional children must remain in the same flex flow as the elements around
them. A missing child contributes neither a box nor a gap; when it appears, the
parent's existing gap separates it on both sides automatically. Do not split
one visual sequence across fragments or nested wrappers that create independent
spacing islands. If a wrapper is required, it becomes a flex parent and declares
the gap for its own immediate children explicitly.
Choose gaps from the 4 px foundational grid and assert the rendered distance between every representative pair of adjacent children. Tests for a flow with optional content must render both the present and absent states and prove that all remaining adjacent pairs keep the declared gap.
An element keeps one position. The same control or status sits in the same place in every row and in every state: a row's fold is on one column whether the row is open or shut, hovered or not, and a section heading's controls share that column. Hover, focus and state changes reveal, dim or recolour; they never move an element, resize it, or swap it for another. Reserve the box of anything that can appear, and fade it in.
An element that owns scrolling (overflow: auto or overflow: scroll) fills
the entire region its parent allocates to it. The scrollport itself has no
margin or padding: its viewport and scrollbar run from edge to edge on both
axes. In a flex layout it normally uses flex: 1 1 auto, min-width: 0,
min-height: 0, and width: 100% as applicable to make that ownership
explicit.
Spacing, readable maximum widths, centering, and focus-ring clearance belong to
an inner content wrapper, never to the scrollport. That wrapper is normally a
flex column with an explicit gap; a further inner measure may use a maximum
width and center the content while the scrollport still spans the full parent.
Keep at least the complete painted extent of an external focus ring inside the
content wrapper's safe gutter so scrolling cannot clip it.
happy-layout/scrollport-no-spacing enforces zero scrollport margin and
padding in production CSS and inline JSX. Do not suppress it: introduce an
inner flex wrapper and put the spacing there.
Rendering tests for every scroll surface must prove at 2× device scale that the scrollport matches its allocated parent region, has zero computed margin and padding, and keeps the painted focus indicator of the first, last, widest, and narrowest representative interactive children visible in Chromium, Firefox, and WebKit.
A fixed header above a scrollport draws no hairline. Once content scrolls under it, a short fade in the surface's own tone marks the edge instead.
Every scrolling surface uses the browser's native scrollbar, painted by the one
shared rule in packages/happy-desktop-ui/src/styles/scrollbar.css. No script
draws, positions, reveals, or hides any part of it: the browser owns scrolling,
dragging, paging, momentum, hit testing, and the thumb's size and position.
Its track is always 8px — 6px of ink plus a 2px clear edge — and neither changes
size between states or surfaces.
- Automatic is the default. The thumb is transparent at rest and appears while the pointer is over its scrollport or the scrollport has keyboard focus. Always visible keeps a quiet thumb at rest.
- Three restrained neutral strengths: 0.32 quiet, 0.50 on the hovered or focused scrollport, and 0.68 while the thumb itself is hovered or dragged. Changes are immediate; a native bar cannot fade.
- The track is transparent and the thumb is fully rounded, in both appearances.
- A vertical scrollport keeps its lane (
scrollbar-gutter: stable) from the start, so overflow beginning or ending never moves, narrows, or rewraps content. Row panels give the lane their trailing inset (--happy-panel-scroll-trailing-inset). A scrollport that is only clipped in some state gives the lane back withscrollbar-gutter: auto. - Never set
scrollbar-widthorscrollbar-colorwhere::-webkit-scrollbaris supported: Chromium stops honouring the pseudo-elements on any element that sets either. Only engines without them get the standard properties, from the same file. - Pierre's code columns live in third-party shadow DOM, which page rules do not reach; the same file is inlined into their stylesheet, so they wear the identical bar.
Never truncate menu or popover headings, headers, buttons, or settings labels. Keep them short enough to fit, or let them wrap. Truncation is only for unbounded user content (titles, paths, branch names, account names), with the full text reachable elsewhere. Such content never sets the width of the popover or row that holds it: the surrounding content does, and the user's text ends in an ellipsis inside that width while the fixed words and marks beside it stay whole.
Picking at a higher picker level (e.g. account) descends to the next level and keeps the picker open; only a pick at the lowest levels (model, effort) closes it.
The macOS traffic lights sit in the window's top-left corner, inside the 40px
title band. That corner is a safe area, defined once by
--happy-window-controls-width and --happy-window-controls-height in
styles/window-chrome.css. Every header sharing the band takes its leading
inset from them. A narrow header keeps that inset and drops its secondary text,
so nothing slides under the lights. Full screen removes the lights but keeps
the band, so nothing jumps to the window's top edge.
Write headings, labels, and buttons in sentence case. Do not use all caps,
typed or via text-transform: uppercase. Existing uppercase styles are legacy;
convert them when you touch them.
Every first-run setup screen is the same four bands, in this order, and
SetupPage is the only component that lays them out:
- Header — the scene, title, and subtitle. Its height does not depend on its contents: the scene box is a fixed 96 px square whether or not a page has art and whatever size that art is drawn at, so the title sits at one coordinate across the whole sequence.
- Spacer — flexible.
- Core — what the page is for, and its primary action. Nothing else.
- Spacer — flexible.
- Auxiliary — everything that is not the point of the page: how a background operation is going, a way to skip an optional step, a footnote.
Pass core content as children and everything in band five as auxiliary. A
skip control, a progress bar, or a status note in children is a defect: it
puts a secondary control at the same height as the primary one. Help is pinned
to the window's bottom-right corner through help, outside the bands
entirely.
Moving between two setup screens must change the words, not where they are.
A sequence whose bodies differ in height, or grow while they are open, uses
placement="top": the title holds one line near the top of the window at the
same coordinate on every page, with the subtitle's line reserved under it. The
body hangs under the words and scrolls inside its own area, so it never moves
the title or the primary action. Anything that can appear in a body has its
box reserved from the first frame, and a list that can outgrow its room
scrolls in its own area and fades at its edges. Between stages only the words
and the body crossfade; the frame stays mounted. Happy Cloud onboarding and the
Cloud connect create and join steps use it.
Prefer fewer buttons.
Errors and troubleshooting go to the Chief of Staff. An error does not say "show the log", and it does not get its own diagnostic buttons such as "View log", "Copy details", or "Open logs folder". It offers one way out, "Ask Chief of Staff", which hands the error and its context to the Chief of Staff. A direct retry may sit beside it when retrying is the obvious recovery.
Use the existing handoff rather than building another one. It writes a labelled
draft into the Chief of Staff's conversation and opens it; nothing is sent on
the user's behalf. HappyAgentWorkspaceStore.errorAssistanceRequest hands off a
conversation error (ConversationErrorCard), and
HappyAgentWorkspaceStore.chiefOfStaffDraftAppend takes any other
HappyAgentChiefOfStaffRequest
(happy-desktop-state/src/happyAgent/happyAgentChiefOfStaffRequest.ts); a new
kind of error adds a variant there.
Nested rounded corners must be true parallel curves. When a descendant edge occupies a rounded corner of an ancestor, use the same inset on the horizontal and vertical axes and calculate each inner radius from the rendered geometry:
inner radius = max(0, outer radius - inset)
Here, inset is the actual distance between the two border-box edges, not only
the numeric value of a CSS padding declaration. It therefore includes the
ancestor border and any padding, gap, or positioning between the boxes. For
example, a 14 px outer radius with a 4 px border-box inset requires a 10 px
inner radius. If the horizontal and vertical insets differ, a circular outer
corner cannot have a circular parallel inner corner; change the layout so the
insets match rather than choosing a compromise radius. Apply the formula per
corner when radii or insets differ by corner.
Normalize pills, circles, percentage radii, and oversized radii to the curve the browser actually renders before applying the formula. A descendant whose corner is outside the ancestor's corner field is an independent rounded shape and does not inherit this relationship. A fully circular mark (border-radius at least half its smaller side) is exempt from the nested-radius rule wherever it sits, because its curve never runs parallel to the container's corner.
The shared happy-desktop-ui renderer audits this contract after every test render in
Chromium, Firefox, and WebKit. Component fixtures must expose rounded visual
parts with data-happy-desktop-ui so nested geometry is included automatically. A
test must fail when a nested curve uses an independently selected radius or
asymmetric horizontal and vertical insets, even if a screenshot looks close.
Every component has its own blueprint page selected from the thin workbench header. A page should show all supported sizes, variants, and important content states with dimension annotations. Fixtures must use props only and must not bootstrap the main app.
Large components follow the same rule. A rail or sidebar is not exempt because it occupies most of the application. Add it to the blueprint and render it as a large card with enough representative desktop canvas to show its real geometry. Full-screen shells should appear as large cards rather than taking over the workbench itself. Blueprint previews must always render at 100% scale: never scale, zoom, crop, or otherwise shrink a component to fit the workbench. Expand the card or allow the workbench to scroll around the actual target viewport instead.
The workbench itself is drawn in the same neutral language as the product: its
chrome, canvas, specimen frames, controls, and annotations resolve to theme roles
only — a colour of its own there is as much a defect as one in a component, and
ESLint holds dev/**/*.css to the same contract as component CSS. Drafting ink
for grids, rules, and ticks is mixed from --text so the drawing inverts with
the appearance instead of being defined twice. A specimen stage paints the real
Happy surface its component sits on (app, chrome, or surface), so a
component is always reviewed against its true background and its footprint reads
as the interruption in the stage grid. The header's appearance control scopes
ThemeScope to the workbench: it defaults to the ambient appearance and pins
light or dark for review without touching the host application.
The blueprint must stay deterministic and screenshot-safe. Avoid entrance animations, backdrop-filter compositing, time-dependent content, network-loaded assets, and system-font dependencies in measurement fixtures.
Visual geometry is a unit-tested API. Each component test creates one renderer
for that component and uses it to render multiple cases into separate,
explicitly sized containers. Tests query rendered parts with the shared
jquery-style $() helper and assert the values returned by the renderer. Do not
mount several unrelated components into one test renderer.
Run every render independently in Chromium, Firefox, and WebKit. The three browsers must agree on the component's contract; a result is not correct merely because one engine looks acceptable.
Each applicable test must assert:
- element coordinates, width, height, and offsets within its parent;
- visible-pixel bounding boxes for painted content;
- computed styles that define the contract, including display, box sizing, width, height, padding, borders, radius, background color, foreground color, opacity, shadows, and alignment;
- text font family, font size, weight, line height, letter spacing, line-box bounds, baseline, glyph-ink bounds, and offsets;
- the optical center of visible non-transparent pixels for text, icons, and other asymmetric painted content;
- exact colors where a shared color is intended, rather than accepting browser-dependent defaults;
- representative fixed, fluid, nested, full-width, and content variants.
Computed-style assertions complement pixel measurement; neither replaces the other. Equal CSS values can rasterize differently, and similar screenshots can hide different layout values.
Wait for bundled fonts and assets before measuring. Do not rely on platform
fonts or synthetic font weights. Every browser context and every screenshot
must use devicePixelRatio === 2. Save the Chromium, Firefox, and WebKit Retina
PNG for a component beside its test file so differences can be reviewed without
rerunning the app.
Mathematical box centering is necessary but insufficient. Fonts and icons have uneven painted mass, transparent padding, ascenders, descenders, and engine-specific rasterization. Measure the pixels users actually see.
For any element with painted content:
- capture it at 2× after fonts and assets are ready;
- ignore fully transparent pixels;
- calculate the visible-pixel bounding box;
- calculate the alpha-weighted optical center of the remaining pixels;
- compare that center with the intended component center at backing-pixel precision;
- correct the asset or component and repeat in all three browsers.
Text must have zero optical baseline drift between supported browsers. Assert both the line metrics and painted centroid. Prefer a bundled font, explicit line height, fixed weight, disabled font synthesis, and integer geometry. Apply a small engine-specific optical correction only when measurement proves that the same font and CSS still rasterize differently; keep that correction explicit and covered by tests.
Text that reads as one line shares one baseline. When a label sits beside other
text in a row — a quiet button after a message, a tab beside a heading, a count
after a title — align the row with align-items: baseline, never by centring
boxes of different heights, and drop any optical lift meant to centre the label
inside its own filled box (--happy-button-label-y: 0px for a Button). Check
the painted baselines match at 2×, not only the DOM boxes.
Measurement precision is finer than the backing-pixel grid. Record DOM and pixel-derived values to
at least 0.001px; use 0.05 CSS px as the default tolerance for a calibrated baseline or
alpha-weighted optical-center value. A visible-pixel bounding edge is necessarily quantized to the
backing-pixel grid, but its discrete value must be asserted exactly; that quantization must not be
reused as a looser tolerance for the continuous alpha-weighted centroid. Prefer integer component
geometry, then sweep any font size, variation, or correction in increments no larger than 0.05px
in all three browsers. Do not assume a fractional transform changes the raster by its declared
amount: tests must measure the response, including snapping or antialiasing changes.
Do not treat the alpha-weighted centroid of an arbitrary string as its baseline or as a universal
vertical-centering target. Glyph content changes painted mass even when typography is perfectly
aligned: AAAA exercises full cap height, Aaa mixes cap height and x-height, aaaa exercises
lowercase x-height, and 1234 exercises lining figures. These strings are different measurement
classes and are not expected to share one painted centroid. If lowercase content may contain
descenders, add a separate probe such as agyp; aaaa alone does not exercise the descender band.
For every supported text class, tests must independently assert:
- the actual rendered baseline and line box, using the browser baseline measurement rather than a canvas estimate;
- visible ink top, bottom, and full-height bounding-box center against the intended container;
- the alpha-weighted centroid for a representative balanced reference string, while documenting intentional content bias for asymmetric strings;
- all supported browsers at 2× with the bundled production font and the production weight, letter spacing, line height, and font-feature settings.
Numbers-only controls need extra care. A digit such as 7 is top-heavy, so forcing every possible
number's alpha centroid to the box center would move its baseline and make the numeral set look
unstable. Use lining numerals so 0 through 9 occupy a common vertical figure band, and use
tabular numerals when counts must keep equal digit advances. Prefer the bundled happy Mono
(JetBrains Mono) for small counters because its lining, tabular digits rasterize consistently in
all supported engines. Counter tests must cover every digit 0–9, repeated and mixed multi-digit
values, and a balanced reference such as 1234; assert a shared baseline and centered full numeral
bounds for every case, then use the balanced reference for the strict centroid assertion.
Measure the real ink bounds in the component coordinate system on every test run. For a measured
text part P inside host H, combine the rendered rectangles with visibleMetrics() as follows:
inkLeft = P.x - H.x + visible.bounds.x, inkTop = P.y - H.y + visible.bounds.y, and derive the
right and bottom edges by adding the visible width and height. Compare the center of those four
edges with H.width / 2 and H.height / 2. Calculate the alpha centroid separately with
P.x - H.x + visible.center.x and P.y - H.y + visible.center.y. Do not substitute the CSS box,
advance width, canvas metrics, or font ascent for either painted measurement.
Pixel reconstruction must use an integer-aligned render surface as its capture coordinate system,
not an element screenshot of the text part. A text box commonly begins at a fractional coordinate;
Playwright rounds an element screenshot's clip to backing pixels, so treating that rounded image as
if it began at the fractional DOM edge can introduce roughly half a CSS pixel of error that later
center calculations accidentally cancel. Capture the stable surface, scan only the selected
element's region, and convert each backing-pixel edge and center back relative to the element's real
getBoundingClientRect() origin.
Keep four typography measurements separate in test output: (1) the DOM line box and baseline, (2)
raw CanvasRenderingContext2D.measureText() font metrics, (3) raster visible bounds, and (4) the
alpha-weighted optical center. Canvas actualBoundingBox* values describe the engine's outline/font
metric model and can differ materially from screenshot pixels; they are diagnostics, never a
substitute for visible bounds. A baseline may also differ numerically between engines while each
engine's painted figure is correctly centered. Assert the measured baseline precisely and require
baseline sharing among adjacent text in the same engine; do not move centered ink merely to force
different engines to report the same raw baseline number.
For a counter, use 0 as an additional calibration glyph because its outer contour is close to
bilaterally symmetric. Assert its signed horizontal and vertical visible-bounds drift and its signed
alpha-centroid drift independently, in addition to the shared numeral baseline. Assert discrete
visible bounds exactly and assert the calibrated alpha-centroid value within 0.05px; assertion
messages must retain the signed drift so a failure says whether the ink is high, low, left, or
right. Run this against the isolated label with the real font, foreground color, OpenType features,
weight, and styling—never against a combined pill screenshot whose fill would overwhelm the text
measurement. For the current CountBadge treatment, a 0.05px font-size sweep established 10.8px
as the centered visible-bounds result; 11px placed the zero's alpha center about 0.08–0.17px
high depending on the engine and foreground treatment.
Emoji rendered as text require a separate contract from ordinary letters and numbers. The declared
UI font usually does not contain color emoji, so the browser falls through the emoji font stack to
an operating-system color font. CSS font-size sizes that font's em square, not the visible
artwork. Individual emoji, variation-selector forms, flags, and zero-width-joiner sequences can
therefore have different advances, painted widths, heights, baselines, and optical mass even when
they share one CSS size.
Put font emoji in a fixed, explicitly sized slot and keep adjacent text or numbers in separate elements. Test the slot geometry first, then capture and measure each representative emoji element independently; never calculate one centroid from a combined emoji-and-label screenshot. Cover plain emoji, symbols with emoji presentation, flags, and joined sequences when the component accepts them. Assert that each glyph is visible, unclipped, and acceptably centered inside its slot, but do not require different artwork to have identical visible bounds. If exact artwork size and optical centering must be identical across operating systems rather than only the supported desktop browsers, use normalized bundled SVG or PNG assets instead of font fallback emoji.
Keyboard shortcut caps follow the same separation rule. Unicode modifier characters such as ⌘,
⇧, ⌥, and ⌃ are not ordinary letters: a mono font may omit them, substitute a platform glyph,
or draw each with a different em-square scale. Do not put modifier symbols and shortcut letters in
one undifferentiated text run. Render supported modifiers as normalized Happy (2)-owned SVG artwork in
fixed symbol slots, and render letters/digits in fixed mono text cells. KeyCap currently uses 9px
symbol slots, 6.5px text cells, bearing-aware zero-gap adjacency, and exactly 4px padding on both
sides.
KeyCap tests must inspect each token independently. Assert SVG viewport and visible-ink size,
unclipped bounds, signed optical center, text font/size/weight, shared text baseline, fixed cell
advance, ink-to-ink gaps, relative painted height between every modifier and a reference capital,
and equal outer padding. Cover every supported modifier plus narrow/wide letters,
digits, short chords (⌘K), multi-modifier chords (⇧⌘P), and named keys (ESC, ENTER). A whole
shortcut centroid cannot prove token parity because the string's content distribution overwhelms a
small or mis-scaled modifier icon.
Avatar initials are uppercase cap-band text, not arbitrary optical-center targets. Every initials
run at one size must share the same live DOM baseline and use the same bundled font metrics. Assert
the painted bounding box for representative wide, narrow, round, and two-letter runs; use O as
the balanced alpha-centroid calibration glyph and record its signed per-browser result within
0.005px. Do not force ST, MJ, AI, or other content-dependent centroids to zero. A correction
may be size/engine-specific only when the O bounds prove it, and transform: none must be tested
separately from a nominal zero transform because enabling a transform can change text rasterization.
Avatar image coverage, initials, and presence indicators are three independent paint contracts.
Measure image clipping against the avatar shape, initials without a presence dot overlapping their
capture, and the presence circle by itself. Presence bounds must equal its declared 8px/10px box,
and its alpha centroid must be within 0.05px of that box center at 2×.
Generated raster icons require the same standard: do not center one by its file rectangle alone. Assert its visible bounds and optical center inside every button, rail item, field, or other container that uses it, since a generated asset often carries uneven transparent margins and must be normalized before component integration. Font icons are exempt from the centroid rule and follow the keyline rule in "Icon systems" below instead.
Every icon in Happy (2) is a font glyph from the two families Happy itself
relies on: Ionicons (~1357 glyphs) and Octicons (~331 glyphs), ported
verbatim from Happy's @expo/vector-icons usage. Both live in happy-desktop-ui, and
application code never imports an icon font or draws its own glyph; it composes
one of these components and passes a name, size, and optional color.
Icon is the curated house vocabulary. Its small IconName union is the
stable set of names product chrome uses, and each name resolves to exactly one
upstream glyph in one family, so a name renders the same glyph Happy renders.
Use it for core product chrome.
Ionicon and Octicon address the same two families by upstream glyph
name. Reach for these when porting a Happy surface that already names a specific
glyph, or when the curated Icon vocabulary has no equivalent; they give the
broad coverage the curated set deliberately does not.
Do not hand-draw an icon, do not add an inline-SVG icon component, and do not
re-back Icon with path data. Adding a name to IconName means picking the
upstream glyph it maps to. How the families are built:
The one exception is src/drawnGlyphs.tsx, the panel affordance behind
sidebar-collapse, sidebar-expand, panel-collapse, and panel-expand.
Neither family ships an arrow-free panel, and Octicons' sidebar-collapse is
drawn on the full 16 box with a 1.5px stroke where an Ionicons outline uses 1px
in a 14 × 12 ink box, so it sat visibly heavier and larger than the glyphs
beside it. Those four names paint shapes drawn to Ionicons' own measured
metrics instead: a 1px stroke with round joins, a 14 × 12 ink box (outer edges
at x 1–15, y 2–14), and a 2px outer corner radius, on stroke centrelines that
land on whole pixels at a 16px box. This file is closed: a missing curated name
is still answered by picking an upstream glyph, never by drawing another shape
here.
- The upstream TrueType fonts are vendored under
packages/happy-desktop-ui/src/assets/fonts/(Ionicons.ttf,Octicons.ttf).@expo/vector-iconsships no woff2, so the TTFs are used as-is through@font-faceinstyles/vector-icon.css; every engine renders them. - Each set is addressed by the upstream glyph name through the generated
name → Private Use Area codepointmaps insrc/vectorIcons/— do not hand-edit those; regenerate them from the upstream glyphmap so a name renders the exact same glyph Happy renders. - A glyph paints as a single PUA character in a square,
currentColorbox that never distorts inside a flex row.sizesets both the font size and the box.
Icon owns centring. Its box is a square flex container that centres the glyph
on both axes, and the font draws every glyph about the centre of its em square,
so the ink of every curated name is centred in its box. A container that holds
an icon gives it a fixed square slot that is itself a centring flex box, such as
the menu's 16px gutter, and never positions the glyph by a margin, padding,
baseline, or a nudge of its own.
Centred ink is not enough: icons in one column must also look the same size and
the same weight. Equal ink boxes do not achieve that. A shape that spends its ink
at the edges of its box — a framed square, a circle — reads smaller than a bare
mark of the same box, and a mark scaled up to match a framed shape thickens with
it. Every curated name therefore sits on a keyline, the proportions Lucide
uses to balance its set (design language,
specification: a 24px canvas,
a 2px stroke, at least 1px of padding, and every icon matched in weight to the
reference circle and square). Measured from Lucide's own SVGs and mapped to
the slot, ink included:
| Keyline | Lucide reference (24 canvas, centrelines) | Ink / slot | Ink at 16 |
|---|---|---|---|
| Framed shape | square 18 × 18; square-pen (compose) |
20/24 | 13–14px |
| Circle | circle r = 10 |
22/24 | 14px |
| Diagonal object | pencil about 2–22 on both axes, one body |
20–22/24 | 13px |
| Bare plus | plus 5–19 |
16/24 | 10.5px |
| Bare cross | x 6–18; diagonals drawn shorter |
14/24 | 9px |
A diagonal object such as the pencil is not a bare stroke: it has a body, so it
runs corner to corner like a framed shape rather than stopping at the cross. The
edit pencil is Octicons' pencil at the family scale, 13px across; Ionicons'
pencils fill their narrow body in to one solid bar at 16 and read as a slash.
compose means create and edit means modify. Starting a conversation, a
message, or anything else new wears compose, the pencil leaving its frame;
renaming or editing a thing that already exists wears edit, the bare pencil.
Never swap them to vary a row's look.
Lucide's square-pen keeps its frame on the centred square keyline and lets
the pen overshoot the top-right corner. Ionicons' create-outline instead
centres frame and pencil together, which sets the frame — the part the eye
reads — 0.75px left of and 1px below the slot centre. compose declares an
opticalOffset of (+0.5, −1)px at 16, applied in em so it follows the box: the
frame lands on the slot centre and the pencil tip overshoots, as Lucide draws
it. An offset is a per-name Icon declaration for an asymmetric drawing whose
upstream centring is off its keyline; a call site never nudges a glyph.
The house stroke is the Ionicons outline stroke: 1px at a 16px box, scaling with
it. Ionicons' outline drawings already sit on these keylines — outer shapes in a
14px live area, add-outline 10px across — so they are used as drawn. A curated
name whose upstream drawing falls off its keyline declares an opticalScale in
Icon's glyph table: the cross 1.1, so it lands just short of the plus. Octicons
are drawn edge to edge on a 16 grid with a 1.5px stroke, so Icon sets the whole
family at 14/16, which puts them in the Ionicons live area and takes most of the
extra weight off. A scaled glyph is laid out at the box's own font size, so its
baseline lands on the same pixel as every other glyph, and is then scaled about
the box centre. The box does not change.
The plus and cross are bare strokes with nothing enclosed, so they are the first
to fade when a box shrinks and the stroke thins below a pixel. They carry a
minimumSize of 16: in a 12 or 14px box they keep their 16px drawing — 10.5px
and 9px of ink at a 1px stroke — centred in the smaller box. That drawing is the
one the hover-revealed 12px row actions and tab close buttons have always shown,
and it is now the same plus and cross a menu row, a button, a dialog, or a
banner shows. The minimum is resolved in CSS against the font size the box
actually renders at, so a surface that overrides an icon's box still gets the
right drawing.
A call site never enlarges an icon's box or font size to compensate for its
glyph, and never shrinks it to tame one either; it fixes the name in Icon
instead.
Prove a font-icon integration with real ink (non-zero visible pixels, which also
proves the font actually loaded) and the correct box geometry in the container
that uses it, across Chromium, Firefox, and WebKit. Where a component or Icon
itself promises a keyline, assert it: the visible ink box against the keyline
table, the ink box centred in its slot to within 0.25px (offset by its declared
opticalOffset, if any), and the stroke weight
derived from alpha mass. Assert those as ranges or relations (the cross smaller
than the plus, the 12px plus equal to the 16px plus), because each platform's
rasterizer quantizes a font glyph's edges differently. Do not assert an ink
centroid on a font icon: its alpha mass sits where the typeface drew it, so a
centroid assertion measures the typeface rather than our layout. Optical
centering still applies to text, avatars, and generated raster assets. Prefer an
accessible aria-label on a standalone, meaningful icon; a decorative icon stays
aria-hidden.
Use Codex image generation for decorative raster backgrounds instead of trying to approximate them with CSS gradients, downloaded stock art, or hand-built placeholder images. Generate the image in a separate Codex terminal session so the implementation session can stay focused on component code and can review the resulting asset deliberately. Start Codex from the repository root, ask it to generate the image, give it the intended output location and aspect ratio, and then inspect the generated file before integrating it.
Every request must describe the actual scene and composition in detail. Include the image's role, subject, camera or perspective, placement of focal elements, areas that must remain quiet enough for UI, palette, lighting, texture, aspect ratio, and exclusions. Use this treatment phrase when the background should match Happy (2)'s retro visual direction: “generate retro dithered technicolor gamma image, 20% muted.” The phrase is a treatment, not a sufficient prompt by itself.
For example, open a separate terminal at the repository root, start Codex, and ask:
Generate a background image and save the final asset at
packages/happy-desktop-ui/src/assets/backgrounds/agent-workspace.png. Generate retro dithered technicolor gamma image, 20% muted. Show a late-1970s computer operations room at night from a slightly elevated three-quarter perspective: violet-black walls, low amber and magenta monitor glow, modular terminals, coiled cables, and one small green status light. Keep the center-left 45% calm and low-contrast so white interface text remains legible. Put the detailed equipment along the right and lower edges, with no people, logos, lettering, UI mockups, watermarks, bloom, or photorealistic lens effects. Use restrained ordered dithering, crisp silhouettes, a limited violet/rose/amber/cyan Technicolor palette, and a desktop-wide 16:9 composition. Produce a clean lossless PNG at 2560 × 1440.
For a quieter abstract surface, ask:
Generate a seamless desktop application background and save it at
packages/happy-desktop-ui/src/assets/backgrounds/relay-field.png. Generate retro dithered technicolor gamma image, 20% muted. Create an abstract field of broad violet-black bands, faint rose and cyan signal arcs, and sparse amber relay points, viewed as a flat graphic rather than a physical scene. Preserve a large low-detail region through the middle for panels and text. Keep contrast subdued, edges crisp, dithering fine and intentional, and the palette limited. No words, icons, logos, borders, gradients that resemble modern glossy UI, noise haze, watermark, or central focal object. Output a seamless 2048 × 2048 lossless PNG.
Treat generated backgrounds as source assets, not unreviewed final UI. Confirm that they contain no accidental text, logos, seams, compression artifacts, or unwanted focal points. Check the crop at every supported desktop window size, verify text contrast with the real overlay, and keep the original high-resolution asset so derivatives can be reproduced. Background images are decorative and must not contain information required to understand or operate the product.
Generate raster icons on a square canvas at a decent working resolution: use 1024 × 1024 px when possible and never less than 512 × 512 px for the source. Generate a strictly black subject on a strictly white background, without color, paper texture, lighting gradients, or a baked shadow unless the design calls for one.
Prepare each generated icon as follows:
- normalize near-black pixels to the black artwork and near-white pixels to the background while retaining useful anti-aliasing at the edge;
- replace the white background with alpha transparency, including white edge matting, rather than merely selecting and deleting the outer white area;
- measure the non-transparent visible bounds and alpha-weighted optical center;
- translate the artwork within the PNG canvas until its optical center is at the canvas center, while retaining consistent clear space on every side;
- export a lossless RGBA PNG at the source resolution and derive smaller sizes from that master;
- verify the final PNG on both light and dark backgrounds at 2× scale.
Optical centering belongs in the PNG itself. Consumers should not need unique CSS nudges to compensate for a badly padded asset. If several icons form a set, normalize their perceived scale, stroke mass, visible padding, and optical center as a group, then test them in their real component containers.
A visual change is complete only when the reusable component exists in
happy-desktop-ui, all supported states appear on its blueprint page, the main app uses
that component instead of defining its own UI, and cross-browser unit tests prove
its dimensions, computed styles, visible bounds, colors, typography, and optical
alignment at Retina scale.