Skip to content

UI: query-options factories, typed pending actions, useNow, plain shell data, latin woff2 fonts - #164

Merged
RikusVanRensburg merged 2 commits into
mainfrom
refactor/RVR/ui-query-pending-fonts
Nov 12, 2026
Merged

RikusVanRensburg merged 2 commits into
mainfrom
refactor/RVR/ui-query-pending-fonts

Conversation

@RikusVanRensburg

Copy link
Copy Markdown
Contributor

Closes #158

What changed and why

  • Query options. queries.ts has one factory per resource (settingsOptions() and the rest). Hooks, the live push table, the pending domains and tests take keys from it. query-keys.ts is gone and the literal keys are gone with it. getSystemInfo and getSystemChecks moved to api/system.ts. The activity fetch merges through the query function's own client.
  • Time. useNow renews the time every 30 s. seen() and uptime() take it instead of reading Date.now() in a render. The system info query lost its 60 s refetchInterval and its redundant staleTime: it is fetched once and refetched by the push when settings or keys change.
  • Shell. The open page is read from the address (usePage, useSyncExternalStore) and changed with goTo; nothing sets it twice. The redirect for a page the role lacks is computed in render. The phone title comes from pageTitles[page]. FrameContext is now { locked, asideSlot }, no effects and no rebuilt ReactNodes.
  • Pending store. Each domain has a discriminated action, keyOf, describe, verdict and send. usePending(name).request(action) marks it pending and sends it as a useMutation; the store no longer reads the query cache and the generics are not erased (the one cast is the cache's untyped data, in judgeCached). The connection secret is the send's input, so it never sits in the store. One fingerprint module (shared/fingerprint.ts): lower case for comparing, upper case only for display.
  • Setup navigation: code now matches docs/ui.md. finish() used to move the address before the server confirmed. Now the page and the address leave only on confirmation, and the app lands on Clients (server or both) or Configuration (client). A refused setup stays on the setup page. Tests added for all three. Confirm tests unaffected.
  • Fonts (decision for the owner to overrule). I kept Latin and Latin Extended, woff2 only; Cyrillic, Greek and Vietnamese are dropped. Instrument Sans has no other subsets; only JetBrains Mono has those three, and text in them falls back to the system font in the --font-sans/--font-mono stacks (Segoe UI and system-ui draw all three). Reasoning in docs/decisions.md. fonts.css now declares 10 woff2 faces with the packages' unicode ranges.
  • sync-design-system.mjs stops with an error if the Google Fonts import survives its pattern.
  • Ack idea: not taken, recorded in docs/decisions.md (no wire change).
  • Tests: pages.test.tsx and auth.test.tsx are split per page (setup, shell, configuration, login, set-password, change-password, live-gate) with shared fixtures.tsx and auth-fixtures.tsx. FakeHub was already gone in UI: one EventSource module with one retry policy #159.

One test changed, on purpose

"is redirected to the overview once the loaded role has no such page" asserted that the address becomes #overview. The issue asks for the redirect in render, so the address is no longer rewritten. The test now asserts that the overview shows, the phone title says Overview and the address is untouched. The test was asserting the old mechanism.

Visible change

The phone top bar says "Devices" on both device pages (it said "Devices on lab" and "Devices on this machine"); the page heading is unchanged.

Testing

  • Native: pnpm --filter koppel.ui typecheck, pnpm --filter koppel.ui lint: clean. pnpm design:sync: generated CSS unchanged.
  • node:24.22.2-bookworm-slim, pnpm 9.15.0: pnpm --filter koppel.ui test 12 files, 89 tests passed; pnpm --filter @koppel/react-ui test 5 files, 32 passed.
  • Not run: Rust tests (no Rust change), contract tests, a manual run in a browser against a real server.
  • Build to a scratch folder: 34 files, 934,354 bytes before; 14 files, 692,555 bytes after. JS 522,640 to 525,739 bytes (gzip 154,105 to 154,823) from the new code.

Docs

docs/ui.md and docs/decisions.md updated.

Changelog notes: no wire, on-disk or settings change. The embedded UI is about 240 KB smaller (font files). Text in Cyrillic, Greek or Vietnamese in a monospace field now uses the system font.

🤖 Generated with Claude Code

@RikusVanRensburg
RikusVanRensburg force-pushed the refactor/RVR/ui-query-pending-fonts branch from 8b95430 to c9abaed Compare November 12, 2026 19:49
RikusVanRensburg and others added 2 commits November 12, 2026 21:50
One factory per resource in queries.ts replaces the query keys and the
repeated useQuery calls. The pending store takes a discriminated action
per domain, sends through useMutation, and no longer reads the query
cache to describe a change. The shell takes plain data: the open page is
read from the address, the redirect and the title are computed in
render, and first run lands on its page once the server confirms setup.
Relative times come from useNow, and the system info is no longer polled.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…I tests

fonts.css declares the ten faces itself with the packages' unicode
ranges, so the program embeds 10 woff2 files instead of every subset in
two formats. The design system sync now stops if the Google Fonts import
is spelled another way. pages.test and auth.test are split per page, with
their shared fixtures in their own files, and the first run, relative
time and no-polling behaviour have tests. docs/decisions.md records the
font decision and why the ack idea is not taken.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
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.

UI query keys, relative times, fonts and setup navigation

1 participant