Skip to content

UI: react-ui primitives, no inline styles in the app, error boundary, real nav links, react-aria forms, one live region - #171

Merged
RikusVanRensburg merged 2 commits into
mainfrom
refactor/RVR/ui-primitives-forms
Nov 12, 2026
Merged

RikusVanRensburg merged 2 commits into
mainfrom
refactor/RVR/ui-primitives-forms

Conversation

@RikusVanRensburg

Copy link
Copy Markdown
Contributor

Closes #147

What changed and why

  • Primitives in react-ui and the design system. Card, Stack, Row, Note, Caption, SectionHeading, Identifier, Mono, Drawer (DrawerSection, Holder, KeyValues, Chips), LabeledValue, FieldGroup, Form, FirstRunShell, PageHead, PanelBody, PanelGrid, PanelNote, ItemMain, EmptyNote, LinkDot, ErrorBoundary, AnnouncerProvider. Each has CSS in resources/design-system/components/bundle.css (synced with pnpm design:sync, generated CSS not hand edited) and a README spec. The app has no inline style and no layout class of its own; app.css is deleted. The drawer header and the first-run shell exist once each. ClientDrawer and AddClient moved out of clients-page.tsx.
  • Dead code gone. SegmentedControl, LinkBanner (the LinkState type now lives with StatusCard) and the plain DeviceCard are removed from the library and from the design system (CSS, specs, previews); the .app-* CSS had no user.
  • Domain leaks. SecretValue takes its label; StatusCard takes a ready version and a generic detail line, so the server-link wording and the version rule live in the app (client/server-link.ts). The status dot is LinkDot.
  • Error boundary and lazy loading. ErrorBoundary guards the auth gate and, as ShellBoundary, the app, with Reload and Sign out. The three signed-out screens are lazy.
  • Navigation, focus, title. Nav items are real links (href="#devices"), so they open in a new tab and take a middle click. A page that opens because the person went to it takes focus on its h1, and every page sets <title> (Devices - Koppel; React 19 hoists it, no effect). A skip link moves focus to the page without touching the address. The first page of a visit leaves focus alone.
  • Forms. react-aria Form and field validation (validate, isRequired) on sign in, first password, password change, add client and the server connection; refusals from the server go to validationErrors under the field. auth/password-rules.ts is the one place for the password rules (mirrors koppel-web/src/auth/password.rs), used by the first password and the change. Every form sends through a useMutation; the .then().catch().finally() chains and the four-useState mirror are gone. ConnectionForm keeps only what the person changed over the stored connection.
  • Secrets. SecretValue drops the secret on Hide, and after a copy made while it was masked.
  • One live region. AnnouncerProvider draws the only role="status"; the 18 other places are plain text. The pending store, the live link, forms, copy failures and sign-out failures speak through useAnnounce(). react-aria keeps its own off-screen announcer for selection changes; that one stays.

Behaviour changes to check

  • Submit buttons stay enabled on the password forms: react-aria checks the rules when the form is sent and says what to fix. They were disabled until valid, which hid the reason. They are off while the link is not live and while sending.
  • Tests changed because the mechanism changed (not edited to pass): the two password tests that asserted a disabled button now assert the messages on send and that nothing is sent; the connection test that waited for the form to show someone-else now asserts the save stays pending (the form keeps what was typed, per docs/ui.md); the role="status" assertions now assert the visible text and the announced sentence; the status card tests no longer look for status or alert roles.
  • The status card's server-link and version tests moved from react-ui (now a generic detail and version) to app-level behaviour.
  • A refusal of a password change goes under the new password if that fails the rules, else under the current password: the server sends no field name. Recorded in docs/decisions.md.
  • The activity feed is no longer a role="log".

Testing

  • Native: pnpm --filter koppel.ui typecheck, pnpm --filter @koppel/react-ui typecheck, pnpm --filter koppel.ui lint: clean. pnpm design:sync: no change after the CSS sync.
  • node:24.22.2-bookworm-slim, pnpm 9.15.0: pnpm --filter koppel.ui test 13 files, 100 tests passed; pnpm --filter @koppel/react-ui test 7 files, 47 passed. New: Announcer, nav links, skip link, focus and title per page, error boundary, Form validation and server errors, layout parts, secret handling, one live region in a full page.
  • Not run: Rust tests (no Rust change), a manual or visual run in a browser (the layout moved to classes the design system defines; nobody has looked at it on a screen in this change), a screen reader.
  • Bundle (built to a scratch folder), from before the 0.2.1 UI work: JS entry 522,640 bytes (gzip 154,105) before UI: one EventSource module with one retry policy #159 and UI: query-options factories, typed pending actions, useNow, plain shell data, latin woff2 fonts #164, 448,063 (gzip 133,676) now. The signed-out screens are three chunks of 1 to 1.6 KB, and two shared chunks (54 KB and 26 KB, react-aria form parts and shared code) load for the app as well, so a signed-in visit downloads about the same JS as before (about 530 KB). Total dist 934,354 bytes before, 698,754 now (the font change is most of it).

Docs

docs/ui.md (new section "Pages, forms and accessibility"), docs/decisions.md, the design system README and a README per new primitive.

Changelog notes: no wire, on-disk or settings change. User-visible: nav links open in a new tab, each page sets its title and takes focus on its heading, a skip link, password forms say what to fix when sent, one screen reader voice.

🤖 Generated with Claude Code

RikusVanRensburg and others added 2 commits November 12, 2026 21:57
…ve region

Card, Stack, Row, Drawer, Holder, KeyValues, Chips, LabeledValue, Form,
FieldGroup, FirstRunShell, PageHead, Note, Caption and the panel parts
move into react-ui and the design system, and the app drops its inline
styles, its app.css and its raw layout classes. SegmentedControl,
LinkBanner and the plain DeviceCard go. The forms use react-aria Form
validation with shared password rules and useMutation, nav items are real
links, the page heading takes focus and sets the title, the signed-out
screens load lazily, and an error boundary guards the gate and the shell.
One Announcer replaces the scattered status regions.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Tests for the Announcer, nav links, skip link, focus and title per page,
the error boundary, Form validation and the layout parts. docs/ui.md and
docs/decisions.md describe the primitives, the one live region, the forms
and the password rules, and the design system has a README per new
primitive.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@RikusVanRensburg
RikusVanRensburg merged commit b995957 into main Nov 12, 2026
@RikusVanRensburg
RikusVanRensburg deleted the refactor/RVR/ui-primitives-forms branch November 12, 2026 19:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

react-ui owns its primitives, the app is free of inline styles, and the UI has an error boundary

1 participant