UserHappyDesign system
Storybook

Component topography

Original documentation preserved from the source revision.

CustomerApp component topography and componentization plan

Date: 2026-08-10

Scope: the non-Cortex route tree of src/App.tsx. iOS and macOS are excluded.

Status: measured current state plus a proposed migration order. Implementation has not started.

Companion document: 2026-08-10-ui-componentization-audit-and-plan.md holds the app-wide target architecture, the token role graph, and the Phase 0–7 plan. This document does not repeat them. It narrows the scope to the CustomerApp, attributes the census to routes, and orders the migration.

Baseline

The census measures origin/dev at c8c81feb, not the local checkout. The local shared checkout sits at cb764a3, which is 19 commits behind. Eight of those 19 commits change CustomerApp surfaces that this census counts: login, nav, dashboard, wizard, audiences, and reports. A census of the stale tree would have reported numbers that no longer exist.

Item Value
Measured commit c8c81feb (origin/dev)
Local checkout cb764a3, 19 commits behind
Method detached worktree; the shared checkout was not switched
Machine-readable census qa-artifacts/customerapp-census-origindev.json
Local-checkout census qa-artifacts/customerapp-census.json
Census script scripts/qa/customerapp-census.mjs
Map generator scripts/qa/build-customerapp-topography.mjs

The scripts live under scripts/qa/ because qa-artifacts/ is listed in .gitignore — it holds generated output only. C0 below therefore has to commit its baseline to a tracked path, not to qa-artifacts/.

src/App.tsx is byte-identical between the two commits, so the route table applies to both. The local checkout reports 215 controls against 209 on origin/dev. The difference is real work already merged, chiefly the dashboard view toggle removed in #404.

One palette fact follows from the same staleness. src/index.css at cb764a3 still declares --color-brand-orange-text: #a84200. On origin/dev that token is #b34700, ratified by Aline in #407. Anyone reading the local tree for the current Text Orange gets a dead value.

Method

An AST pass over the TypeScript compiler reads each non-test, non-story src/**/*.tsx file. The pass records JSX intrinsic elements by tag, input elements by type, JSX style props, raw <svg> roots, hex literals, arbitrary Tailwind values, imported lucide-react symbols, and full-viewport overlay wrappers.

The route table is transcribed from src/App.tsx. For each route the pass walks the import graph from the page module, resolves relative specifiers inside src, and takes the transitive closure. Routes under <Route element={<Layout />}> also include the closure of Layout.

Double-count policy

The census reports two different numbers. Read them for different purposes.

  1. Per-route reachable counts. Every file a route can render counts toward that route. Shared files therefore count once for each route that reaches them. Use these numbers to judge the blast radius and the QA burden of one route.
  2. Per-group owned counts. Every file is attributed to exactly one bucket. A file reachable from Layout belongs to shared-shell. Any other file belongs to the first route group that reaches it. The owned counts sum to the whole and never double count. Use these numbers to size the work.

The two views disagree by design. A statement such as "the CustomerApp has 140 buttons" always refers to the owned view.

Validation against the prior audit

Run against the same tree the earlier app-wide audit used, this pass reproduces its per-file numbers exactly on raw controls and inline styles: Panels.tsx 61 controls and 7 style props, Team.tsx 19 and 0, Profile.tsx 14 and 0, TaskCompletionPulse.tsx 13 and 0, PulseSessions.tsx 12 and 0.

One metric does not reconcile. The earlier audit reports 267 styled intrinsic elements for Panels.tsx. This pass counts 288 intrinsic elements that carry a className, of which 238 use a string literal and 50 use an expression. No obvious tag filter produces 267. This document therefore states its own definition and uses it consistently. Treat the styled-element figure as a migration population, not as a defect count.

Routes and view categories

The categories come from the router structure, not from an invented taxonomy. Guard nesting and layout nesting define them.

Group Routes What distinguishes it
shared-shell — Files reachable from Layout. Chrome for every authenticated screen.
shell 16 RequireUserSession plus Layout. The signed-in product.
shell-admin 1 Same shell behind an extra RequireStaffRole minRole="admin" guard.
participant 4 Authenticated or token-entry, but deliberately without Layout chrome.
auth 5 Sign-in, sign-out, and link verification.
public 7 Unauthenticated demo and marketing pages.
fallback 1 * catch-all.

Total: 34 route entries over 33 distinct paths. /pulse-sessions/create and /pulse-sessions/create-v3 render the same component.

Route membership

  • shell — /, /pulse-sessions, /pulse-sessions/create, /pulse-sessions/create-v3, /pulse-sessions/:id/results, /v0/manage-pulses, /panels, /panels/new, /panels/:listId, /insights, /insights/sample, /insights/:id, /analytics, /team, /profile, /help-requests
  • shell-admin — /system-help-inbox
  • participant — /pulse-sessions/preview, /preview/:previewId, /pulse/:token, /survey/:token
  • auth — /login, /logout, /auth/verify, /auth/verify-web, /auth/impersonate
  • public — /sentiment-demo, /pulse-demo, /tasks/ceo-notifications, /contact, /privacy, /terms, /help
  • fallback — *

