page title: derive from the route path instead of a hand-maintained table

RULES was a hardcoded map from every route prefix to a title, which meant a
new route silently fell through to 'Officer' until somebody remembered to
add an entry — the gap that hit installed-plugin routes, which had no entry
at all. titleForPath now takes the URL's first path segment and title-cases
it, so every route gets a sane tab title for free, including ones a plugin
adds at runtime. Trade-off: a few routes lose their hand-tuned casing
(QR Transfer -> Qr Transfer, Command HQ -> Command Hq) and settings
sub-routes collapse to the one 'Settings' title instead of a distinct one
per section — both accepted as the point of removing the table.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-19 18:03:33 +00:00
co-authored by Claude Opus 5
parent 6235662492
commit ab636eaa42
2 changed files with 19 additions and 37 deletions
+5 -3
View File
@@ -349,9 +349,11 @@ Worked examples: `/soulseek`, `/music`, `/chat`.
(`{ key, name, icon, component, availableOnPanel: false }`) and registered in `AppRegistry.tsx`.
The Workspace/Panel framework is orthogonal to routing — it contains no route navigation, and panels
live inside the Route element tree, so they can call `useParams`/`useSearchParams` directly.
- **Page title by route.** Add a rule to `RULES` in `src/apps/officer-web/state/usePageTitle.ts`
(`{ match: (p) => p.startsWith('/<name>'), title: '<Name>' }`, most-specific first);
`usePageTitleSync` does the rest. `startsWith` means nested routes are covered.
- **Page title by route.** Automatic — no rule to add. `titleForPath` in
`src/apps/officer-web/state/usePageTitle.ts` takes the URL's first path segment, turns `kebab-case`
into `Title Case`, and that's the tab title; `usePageTitleSync` does the rest. A screen that wants to
say more than its route does (a chat's own name, not just "Chat") publishes an override instead —
`usePublishPageTitle` in `officerdev`.
### The URL is the source of truth for selection