⚙️ Settings Components
This section documents the components used for the Settings pages (User Preferences, Global Settings, Profile, Users, Security).
🏗️ Architecture
The settings system uses a modular architecture based on a common layout and reusable field components.
🗂️ Tab registry
The tabs of the Settings page are a registry: SETTINGS_TABS in
lib/features/settings/settingsTabs.ts. routes/(app)/settings/[...path]/+page.svelte names no tab itself:
it draws its two bars and the active body from that list. Each entry is a SettingsTab:
| Field | Role |
|---|---|
id |
The suffix of its settings-tab-{id} test id, and the ?tab= value of 1.2, still read |
path |
Its address (lot B10), from the table of settingsPaths.ts: /settings/<tab>, or /settings/admin/<tab> for a member of Administration |
labelKey |
Catalogue key of the label, drawn as $_(labelKey) on the tab and in the heading shown on a phone |
icon |
Lucide icon of the tab button |
order |
Position in the bar, left to right; for a member of a group, in the group's second bar |
component |
The tab body |
visible?(ctx) |
Who sees the tab; when absent, everyone does |
props?(ctx) |
Props spread on the body |
group? |
The id of the group of SETTINGS_TAB_GROUPS the tab belongs to: the top bar shows the group as one entry, and a second bar lists its members |
badge?(ctx) |
The number its button shows, none for 0; a group's entry shows the sum of its visible members' |
prefetch?(ctx) |
What the page starts loading before the tab is opened, so that badge can count: run when the page opens, and again when the context changes, for every visible tab that has one |
alignEnd? |
On a wide screen, starts the right-hand side: this entry and every entry after it sit on the right (sm:ml-auto on its button). One tab or one group carries it: today the administration group, and no tab |
ctx is a SettingsTabContext, {isSuperuser}, which the page derives from the auth store
($auth.user?.is_superuser ?? false). The registry holds nine tabs:
id |
order |
Body | Visible to | group |
Extras |
|---|---|---|---|---|---|
profile |
10 | ProfileTab |
everyone | — | — |
preferences |
20 | PreferencesTab |
everyone | — | — |
plugins |
25 | PluginSettingsTab |
everyone | — | — |
about |
30 | AboutTab |
everyone | — | — |
admin |
100 | GlobalSettingsTab |
administrators | administration |
Label settings.globalSettings (Global Settings), icon Settings2; visible: (ctx) => ctx.isSuperuser (lot N69-2, decision D4 a); props: (ctx) => ({canEdit: ctx.isSuperuser}), kept: see GlobalSettingsTab |
users |
110 | UsersTab |
administrators | administration |
visible: (ctx) => ctx.isSuperuser |
backup |
120 | BackupTab |
administrators | administration |
visible: (ctx) => ctx.isSuperuser |
email |
130 | EmailSettingsTab |
administrators | administration |
visible: (ctx) => ctx.isSuperuser |
security |
140 | SecurityTab |
administrators | administration |
visible: (ctx) => ctx.isSuperuser; badge: () => securityChecks.attentionCount; prefetch: (ctx) => { if (ctx.isSuperuser) void securityChecks.ensureLoaded(); } |
The admin id stays as it was, so ?tab=admin, the link of the
open-registration warning, still opens the global settings (the
warning shows to administrators only, as the tab does; for a regular user, ?tab=admin names a
hidden tab and opens profile, the first visible one);
lot A8b changed only its label and its icon, the group having taken the Shield, and removed the
key settings.admin (Admin) from the catalogues. Five bodies are in lib/features/settings/tabs/,
the Security tab's in lib/features/settings/security/ (SecurityTab). The Plugins
tab's body, lib/features/plugin-settings/PluginSettingsTab.svelte (label pluginSettings.tab.label),
the Backup tab's, lib/features/backup/BackupTab.svelte (label backup.tab), and the Email tab's,
lib/features/email/EmailSettingsTab.svelte (label email.tab.label), live with their features:
for the Plugins tab see Plugin Settings › The Interface,
for the Email tab The Email Tab. The Plugins tab takes no
props: every user sees it, and the catalogue the API returns already says which fields this user may
change.
Groups
SETTINGS_TAB_GROUPS, in the same module, holds the groups of the top bar (decision P13 b), each a
SettingsTabGroup, {id, labelKey, icon, alignEnd?}. There is one today, administration: label
settings.administration (Administration), icon Shield, alignEnd: true. Its members are
admin, users, backup, email and security; profile, preferences, plugins and about
belong to no group. A group's id is a ?tab= value and a test-id suffix too
(settings-tab-administration): it is URL-safe, and no tab's id.
settingsBar(tabs, groups, ctx) gives the entries of the top bar, SettingsBarEntry[], as a new
array, and leaves the lists it is given as they were: the tabs of visibleSettingsTabs(tabs, ctx),
by order, each a {kind: 'tab', tab} entry, except the visible members of a group, gathered into
one {kind: 'group', group, members} entry placed where its first visible member would be,
members being its visible members by order. A group without a visible member has no entry, and a
tab whose group names none of groups stays a tab entry. A regular user's bar is profile,
preferences, plugins and about: every member of administration is an administrator's (since
lot N69-2), so the group has no entry for them; an administrator's ends with administration and
its five members.
The page
The page is the runtime of the registry, written in Svelte 5 runes:
- Top bar:
settingsBar(SETTINGS_TABS, SETTINGS_TAB_GROUPS, ctx), handed toTabBarwith the labels hidden on a phone (hideLabelOnMobile). A tab entry is drawn as its tab (settings-tab-{id}, its icon,$_(labelKey)); a group entry with the group's icon and label, and the test idsettings-tab-{groupId}. An entry whose tab or group hasalignEndgetssm:ml-auto. The top bar selects the entry of the open tab: the tab itself, or the group of the open member. - Second bar: while the open tab is a member of a group with at least two visible members, a
second
TabBar, insidedata-testid="settings-subtabs", lists those members, each with its ownsettings-tab-{id}, icon, label (hidden on a phone too) and badge, the open one selected. It takes the same props (hideLabelOnMobile,scrollable) and the same colour roles as the top bar. A group with one visible member gets no second bar: its entry opens that member directly, and the member has nosettings-tab-{id}of its own. No context of today's registry makes such a group since lot N69-2 (a regular user sees no member ofadministration, an administrator all five), but the page still handles it, on a registry of the test's own (see the tests below). - Clicks (
selectTop()): a tab entry opens its tab; a group entry opens the group's first visible member, unless one of its members is open already, which stays, its body not mounted again. A member of the second bar opens that member. - Both bars are
scrollable: entries that do not fit the card (French or Spanish on a narrow screen) scroll sideways instead of being clipped by itsoverflow-hidden, the active one stays whole in view, and the sides that hide entries fade (see Scrollable tab bar). - Body: the active tab's
componentalone, withprops(ctx)spread on it. The spread is live: when the auth store changes, the body on screen receives the new props. The heading shown on a phone names the active tab, a member and never its group: Global Settings, not Administration. - Addresses (lot B10): every tab has one,
path, and every group too (/settings/admin). One route,settings/[...path], serves them all,/settingsincluded.settingsPlaceOf(pathname, tabs, groups)reads an address back: the page, a tab, a group, or nothing the registry knows. An address opens its tab at the first render and whenever it changes (Back, Forward, a link); a group's address opens its first visible member. Choosing a tab writes its address withgoto(path, {noScroll, keepFocus}), as a new entry of the history./settingsopens the first tab and keeps its address. An unknown address, or the address of a tab this user cannot see once the user is known, goes back to/settings(replaceState). Links never write an address by hand:settingsTabHref(id, query?)ofsettingsPaths.ts, a module that imports no tab body. - Active tab: always a tab, never a group. At
/settings, the first visible tab, unless the?tab=of 1.2 names a visible tab or a group; the address then becomes the tab's own (replaceState): a member'sidopens that member inside its group (with the second bar when the group has two visible members or more), a group'sidits first visible member (?tab=administrationopensadmin, for an administrator). The choice runs in$effect.pre, so the tab that?tab=names is the first body mounted: the default body never mounts, not even for an instant. A?tab=value is applied once: a later page update that keeps it does not take back the tab the user picked, while a new value, or the same one after a tab's address, is applied again. An unknown id, the id of a tab this user cannot see, or that of a group with no visible member, is ignored: a regular user's?tab=adminor?tab=administrationopensprofile, and the body of Global Settings never mounts for them. A?tab=naming a tab that becomes visible later (the user is promoted while on the page) is applied when the tab appears, inside its group. If the active tab stops being visible, the first visible tab opens. - Badges: a tab entry shows its
badge(ctx), a group entry the sum of its visible members', andTabBardraws none for0. They are read while the bars are derived, so a badge follows the reactive state it reads: a count that arrives after the first render shows at once. - Prefetch: an
$effectcalls theprefetch(ctx)of every visible tab that has one, when the page mounts and again whenever the context changes (a promotion included, which prefetches the tab that has just appeared); never for a tab this context does not show. The calls run insideuntrack(): a prefetch reads the state it fills (ensureLoaded()reads the security checks'status), and a tracked read would run the effect again each time that state moves — after a failure, a new request, in a loop. So nothing else prefetches again: not a change of tab, of group or of?tab=, nor a change of the state a prefetch reads.
Adding a tab takes one entry in SETTINGS_TABS, plus the import of its body. The users
entry, a tab only administrators see, in the administration group, is a complete example:
import {Users} from 'lucide-svelte';
import UsersTab from '$lib/features/settings/tabs/UsersTab.svelte';
export const SETTINGS_TABS: readonly SettingsTab[] = [
// profile (10), preferences (20), plugins (25), about (30), admin (100, administration)
// Administrators only: the accounts (decision D-A10) and every account link (lot UA3).
{id: 'users', labelKey: 'settings.users', icon: Users, order: 110, component: UsersTab, visible: (ctx) => ctx.isSuperuser, group: 'administration'},
];
order: a free number between the neighbours. The orders leave gaps, so no other tab is renumbered; 110 putsusersafter Global Settings (100) in the group's second bar. A tab without agroupand with anorderbetween 30 and 100 lands after About, on the left; above 100, after the group's entry, which sits where its first member (100) would be, so on the right. Everyorderis unique.visible:(ctx) => ctx.isSuperuserkeeps the tab out of a regular user's bars altogether, and a?tab=naming it is ignored for them. Leavevisibleout for a tab everyone sees.group:'administration'for a tab that looks after the instance: it has no button of its own in the top bar, and shows in the group's second bar. Leave it out for a tab of the top bar.props: only when the body depends on the context, asadmindoes forcanEdit. Since lot N69-2 only administrators see that tab, socanEditis alwaystrueon screen: the read-only branch,canEdit: false, stays inGlobalSettingsTab, unreached from the interface, until a cleanup.badgeandprefetch: only for a tab whose button counts something, todaysecurityalone.badgereads a reactive count synchronously,0until there is one;prefetchstarts what the count needs, does nothing for a context the tab is not for, and nothing again once loaded, assecurityChecks.ensureLoaded()does.alignEnd: one tab or one group carries it, today theadministrationgroup; no tab does, though the page still honours a tab's.idandlabelKey: theidis unique, made of lowercase letters, digits and dashes, starts with a letter, and is no group'sid; thelabelKeyis a sentence in all four catalogues.- Tests:
lib/features/settings/settingsTabs.test.tspins the content of the registry through itsTODAYtable, so the new tab adds its row there in the same change, its id to theCONTEXTSandBARSlists of those who see it and, when it joins the group, toADMINISTRATION, with avi.mockof its body module like the others; the cases that list today's tabs by name follow it (usersalso has two cases of its own: STAB-01, hidden from a regular user, and STAB-02, order 110 afteradmin, both members of the group;adminhas one, rewritten by lot N69-2: hidden from a regular user, shown to an administrator, itspropsstill{canEdit: isSuperuser}). The same file checks the ids, the orders and the labels in the four catalogues, the group and what its tabs carry (STAB-03 to STAB-14: one group, its label, icon and members, no tab withalignEnd,securitythe only tab with a badge and a prefetch, the bar of each context; STAB-14, lot N69-2: noadministrationentry nor any of its members in a regular user's bar, the entry once in an administrator's,adminits first member), andsettingsBar()on lists of its own (SBAR-01 to SBAR-05).routes/(app)/settings/page.tabs.test.tstests the page on a registry of its own, with two groups (crew, andoffice, the stand-in for Administration as lot A8b had it, with one visible member for a regular user) and counts in a reactive box (SPAGE-01 to SPAGE-21: the top bar, the second bar and its clicks,?tab=naming a member or a group, the badges and their sums, the prefetch at the start, again for a new context and never otherwise). SPAGE-22 to SPAGE-24 (lot N69-2) render the page on the real registry: a regular user's page with neithersettings-tab-administrationnorsettings-tab-admin, Profile open;?tab=adminand?tab=administrationopening Profile for a regular user, the Global Settings body never mounted, and Global Settings, withcanEdit: true, inside its group for an administrator. The file loads the realsettingsTabsmodule (importOriginal), which imports every body: the mocked module'sSETTINGS_TABSandSETTINGS_TAB_GROUPSare getters, answering the real lists while a case setsmocks.registry.realand the synthetic ones otherwise, and each real body is a probe named by its module (mocks.realBodies). A new tab adds its body there, with itsvi.mock(a store the registry imports gets a no-op stand-in, assecurityChecksdoes)../dev.py test front-utility core-unitrunssettingsTabs.test.ts,./dev.py test front-utility component-unitrunspage.tabs.test.ts.
📐 SettingsLayout
The SettingsLayout component provides the structural shell for all settings tabs.
Features:
- Two-Column Layout: Sidebar navigation on the left, content on the right.
- Global Actions: "Save All", "Undo All", "Reset All" buttons in the header.
- Lock Toggle: Optional lock button for admin settings (prevents accidental edits).
- Responsive: Stacks vertically on mobile.
Props:
categories: Array of{ id, icon, labelKey }for the sidebar.selectedCategory: ID of the currently active category filter.hasChanges: Boolean to show Save/Undo buttons.hasNonDefaults: Boolean to show Reset button.isLocked: Boolean state of the edit lock.
🎨 PreferencesTab
Manages user-specific settings (Language, Currency, Theme) and hosts the Onboarding category
described below. Its categories are display (Language), currency (Default Currency),
appearance (Theme) and onboarding, plus All Settings when none is selected.
Logic (lib/features/settings/tabs/PreferencesTab.svelte):
- Load: Fetches Global Defaults (
/settings/global) and User Settings (/settings/user) in parallel. - State Tracking:
originalValues: The values currently saved in the DB.editedValues: The values currently in the form inputs.globalDefaults: The system-wide default values —FALLBACK_DEFAULTS(en,EUR,auto) when/settings/globalcannot be loaded.
- Computed States:
isModified:editedValues !== originalValues(Shows Save/Undo).isNonDefault:originalValues !== globalDefaults(Shows Reset, but only while the field has no pending edit:SettingActions.svelte).
- Persistence: Saves to
/settings/userviaPUT, one field per request. Save sends that field; Save All sends the modified fields one after the other, then reports what was saved and what failed in a single toast (success, partial or error). Language and theme take effect only once their write succeeds (currentLanguage.set(),applyTheme()), anduserSettings.setDirect()then writes the saved language, currency and theme into the store. Reset only copies the global default intoeditedValues: it still has to be saved.
The Default Currency (base_currency) is proposed when something new is created: BrokerForm.svelte
uses it for the first initial balance, AssetModal.svelte for a new asset's currency and
PacPlannerTool.svelte for a new plan's valuation currency. The Dashboard, the Brokers list and
detail pages, and the risk panel of the Assets page start their display currency from the global
default_currency ($globalSettings) instead.
🧭 OnboardingReplaySection
OnboardingReplaySection.svelte (in frontend/src/lib/features/onboarding/components/) is the
Onboarding category of PreferencesTab
({id: 'onboarding', icon: Compass, labelKey: 'onboarding.settings.category'}). The tab renders
it when that category is selected and in the All Settings view (no category selected). It lists
every onboarding flow with its progress and lets the user replay any of them without changing that
recorded progress. This section covers the Settings UI only; the mechanics behind it — when a guide
is due, what a replay does once it runs, where its position is kept — are explained in
Onboarding Guides.
What it lists. The section reads onboarding.progress?.flows, the per-user progress that the
app bootstrap loads from GET /api/v1/settings/onboarding: one OnboardingProgressItem for each
of the 15 flows of ONBOARDING_FLOW_VERSIONS (backend/app/services/accounts/onboarding_service.py;
enum OnboardingFlow in backend/app/db/models.py). The section sorts them into collapsible
groups; Setup and Core tour start open:
Group (onboarding.settings.groups.*) |
Flows |
|---|---|
setup |
welcome |
core |
intro_tour |
transactions |
transactions_page_guide, transaction_create_guide, transaction_bulk_guide, import_guide |
broker |
broker_page_guide, broker_guide, broker_detail_guide |
fx |
fx_page_guide, fx_guide, fx_detail_guide |
asset |
asset_page_guide, asset_guide, asset_detail_guide |
tools |
tools_page_guide |
A group header counts its flows that are completed at the current version
({completed}/{total} guides completed). Each row shows the flow name (onboarding.flows.<flow>),
its status (Pending, Completed or Skipped) and the Seen v{seen} · current v{current}
label. Statuses are display-only: nothing in the section calls a complete or skip endpoint.
New version. When the version the user went through is older than the current one
(update_available), the row adds the New version to view badge and its group no longer
counts it as completed. Such a guide is due again and starts by itself at its next trigger.
Step-managed flows. The rows of transaction_bulk_guide (4 steps) and import_guide
(9 steps) add a collapsible list of their steps, each with its status, under a
{completed}/{total} counter in which a skipped step counts as done and a step with a newer
version does not. The row's own status summarizes its steps.
Replay per flow. The row button depends on the flow:
welcome→ Replay arms a Welcome replay (onboarding.startReplay) and opens/welcome. There, Continue saves the chosen language, currency and avatar through the regularPUT /api/v1/settings/userwithout touching the Welcome status, and Exit tour saves nothing.intro_tour→ Replay starts the tour at once, in replay mode, from its opening scene (onboardingGuide.startIntroReplay()), and opens/dashboard.- every other flow → Replay at next trigger only arms the replay
(
onboardingGuide.armReplay(flow); for Import and Bulk, with all their steps), and a toast says the guide is ready in this browser. The guide starts the next time its page, modal or wizard asks for it. While armed, the row reads Ready in this browser: {flow} starts at its next trigger. and the button becomes Cancel activation (onboarding.clearReplay).
Replay all arms every flow in list order — Welcome with onboarding.startReplay, the intro
with onboardingGuide.prepareIntroReplay(), all the others with armReplay — then opens
/welcome. If one of them cannot be armed (for example when localStorage is unavailable), the
section clears the replays it already armed, then shows the error. Every button is disabled while
an action runs. When the progress could not be loaded at all, the list is replaced by the error
and a Retry button (appBootstrap.load(true)).
👤 ProfileTab
Manages user profile information:
- Avatar: Editable via
ImagePickerWrapper→AssetPickerModal→ crop - Username and Email: editable once the edit lock is open, each with its own save and undo
(
PUT /api/v1/auth/profile) - The email's password (Changing the Email):
while the tab is unlocked and the email is another address than the stored one, a password input
appears under the email's hint (
profile-email-password,autocomplete="current-password", placeholdersettings.currentPassword), described byprofile-email-password-hint(settings.emailPasswordHint). Both email Saves andprofile-save-allstay disabled while it is empty; the username's Saves do not wait for it. The email's request is{email, current_password}, the username's never carries the password. The password is emptied whenever the email is back to the stored address, after a save included - Only the capitals changed (P18, A-25): «another address» is decided by
sameEmail()oflib/features/auth/emailCase.ts, which folds A–Z only, like the server's index onlower(email)(user_service.email_fold). The stored address in other A–Z capitals is still a modification (the row stays marked, the Saves are on, the new form is saved), but no password input appears and the request is{email}alone, without acurrent_passwordkey (the server refuses an empty one). Letters outside A–Z compare as written:émile@…→Émile@…asks for the password - Refusals:
CURRENT_PASSWORD_REQUIRED,CURRENT_PASSWORD_INVALIDand, since lot A8b (C11),TOO_MANY_ATTEMPTS, the429of the failed sign-in limit, are worded by the tab (PASSWORD_REFUSALS:settings.currentPasswordRequired,settings.currentPasswordIncorrect,settings.tooManyPasswordAttempts, Too many wrong passwords: wait a few minutes and try again.) and published onprofile-errorasdata-error-code. The typed email stays; the password is emptied after the first two, and kept afterTOO_MANY_ATTEMPTS, since it may be right and waiting is all there is to do. Since lot A-21a,PASSWORD_REFUSALSalso holdsUSERNAME_INVALID, a new username holding@(see Which Account an Identifier Names):auth.validation.usernameNoAt, the key of the registration card's own check, published asdata-error-codelike the others, never the server's sentence norsettings.updateFailed; the username goes back to the stored value. Any other refusal shows the server'sdetailwhen it is a sentence (Email already registered),settings.updateFailedfor any otherdetail(another code, a422list), and puts the field back to the stored value. The banner clears after 5 seconds - Password change: opens
PasswordChangeModal(features/settings/PasswordChangeModal.svelte): the current password, the new one withPasswordStrengthunder it, and the confirmation. The modal bindsPasswordStrength'svalid(bind:valid={passwordMeetsRules}) and keeps no copy of the password rules:password-change-submitstays disabled until the three fields are filled, the rules hold and the confirmation matches. A refusal with status429whosedetailis{error_code: "TOO_MANY_ATTEMPTS", …}, the failed sign-in limit, showssettings.tooManyPasswordAttempts(lot A8b, C11), and the three fields keep what was typed; a429with another code, with a sentence or with a proxy's page, andTOO_MANY_ATTEMPTSon another status, go on to the cases below. A refusal whosedetailis{error_code: "PASSWORD_TOO_WEAK", …}showsauth.validation.passwordTooWeak; the plain-stringdetails of a wrong current password (incorrect) and of a new password equal to it (different) showsettings.currentPasswordIncorrectandsettings.passwordMustBeDifferent; anything else, the messagetrySaveextracts,settings.passwordChangeFailedwhen it finds none. An objectdetailis never lower-cased as a string: before A6c that threw - Delete account:
delete-account-buttonopens theAccountDeletionDialoginselfmode, withtestIdPrefix="profile-delete"; once the account is deleted, the tab callsauth.logout()and goes to/ - Edit mode toggle to prevent accidental changes
Tests of the email's password: tabs/ProfileTab.test.ts (./dev.py test front-utility component-unit;
since A8b also the limit's TOO_MANY_ATTEMPTS through the row's Save and through profile-save-all:
the key and its code on the banner, the new email and the typed password kept, and three other
429s worded as any other refusal), and the «A6e» block of frontend/e2e/settings.spec.ts
(./dev.py test front-utility settings) on the lane's real backend, with a throwaway account and a
second browser context signed in before the change, and signed out by it. The password change:
PasswordChangeModal.test.ts, in the same component-unit action (what enables Save, what reaches
the server, the refusals with PASSWORD_TOO_WEAK among them, the rules taken from
PasswordStrength, and the limit's 429: the key, never the server's sentence, the fields kept and
usable, no success and no toast).
🌍 GlobalSettingsTab (administrators only)
System-wide configuration with lock toggle:
- Max file upload size
- Registration mode: a select with three options,
open,inviteanddisabled(settings.registrationModes.*: Open, By invitation, Closed) - Scheduler configuration and new-user defaults
- Other app-wide settings
Only a superuser has this tab (lot N69-2, decision D4 a): its entry in the
tab registry (admin, labelled Global Settings) has
visible: (ctx) => ctx.isSuperuser, like every other member of the administration
group, of which it is the first. A regular user has no group at all, and a
?tab=admin opens their profile (The page). The entry still passes canEdit
through props: (ctx) => ({canEdit: ctx.isSuperuser}), so the tab always gets canEdit: true on
screen; without canEdit it would show a read-only indicator (settings-readonly-indicator)
instead of the lock toggle (settings-lock-toggle) and the bulk Save/Undo/Reset actions, a branch
no longer reached from the interface and kept until a cleanup. Hiding the tab hides no value: the
app still reads the global settings for every signed-in user, through GET /api/v1/settings/global
(Settings System).
Space limit (lot B10). storage_limit_mb, in the Memory category, is a SettingNumber
(default 0, no limit), named and explained as in Files › Advanced (storage.limit.label,
storage.limit.hint, through the label and hint override maps). The hosting provider can fix it
with LIBREFOLIO_STORAGE_LIMIT_MB; the tab learns it from the same answer as the space bar,
limit_locked of GET /backup/instance/storage (getInstanceStorage): the field is then disabled
even with the tab unlocked, its hint becomes storage.limit.locked, Reset All to Defaults skips
it, and its card global-setting-storage_limit_mb carries data-locked="true" ("false"
otherwise). Open the settings on a refusal of the limit links
/settings/admin/global?setting=storage_limit_mb (STORAGE_LIMIT_SETTINGS_HREF): once the list is
in, ?setting=<key> selects the row's category, brings the row into view and highlights it
(data-highlighted="true"), once per value. The lock stays closed: the administrator opens it by
hand (the developer's choice). A key the tab hides, or no row, changes nothing.
For the three display defaults (default_language, default_currency, default_theme) the
tab reuses the same shared Setting* wrappers as the PreferencesTab, passing the
embedded prop (see below) so they sit inside the tab's own cards without double separators.
Registration mode. registration_mode, in the Security category, is a SettingSelect
(default invite, SETTING_DEFAULTS, as in GLOBAL_SETTINGS_DEFAULTS: Reset to Default and
Reset All to Defaults propose invite, also on an upgraded instance that kept open). The
server variable LIBREFOLIO_REGISTRATION can pin it
(Registration Modes); the tab learns
it from the instance configuration,
instanceConfig.config.accounts.registration_locked:
- Locked by the variable: the select shows the mode in force,
instanceConfig.config.accounts.registration_mode, not the stored row; it is disabled even with the tab unlocked; its hint becomessettings.lockedByEnvwith{variable: LIBREFOLIO_REGISTRATION}(Set on the server by LIBREFOLIO_REGISTRATION: change it there.); and Reset All to Defaults skips it. Its card,global-setting-registration_mode, carriesdata-locked="true"("false"otherwise). - A save that meets the lock anyway — for example before the configuration arrived — gets
409SETTING_LOCKED_BY_ENV; the tab showssettings.lockedByEnvwith thevariableof the answer. - After a save that includes
registration_mode, alone or with Save All, the tab callsinstanceConfig.load({force: true}), so the login page's Register here, the/invitepage, the open-registration warning and the Security tab's finding of the same name, with its badge, follow the new mode on this page load.
🧹 CachePanel
CachePanel.svelte shows the status of every named backend cache (the theine registry): name,
current_size / maxsize, and a human-formatted TTL, refreshed on demand. It sits in the Memory
category of the Global Settings tab, so only administrators see it
since lot N69-2, although GET /api/v1/settings/cache/status still answers any authenticated user;
the per-cache Clear and Clear all buttons appear only when the
canEdit prop is set (it mirrors the Global-settings lock). Both clear actions pass through a
danger confirmation modal — after a clear, the next fetch hits the providers again. Backend
contract: Cache Registry & Admin.
👥 UsersTab
lib/features/settings/tabs/UsersTab.svelte, the registry's users entry: administrators only,
no props. The accounts of the instance, every account link (lot UA3) and the places taken. User side:
Users & Invitations; backend:
Administrator API.
- Load: on mount,
GET /usersandGET /users/account-linksin parallel (list_accounts_api_v1_users_get,list_account_links_api_v1_users_account_links_get); the accounts andusagecome from the first, the links from the second, split by theirstate:open, or closed (used,expired,revoked). The root,users-tab, carriesdata-busy('true'while the lists load, at mount and after every action;aria-busytoo). A failed load showssettings.usersTab.errors.loadabove the list, with an error toast. - Every action reloads:
perform()runs the call, notifies its outcome, then callsload()whether it succeeded or not. The tab never updates a row by itself: it shows the backend's answer. The invitation and reset-link dialogs reload when they close (the new link is an open row), the deletion dialog after a deletion. - Header:
users-usagewithdata-usedanddata-max(empty without a limit), drawn withsettings.usersTab.usage({used} / {max} accounts) orusageUnlimited.users-billing-link(target="_blank",rel="noopener noreferrer") only whenusage.billing_urlis set. The instance is full whenmax_usersis set andused >= max_users: bannerusers-limit-banner(role="status"), withusers-limit-billing-linkwhen there is a billing URL. - Invite (
users-invite-button) is disabled withdata-disabled-reason:registration-disabledwheninstanceConfig.config.accounts.registration_modeisdisabled, checked first as the backend does, elselimitwhen the instance is full. Withregistration-disabled,users-invite-blockedsays why:settings.usersTab.invite.blockedLocked, namingLIBREFOLIO_REGISTRATION, whenregistration_locked;settings.usersTab.invite.blockedotherwise. - Accounts (
users-accounts): oneUserRowper account, in the backend's order.isSelfcompares the account with$currentUser.id;isOnlyActiveAdminis true for the account that is the only one withis_superuserandis_active. - Account links (
users-links): twoAccountLinksTable, the open links (users-links-open) and, inside aFoldPanelfolded by default (users-links-closed-fold, its title Closed links ({count})), the closed ones (users-links-closed). - Confirmations: one
ConfirmModal,testId="users-confirm"(on its header; its buttons areconfirm-modal-confirmandconfirm-modal-cancel), for deactivate, cancel the setup link, promote, demote, sign out everywhere, restart the guides and revoke a link;dangerfor deactivate, cancel the setup link, demote and revoke. Title and message come fromsettings.usersTab.confirm.<kind>.*, the kind in camelCase (cancelSetup,signOut,revokeLink…), with{username}, or{type}and{target}for a link (its account, else its address, elsesettings.usersTab.links.anyone). Reactivate runs at once; the reset link and the deletion open their own dialogs. - Cancel the setup link (
cancel-setup, lot A-43), for the initial administrator waiting for its setup: once confirmed,PATCH /users/{id}{is_active: false, cancel_setup: true}, which revokes its setup links (Cancelling the setup link). The row still reads Waiting for setup afterwards, so a success toast (settings.usersTab.toasts.setupCancelled, The setup link of {username} no longer works.) tells what changed.cancel_setup(lot A-51) makes the request a cancellation and nothing else, never the deactivation itsis_active: falsealone would be: when the administrator completed its setup after the list was loaded, the backend answers409SETUP_COMPLETEDand changes nothing. The tab then showssettings.usersTab.errors.SETUP_COMPLETEDin an error toast (This administrator completed its setup in the meantime: nothing was changed.), notifiesaccounts.action.failedwith no success event, and reloads: the row shows the account active (A setup completed meanwhile).
| Action | Call | Event on success | Toast |
|---|---|---|---|
| deactivate | PATCH /users/{id} {is_active: false} |
accounts.user.deactivated |
— |
| cancel the setup link | PATCH /users/{id} {is_active: false, cancel_setup: true} |
accounts.user.setup-cancelled |
success |
| reactivate | PATCH /users/{id} {is_active: true} |
accounts.user.reactivated |
— |
| promote | PATCH /users/{id} {is_superuser: true} |
accounts.user.promoted |
— |
| demote | PATCH /users/{id} {is_superuser: false} |
accounts.user.demoted |
— |
| sign out everywhere | POST /users/{id}/sessions/revoke |
accounts.user.sessions-revoked |
success |
| restart the guides | POST /users/{id}/onboarding/reset, body null: every flow |
accounts.user.onboarding-reset |
success |
| revoke a link | DELETE /users/account-links/{link_id} |
accounts.link.revoked |
— |
| invite | InviteDialog: POST /users/invites |
accounts.invite.created |
— |
| reset link | ResetLinkDialog: POST /users/{id}/password-reset-link |
accounts.reset-link.created |
success |
| delete | AccountDeletionDialog: DELETE /users/{id} |
accounts.user.deleted |
success |
App events. Every outcome goes through notify() (lib/stores/app/notify.svelte.ts), which
keeps it in window.__lf.events, where the E2E reads it (frontend/e2e/fixtures/app-events.ts); the
toast, when there is one, is a field of the same call.
| Event | detail |
|---|---|
accounts.user.deactivated, setup-cancelled, reactivated, promoted, demoted, sessions-revoked, onboarding-reset |
{user_id} |
accounts.link.revoked |
{link_id, purpose} |
accounts.invite.created |
{invite_id, grants_admin} |
accounts.reset-link.created |
{user_id} |
accounts.user.deleted |
{user_id, brokers_deleted, mode} |
accounts.address.checked |
{state, purpose}, without a toast (LinkShare) |
accounts.link.copied |
{purpose}, with a success toast (LinkShare) |
accounts.action.failed |
{action, code}, plus user_id, or link_id and purpose, when there is one, always with an error toast. action is load, deactivate, cancel-setup, reactivate, promote, demote, sign-out, restart-guides, revoke-link, invite, reset-link or delete; code comes from accountErrors.ts |
UserRow
lib/features/settings/users/UserRow.svelte. Props: account (AdminAccount, the GET /users
item, with holds_place, pending_setup, pending_verification and avatar_url when they are sent:
all four optional in users/types.ts), isSelf, isOnlyActiveAdmin, full,
onAction(action, account).
- The
<li>isusers-row, withdata-user-id,data-username,data-active,data-admin,data-pending-setup,data-pending-verification,data-protectedanddata-self("true"or"false";data-pending-setupis"false"when the field is absent, the answer of an older server;data-pending-verificationis the derived state of an account waiting for its email verification, described below, not the raw flag). users-row-toggle, a button witharia-expandedandaria-controls, shows the chevron, the account's avatar, the username, the badges (settings.usersTab.badges.you,admin,inactive, with the test idusers-badge-inactive,protected, and the two of a waiting account below), the email andsettings.usersTab.createdOn, and opens or closes the panel of actions under the row.- The avatar (lot N69-4, decision D8 a): a
UserAvatarright after the chevron, givenaccount.avatar_url ?? null, its rootusers-row-avatarwithdata-avatar="image"or"initial": an image uploaded to the app asked for as its 48×48 preview, an address elsewhere as it is, and the username's initial in a neutral circle for an account without one,avatar_urlnull or absent. - The own row (
isSelf) has no action:users-self-hint, with a link to/settings/profile(settingsTabHref('profile')). - The buttons:
users-action-deactivatefor an active account orusers-action-reactivatefor an inactive one,users-action-cancel-setupin its place for an account withpending_setup;users-action-demotefor an administrator orusers-action-promotefor a regular account; thenusers-action-reset-link,users-action-sign-out,users-action-restart-guidesandusers-action-delete. -
An account waiting for its setup (
pending_setup, the initial administrator whose setup link was never used, nor the account set up another way): the badgeusers-badge-pending-setup(settings.usersTab.badges.pendingSetup, Waiting for setup, in the tab's neutral style) in place ofinactive; nousers-action-reactivate, and so nolimitreason on a full instance; under the buttons,users-pending-setup-hint(settings.usersTab.pendingSetupHint): the account activates through its setup link, and a lost link is replaced withdev.py user setup-linkor by the hosting provider. The backend refuses its reactivation anyway, with409PENDING_SETUP(Account Errors). Since lot A-43:users-action-cancel-setup(settings.usersTab.actions.cancelSetup, Cancel setup link, theLink2Officon, the style of the row's other actions) stands where Reactivate would, and hands the account toonAction('cancel-setup', account): the tab confirms, then cancels (UsersTab). On a protected account it is turned off with the reasonprotected(cancelReason), shown under the buttons as for Deactivate: the backend refuses the cancellation with409ACCOUNT_PROTECTED;users-action-demoteis turned off with the reasonpending-setup(settings.usersTab.reasons.pendingSetup): the account keeps its role until its setup, and the backend refuses its demotion with409PENDING_SETUPtoo;users-action-deletestays enabled, without thedemote-firstreason: the backend deletes the waiting administrator directly (Deleting an Account).
Its other buttons are those of any inactive account.
-
An account waiting for its email verification (
pending_verification, lot E-7, the developer's decisions of 21/10/2026): the row derivespendingVerification = account.pending_verification === true && !account.is_active && !pendingSetup, so an active account that arrives with the flag is drawn as any active account, and the setup's wait wins over it. Then:- the badge
users-badge-pending-verification(settings.usersTab.badges.pendingVerification, Waiting for verification, in the tab's neutral style) is drawn in place ofinactive, whoseusers-badge-inactiveis then absent; itstitleis the hover hintsettings.usersTab.pendingVerificationHint.holds_placetakes no part in it: the badge is the same for a live link and for one that has expired, and an older server that sends no flag leaves the row with Deactivated; - the opened panel shows
users-pending-verification-hint, the samesettings.usersTab.pendingVerificationHint, under the buttons (the setup'susers-pending-setup-hinttakes that place forpending_setup); - the buttons are those of any inactive account,
users-action-reactivateincluded: the badge changes what the row says, not what it offers. On a full instance Reactivate is turned off with thelimitreason unlessholds_place, so a waiting account whose link has expired reads Waiting for verification with a Reactivate turned off.
- the badge
A button the backend would certainly refuse is disabled, with data-disabled-reason; the first
condition that holds gives the reason:
| Button | data-disabled-reason |
|---|---|
users-action-deactivate |
protected when account.protected; last-admin when the account is an administrator and isOnlyActiveAdmin |
users-action-reactivate |
limit when full, unless account.holds_place: an account waiting for its email verification with a live link already holds its place (Email Verification); pending_verification changes nothing here, so once the link has expired the reason comes back. Never drawn for an account with pending_setup |
users-action-cancel-setup |
protected when account.protected: the backend refuses the cancellation of a protected account (409 ACCOUNT_PROTECTED). Drawn only for an account with pending_setup |
users-action-demote |
protected when account.protected; pending-setup when the account has pending_setup; last-admin when the account is active and isOnlyActiveAdmin |
users-action-delete |
protected when account.protected; demote-first when the account is an administrator, active or not, unless it has pending_setup |
Promote, the reset link, sign out everywhere and restart the guides are never disabled. Under the
buttons, one line per distinct reason (settings.usersTab.reasons.*). The backend stays the
authority: last-admin never shows in a live session, as whoever reads the tab is an active
administrator and their own row has no actions, so the 409 LAST_ADMIN of the server covers what
the row cannot see.
AccountLinksTable
lib/features/settings/users/AccountLinksTable.svelte (lot UA3). Props: links (AccountLink[],
the GET /users/account-links items, users/types.ts), variant (open or closed), testId,
isLoading?, onRevoke?(link). A DataTable with its own
ColumnVisibilityToggle: sorting, Excel-style column filters, column visibility, widths and order
kept per table (storageKey settings.users.accountLinks.<variant>), pagination by 10; no selection.
The root carries testId and data-count; each row data-row-id (the link's id).
| Column | Cell | Filter |
|---|---|---|
| Type | AccountLinkTypeBadge: a neutral pill, one lucide icon per purpose (account-link-type, data-purpose), settings.usersTab.links.purpose.<purpose> |
enum of the five purposes |
| For | the account's username (→ new address for an email_change), else the address, else settings.usersTab.links.anyone; the Admin badge (account-link-admin) for an invitation that grants it |
text |
| Created by | created_by_username, — without one |
text |
| Created, Expires | date and time | date range |
| State | AccountLinkStateCell (account-link-state, data-state): the state pill on the state roles (open info, used success, expired warning, revoked neutral), then, closed, its date (account-link-state-detail) and, used, settings.usersTab.links.usedBy |
enum of the variant's states |
The open table's row menu has Revoke (account-link-revoke) on the rows whose revocable the
backend set; the tab confirms it. The tables decide nothing: the state and revocable are the
backend's.
Invitations and Reset Links
InviteDialog.svelte: propsopen,onClose,onCreated?(response). AModalBase(testId="users-invite-dialog",trapFocus) whose form starts empty at every opening:users-invite-email(sent trimmed, and only when not blank),users-invite-admin(grants_admin),users-invite-create,users-invite-cancel. A success showsLinkSharewithpurpose="invite", the response'spathandurl,expiresAtfrom the invitation andcontext: {email};users-invite-donecallsonClose, thenonCreated. A refusal stays on the form:users-invite-error, withdata-error-code.ResetLinkDialog.svelte: propsopen,account: {id, username},onClose. It opens on its explanation (settings.usersTab.reset.message) withusers-reset-createandusers-reset-cancel; a success showsLinkSharewithpurpose="password_reset"andcontext: {username, userId}, closed byusers-reset-close. A failure showsusers-reset-error, withdata-error-code.
LinkShare
lib/features/settings/users/LinkShare.svelte: the panel both dialogs share a link through. Props:
purpose (LinkPurpose; the dialogs pass invite or password_reset), path (the page with the token in the
fragment, as the backend's token_path() builds it), url (LIBREFOLIO_PUBLIC_URL followed by
path, or null), expiresAt, context? ({username?, email?, userId?}). The root is
link-share, with data-purpose.
- Address:
link-share-address, editable, starts frominitialBase(url, path, window.location.origin)(users/linkShare.ts): the part ofurlbeforepathwhenurlends with it — the public address, with the path prefix of a reverse proxy — otherwise the browser's origin; trailing slashes removed either way. - Link:
link-share-link, read-only, iscomposeLink(address, path): the normalized address followed bypath, character for character. Not a URL resolution, which would drop a path prefix, and no re-encoding of the token. - Expiry:
link-share-expires, withdata-expires-at. - Check:
link-share-probe, whosedata-stateis one of:
data-state |
When |
|---|---|
idle |
The address, once normalized, is the starting one: no check |
checking |
500 ms after the last keystroke on a changed address, while checkAddress() runs |
match, mismatch, unverifiable |
The verdict of the check |
invalid |
normalizeBase() refuses the address: not an absolute http: or https: URL, or with credentials, a ? or a #. No check runs, and link-share-copy is disabled |
A newer edit outruns an older check: each run takes a generation number, and the verdict of a stale
one is dropped. Each verdict is notified as accounts.address.checked, without a toast.
checkAddress(base, {issueNonce, fetchImpl?, timeoutMs?}) (users/addressProbe.ts) never throws.
The nonce comes from the Zodios client (issue_address_probe_api_v1_users_address_probe_post,
POST /users/address-probe); then GET <base>/api/v1/auth/address-probe?nonce=… (probeUrl())
goes through a bare fetch — the global one, read at call time, or fetchImpl — called as a plain
function, with {method: 'GET', credentials: 'omit', cache: 'no-store', referrerPolicy:
'no-referrer', signal} and nothing else: no headers, no body, no mode. It must stay a CORS
simple request, as the backend's CORSMiddleware refuses every preflight. A 2xx with
{match: true} is match, with {match: false} mismatch; anything else is unverifiable: the
nonce refused, a network or CORS error, mixed content, a local-network permission denied, another
status, a body that is not JSON or has no boolean match, or PROBE_TIMEOUT_MS (8 s) passed, when
the request is aborted. The server's half: Address Probe.
- Copy:
link-share-copywrites the link withwriteTextToClipboard()($lib/utils/clipboard: the Clipboard API, then the legacy copy) and notifiesaccounts.link.copiedwith a success toast (settings.linkShare.copied). When neither transport works, the link input is focused and selected, for a copy by hand. The button is disabled only ininvalid. - Extra actions:
link-share-actionsdraws the registered actions, see below.
Link-Share Actions Registry
lib/features/settings/users/linkShareActions.ts holds LINK_SHARE_ACTIONS: LinkShareAction[],
with one entry since workstream E's lot E4,
{id: 'send-by-email', component: SendLinkByEmail, visible: () => sendByEmailVisible()}: «Send by email», shown
while email.links is true (Send by Email). An entry is
{id, component, visible?}: component receives
{link, purpose, context} (LinkShareActionProps), and visible({purpose, context}) filters it;
without visible the action is always shown. visibleLinkShareActions(purpose, context) returns
the visible ones in registry order, and LinkShare draws each in link-share-actions. Adding an
action is one line in the list, as «Send by email» shows; the dialogs do not change:
// `MyAction` stands for your own component
export const LINK_SHARE_ACTIONS: LinkShareAction[] = [
{id: 'my-action', component: MyAction, visible: ({purpose}) => purpose === 'invite'},
];
Account Errors
lib/features/settings/users/accountErrors.ts turns a failed call into what the UI shows, for the
tab, its dialogs and the deletion dialog. describeAccountError(error, action?) returns
{code, key, params?, message?}; accountErrorText(error, $_) returns message when there is one,
the translated key otherwise.
| Answer | code |
Shown |
|---|---|---|
detail.error_code among LAST_ADMIN, USER_LIMIT_REACHED, REGISTRATION_DISABLED, ACCOUNT_PROTECTED, SELF_DELETION, DEMOTE_FIRST, PENDING_SETUP, SETUP_COMPLETED (ACCOUNT_ERROR_CODES) |
that code | settings.usersTab.errors.<code>, but for LAST_ADMIN on a deletion (next row); a detail.billing_url is passed as params.billingUrl. PENDING_SETUP is the 409 of a reactivation or, since lot A-43, a demotion of the initial administrator waiting for its setup: a list loaded earlier may still offer either. SETUP_COMPLETED (lot A-51) is the 409 of a cancellation of a setup link that the administrator spent since the list was loaded |
detail.error_code LAST_ADMIN on a deletion (action is 'delete', lot A-16) |
LAST_ADMIN |
settings.usersTab.errors.LAST_ADMIN_DELETION, which says to make another account an administrator first: on a deletion it can only be the 400 of DELETE /auth/users/me, the last active administrator deleting their own account, as another administrator's deletion answers 409 DEMOTE_FIRST. Without 'delete', the 409 LAST_ADMIN of a deactivation or a demotion keeps settings.usersTab.errors.LAST_ADMIN |
404 |
NOT_FOUND |
settings.usersTab.errors.NOT_FOUND |
422 |
INVALID_INPUT |
settings.usersTab.errors.INVALID_INPUT |
500 of a deletion (action is 'delete') |
DELETION_FAILED |
settings.usersTab.errors.DELETION_FAILED: nothing was deleted |
400 or 409 whose detail is a sentence |
null |
The server's sentence, as it is: a fallback for a refusal that carries no code. Every 400 and 409 of the calls these components make carries one today |
| Anything else | null |
settings.usersTab.errors.generic |
🗑️ AccountDeletionDialog
lib/features/settings/AccountDeletionDialog.svelte: the one dialog for deleting an account, one's
own from ProfileTab or another's from UsersTab. A ModalBase with
trapFocus. The rule it shows and applies is the backend's:
Deleting an Account.
| Prop | Role |
|---|---|
open |
Opens the dialog; every opening loads the preview again and clears the typed name |
mode |
'self' or 'admin' |
account |
{id, username, is_active} |
testIdPrefix |
The prefix p of every test id: profile-delete in the Profile tab, users-delete in the Users tab |
onClose |
Closes the dialog: cancel, a close request of ModalBase, or once Deactivate is done |
onDeleted(result) |
After a deletion, with {user_id, brokers_deleted}, the number of brokers that went |
onDeactivate? |
Administrators only: deactivate the account instead |
mode="self" |
mode="admin" |
|
|---|---|---|
| Preview | GET /auth/users/me/deletion-preview |
GET /users/{id}/deletion-preview |
| Deletion | DELETE /auth/users/me |
DELETE /users/{id} |
| Title and warning | settings.deleteAccountConfirm, settings.deleteAccountWarning |
settings.accountDeletion.titleAdmin, settings.accountDeletion.warningAdmin |
| After a deletion | ProfileTab: auth.logout(), then / |
UsersTab: closes the dialog, reloads |
- Deactivate first: in
adminmode, for an active account and withonDeactivategiven, the dialog opens with Deactivate instead? and${p}-deactivate, which awaitsonDeactivate(), then closes. The Users tab passes its own deactivation (PATCH {is_active: false},accounts.user.deactivated, reload). - Preview (
${p}-preview;${p}-dialogcarriesdata-busywhile it loads):${p}-broker-deleted, withdata-broker-idanddata-transactions, for each broker that goes (orsettings.accountDeletion.noBrokersDeleted);${p}-broker-left, withdata-broker-idanddata-role(OWNER,EDITORorVIEWER), for each broker where only the access goes;${p}-unpaired, withdata-count, whentransfers_unpairedis above 0. - Confirmation:
${p}-confirm-inputstays disabled until the preview is in;${p}-confirm(settings.deleteAccountPermanently) is enabled only while the typed text equals the username exactly.${p}-cancelcloses. A failed preview showssettings.accountDeletion.previewFailedin${p}-error, and the deletion stays out of reach. - Outcome: a success notifies
accounts.user.deleted, with a success toast (settings.accountDeletion.deletedSelf, ordeletedAdminwith{username, count}), then callsonDeleted;brokers_deletedis counted from the preview, as the deletion answers no numbers. A failure shows${p}-error, withdata-error-code, and notifiesaccounts.action.failedwith an error toast. The last active administrator deleting their own account gets the400LAST_ADMIN(lot A-16), shown assettings.usersTab.errors.LAST_ADMIN_DELETION, You are the last active administrator: make another account an administrator before deleting yours., and the dialog stays open.
🧪 Users Tab and Account Deletion Tests
./dev.py test front-utility core-unit:users/linkShare.test.ts(initialBase,composeLink),users/addressProbe.test.ts(normalizeBase,probeUrl, andcheckAddress: the request options key by key, every verdict, the deadline on fake timers, never the network),users/accountErrors.test.ts(every code ofACCOUNT_ERROR_CODES,PENDING_SETUPincluded, the answers read from the status, and each key a sentence in the four catalogues; AERR-13 and AERR-14, lot A-51: the409SETUP_COMPLETEDworded by its key, never the server's sentence; AERR-15 to AERR-19, lot A-16: the400LAST_ADMINof a deletion worded byLAST_ADMIN_DELETION, the409LAST_ADMINof the other actions keepingLAST_ADMIN), and theusersrow ofsettingsTabs.test.ts../dev.py test front-utility component-unit:tabs/UsersTab.test.ts(the tab against a mocked server that changes as the backend would; UTAB-55 to UTAB-60, lot A-43: the cancellation of a setup link confirmed as danger, its onePATCH, event and toast, a dismissed confirmation that sends nothing, a stale demotion'sPENDING_SETUP, and the keys in the four catalogues; UTAB-61 and UTAB-62, lot A-51: the cancellation's body exactly{is_active: false, cancel_setup: true}, and a409SETUP_COMPLETEDworded by its key, with no success, the row reloaded active),users/LinkShare.component.test.ts(notLinkShare.test.ts:linkShare.test.tsis in the same folder, and macOS volumes ignore case),users/InviteDialog.test.ts,users/ResetLinkDialog.test.ts,users/UserRow.pendingSetup.test.ts(the row of an account waiting for its setup: the badge,data-pending-setup, no Reactivate and nolimitreason, the hint; since lot A-43, UPS-12 to UPS-23:users-action-cancel-setupin its place, turned off withprotectedon a protected account (UPS-23),users-action-demoteoff withpending-setup,users-action-deleteenabled; every other row unchanged),users/UserRow.verification.test.ts(UVR-01 to UVR-03, lot E5b: Reactivate on a full instance usable withholds_place, off withlimitwithout it; UVR-04 to UVR-11, lot E-7: the badgeusers-badge-pending-verificationwith its hover hint in place ofusers-badge-inactive, for a live link, an expired one andholds_placeabsent alike;data-pending-verificationas the derived state; an inactive account without the flag keeping Deactivated; the hint in the opened panel, with Reactivate still offered, usable on a full instance only with a live link;pending_setupwinning over the flag; an active account with the flag drawn with no badge),users/UserRow.avatar.test.ts(URA-01 to URA-04, lot N69-4: the avatar in the toggle, between the chevron and the username, an uploaded image asked for as its 48×48 preview, an address as it is, the initial without one, and the toggle still opening its panel),AccountDeletionDialog.test.ts(both modes; ADEL-28 and ADEL-29, lot A-16: a refused own deletion worded in the interface language, the400LAST_ADMINasLAST_ADMIN_DELETIONwith the dialog left open, the500asDELETION_FAILED) andtabs/ProfileTab.test.ts../dev.py test front-utility admin-users(frontend/e2e/settings/admin-users.spec.ts): the tab on the lane's real backend,e2e_test_adminacting on disposable accounts only. Only an administrator has the tab; the own row has no action; deactivate and reactivate, promote and demote; a reset link and an invitation, each token inspected live, the invitation then revoked; the address check (matchon the lane's other loopback origin, through the real CORS path,unverifiableon a closed port,invalidforftp://,mismatchfrom a stubbed stranger, back toidle); a deletion with its preview; sign out everywhere; the guides restarted. The deletion of one's own account through the Profile tab is./dev.py test front-user account-deletion(frontend/e2e/brokers/account-deletion.spec.ts).
🛡️ SecurityTab
lib/features/settings/security/, the registry's security entry (lot A8b): administrators only,
no props, the only tab with a badge and a prefetch. It lists the
configuration checks that
GET /api/v1/security/checks
evaluates, and one check that only the browser can make, most severe first. Administrator side:
«Security» in Global Settings.
| File | Role |
|---|---|
securityChecksApi.ts |
The seam over the generated client: fetchSecurityChecks() calls list_security_checks_api_v1_security_checks_get once and resolves to the items of the answer as they came, SecurityCheck[] ({check_id, severity, i18n_key, detail}, severity one of ok, info, warning, error); a refusal or a network error propagates |
securityFindings.ts |
Pure: what the tab lists, from the server's checks and from what only the browser knows |
securityChecks.svelte.ts |
The state: one read per page load, shared by the tab, the badges and, since lot N69b, the sidebar's dot |
SecurityTab.svelte |
The body |
The findings. securityFindings(checks, browser), where browser is
{registrationMode, registrationLocked, hostname}, returns {attention, passed}, two lists of
SecurityFinding, {id, severity, messageKey, params, action?, source}; it changes neither of its
inputs.
attention: every check that is notok, itscheck_idasid, itsi18n_keyasmessageKey, a copy of itsdetailasparams,source: 'server'; sorted error → warning → info by a stable sort, so that within a severity the server's order holds.- The browser's own check:
openRegistrationNoticeFor({isAdmin: true, ...browser})(Open-Registration Warning), registrationopenreached through a host thatisLocalHost()does not call local. Its notice becomes awarningwith the notice'sid(accounts.openRegistration),messageKey,params({}today) andaction,source: 'browser', and nothing else of it (nodismissible). Pushed after the server's findings, the stable sort puts it after the server's warnings and before the infos. With the mode pinned byLIBREFOLIO_REGISTRATIONthe notice isauth.notices.openRegistrationLocked, without an action. The finding holds whether or not the notice was closed: the tab does not read the instance notices. passed: theokchecks, in the server's order, with the severityinfoand never an action; their message is the check's ownoksentence.- Actions, the in-app links where a setting of the app fixes the finding (
SERVER_ACTIONS):email.smtp,email.smtp_encryptionandemail.links→settings.securityTab.openEmail(Open the Email tab),/settings/admin/email;platform.plugin_secrets→settings.securityTab.openPlugins(Open the plugin settings),/settings/plugins; the browser's finding → its notice's action,auth.notices.openRegistrationAction(Change who can sign up),/settings/admin/global. The other checks are fixed in the server's configuration: no link. attentionCount(findings): the errors and the warnings ofattention, the browser's included, never an info. It is the badge.attentionSeverity(findings)(lot N69b): how serious whatattentionCountcounts is:'error'when an attention finding is an error, wherever it sits in the list, else'warning'when one is a warning, elsenull. An info never counts, so it isnullexactly whenattentionCountis0. It changes nothing it reads. It is the colour of the sidebar's dot.
The state. createSecurityChecks({fetch?, browser?}) builds a store; securityChecks is the
app's, created at import, asking nothing until it is told to. Its getters are reactive: status
(idle, loading, ready or error), checks, answered (true once a read has succeeded),
findings, attentionCount and attentionSeverity, which are securityFindings(checks, browser()),
its count and its severity once answered; empty lists, 0 and null before.
ensureLoaded()reads once: nothing while a read is under way, whose promise concurrent calls share, nor onceready; again after a failure. There is no retry of its own.reload()always reads, sharing a read under way. The last checks stay listed meanwhile, and after a failure, which only setsstatustoerror.- The default
browser()takes the registration frominstanceConfig.config.accountsonly onceinstanceConfig.loaded: before, the configuration in force is the default one, whose mode isopen, and an invite-only instance would warn for nothing. The host iswindow.location.hostname. Asfindingsis computed on each read, the browser's finding followsinstanceConfig: a save ofregistration_modein GlobalSettingsTab, which reloads it, adds or removes the finding, badge and dot included, without a new request. - The default
fetchisfetchSecurityChecks().
The badge. The registry's security entry reads securityChecks.attentionCount as its badge,
summed on the administration entry, and its prefetch calls securityChecks.ensureLoaded() for an
administrator, nothing for a user. The page runs the prefetch when it opens, so the number shows
before the tab is opened; the tab's own onMount calls ensureLoaded() too. Since lot N69b the
sidebar's connection line has usually asked already, on the first page of the load
(The sidebar's dot): the prefetch and the tab then share its read, or read
nothing once it has succeeded. The store lives as long as the page load: leaving Settings and coming
back reads nothing again (unless the last read failed), «check again» or a reload of the page does.
The body. SecurityTab.svelte, prop checks: the store to show, securityChecks unless a test
hands its own. The root, security-tab, carries data-status (the store's status), and
data-busy and aria-busy, true while a read runs.
- Header:
settings.securityTab.title(Security checks),settings.securityTab.description, and Check again (security-refresh,settings.securityTab.refresh), which callsreload(), disabled while a read runs, its icon spinning. - Before the first answer (
idleorloading):security-loading, two pulsing placeholder rows. - A failed read:
security-load-error,role="alert",settings.securityTab.loadError(The security checks could not be loaded.) with Try again (security-retry,reload()). After a failed «check again», the last findings stay listed under it. - The findings: one
security-findingper attention finding, withdata-check-idanddata-severity: the severity's icon (AlertCircle,AlertTriangle,Info, hidden from screen readers), the severity in words for screen readers only (sr-only,settings.securityTab.severity.error,.warning,.info: Error, Warning, Information, then a colon), the message$_(messageKey, {values: params}), and the action as a link (security-finding-action). - The help of a check (FB-27):
CheckHelp.svelte(features/instance/components/) on every finding and passed check, fromcheckGuides.json: aguideshows the «Guide»DocsLink(security-guide); asupportcheck that has not passed shows «Contact support» (check-support,settings.securityTab.support), a link to the instance'sLIBREFOLIO_SUPPORT_URLwith the report ofbuildCheckReport()(code, severity, instance address, version, date); without a usable address, a line,check-support-missing(settings.securityTab.supportMissing), never a GitHub issue. See The Checks on Demand. - No finding:
security-all-clear,settings.securityTab.allClear(Nothing needs your attention.). An info is a finding, so it is not all clear. - The passed checks: a closed
<details>,security-passed, whose summary counts them (a neutral chip andsettings.securityTab.passed, an ICU plural: 1 check passed, N checks passed), with onesecurity-passed-check(data-check-id) perokcheck. - Colours: roles only, after the state convention of
STATUS_TONES(lib/theme/toneClasses.ts), written in the component: a tint per severity,bg-lf-X-soft text-lf-X-on-soft border-lf-X-linewithXdanger,warningorinfo(successfor the all-clear), and a neutral chip,bg-lf-neutral text-lf-secondary, for the count of the passed checks.
Tests: ./dev.py test front-utility core-unit runs security/securityChecksApi.test.ts (one call
of the generated client, its items as they came, an empty answer, a failure that propagates),
security/securityFindings.test.ts (the order by severity and within one, the passed checks, which
findings link where, the browser's finding against openRegistrationNoticeFor() for every mode, pin
and host, the inputs left as they were, attentionCount; since lot N69b, attentionSeverity: an
error wherever it sits among warnings, warnings with or without infos, null for infos only or for
nothing, null exactly when attentionCount is 0 on what securityFindings lists, the browser's
warning included, a frozen list left as it was) and security/securityChecks.test.ts (idle at
creation, ensureLoaded() once and shared, reload() keeping the last checks, the failures, the
findings following the browser's state, the reactive getters, the defaults: the generated client,
instanceConfig and the page's host; since lot N69b, the getter attentionSeverity: null before
the first answer, even after a failed read, then the most severe of each answer, a reactive read
following reload() and the browser's state). ./dev.py test front-utility component-unit
runs security/SecurityTab.test.ts (the store it is given, the placeholder, the findings and their
words, the links, the all-clear, the passed checks, «check again», the failures, colour roles only,
every key a message of the four catalogues).
The sidebar's dot
Lot N69b (point 1 of N69; decisions D1 a, D2 a, D3 a) shows an administrator the tab's count from
every page of the app shell: as a dot on the sidebar's connection line,
lib/components/layout/ConnectionSecurityIndicator.svelte (plan 36), and, on a phone, on the menu
button of Header.svelte. Both only read securityChecks and the auth
store. Neither has a branch for the managed profile (D1 a): the dot is the same there.
- Who sees it.
isAdminis$auth.user?.is_superuser === true. The line's count,attention, issecurityChecks.attentionCountfor an administrator and0for anyone else; its severity issecurityChecks.attentionSeveritywhileattention > 0, none otherwise. The role is checked in the components, not in the store:securityChecksis not reset when the account changes (it has noregisterClientSessionReset, as since lot A8b), so an administrator's answer stays in memory for the rest of the page load, and a member who signs in after them in the same tab is shown none of it. - One read per page load. An
$effectof the line callssecurityChecks.ensureLoaded()for an administrator, insideuntrack():ensureLoaded()reads the store'sstatusand moves it, and a tracked call would run the effect again at each move — after a failure, a new request, in a loop. The page's prefetch is untracked for the same reason. The effect depends onisAdminalone; the sidebar belongs to the app shell, on every page and on a phone too (off-screen until the menu opens); andensureLoaded()reads nothing more once a read has succeeded: one read per page load, on its first page. A failed read is not retried by the line: the next page load retries it, and so do Settings (its prefetch and the tab's mount) and Try again. Anyone else never asks: no request toGET /api/v1/security/checks, which would answer them403. The header never asks either: it reads what the line loaded. - The root,
connection-security, publishesdata-security-attention, the count (0for anyone not an administrator, and until the answer), anddata-security-severity,error,warningornone, besidedata-level,data-reasonanddata-server-checked. Since lot A-62 it also publishesdata-security-checks, where the checks stand:offfor anyone not an administrator,pendingfor an administrator until the first answer,readyfrom the first answer on (while Check again reloads, and after a later reload failed, too),errorwhen the first read failed and nothing has answered yet. The expression is!isAdmin ? 'off' : securityChecks.answered ? 'ready' : securityChecks.status === 'error' ? 'error' : 'pending'. Invisible to the user, it is there for the tests and the gallery to wait on the checks instead of guessing a delay. - The dot,
connection-security-attention-dot: on the corner of the level's icon, inside the toggle (connection-security-toggle), withdata-severitythe severity andaria-hidden="true"; drawn whileattention > 0, with the sidebar expanded or collapsed. A dot, not a number (D3 a):bg-lf-bar-dangerfor an error,bg-lf-bar-warningfor warnings only, with aring-2 ring-lf-barin the bar's colour that cuts it out of the icon. - The name. Colour is not the only sign (WCAG 1.4.1): while
attention > 0, the toggle'saria-labelis «‹level label› — ‹attention text›», expanded and collapsed, and itstitlethe same when collapsed. The attention text is$_('connectionSecurity.attention', {values: {count}}), an ICU plural in the four catalogues of theappsubsystem (1 security warning, 2 security warnings: the errors are counted in it). Without attention the toggle is named as before: by the level label inaria-labelandtitlewhen collapsed, by its visible label when expanded. - The link,
connection-security-attention-link: in the details, after the reason and before the administrator's cookie line and the docs link, an<a href="/settings/admin/security">whose text is the attention text after aShieldAlerticon, withdata-severitythe severity and its border and icon inlf-bar-dangerorlf-bar-warning. A click callscloseDetails()while the app navigates to the tab. - The menu button (D2 a). On a phone the sidebar, and the line with it, hide behind
mobile-menu-toggle. Its dot,mobile-menu-security-dot, until N69b for an insecure connection alone (plan 36), is drawn while the connection is insecure or an administrator'sattentionCountis above0: one dot either way. Itsdata-severityiserrorwhen the connection is insecure orattentionSeverityiserror,warningotherwise;bg-lf-dangerorbg-lf-warning, withring-2 ring-lf-headerandaria-hidden="true". The button'saria-labelstarts with$_('nav.toggleMenu'), the translated «Toggle menu» (a key of the base catalogue since lot A-62; it was an English literal), followed by the insecure level's label when the connection is insecure and by the attention text with attention, each after « — ».
Tests: ./dev.py test front-utility component-unit runs
lib/components/layout/ConnectionSecurityIndicator.test.ts and lib/components/layout/Header.test.ts
(the latter also in onboarding-component-unit). Each file fakes the checks' store over a reactive
box, one list of findings from which findings, attentionCount and attentionSeverity derive as in
the real store, with ensureLoaded and reload spied and the answer landed by the case; and each
gives connectionSecurity.attention an ICU message of its own, so that a name reads the key, the
plural branch and the count, never a translation. N69b's describe closes Header.test.ts (A-62's
nests inside it) and comes just before A-62's, the last, in ConnectionSecurityIndicator.test.ts:
- the line, 6 cases: an administrator with warnings (
2andwarningon the root, the dot in the toggle, the count in the name, the link after the reason, which closes the details); with an error among them (erroron the root and the dot); with infos only (0andnone, no dot nor link, the name as before, expanded and collapsed); a member over a store holding an administrator's warnings (0andnone, no dot nor link, and no call ofensureLoaded(),reload()or the generated client); collapsed (the dot, and the singular in the name and the title); an administrator's line asking the store once from its mount and following the answer when it lands; - the header, 5 cases: an administrator with warnings, then with an error among them, on a secure
connection (the dot and its severity, the count appended to the name, nothing for infos only); a
member on an insecure connection (the plan-36 dot, now
data-severity="error", nothing about the checks in the name); an administrator with warnings on an insecure connection (one dot,error; the name carries the level, then the count); a member over an administrator's warnings, then an administrator signed in on the same header, the control. The header never callsensureLoaded()norreload().
Lot A-62 adds the last describe of the indicator's file and one inside N69b's in the header's:
- the line, «the checks signal on the root (A-62)», 10 cases: a member over a store that holds the
answer, a failed first read or a read under way, and nobody signed in (
offeach time, and a member's line never asks the checks); an administrator before the answer (pending, the line's own request having moved the store toloading); an answer already there at mount (ready, an answer with nothing to look at included);pendingthenreadywhen the answer lands;readykept during a Check again reload and after a later reload failed; a first read that failed (error, and no second request); - the header, «the burger's name starts with the translated toggle menu (A-62)», 4 cases: a member on
a secure connection (the first part alone) and on an insecure one (then the level); an
administrator with warnings, on a secure connection (then the count) and on an insecure one (the
level, then the count, in that order). The describe gives
nav.toggleMenua marker of its own (⟦nav.toggleMenu⟧, throughaddMessages), so that the name must start with that key's text and not with a literal.
./dev.py test front-utility connection-security runs
frontend/e2e/layout/connection-security.spec.ts on the desktop and the mobile projects. Its describe
«An administrator: the security dot (N69-1)» runs under a loopback name, where the browser adds no
open-registration finding of its own, and reads the root's two attributes, the dots and the link:
- ADOT-E-01, the lane as it is:
accounts.login_limitis a warning on every lane (dev.py server --testsetsLIBREFOLIO_LOGIN_LIMIT=off), read first as a precondition. The page reads the checks once, and the line's count and severity are those of that very read (platform.client_addressmay differ from one server process to another), with, on a phone, the burger's dot. Its link opens Settings › Administration › Security and closes the details, and the tab lists as many errors and warnings without a second read; - ADOT-E-02, stubbed (
page.route), one error and two warnings, an info and an ok besides:3anderror, the dot expanded and, on desktop, collapsed, the burger's on a phone, the link; - ADOT-E-03, stubbed, every check ok:
0andnoneonce the Security tab has settled on the same answer, no dot on the line nor, on a phone, on the burger, no link; - ADOT-E-04, stubbed, one warning:
1andwarning, on the line and, on a phone, on the burger; - ADOT-E-05, a member:
0andnone, no dot, and no read of the checks through a sign-in, a page load and a navigation to Settings.
A stubbed case counts one read for its page load, answered by the stub.
ℹ️ AboutTab
Read-only system information:
- Version (from Git tag)
- Backend/frontend info
Between the links (website, GitHub, license) and the system information sit two cards:
- Support (
about-support-card):SupportActions, whose Buy Me a Coffee link and «Or share» divider followdonationsVisible(), shown only onceGET /system/instancehas answeredselfhosted(Instance configuration). The share buttons stay on every instance. - Legal notice (
about-legal-card): thelegal.titleheading, thenLegalNotice. It does not depend on the diagnostics: it shows, links included, whenGET /system/infofails.
The legal notice
lib/features/legal/ holds the legal notice of the instance (F09, workstream A; its places are
decision D-A11): two components that read legal of instanceConfig, the {terms_url, privacy_url}
of GET /system/instance
(Public instance configuration).
| Component | Shows | Used by |
|---|---|---|
LegalNotice.svelte (legal-notice) |
legal.disclaimer, then a row with Terms of service (legal-terms-link, legal.terms) and Privacy policy (legal-privacy-link, legal.privacy), each only while its address is set; no row without either |
AboutTab (about-legal-card); WelcomePage, under its card (Welcome) |
LegalLinks.svelte (legal-links) |
One line: legal.disclaimerShort, then the same two links, each after a ·. Prop tone: page (the default) or bar, the colours of the sidebar's bar |
AuthPageFrame (auth-legal-links), under the card of every sign-in page; Sidebar (sidebar-legal-links, tone="bar"), after the version while the sidebar is expanded |
- Both links open in a new tab, with
rel="noopener noreferrer": the page they open gets nowindow.openerand noReferer. - Neither component loads the configuration: the page around it does (the
(app)layout,AuthPageFrame). The default configuration has nolegal, so until the answer the notice shows without links, and the links appear in place when it lands. - The keys
legal.title,legal.disclaimer,legal.disclaimerShort,legal.termsandlegal.privacybelong to theappi18n subsystem (frontend/src/lib/i18n/app/, prefixlegal). - AI Export renders
legal.titleandlegal.disclaimertoo, without the components and without links, as thelegal_noticesection of every prompt (Exact Prompt Order): a change to either text changes every exported prompt. - Colour roles only, as everywhere: no palette class and no
dark:variant, which the tests check in each place. - Tests:
./dev.py test front-utility component-unitrunsLegalNotice.test.ts,LegalLinks.test.ts,AboutTab.legal.test.ts,AuthPageFrame.legal.test.tsandSidebar.legal.test.ts;./dev.py test front-utility onboarding-component-unitrunsWelcomePage.legal.test.ts.
🔧 Field Components
Each setting type has a specialized component that handles its own UI and events.
SettingSelect: Generic dropdown (usesSimpleSelect).SettingCurrency: Searchable currency selector (usesSearchSelect).SettingTheme: Radio buttons for Light/Dark/Auto theme with visual preview.SettingNumber: Numeric input with increment/decrement.SettingToggle: Boolean toggle switch.
Common Props for Field Components:
value: Two-way bound value.label: Field label.hint: Helper text.isModified: Highlights the field if changed.isNonDefault: Shows a "Reset to Default" indicator.isLocked: Disables input.
The three wrappers shared with the Global Settings tab — SettingSelect, SettingCurrency,
SettingTheme — also accept embedded: when true, the row drops its own padding and
bottom border so it can sit inside a parent card without a double separator. The standalone
Preferences tab renders rows in a list and keeps the default; the Global Settings tab embeds
the shared wrappers in its own per-setting cards and passes embedded.
💻 Usage Example
Both components take callback props (onsaveAll, onundoAll, onresetAll on the layout;
onsave, onundo, onreset on a field), not component events:
<script lang="ts">
import SettingsLayout from '$lib/features/settings/SettingsLayout.svelte';
import SettingSelect from '$lib/features/settings/SettingSelect.svelte';
let original = $state('option1');
let value = $state('option1');
let hasChanges = $derived(value !== original);
function save() {
// persist `value`, then:
original = value;
}
</script>
<SettingsLayout title="My Settings" {hasChanges} onsaveAll={save} onundoAll={() => (value = original)}>
<SettingSelect
bind:value
label="Choose Option"
options={[{value: 'option1', label: 'One'}]}
isModified={hasChanges}
onsave={save}
onundo={() => (value = original)}
/>
</SettingsLayout>