/survey/:token renders LegacySurveyRedirect, which is declared inside App.tsx and renders no markup. Its counts are zero by design.

Element census by grouping

Owned view. Each file counts once. 70 files in total.

Group Files Controls button input select textarea a form label table raw svg
shared-shell 9 13 13 0 0 0 1 0 0 0 2
shell 39 153 98 41 9 5 3 7 44 8 4
shell-admin 2 3 2 1 0 0 0 1 0 0 0
participant 9 23 18 1 0 4 3 0 3 0 3
auth 3 7 5 2 0 0 14 2 2 0 1
public 7 10 4 5 0 1 3 2 6 0 0
fallback 1 0 0 0 0 0 0 0 0 0 1
Total 70 209 140 50 9 10 24 12 55 8 11

"Controls" counts button, input, select, and textarea only.

Design-system debt by grouping

Group JSX style props Hand-rolled overlays Hex literals Arbitrary Tailwind values Distinct button class recipes
shared-shell 1 0 100 138 9
shell 38 9 985 1,316 72
shell-admin 0 0 17 19 2
participant 4 1 162 236 18
auth 0 0 77 91 5
public 13 0 0 6 4
fallback 0 0 19 6 0
Total 56 10 1,360 1,812 110

140 raw buttons carry 110 distinct class recipes. That ratio is the core finding. The CustomerApp has almost as many button treatments as it has buttons.

The per-group recipe counts sum to exactly the repository-wide total of 110. No button recipe is shared across two groups. Reuse is not merely low; between groups it is zero.

Input types

50 raw input elements across the CustomerApp:

type Count
text 30
email 10
checkbox 5
file 2
url 1
search 1
radio 1

checkbox and radio need selection components rather than a text-field component. file needs an upload component that owns its own accessible name and its own error state.

Per-route reachable counts

Shared files count for every route that reaches them. Use this table to size QA per route.

Route Group Reachable files Controls button input style props Overlays
/panels shell 13 76 55 19 9 5
/panels/new shell 13 76 55 19 9 5
/panels/:listId shell 13 76 55 19 9 5
/pulse-sessions/create shell 23 32 26 4 4 1
/pulse-sessions/create-v3 shell 23 32 26 4 4 1
/team shell 11 32 23 6 1 0
/profile shell 11 26 18 6 1 0
/pulse-sessions shell 14 25 21 3 2 2
/pulse/:token participant 9 24 19 1 4 1
/pulse-demo public 9 22 16 3 1 1
/ shell 13 21 21 0 7 0
/preview/:previewId participant 9 20 16 1 1 1
/pulse-sessions/:id/results shell 11 20 18 2 1 1
/help-requests shell 16 20 16 1 1 0
/pulse-sessions/preview participant 9 19 15 1 1 1
/system-help-inbox shell-admin 16 19 17 1 1 0
/insights/:id shell 12 16 16 0 17 0
/analytics shell 13 15 15 0 4 0
/v0/manage-pulses shell 12 14 14 0 2 0
/insights shell 13 14 13 0 2 0
/insights/sample shell 12 14 14 0 16 0
/login auth 1 6 4 2 0 0
/contact public 1 5 1 3 0 0
/sentiment-demo public 4 2 2 0 16 0
/auth/verify auth 1 1 1 0 0 0
/auth/verify-web auth 1 1 1 0 0 0
/auth/impersonate auth 1 1 1 0 0 0
/help public 1 1 1 0 0 0
/logout, /privacy, /terms, /tasks/ceo-notifications, /survey/:token, * mixed ≤1 0 0 0 0 0

/panels is the single largest surface. It carries 36 percent of all CustomerApp controls through one file.

Uncomponentized elements

1. Interactive controls are owned by pages

Panels.tsx alone declares 61 raw controls. Team.tsx declares 19, TaskCompletionPulse.tsx 13, Profile.tsx 13, and PulseSessions.tsx 12. Each site owns its own padding, radius, hover treatment, focus ring, disabled state, and icon spacing.

2. Buttons have no bounded variant set

110 distinct class recipes serve 140 buttons, and no recipe crosses a group boundary. A semantic API of roughly six intents replaces them: primary, secondary, quiet, destructive, link, and icon-only.

3. CSS is authored inside markup

56 JSX style props remain. The hotspots are DetailedReport.tsx with 15 and SentimentDemo.tsx with 13. Panels.tsx has 7 and PulseCard.tsx has 4. These carry shadows, measurements, opacity, gaps, and data-driven widths. Data-driven width needs a semantic progress or chart component, not a find-and-replace.

4. The same meaning resolves to different SVGs

The CustomerApp imports 75 distinct lucide-react symbols directly. Semantic collisions exist now:

  • success or done — Check in 5 files, CheckCircle2 in 5, CheckCircle in 3;
  • warning — AlertTriangle in 4 files, Info in 2, AlertCircle in 1;
  • busy — Loader2 in 2 files, RefreshCw in 1.

Thirteen files express one product meaning with three different glyphs.

5. Brand marks are duplicated with different geometry

