feat(tui): clarify monitoring continuity and quitting
This commit is contained in:
+54
-1
@@ -449,7 +449,7 @@ def _format_headline(proj) -> str:
|
||||
|
||||
|
||||
def _append_service_facts(lines: List[str], service: Dict[str, Any]) -> None:
|
||||
"""Append the four separate service facts (§7.3, LC-9)."""
|
||||
"""Append service facts and dashboard-clarity monitoring state."""
|
||||
boot = "enabled" if service.get("boot_enabled") else "disabled"
|
||||
activity = "active" if service.get("timer_active") else "inactive"
|
||||
|
||||
@@ -473,6 +473,55 @@ def _append_service_facts(lines: List[str], service: Dict[str, Any]) -> None:
|
||||
|
||||
lines.append("boot: %s · timer: %s · last collect: %s%s · freshness: %s%s"
|
||||
% (boot, activity, collect, collect_age, freshness_str, freshness_age))
|
||||
lines.append("CONTINUITY: %s" % monitoring_continuity(service))
|
||||
if service.get("deliberately_paused"):
|
||||
lines.extend(deliberate_pause_lines())
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Dashboard clarity parity wording (DC-2, DC-3)
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
_CONTINUITY_ACTIVE = "monitoring: active in background · persists across reboots"
|
||||
_CONTINUITY_DISABLED = "monitoring: does not start on next boot"
|
||||
_PAUSED_TITLE = "monitoring: paused — deliberate disable"
|
||||
_PAUSED_CONSEQUENCE = (
|
||||
"paused time is excluded from your usage habit · resume: fenris monitor resume"
|
||||
)
|
||||
|
||||
|
||||
def monitoring_continuity(service: Dict[str, Any]) -> str:
|
||||
"""Return the boot-persistence wording, independent of timer runtime."""
|
||||
return _CONTINUITY_ACTIVE if service.get("boot_enabled") else _CONTINUITY_DISABLED
|
||||
|
||||
|
||||
def deliberate_pause_lines() -> List[str]:
|
||||
"""Return the exact CLI/TUI presentation for a sanctioned pause."""
|
||||
return [_PAUSED_TITLE, _PAUSED_CONSEQUENCE]
|
||||
|
||||
|
||||
def is_deliberately_paused(conn: sqlite3.Connection, service: Dict[str, Any]) -> bool:
|
||||
"""Whether the latest closed period was ended by Fenris's own pause path.
|
||||
|
||||
Raw systemd operations have no `user_disabled` row, so they must never be
|
||||
presented as a Deliberate disable. A live enabled timer also wins over a
|
||||
stale period marker, keeping the presentation consistent with service facts.
|
||||
"""
|
||||
if service.get("boot_enabled") or service.get("timer_active"):
|
||||
return False
|
||||
|
||||
open_period = conn.execute(
|
||||
"SELECT 1 FROM monitoring_periods WHERE ended_at IS NULL LIMIT 1"
|
||||
).fetchone()
|
||||
if open_period is not None:
|
||||
return False
|
||||
|
||||
row = conn.execute(
|
||||
"SELECT end_cause FROM monitoring_periods "
|
||||
"WHERE ended_at IS NOT NULL "
|
||||
"ORDER BY ended_at DESC, id DESC LIMIT 1"
|
||||
).fetchone()
|
||||
return row is not None and row[0] == "user_disabled"
|
||||
|
||||
|
||||
def format_disclosures() -> str:
|
||||
@@ -562,6 +611,10 @@ def get_status(store_path: Optional[Path] = None, clock_now: Optional[datetime]
|
||||
|
||||
service["freshness"] = freshness
|
||||
service["freshness_age_s"] = freshness_age_s
|
||||
try:
|
||||
service["deliberately_paused"] = is_deliberately_paused(conn, service)
|
||||
except sqlite3.Error:
|
||||
service["deliberately_paused"] = False
|
||||
|
||||
# --- Drive anomalies (§9.7, FL-7) ---
|
||||
drive_facts = []
|
||||
|
||||
Reference in New Issue
Block a user