fix(cli): honor persisted status bar visibility
This commit is contained in:
24
cli.py
24
cli.py
@@ -3954,6 +3954,26 @@ def _estimate_tui_input_height(
|
||||
return min(max(visual_lines, 1), max(1, int(max_height or 1)))
|
||||
|
||||
|
||||
def _status_bar_visible_from_display_config(display_config: object) -> bool:
|
||||
"""Return the initial classic-CLI status-bar visibility from display config.
|
||||
|
||||
``display.tui_statusbar`` is the persisted user-facing setting toggled by
|
||||
the TUI/statusbar controls. YAML parses bare ``off`` as ``False``, while
|
||||
older config snapshots or hand edits may use strings such as ``"off"`` or
|
||||
``"hidden"``. Treat those values consistently so a new CLI process does not
|
||||
re-enable a status bar that the user deliberately disabled.
|
||||
"""
|
||||
if not isinstance(display_config, dict):
|
||||
display_config = {}
|
||||
statusbar_config = display_config.get(
|
||||
"statusbar",
|
||||
display_config.get("tui_statusbar", "top"),
|
||||
)
|
||||
if isinstance(statusbar_config, str):
|
||||
return statusbar_config.strip().lower() not in {"0", "false", "hidden", "no", "off"}
|
||||
return statusbar_config is not False
|
||||
|
||||
|
||||
def _collect_query_images(query: str | None, image_arg: str | None = None) -> tuple[str, list[Path]]:
|
||||
"""Collect local image attachments for single-query CLI flows."""
|
||||
message = query or ""
|
||||
@@ -4865,7 +4885,9 @@ class HermesCLI(CLIAgentSetupMixin, CLICommandsMixin, CLIBillingMixin):
|
||||
self._voice_barge_phase = None # "generation" or "playback" phase of the last barge trip
|
||||
|
||||
# Status bar visibility (toggled via /statusbar)
|
||||
self._status_bar_visible = True
|
||||
self._status_bar_visible = _status_bar_visible_from_display_config(
|
||||
CLI_CONFIG.get("display") if isinstance(CLI_CONFIG, dict) else None
|
||||
)
|
||||
# Battery read-out in the status bar (toggled via /battery, off by
|
||||
# default). Persisted to display.battery so it survives restarts.
|
||||
self._battery_visible = bool(CLI_CONFIG["display"].get("battery", False))
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import time
|
||||
from copy import deepcopy
|
||||
from datetime import datetime, timedelta
|
||||
from types import SimpleNamespace
|
||||
from unittest.mock import MagicMock, patch
|
||||
@@ -74,6 +75,23 @@ class TestCLIStatusBar:
|
||||
|
||||
assert snapshot["session_title"] == "user-profiles"
|
||||
|
||||
def test_status_bar_config_helper_treats_persisted_off_as_hidden(self):
|
||||
for value in (False, "off", "false", "hidden", "no", "0"):
|
||||
assert cli_mod._status_bar_visible_from_display_config({"tui_statusbar": value}) is False
|
||||
|
||||
for value in (True, "top", "bottom", "on", None):
|
||||
assert cli_mod._status_bar_visible_from_display_config({"tui_statusbar": value}) is True
|
||||
|
||||
def test_status_bar_initial_visibility_honors_tui_statusbar_config(self, monkeypatch):
|
||||
config = deepcopy(cli_mod.CLI_CONFIG)
|
||||
config.setdefault("display", {})["tui_statusbar"] = False
|
||||
config["display"].pop("statusbar", None)
|
||||
monkeypatch.setattr(cli_mod, "CLI_CONFIG", config)
|
||||
|
||||
cli_obj = HermesCLI(model="test-model", toolsets=[], provider="auto")
|
||||
|
||||
assert cli_obj._status_bar_visible is False
|
||||
|
||||
def test_context_style_thresholds(self):
|
||||
cli_obj = _make_cli()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user