Login.tsx embeds a Google mark at viewBox="0 0 18 18". Profile.tsx embeds a different Google mark at viewBox="0 0 48 48" with different path data. Both hardcode Google brand hexes. One GoogleMark component removes the divergence.

6. Raw SVG lives in feature files

11 raw <svg> roots sit in 10 files: Layout.tsx (help glyph), AppFooter.tsx (tagline wordmark), SentimentIcon.tsx, SentimentFaceMark.tsx, PulseStepIndicator.tsx, NotFound.tsx (illustration), Survey.tsx (2), TaskCompletionPulse.tsx, Login.tsx, and Profile.tsx. These assets are legitimate. Most of their locations are not.

SentimentFaceMark.tsx is the exception, and it is the model for the rest. #409, #413, and #418 extracted the Likert face into one named component whose geometry is lifted verbatim from Figma frame 4202:3001, then pointed the report table, the picker, and the participant view at it. That is precisely the target pattern: one meaning, one mark, one owner, sourced from the design canon.

7. Overlays repeat focus and dismissal logic

10 hand-rolled full-viewport overlays exist: 5 in Panels.tsx, 2 in PulseSessions.tsx, and one each in PulseResults.tsx, PulseHelpPanel.tsx, and ConfirmSendModal.tsx. Each repeats backdrop, layering, Escape handling, and focus return.

ConfettiBurst.tsx also pins itself full-viewport but is counted separately as decorative: it is pointer-events-none, so it owns no focus behaviour and must not be routed through Dialog.

Read 10 as a floor. The scan keys on fixed plus inset-0, so an absolute inset-0 overlay or the long-form top-0 right-0 bottom-0 left-0 spelling would not be counted.

8. Tokens are bypassed at call sites

1,360 hex literals and 1,812 arbitrary Tailwind values remain. The hex figure was checked for contamination by bare issue references such as #407: every match in these files is 3 or 6 characters (1,356 six-character, 4 three-character) and none is a PR number, so the count is real CSS colour. src/index.css already defines semantic roles, so most of these are avoidable today. The existing palette guard checks vocabulary, not ownership, so it cannot catch a correct hex used in the wrong slot.

Migration order for the CustomerApp

This order follows the app-wide plan but sequences the CustomerApp specifically. Each tranche is one reviewable PR in its own worktree.

C0 — Ratchet. scripts/qa/customerapp-census.mjs is already in a tracked path; add the Vitest wrapper and commit the per-file baseline to a tracked path (not qa-artifacts/, which is ignored). CI fails on any increase. No source changes.

Tracking is separate from the ratchet and already wired: one snapshot per prod promotion, appended by the existing deploy job and stored in R2. Per-merge-to-dev was rejected as too noisy — 30 consecutive merges moved the foundation zero times, so a per-merge series is almost all silence. No new GitHub Actions workflow, and nothing commits back to git.

C1 — Assets first. Build src/ui/icons, src/ui/brand, and src/ui/illustrations. Move the 11 raw SVG roots and both Google marks into named components, following the SentimentFaceMark precedent. Map the three check glyphs to one status.success name. Low risk, removes a whole defect class.

C2 — Actions. Build Button, IconButton, and LinkButton with about six intents. Migrate shared-shell first: 9 files, 13 controls, 9 recipes. Every authenticated route improves at once.

C3 — Fields. Build Field, TextField, Textarea, Select, Checkbox, RadioGroup, SearchField, and a file-upload control. The 50 inputs, 9 selects, and 10 textareas resolve here.

C4 — Overlays. Build Dialog, Drawer, and Popover on one accessible behavior layer. Replace all 10 hand-rolled overlays. ConfettiBurst stays as it is.

C5 — Routes by risk, ascending. auth and public first, since they are small and low traffic. Then participant, which is customer-facing and must not regress. Then shell route by route. /panels goes last, after fields, tables, cards, dialogs, menus, and icon buttons are proven.

C6 — Inline style elimination. DetailedReport.tsx and SentimentDemo.tsx need semantic report and chart components, so they follow the primitives rather than leading.

C7 — Zero. Delete the baselines. Hard-fail on raw controls outside src/ui, on style props, on raw SVG outside asset modules, on direct icon imports, and on literal visual values. Add a dependency-boundary test so feature code imports only the public src/ui API.

Verification per tranche

  • unit and interaction tests for each primitive and each state;
  • accessible name, focus movement, Escape behavior, and keyboard-only use;
  • Storybook coverage for every variant and both themes;
  • route screenshots at desktop and mobile widths before and after;
  • the census script at a strictly lower baseline;
  • focused feature tests, then tsc --noEmit.

Regenerating the census

Run from the repository root:

# current checkout
node scripts/qa/customerapp-census.mjs

# another tree, e.g. a detached worktree at origin/dev
node scripts/qa/customerapp-census.mjs /path/to/worktree customerapp-census-origindev.json

# rebuild the interactive map from the census
node scripts/qa/build-customerapp-topography.mjs

The script rewrites the named JSON under qa-artifacts/ and prints the summary tables. Update the route table inside the script whenever src/App.tsx gains or loses a route.

Source: docs/ux-reviews/2026-08-10-customerapp-component-topography.md