The core speaks English only; every other language is a kind: "translation" plugin
(translation-<lang>; the French one is translation-fr in ai-agent-plugins, seeded once at start).
- plugins: kind translation (typed_manifest.parse_translation: lang, name, englishName, flag,
locale, promptLine, ui/backend JSON dictionaries — strict, operator-only, in the fingerprint);
a top-level "languages" field on any plugin (default ["en"]) shown on its page; seeding takes
translation-*; plugins/translations.py reads the enabled ones (first by id wins a code).
- core/i18n: tr / langs / localized / clean_pref / effective_lang read the installed
translations; a pick whose translation is gone reads English and is kept; browserLang records
any base code. core/i18n_fr.py and FRENCH_LINE are gone (language_line = the plugin's promptLine).
- The owner picks a language too (users.json ownerLang, PUT /api/me {lang}; English by default).
- Public GET /api/i18n/languages and /api/i18n/{lang} (ETag/304), guest host and sign-in included.
- Coverage: backend/core/i18n_keys/{ui,backend}.json (kept by the two i18n tests,
UPDATE_I18N_KEYS=1); a translation's page shows translated / missing / stale / placeholder
mismatches.
- Frontend: frontend/src/i18n/fr removed; the dictionary comes from the hub, cached in
localStorage and revalidated in the background (first boot in a language waits <= 4 s, any
failure is English); Lang is a string; number/currency style from the translation's locale;
LanguageSelect lists English + installed translations (hidden when none); Settings → Plugins
has a Translations kind (tab, catalog filter, group) and a Translation section with the
missing-strings count; mock is English only.
- Tests: test_i18n.py rewritten on a made-up translation; i18n_testkit.speaking() for the
tests that need a second language. authz golden, openapi.json + src/generated regenerated;
docs/plugins.md (Translations), CLAUDE.md, i18n README, docs/settings.md.
Changelog
- Added: languages are plugins — Settings → Plugins → Translations; the owner can pick a language.
- Changed: French moved to the translation-fr plugin (seeded at start: nothing changes for guests).
- Removed: the core's built-in French dictionaries.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
218 lines
13 KiB
Markdown
218 lines
13 KiB
Markdown
# Settings — one registry, filtered by permission
|
||
|
||
*Since 2026-11-23. Decisions: the homelab's
|
||
`data/log/2026-11-23-ai-agent-settings-reorg.md` → "Revision 2" (groups, the
|
||
role table; entries a role lacks are **hidden**; search covers pages and
|
||
rows; Cmd+K has a Settings section; one Settings for everyone). Related:
|
||
[permissions.md](permissions.md).*
|
||
|
||
## The single source
|
||
|
||
`frontend/src/business/settings/registry.ts` lists every Settings destination
|
||
once — `{ id, group, label, hint, short?, icon, to, match[], perm | anyPerm[] |
|
||
allPerms[], unless?, when?, operator?, variants?, desktopOnly?, keywords[], bar? }` — in
|
||
five groups: **You**, **Your logins & tools**, **Workspace**, **People &
|
||
security**, **This machine**. Everything else reads it, filtered by what the
|
||
caller holds (`me.perms` from `/api/me`, `business/users/access.ts`):
|
||
|
||
| reader | file |
|
||
|---|---|
|
||
| the left panel (one for everyone; search box, groups) | `business/settings/components/SettingsPanel.tsx` |
|
||
| the bottom bar's drawers (owner: Settings tab; others: *Me* = You, *Settings* = the rest) | `business/composer/components/BottomBar.tsx` |
|
||
| `SUB_SECTIONS.settings` / `navKeyOf` | `nav.ts` |
|
||
| the command palette's Settings section (pages + rows) | `business/keyboard/components/CommandPalette.tsx` |
|
||
| the routes' guard (`RequiresSettings`: the entry owning the path names the permission) | `business/users/guards.tsx`, `root.tsx` |
|
||
|
||
A group with no visible entry disappears. While `/api/me` loads or fails
|
||
everything is allowed (the owner never waits; an older backend mid-deploy
|
||
can't lock the admin out) — the guards render, like `OwnerOnly`.
|
||
|
||
### Variants: one page, drawn per caller
|
||
|
||
An entry with `variants` is the same page for different people — the
|
||
operator's whole set, or a person's own. The **first** variant the caller fits
|
||
(its `perm` / `anyPerm` / `allPerms`, minus `unless`, plus `when`) decides the
|
||
label, `short`, hint, icon, keywords, group and `at` (listed just before that
|
||
entry of its group), and the page's **scope**: `settingsScope(id, access)` /
|
||
`useSettingsScope(id)` (`business/settings/useScope.tsx`) → `"hub"`, `"mine"` or
|
||
null. The page reads the scope and draws the same components on the API that
|
||
caller has; the guard lets in whoever fits **any** variant. While `/api/me` is
|
||
pending the hook returns `undefined` and the page shows `ScopeLoading` (a guest
|
||
must not mount the operator's variant and fire its 403s); when `/api/me`
|
||
**fails** the scope is `"hub"`, like `useIsOwner` — the operator is never locked
|
||
out. A variant's `listed` only hides the entry (the scope and guard ignore it).
|
||
|
||
| entry (`id`) | `hub` — the operator | `mine` — a person |
|
||
|---|---|---|
|
||
| `profiles` | **Machines** (This machine), `workers.read` + `accounts.manage` | **My computers** (Your logins & tools), `self`, not `workers.manage`; listed with `computers.pair` or `runs.start` |
|
||
| `accounts` | **Logins** (This machine), `accounts.manage` | **My logins** (Your logins & tools, first), `self.claude`, not `accounts.manage` |
|
||
|
||
The ids stay `profiles` / `accounts` so saved panel and drawer orders keep
|
||
their place; a person's old `computers` key maps to `profiles` (`RENAMED` in
|
||
`SettingsPanel.tsx`, `GUEST_RENAMED` in `BottomBar.tsx`).
|
||
|
||
## Who sees what
|
||
|
||
| Role | You | Your logins & tools | Workspace | People & security | This machine |
|
||
|---|---|---|---|---|---|
|
||
| **Operator** | all | AI apps (their own variants elsewhere) | all | all | Machines (+ People's computers), Logins, and the rest |
|
||
| **Admin** (team mode) | all | My logins, Budget, Jobs, My computers, AI apps, Projects | all | all | – |
|
||
| **Member** | all | My logins, Budget, Jobs, My computers, AI apps, Projects | – | – | – |
|
||
| **Guest** | all | My logins, Budget, Jobs, My computers, Projects (+ AI apps when allowed) | – | – | – |
|
||
| **Viewer** | all | Projects | – | – | – |
|
||
|
||
`registry.test.ts` holds this table. Two differences from the approved table,
|
||
left on purpose: viewers see **Projects** (they hold `projects.read`; the page
|
||
lists their grants), and all of **You** — its pages call only `self` routes.
|
||
*You* lists **Drafts** (`/drafts`) for everyone but the operator, whose Drafts
|
||
are under Files. *My computers* is listed to whoever may pair or run (whether
|
||
they still have computers isn't in `/api/me`): with computers switched off it
|
||
lists the ones they keep, removable, with no *Add*. *AI apps* is listed with
|
||
`mcp.connect`, but opens for anyone signed in (it says to ask the owner).
|
||
|
||
On a phone a guest's *Settings* drawer has five slots: My logins, Budget,
|
||
Jobs, My computers, AI apps — Projects is in its stash (the bottom bar's own
|
||
Projects tab is the projects list).
|
||
|
||
## Permissions per entry
|
||
|
||
Each entry needs the permission(s) of the routes its page calls
|
||
(`backend/authz/routes.py`); several when the page needs several (`allPerms`),
|
||
so it shows only where the page works:
|
||
|
||
- You — Profile, Display, Notifications, Extras, Drafts: `self` (Drafts: not
|
||
the operator).
|
||
- A plugin's Settings page (`ui.pages[].nav: "settings"` since 2026-11-27 —
|
||
Keyboard, Prompt shortcuts, What's new and the What's new editor, their
|
||
plugins'): listed whenever the plugin is active for the caller and they
|
||
hold the page's `perm` if it names one (`/api/plugins/ui` lists only those;
|
||
the editor's is `users.manage`), in its `group` after its `after`
|
||
(`business/settings/pluginEntries.tsx`, `visibleEntries(a, extra)`), at
|
||
`/settings/p/<plugin>/<page>`.
|
||
- Skills & agents (`/settings/setup`, Your logins & tools): `workers.manage`
|
||
+ `lab.read` + `users.manage` — the lab sync, the catalog, what every
|
||
guest gets.
|
||
- My logins `self.claude` · Budget: not the operator, and `self.claude`, or
|
||
`runs.start` with a budget on their runs · Scheduled jobs: the cron-jobs
|
||
plugin's `mine` page (its grant; hidden from `automation.manage`, whose
|
||
Cron jobs page is the plugin's `jobs`) · My computers
|
||
`self` (listed: `computers.pair` or `runs.start`) · AI apps `self` (listed:
|
||
`mcp.connect` or `mcp.manage`) · Projects
|
||
`projects.read`, not the operator.
|
||
- Models, Tags, Fresh context: `lab.settings` · Users, Roles: `users.manage`
|
||
· Security, Approvals: `security.manage`.
|
||
- Machines: `workers.read` + `accounts.manage` (a row lists its logins) ·
|
||
Logins: `accounts.manage` · a plugin's hub key (spend, key settings):
|
||
`plugins.manage` · Cron jobs: `automation.manage` ·
|
||
Claude Code hooks: `lab.context.edit` (reading is `lab.read`, but the page
|
||
is the editor). Browser left for the `lab-chrome` plugin's page
|
||
(`/settings/browser` redirects there, 2026-11-26) and `lab.integrations` with
|
||
it.
|
||
|
||
**Operator variants.** Jobs (`unless: automation.manage`), Projects and
|
||
Budget (`when: not the operator`) are a person's pages; the operator's are Cron
|
||
jobs and their Profile, and those pages forward them there. `unless` / `when` only hide the entry — the guard checks
|
||
the permission alone, so the forward still works. `operator: { label, hint }`
|
||
is what the operator reads instead (Push notifications).
|
||
|
||
## Machines and Logins
|
||
|
||
Settings → **Machines** (`/settings/machines`, `business/machines/`) and
|
||
**Logins** (`/settings/logins`, `business/logins/`) replaced Profiles and
|
||
Accounts; every old URL redirects, query and hash kept
|
||
(`/settings/profiles/…`, `/settings/workers/…`, `/settings/accounts/…`,
|
||
`/settings/computers`, `/settings#subscription`, `/settings#claude`).
|
||
|
||
- **Operator** (`hub`): every machine by profile — `MachineRow` (name, up/down,
|
||
*default*, login chips, one "N to fix" badge) — and, in the built-in Guests
|
||
group, **People's computers**: every guest's own computer, the same row
|
||
(`ComputerMachineRow`), opening the same machine page. A machine page
|
||
(`/settings/machines/<profile>/<runner>`): `MachineHeader` (name in place,
|
||
status, ⋯), the *Needs you* strip, tabs Logins · Tools · Details. *Add
|
||
machine* (`?pair`) is the 3-step `PairWizard`. Logins: every hub login by
|
||
harness; a login page starts with its state, *Plan & cost* folded.
|
||
- **A person** (`mine`): *My computers* is the same frame, list row, header,
|
||
strip and tabs on `/api/me/computers` (`pages/MyMachines.tsx`,
|
||
`pages/Computer.tsx`, a computer at `/settings/machines/computers/<id>` —
|
||
the operator opens anyone's there too). No profile, no *default*; ⋯ Pause /
|
||
Remove, rename in place; Logins tab = which Claude a run there bills + the
|
||
terminal sessions (*Ask at start*, Sync); Tools = the Setup checklist;
|
||
Details = system, start dir, spend. The waiting banner and the limits (a
|
||
fold) stay on the list; `?pair` opens the guest *Add a computer* wizard.
|
||
`business/machines/computer.ts` is the one adapter between the two API
|
||
shapes (`computerSummary`, `computerNeeds` — the same `needsYou` rules);
|
||
`NeedsYouStrip` takes the person's own buttons (`actions`).
|
||
- *My logins* (`pages/MyLogins.tsx`): one row per login of their own
|
||
(`myLogins(me)` — their Claude today; their opencode / MCP logins, a later
|
||
backend round, only add rows), a login page with the same `SignIn` block
|
||
(`GuestClaudeCard`, `guestClaudeApi`) and their 5-hour / week gauges. Budget
|
||
keeps spend and budget and links there.
|
||
|
||
**The text rule** (these pages, and any new settings page): no intro
|
||
paragraph — a subtitle of at most 8 words; the long explanation behind *How it
|
||
works* (`technical/HowItWorks.tsx`) or an ⓘ (`InfoHint`); a control has a label
|
||
and at most one short line; no terminal command in the page flow (a button
|
||
does it; the command sits behind *From a terminal instead* or an ⓘ); a
|
||
section with nothing to say is one line. Folds (`technical/Fold.tsx`) keep
|
||
their summary visible — under the title on a phone. Everything a non-operator
|
||
reaches is in French too; the operator's own help stays English (the owner's
|
||
UI is always English).
|
||
|
||
**The hub's name.** The local runner is never written "Homelab" in the UI:
|
||
`useHubName()` (`lib/hubName.ts`) reads `/api/me` `hubName` — backend
|
||
`HUB_LABEL` (default: `HUB_NAME` capitalised, so "Homelab" here; "Devbox" on
|
||
a standalone hub) — `{ name, the }` ("the Homelab" / "le Homelab").
|
||
`runnerLabel(workers, runner, hub)` and `setupRows(…, hub)` take it. The mock
|
||
takes `?mockHub=Devbox`.
|
||
|
||
## Search
|
||
|
||
The panel's box (pinned at the top) and the palette share
|
||
`business/settings/search.ts`: fuse.js over the visible pages (label, hint,
|
||
keywords, group) and the visible `SETTING_ROWS` (`rows.ts`; a row is offered
|
||
when its page is visible and its `who` fits), shown as *Display › Timezone*
|
||
and opening `page?row=<id>` (the row scrolls into view and rings), and —
|
||
for whoever sees Settings → Plugins — the live plugins' `nav: "tools"` pages
|
||
(`GET /api/plugins` → `ui.pages`, shown under *Plugins*: "mcp" finds the MCP
|
||
servers plugin's page). ↑ ↓ ↵ in
|
||
the box; Esc clears, a second Esc leaves it. **`/`** focuses it — the
|
||
`settings.search` action (`lib/keyboard/actions.ts`, context `settings`): it
|
||
answers only while the panel is mounted and wins there over *Search
|
||
conversations*, so both keep `/`; rebindable in Settings → Keyboard.
|
||
|
||
## Saved layouts
|
||
|
||
- The panel: one order `settings-panel` (hold an entry to move it **within
|
||
its group**; no stash — hiding a page is what permissions do now). The
|
||
old ids `composer` / `pet` / `clarifier` / `misc` expand to `extras`, `push`
|
||
to `notifications`, `computers` to `profiles`.
|
||
- The owner's bar: `nav-sub`, keys `settings/<id>`. `bar` on an entry is its
|
||
slot in the pre-registry drawer, so a saved drawer keeps its five slots and
|
||
the new pages land behind them; hidden pages keep their place on a reorder.
|
||
- Others' bar: `guest-you`, `settings/misc` → `settings/extras`,
|
||
`settings/whats-new` and `settings/news` → `settings/p:whats-new:news`
|
||
(the plugin's page since 2026-11-27); *Drafts* is the registry's `drafts`
|
||
entry (You → the *Me* drawer, key `settings/drafts` as before).
|
||
|
||
## Adding a settings page
|
||
|
||
1. The page under `business/<area>/pages/` (lazy, like the others) and its
|
||
route in `root.tsx` **inside** `<RequiresSettings>`.
|
||
2. An entry in `registry.ts`: its group, the permission its API calls need
|
||
(the narrowest catalog id; check `authz/routes.py`), a hint, keywords,
|
||
`match` with any detail-page prefix. Nothing else to list: the panel, the
|
||
drawers, the palette and the guard pick it up.
|
||
3. Rows on it: a `setting="<page>.<row>"` anchor each and a `SETTING_ROWS`
|
||
entry (`rows.test.ts` checks both ways).
|
||
4. Every new string through `t()` (`UPDATE_I18N_KEYS=1 npx vitest run src/i18n` refreshes the key list); its French goes in the `translation-fr` plugin (ai-agent-plugins), not here.
|
||
5. `registry.test.ts` checks the route exists, the permission is a catalog id
|
||
(`mock/rolesCatalog.json`) and the role table.
|
||
|
||
Renaming a page (Profiles → Machines): change the entry's `label`, `to` and
|
||
`match` (keep the old path in `match` and add a redirect route), and keep its
|
||
`id` unless saved layouts may lose it — or map the old id in `RENAMED`
|
||
(`SettingsPanel.tsx`) / `GUEST_RENAMED` (`BottomBar.tsx`).
|
||
|
||
The mock shows any role: `?mock=1&mockRole=member|viewer|admin` (sticky,
|
||
`=0` clears), `&mockGuest=1` for the Guest (`frontend/src/mock/README.md`).
|