Adding a setting
Settings are of two kinds. Almost every new one is a preference: one field in a validated JSON object stored in
settings.preferences_json. No migration is needed for it.
A preference
- The schema. Add the field to its section in
preferencesSchema,src/shared/config/preferences.ts, with a default:z.boolean().default(false), an enum, orint(RANGE)with a{ min, max, default }constant next to the others. A stored row without the field reads the default, so older profiles keep working. - The control. Add it to the section component in
src/renderer/components/settings/sections/, for example aSwitchwithpatchSection(setPrefs, 'assistant', { yourField: next }). Use the design system's controls (Switch,NumberField,SelectField,RadioCards). - The texts. The label and, if needed, a hint under
preferences.*insrc/shared/i18n/catalog.ts, in both languages. Say what changes for the person, not how the code works. - The use. Read it where it matters: in main through
readPreferences(getDatabase()), in the renderer throughsrc/renderer/state/preferencesState.ts. - When it applies. Most settings apply on Save; if it must apply at once, say so in the hint.
- Tests.
tests/unit/preferences.test.ts(default, range, a stored row without the field) andtests/unit/preferencesRenderer.test.tsif the window reads it.tests/e2e/preferences.test.tscovers the window. - The wiki. The setting's line in Every setting and on the page of its
section under
docs/wiki/interface/Settings-*.md, both languages. If it sends anything off the computer, also Privacy.
A column on the settings row
Only for a value that must be read before the preferences (for example the language or an address checked with a
special rule). It needs a migration (The database and migrations), a field in
nonSecretSettingsSchema (src/shared/config/schema.ts) and its default in nonSecretDefaults.
Never a secret
A key, a password or a token is never a setting. The settings schema refuses values that look like one ("Settings
cannot hold a key or a password"). Secrets go through the key and token stores in src/main/settings/.