HubSettings Module
Hub-wide user-editable settings. Persisted as a single JSON document under the XDG config home. **Phase 2 scope note**: the planning sketch included a `LastLobby` field of type `LobbyConfig option` for persisting the user's most recent lobby. That field is deferred to Phase 3 (task T027, when `LobbyConfig` lands); the current JSON schema reserves room for it via a forward-compatible `SchemaVersion` field but does not yet emit / consume it.
Types
| Type | Description |
|
JSON-serialisable record. All fields are required on write; missing fields on read are filled from `defaults`. |
Functions and values
| Function or value |
Description
|
|
Factory values identical to a fresh-install state: no overrides, port `5021`, graphical-viewer toggle off, start-paused toggle on, 8 concurrent render subscribers, 8 concurrent log-stream subscribers, schema `3`.
|
|
Loads settings from `settingsPath ()`.
Behaviour:
* File absent → `defaults`.
* Parse error or missing required field → `defaults` with a
diagnostic written to stderr. Never raises on malformed JSON.
* `GrpcPort` outside `[1024, 65535]` → the field is clamped to
`defaults.GrpcPort`; other fields are preserved.
|
|
Atomically writes `settings` to `settingsPath ()`. The write is temp-file-plus-rename to prevent torn reads: serialises to a sibling `*.tmp` file, flushes, then renames over the target. Returns `Ok ()` on success; `Error msg` carries an operator-visible reason on failure (permissions, I/O error, serialisation).
|
Full Usage:
settingsPath ()
Parameters:
unit
Returns: string
|
Returns the absolute filesystem path where settings are read / written. Resolves in this order: `$XDG_CONFIG_HOME/fsbar-hub/settings.json` when the variable is set and non-empty; otherwise `$HOME/.config/fsbar-hub/settings.json`.
|
Full Usage:
updateLaunchGraphicalViewerDefault settings value
Parameters:
HubSettings
value : bool
Returns: HubSettings
|
Return a copy of `settings` with `LaunchGraphicalViewerDefault = value`. Pure transformation.
|
Full Usage:
updateMaxLogStreamSubscribers settings value
Parameters:
HubSettings
value : int
Returns: Result<HubSettings, string>
|
Return a validated copy of `settings` with `MaxLogStreamSubscribers = value`. Rejects values outside `[1, 32]` with an operator-visible reason (feature 042 R7).
|
Full Usage:
updateMaxRenderFrameSubscribers settings value
Parameters:
HubSettings
value : int
Returns: Result<HubSettings, string>
|
Return a validated copy of `settings` with `MaxRenderFrameSubscribers = value`. Rejects values outside `[1, 32]` with an operator-visible reason (data-model §HubSettings).
|
Full Usage:
updateStartPausedDefault settings value
Parameters:
HubSettings
value : bool
Returns: HubSettings
|
Return a copy of `settings` with `StartPausedDefault = value`. Pure transformation; callers persist via `save` and publish a `HubEvent.HubSettingsChanged` if desired.
|
FSBarV1_Archived