Skip to content

Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.

feat(config): add ui.bar_size_scale with clamp validator + persist helper

Ruben Lütke508c9d3f0977
diff --git a/jarvis/core/config.py b/jarvis/core/config.py
index 358a5e4fb2..14cd69fb3e 100644
--- a/jarvis/core/config.py
+++ b/jarvis/core/config.py
@@ -1432,6 +1432,12 @@ class UIConfig(BaseModel):
bar_persistent: bool = True
# Hex accent the bar lights up with during activity (gold on-brand).
bar_accent: str = "#e7c46e"
+ # Jarvis bar size multiplier (Settings → "Bar size" slider). 1.0 = the
+ # signed-off default look; the whole bar scales proportionally (width AND
+ # height together, shape preserved) below/above it, on top of the
+ # screen-adaptive scale. Range mirrors renderer.USER_SIZE_MIN/MAX (0.5–2.0);
+ # the renderer re-clamps, so this validator only sanitizes a corrupt value.
+ bar_size_scale: float = 1.0
# Remembered "open with" choice for Outputs artifacts: an opener id
# ("default" = OS default app, "browser", or an editor key like "code").
# Empty = ask via the chooser dialog on first open. Desktop-only.
@@ -1449,6 +1455,20 @@ class UIConfig(BaseModel):
return "jarvis_bar"
return v
+ @field_validator("bar_size_scale", mode="before")
+ @classmethod
+ def _clamp_bar_size_scale(cls, v: object) -> object:
+ # Sanitize a persisted "Bar size" value on load: clamp into the
+ # supported 0.5–2.0 range and fall back to 1.0 for a non-numeric /
+ # non-finite value so a corrupt jarvis.toml can never brick the bar.
+ try:
+ f = float(v) # type: ignore[arg-type]
+ except (TypeError, ValueError):
+ return 1.0
+ if f != f or f in (float("inf"), float("-inf")): # NaN / ±inf
+ return 1.0
+ return max(0.5, min(2.0, f))
+
class DuckingConfig(BaseModel):
"""Audio ducking — "Mute music while dictating" (Taskbar section).
diff --git a/jarvis/core/config_writer.py b/jarvis/core/config_writer.py
index bda73d5824..d7a4fb369b 100644
--- a/jarvis/core/config_writer.py
+++ b/jarvis/core/config_writer.py
@@ -732,6 +732,22 @@ def set_bar_persistent(enabled: bool, *, path: Path = DEFAULT_CONFIG_FILE) -> No
_patch_table(path, "ui", "bar_persistent", bool(enabled))
+def set_bar_size_scale(scale: float, *, path: Path = DEFAULT_CONFIG_FILE) -> None:
+ """Persist ``[ui] bar_size_scale`` (the 'Bar size' slider).
+
+ TOML-only (not drift-guarded); the Settings route applies it live to the
+ running bar. The value is clamped into the supported 0.5–2.0 range here so
+ a bad request can never write an out-of-range number to disk.
+ """
+ try:
+ f = float(scale)
+ except (TypeError, ValueError):
+ f = 1.0
+ if f != f or f in (float("inf"), float("-inf")): # NaN / ±inf → default
+ f = 1.0
+ _patch_table(path, "ui", "bar_size_scale", max(0.5, min(2.0, f)))
+
+
def set_mute_music(enabled: bool, *, path: Path = DEFAULT_CONFIG_FILE) -> None:
"""Persist ``[ducking] enabled`` (the 'mute music while dictating' toggle).