CLI for SidePulse
Python
Polish SidePulse status bar session settings
Peter Kuhar099c1aeb3ef9
diff --git a/src/sidepulse/__main__.py b/src/sidepulse/__main__.pyindex bfdcd0c..6c48f1c 100644--- a/src/sidepulse/__main__.py+++ b/src/sidepulse/__main__.py@@ -1,4 +1,4 @@-from .cli import main+from .cli import sidepulse_mainif __name__ == "__main__":- raise SystemExit(main())+ raise SystemExit(sidepulse_main())diff --git a/src/sidepulse/settings.py b/src/sidepulse/settings.pyindex 919f903..a4710bf 100644--- a/src/sidepulse/settings.py+++ b/src/sidepulse/settings.py@@ -75,6 +75,8 @@ DEFAULT_LID_OPEN_ANIMATION_PROGRAM = "\n".join()DEFAULT_LID_CLOSED_ANIMATION_SECONDS = 0.9DEFAULT_LID_OPEN_ANIMATION_SECONDS = 1.0+DEFAULT_RECENT_SESSION_RETENTION_SECONDS = 48 * 60 * 60+DEFAULT_IDLE_TIMEOUT_SECONDS = 60 * 60@dataclass(frozen=True)@@ -129,6 +131,8 @@ class AgentMonitorSettings:grok_session_open_action: str = SESSION_OPEN_TERMINALsession_terminal_app: str = TERMINAL_APP_TERMINALcustom_terminal_path: str = ""+ recent_session_retention_seconds: float = DEFAULT_RECENT_SESSION_RETENTION_SECONDS+ idle_timeout_seconds: float = DEFAULT_IDLE_TIMEOUT_SECONDSsetup_screen_completed: bool = Falsedef transcript_enabled(self, provider: str) -> bool:@@ -396,6 +400,24 @@ class AgentMonitorSettings:def with_virtual_status_device(self, enabled: bool) -> "AgentMonitorSettings":return replace(self, virtual_status_device_enabled=bool(enabled))+ def with_agent_list_timing(+ self,+ *,+ recent_session_retention_seconds: float | None = None,+ idle_timeout_seconds: float | None = None,+ ) -> "AgentMonitorSettings":+ retention = self.recent_session_retention_seconds+ idle_timeout = self.idle_timeout_seconds+ if recent_session_retention_seconds is not None:+ retention = normalize_seconds_setting(recent_session_retention_seconds)+ if idle_timeout_seconds is not None:+ idle_timeout = normalize_seconds_setting(idle_timeout_seconds)+ return replace(+ self,+ recent_session_retention_seconds=retention,+ idle_timeout_seconds=idle_timeout,+ )+def to_dict(self) -> dict[str, Any]:return {"led_display": self.led_display,@@ -420,6 +442,10 @@ class AgentMonitorSettings:"app": self.session_terminal_app,"custom_path": self.custom_terminal_path,},+ "agent_list": {+ "recent_session_retention_seconds": self.recent_session_retention_seconds,+ "idle_timeout_seconds": self.idle_timeout_seconds,+ },"setup_screen_completed": self.setup_screen_completed,}@@ -463,6 +489,10 @@ def load_settings(path: Path | None = None) -> AgentMonitorSettings:if not isinstance(terminal, dict):terminal = {}+ agent_list = data.get("agent_list")+ if not isinstance(agent_list, dict):+ agent_list = {}+led_display = _led_display_setting(data.get("led_display"), LED_DISPLAY_AGENT)session_open_preferences = _session_open_preferences(data.get("session_open_preferences")@@ -514,6 +544,17 @@ def load_settings(path: Path | None = None) -> AgentMonitorSettings:grok_session_open_action=grok_session_open_action,session_terminal_app=normalize_terminal_app(terminal.get("app")),custom_terminal_path=_string_setting(terminal.get("custom_path")),+ recent_session_retention_seconds=_nonnegative_float_setting(+ agent_list.get(+ "recent_session_retention_seconds",+ data.get("recent_session_retention_seconds"),+ ),+ DEFAULT_RECENT_SESSION_RETENTION_SECONDS,+ ),+ idle_timeout_seconds=_nonnegative_float_setting(+ agent_list.get("idle_timeout_seconds", data.get("idle_timeout_seconds")),+ DEFAULT_IDLE_TIMEOUT_SECONDS,+ ),setup_screen_completed=_bool_setting(data.get("setup_screen_completed"), False),)@@ -635,6 +676,18 @@ def _float_setting(value: object, default: float) -> float:return default+def _nonnegative_float_setting(value: object, default: float) -> float:+ if isinstance(value, (int, float)):+ return normalize_seconds_setting(value)+ return default+++def normalize_seconds_setting(value: object) -> float:+ if isinstance(value, (int, float)):+ return max(0.0, float(value))+ return 0.0++def normalize_brightness(value: object) -> int:if value is None:return 255diff --git a/src/sidepulse/status_bar.py b/src/sidepulse/status_bar.pyindex 10e6a9d..9cdda9c 100644--- a/src/sidepulse/status_bar.py+++ b/src/sidepulse/status_bar.py@@ -143,6 +143,8 @@ from .settings import (CLOSED_LID_AWAKE_ALWAYS,CLOSED_LID_AWAKE_CHOICES,CLOSED_LID_AWAKE_NEVER,+ DEFAULT_IDLE_TIMEOUT_SECONDS,+ DEFAULT_RECENT_SESSION_RETENTION_SECONDS,LED_DISPLAY_AGENT,LED_DISPLAY_BATTERY,LED_DISPLAY_CUSTOM,@@ -215,7 +217,7 @@ STATUS_BAR_KEEPALIVE_VOLUME_NAMES = ()STATUS_BAR_REFRESH_SECONDS = 15.0STATUS_BAR_DEVICE_POLL_SECONDS = 2.0-STATUS_BAR_RECENT_COMPLETED_SECONDS = 20 * 60.0+STATUS_BAR_SESSION_HISTORY_LIMIT = 10SCREEN_BAR_FEATURE_ENABLED = TrueSTATUS_BAR_MAX_LINES_PER_SOURCE = 500STATUS_BAR_STARTUP_REPLAY_LINES = 200@@ -606,6 +608,10 @@ class StatusBarController(NSObject):def setBatteryPowerPreviewFromCheckbox_(self, sender):self.set_battery_power_preview(sender.state() == NSOnState)+ @objc.IBAction+ def saveAgentListTiming_(self, _sender):+ self.save_agent_list_timing_from_fields()+@objc.IBActiondef setDeviceDisplayAgent_(self, sender):self.set_device_display(sender.representedObject(), LED_DISPLAY_AGENT)@@ -689,7 +695,7 @@ class StatusBarController(NSObject):socket_path = default_event_socket_path()return LiveAgentMonitor(sources=(SourceSpec("event-bus", socket_path),),- stale_after_seconds=3600,+ stale_after_seconds=self.settings.idle_timeout_seconds,latest_state_path=default_latest_state_path(),)@@ -958,6 +964,14 @@ class StatusBarController(NSObject):self.settings_fields.get("open_animation_duration"),f"{opened.duration_seconds:g}",)+ set_text_control_value(+ self.settings_fields.get("recent_session_retention_hours"),+ f"{self.settings.recent_session_retention_seconds / 3600:g}",+ )+ set_text_control_value(+ self.settings_fields.get("idle_timeout_minutes"),+ f"{self.settings.idle_timeout_seconds / 60:g}",+ )def set_settings_message(self, message: str) -> None:set_field_value(self.settings_fields.get("message"), message)@@ -1060,6 +1074,39 @@ class StatusBarController(NSObject):self.refresh_settings_window()self.refresh_(None)+ def save_agent_list_timing_from_fields(self) -> None:+ retention_text = text_control_value(+ self.settings_fields.get("recent_session_retention_hours")+ )+ idle_text = text_control_value(self.settings_fields.get("idle_timeout_minutes"))+ try:+ retention_hours = float(retention_text) if retention_text else (+ DEFAULT_RECENT_SESSION_RETENTION_SECONDS / 3600+ )+ idle_minutes = float(idle_text) if idle_text else (+ DEFAULT_IDLE_TIMEOUT_SECONDS / 60+ )+ except ValueError:+ self.set_settings_message("Agent list timing must be numeric.")+ return++ try:+ self.settings = self.settings.with_agent_list_timing(+ recent_session_retention_seconds=retention_hours * 3600,+ idle_timeout_seconds=idle_minutes * 60,+ )+ save_settings(self.settings)+ except Exception as exc:+ self.set_settings_message(f"Could not save agent list timing: {exc}")+ self.settings = load_settings()+ self.refresh_settings_window()+ return++ self.reload_monitor()+ self.set_settings_message("Agent list timing saved.")+ self.refresh_settings_window()+ self.refresh_(None)+def set_battery_led_display(self, enabled: bool) -> None:try:display = LED_DISPLAY_BATTERY if enabled else LED_DISPLAY_AGENT@@ -1976,7 +2023,7 @@ def build_menu(snapshot, state: StatusBarState, target: StatusBarController) ->menu.addItem_(disabled_menu_item("Agents"))- statuses = recent_statuses(snapshot)+ statuses = recent_statuses(snapshot, target.settings)if not statuses:menu.addItem_(disabled_menu_item("No recent sessions"))else:@@ -2310,6 +2357,13 @@ def build_settings_window(target: StatusBarController) -> NSWindow:tab_width,tab_height,)+ behavior_tab = add_settings_tab(+ tab_view,+ "behavior",+ "Behavior",+ tab_width,+ tab_height,+ )diagnostics_tab = add_settings_tab(tab_view,"diagnostics",@@ -2410,6 +2464,15 @@ def build_settings_window(target: StatusBarController) -> NSWindow:add_button(sleep_tab, "Reset", 124, 14, 90, 28, target, "resetLidOpenAnimation:")add_button(sleep_tab, "Save Animations", 490, 14, 146, 28, target, "saveLidAnimations:")+ add_label(behavior_tab, "Agent List", 24, 398, 240, 24)+ add_label(behavior_tab, "Keep last 10 sessions for", 32, 356, 180, 22)+ retention_hours = add_editable_field(behavior_tab, "", 224, 354, 58, 24)+ add_label(behavior_tab, "hours", 292, 356, 60, 22)+ add_label(behavior_tab, "Idle timeout", 32, 316, 120, 22)+ idle_minutes = add_editable_field(behavior_tab, "", 224, 314, 58, 24)+ add_label(behavior_tab, "minutes", 292, 316, 80, 22)+ add_button(behavior_tab, "Save", 32, 266, 90, 28, target, "saveAgentListTiming:")+add_label(diagnostics_tab, "Debug Log", 24, 398, 240, 24)debug_log_status = add_label(diagnostics_tab, "", 32, 360, 588, 22)add_button(diagnostics_tab, "Export CSV", 32, 318, 110, 28, target, "exportDebugCsv:")@@ -2434,6 +2497,8 @@ def build_settings_window(target: StatusBarController) -> NSWindow:"closed_animation_duration": closed_duration,"open_animation_program": open_program,"open_animation_duration": open_duration,+ "recent_session_retention_hours": retention_hours,+ "idle_timeout_minutes": idle_minutes,"message": message,"settings_path": settings_path,}@@ -3256,20 +3321,30 @@ def build_error_menu(exc: Exception) -> NSMenu:return menu-def recent_statuses(snapshot) -> list[AgentStatus]:- statuses = coalesced_menu_statuses(menu_statuses(snapshot))+def recent_statuses(+ snapshot,+ settings=None,+ *,+ limit: int = STATUS_BAR_SESSION_HISTORY_LIMIT,+) -> list[AgentStatus]:+ statuses = coalesced_menu_statuses(menu_statuses(snapshot, settings))statuses.sort(key=lambda status: (status.priority, -status.updated_at.timestamp()))- return statuses[:12]+ return statuses[:limit]-def menu_statuses(snapshot) -> tuple[AgentStatus, ...]:+def menu_statuses(snapshot, settings=None) -> tuple[AgentStatus, ...]:statuses = list(snapshot.statuses)now = snapshot.collected_at+ retention_seconds = (+ settings.recent_session_retention_seconds+ if settings is not None+ else DEFAULT_RECENT_SESSION_RETENTION_SECONDS+ )statuses.extend(statusfor status in getattr(snapshot, "stale_statuses", ())if status.mode == AgentMode.COMPLETED- and status.age_seconds(now) <= STATUS_BAR_RECENT_COMPLETED_SECONDS+ and status.age_seconds(now) <= retention_seconds)return tuple(statuses)diff --git a/src/sidepulse/status_bar_launch.py b/src/sidepulse/status_bar_launch.pyindex c02a54d..8f27934 100644--- a/src/sidepulse/status_bar_launch.py+++ b/src/sidepulse/status_bar_launch.py@@ -2,6 +2,7 @@ from __future__ import annotationsimport osimport plistlib+import shleximport subprocessimport sysfrom dataclasses import dataclass@@ -14,6 +15,9 @@ LAUNCH_AGENT_LABEL = "io.sidepulse.agentstatus"LAUNCH_AGENT_FILENAME = f"{LAUNCH_AGENT_LABEL}.plist"LEGACY_LAUNCH_AGENT_LABEL = "com.sidepulse.agentstatus"LEGACY_LAUNCH_AGENT_FILENAME = f"{LEGACY_LAUNCH_AGENT_LABEL}.plist"+PIXIEPULSE_LEGACY_LAUNCH_AGENT_LABEL = "com.pixiepulse.agentstatus"+PIXIEPULSE_LEGACY_LAUNCH_AGENT_FILENAME = f"{PIXIEPULSE_LEGACY_LAUNCH_AGENT_LABEL}.plist"+STATUS_BAR_DISPLAY_NAME = "SidePulse Status Bar"@dataclass(frozen=True)@@ -35,6 +39,15 @@ def legacy_launch_agent_path(home: Path | None = None) -> Path:return base / "Library" / "LaunchAgents" / LEGACY_LAUNCH_AGENT_FILENAME+def pixiepulse_legacy_launch_agent_path(home: Path | None = None) -> Path:+ base = home or Path.home()+ return base / "Library" / "LaunchAgents" / PIXIEPULSE_LEGACY_LAUNCH_AGENT_FILENAME+++def status_bar_launcher_path(home: Path | None = None) -> Path:+ return default_user_data_dir(home) / "sidepulse" / "status-bar" / STATUS_BAR_DISPLAY_NAME++def launch_agent_installed(plist_path: Path | None = None) -> bool:target = plist_path or launch_agent_path()return target.exists()@@ -42,28 +55,19 @@ def launch_agent_installed(plist_path: Path | None = None) -> bool:def build_launch_agent_plist(python_executable: Path | str | None = None,+ launcher_path: Path | None = None,stdout_path: Path | None = None,stderr_path: Path | None = None,) -> dict[str, Any]:executable = str(python_executable or sys.executable or "python3")+ launcher = str(launcher_path or status_bar_launcher_path())state_dir = default_state_dir()stdout = stdout_path or state_dir / "status-bar.out.log"stderr = stderr_path or state_dir / "status-bar.err.log"- if getattr(sys, "frozen", False) and python_executable is None:- program_arguments = [executable, "status-bar", "start", "--foreground"]- else:- program_arguments = [- executable,- "-m",- "sidepulse",- "status-bar",- "--foreground",- ]-plist: dict[str, Any] = {"Label": LAUNCH_AGENT_LABEL,- "ProgramArguments": program_arguments,+ "ProgramArguments": [launcher],"RunAtLoad": True,"StandardOutPath": str(stdout),"StandardErrorPath": str(stderr),@@ -82,12 +86,27 @@ def install_launch_agent(plist_path: Path | None = None,python_executable: Path | str | None = None,legacy_plist_path: Path | None = None,+ pixiepulse_legacy_plist_path: Path | None = None,+ launcher_path: Path | None = None,) -> LaunchAgentResult:target = plist_path or launch_agent_path()legacy_target = legacy_plist_path if legacy_plist_path is not None else (legacy_launch_agent_path() if plist_path is None else None)- plist = build_launch_agent_plist(python_executable=python_executable)+ pixiepulse_legacy_target = (+ pixiepulse_legacy_plist_path+ if pixiepulse_legacy_plist_path is not None+ else (pixiepulse_legacy_launch_agent_path() if plist_path is None else None)+ )+ launcher = launcher_path or status_bar_launcher_path()+ launcher_changed = install_status_bar_launcher(+ launcher,+ python_executable=python_executable,+ )+ plist = build_launch_agent_plist(+ python_executable=python_executable,+ launcher_path=launcher,+ )data = plistlib.dumps(plist, sort_keys=False)existing = target.read_bytes() if target.exists() else Nonechanged = existing != data@@ -99,7 +118,10 @@ def install_launch_agent(legacy_removed = Falseif legacy_target is not None:legacy_removed = remove_legacy_launch_agent(legacy_target)- changed = changed or legacy_removed+ pixiepulse_legacy_removed = False+ if pixiepulse_legacy_target is not None:+ pixiepulse_legacy_removed = remove_legacy_launch_agent(pixiepulse_legacy_target)+ changed = changed or legacy_removed or pixiepulse_legacy_removed or launcher_changedstarted = Falseif start:@@ -128,6 +150,42 @@ def uninstall_launch_agent(plist_path: Path | None = None) -> LaunchAgentResult:)+def install_status_bar_launcher(+ launcher_path: Path | None = None,+ *,+ python_executable: Path | str | None = None,+) -> bool:+ target = launcher_path or status_bar_launcher_path()+ script = build_status_bar_launcher_script(python_executable=python_executable)+ data = script.encode()+ existing = target.read_bytes() if target.exists() else None+ changed = existing != data+ target.parent.mkdir(parents=True, exist_ok=True)+ if changed:+ target.write_bytes(data)+ target.chmod(0o755)+ return changed+++def build_status_bar_launcher_script(+ python_executable: Path | str | None = None,+) -> str:+ executable = str(python_executable or sys.executable or "python3")+ if getattr(sys, "frozen", False) and python_executable is None:+ command = [executable, "status-bar", "start", "--foreground"]+ else:+ command = [executable, "-m", "sidepulse", "status-bar", "--foreground"]+ quoted = " ".join(shlex.quote(part) for part in command)+ return "\n".join(+ [+ "#!/bin/sh",+ "export PYTHONUNBUFFERED=1",+ f"exec {quoted}",+ "",+ ]+ )++def restart_launch_agent(plist_path: Path) -> None:bootout_launch_agent(plist_path)subprocess.run(@@ -162,6 +220,15 @@ def launch_domain() -> str:return f"gui/{os.getuid()}"+def default_user_data_dir(home: Path | None = None) -> Path:+ if home is None:+ xdg_data_home = os.environ.get("XDG_DATA_HOME")+ if xdg_data_home:+ return Path(xdg_data_home).expanduser()+ base = home or Path.home()+ return base / ".local" / "share"++def launch_agent_path_env(python_executable: str) -> str:candidates = [Path.home() / ".local" / "bin",diff --git a/tests/test_sidepulse.py b/tests/test_sidepulse.pyindex 971181e..c7da148 100644--- a/tests/test_sidepulse.py+++ b/tests/test_sidepulse.py@@ -106,6 +106,8 @@ from sidepulse.settings import (CLOSED_LID_AWAKE_AGENTS,CLOSED_LID_AWAKE_ALWAYS,CLOSED_LID_AWAKE_NEVER,+ DEFAULT_IDLE_TIMEOUT_SECONDS,+ DEFAULT_RECENT_SESSION_RETENTION_SECONDS,LID_ANIMATION_CLOSED,LID_ANIMATION_OPEN,LED_DISPLAY_CUSTOM,@@ -127,7 +129,9 @@ from sidepulse.settings import ()from sidepulse.status_bar_launch import (LAUNCH_AGENT_LABEL,+ STATUS_BAR_DISPLAY_NAME,build_launch_agent_plist,+ build_status_bar_launcher_script,install_launch_agent,launch_agent_installed,)@@ -1093,7 +1097,7 @@ class AgentMonitorTests(unittest.TestCase):agent_id="claude:session:old-done",display_name="old: Old done (old-done)",mode=AgentMode.COMPLETED,- updated_at=now - timedelta(minutes=25),+ updated_at=now - timedelta(hours=49),event_name="Stop",session_id="old-done",cwd="/Users/pero/pgit/old",@@ -1114,6 +1118,62 @@ class AgentMonitorTests(unittest.TestCase):["working", "recent-done"],)+ def test_status_bar_recent_statuses_keeps_last_ten_within_retention(self) -> None:+ try:+ from sidepulse import status_bar+ except SystemExit as exc:+ self.skipTest(str(exc))++ now = datetime.now(timezone.utc)+ stale_done = tuple(+ AgentStatus(+ provider="codex",+ agent_id=f"codex:session:done-{index}",+ display_name=f"project: Done {index} (done-{index})",+ mode=AgentMode.COMPLETED,+ updated_at=now - timedelta(hours=index),+ event_name="Stop",+ session_id=f"done-{index}",+ cwd="/Users/pero/pgit/project",+ stale=True,+ )+ for index in range(1, 13)+ )+ too_old = AgentStatus(+ provider="claude",+ agent_id="claude:session:too-old",+ display_name="old: Too old (too-old)",+ mode=AgentMode.COMPLETED,+ updated_at=now - timedelta(hours=50),+ event_name="Stop",+ session_id="too-old",+ cwd="/Users/pero/pgit/old",+ stale=True,+ )+ snapshot = MonitorSnapshot(+ aggregate=AggregateStatus(AgentMode.IDLE_READY, 0, 13, None),+ statuses=(),+ stale_statuses=(*stale_done, too_old),+ sources=(),+ collected_at=now,+ )++ statuses = status_bar.recent_statuses(+ snapshot,+ AgentMonitorSettings(recent_session_retention_seconds=48 * 60 * 60),+ )++ self.assertEqual(len(statuses), 10)+ self.assertEqual(statuses[0].session_id, "done-1")+ self.assertEqual(statuses[-1].session_id, "done-10")+ self.assertNotIn("too-old", [status.session_id for status in statuses])++ shorter = status_bar.recent_statuses(+ snapshot,+ AgentMonitorSettings(recent_session_retention_seconds=2.5 * 60 * 60),+ )+ self.assertEqual([status.session_id for status in shorter], ["done-1", "done-2"])+def test_codex_session_options_are_codex_specific(self) -> None:try:from sidepulse import status_bar@@ -1556,16 +1616,42 @@ class AgentMonitorTests(unittest.TestCase):if hasattr(view, "numberOfTabViewItems")]self.assertEqual(len(tab_views), 1)- self.assertEqual(tab_views[0].numberOfTabViewItems(), 4)+ self.assertEqual(tab_views[0].numberOfTabViewItems(), 5)self.assertIn("debug_log_status", target.settings_fields)self.assertIn("session_terminal", target.settings_fields)self.assertIn("custom_terminal_path", target.settings_fields)+ self.assertIn("recent_session_retention_hours", target.settings_fields)+ self.assertIn("idle_timeout_minutes", target.settings_fields)self.assertIn("closed_animation_program", target.settings_fields)self.assertIn("closed_animation_duration", target.settings_fields)self.assertIn("open_animation_program", target.settings_fields)self.assertIn("open_animation_duration", target.settings_fields)self.assertNotIn("closed_lid_system_override", target.settings_buttons)+ def test_status_bar_monitor_uses_idle_timeout_setting(self) -> None:+ try:+ from sidepulse import status_bar+ except SystemExit as exc:+ self.skipTest(str(exc))++ with tempfile.TemporaryDirectory() as tmp:+ fake = SimpleNamespace(+ settings=AgentMonitorSettings(idle_timeout_seconds=1234)+ )+ with (+ patch(+ "sidepulse.status_bar.default_event_socket_path",+ return_value=Path(tmp) / "events.sock",+ ),+ patch(+ "sidepulse.status_bar.default_latest_state_path",+ return_value=Path(tmp) / "latest.json",+ ),+ ):+ monitor = status_bar.StatusBarController.build_monitor(fake)++ self.assertEqual(monitor.stale_after_seconds, 1234)+def test_status_bar_setup_window_has_first_launch_controls(self) -> None:try:from sidepulse import status_bar@@ -2830,6 +2916,26 @@ class AgentMonitorTests(unittest.TestCase):self.assertEqual(helper.status_bar_command, "install-sleep-helper")self.assertTrue(helper.dry_run)+ def test_python_module_entrypoint_uses_sidepulse_cli(self) -> None:+ root = Path(__file__).resolve().parents[1]+ env = {+ **os.environ,+ "PYTHONPATH": str(root / "src"),+ }+ result = subprocess.run(+ [sys.executable, "-m", "sidepulse", "status-bar", "--help"],+ cwd=root,+ env=env,+ stdout=subprocess.PIPE,+ stderr=subprocess.PIPE,+ text=True,+ check=False,+ )++ self.assertEqual(result.returncode, 0, result.stderr)+ self.assertNotIn("Helo World", result.stdout)+ self.assertIn("Start/stop the menu-bar app", result.stdout)+def test_sidepulse_sdejectguard_command_shape(self) -> None:parser = cli_module.build_sidepulse_parser()@@ -3653,6 +3759,41 @@ class AgentMonitorTests(unittest.TestCase):self.assertEqual(save_settings(saved), settings_path)self.assertEqual(load_settings(), saved)+ def test_settings_round_trip_agent_list_timing(self) -> None:+ with tempfile.TemporaryDirectory() as tmp:+ settings_path = Path(tmp) / "settings.json"+ settings = AgentMonitorSettings().with_agent_list_timing(+ recent_session_retention_seconds=36 * 60 * 60,+ idle_timeout_seconds=15 * 60,+ )++ save_settings(settings, settings_path)+ loaded = load_settings(settings_path)++ self.assertEqual(+ AgentMonitorSettings().recent_session_retention_seconds,+ DEFAULT_RECENT_SESSION_RETENTION_SECONDS,+ )+ self.assertEqual(+ AgentMonitorSettings().idle_timeout_seconds,+ DEFAULT_IDLE_TIMEOUT_SECONDS,+ )+ self.assertEqual(loaded.recent_session_retention_seconds, 36 * 60 * 60)+ self.assertEqual(loaded.idle_timeout_seconds, 15 * 60)++ def test_settings_migrates_missing_agent_list_timing_to_defaults(self) -> None:+ with tempfile.TemporaryDirectory() as tmp:+ settings_path = Path(tmp) / "settings.json"+ settings_path.write_text(json.dumps({"led_display": "agent"}))++ loaded = load_settings(settings_path)++ self.assertEqual(+ loaded.recent_session_retention_seconds,+ DEFAULT_RECENT_SESSION_RETENTION_SECONDS,+ )+ self.assertEqual(loaded.idle_timeout_seconds, DEFAULT_IDLE_TIMEOUT_SECONDS)+def test_default_sources_respect_transcript_settings(self) -> None:settings = AgentMonitorSettings(codex_transcripts_enabled=False,@@ -3922,8 +4063,10 @@ class AgentMonitorTests(unittest.TestCase):self.assertIn("Remove", titles)def test_status_bar_launch_agent_plist_runs_foreground_command(self) -> None:+ launcher = Path("/tmp/SidePulse Status Bar")plist = build_launch_agent_plist(python_executable="/usr/bin/python3",+ launcher_path=launcher,stdout_path=Path("/tmp/sidepulse.out.log"),stderr_path=Path("/tmp/sidepulse.err.log"),)@@ -3931,19 +4074,19 @@ class AgentMonitorTests(unittest.TestCase):self.assertEqual(plist["Label"], LAUNCH_AGENT_LABEL)self.assertEqual(plist["ProgramArguments"],- [- "/usr/bin/python3",- "-m",- "sidepulse",- "status-bar",- "--foreground",- ],+ [str(launcher)],)self.assertTrue(plist["RunAtLoad"])self.assertEqual(plist["StandardOutPath"], "/tmp/sidepulse.out.log")self.assertEqual(plist["StandardErrorPath"], "/tmp/sidepulse.err.log")self.assertNotIn("KeepAlive", plist)+ def test_status_bar_launcher_uses_background_item_name(self) -> None:+ script = build_status_bar_launcher_script(python_executable="/usr/bin/python3")++ self.assertEqual(STATUS_BAR_DISPLAY_NAME, "SidePulse Status Bar")+ self.assertIn("exec /usr/bin/python3 -m sidepulse status-bar --foreground", script)+def test_status_bar_launch_agent_installed_checks_plist(self) -> None:with tempfile.TemporaryDirectory() as tmp:plist = Path(tmp) / "io.sidepulse.agentstatus.plist"@@ -3954,15 +4097,9 @@ class AgentMonitorTests(unittest.TestCase):def test_frozen_status_bar_launch_agent_uses_sidepulse_executable(self) -> None:with patch("sidepulse.status_bar_launch.sys.frozen", True, create=True):- plist = build_launch_agent_plist(- stdout_path=Path("/tmp/sidepulse.out.log"),- stderr_path=Path("/tmp/sidepulse.err.log"),- )+ script = build_status_bar_launcher_script()- self.assertEqual(- plist["ProgramArguments"],- [sys.executable, "status-bar", "start", "--foreground"],- )+ self.assertIn("status-bar start --foreground", script)def test_frozen_hook_command_uses_internal_cli(self) -> None:with patch("sidepulse.install.sys.frozen", True, create=True):@@ -4015,7 +4152,10 @@ class AgentMonitorTests(unittest.TestCase):base = Path(tmp)target = base / "io.sidepulse.agentstatus.plist"legacy = base / "com.sidepulse.agentstatus.plist"+ pixiepulse_legacy = base / "com.pixiepulse.agentstatus.plist"+ launcher = base / "SidePulse Status Bar"legacy.write_bytes(b"old")+ pixiepulse_legacy.write_bytes(b"old")with (patch("sidepulse.status_bar_launch.default_state_dir", return_value=base / "state"),@@ -4025,14 +4165,20 @@ class AgentMonitorTests(unittest.TestCase):start=False,plist_path=target,legacy_plist_path=legacy,+ pixiepulse_legacy_plist_path=pixiepulse_legacy,+ launcher_path=launcher,python_executable="/usr/bin/python3",)self.assertTrue(result.changed)self.assertTrue(target.exists())+ self.assertTrue(launcher.exists())+ self.assertEqual(plistlib.loads(target.read_bytes())["ProgramArguments"], [str(launcher)])self.assertFalse(legacy.exists())- run.assert_called_once()- self.assertEqual(run.call_args.args[0][0:2], ["launchctl", "bootout"])+ self.assertFalse(pixiepulse_legacy.exists())+ self.assertEqual(run.call_count, 2)+ self.assertEqual(run.call_args_list[0].args[0][0:2], ["launchctl", "bootout"])+ self.assertEqual(run.call_args_list[1].args[0][0:2], ["launchctl", "bootout"])def test_sd_eject_guard_plist_shapes_for_user_and_system_scopes(self) -> None:for scope in ("user", "system"):