chore: round-2 review nits (re-review #9)
- tests/agent/test_session_activity.py asserts against ACTIVITY_DESCRIPTION_MAX instead of the literal 120. - The session-stall WARNING log line names its config knob (agent.session_stall_timeout) so operators can find the setting. - hermes_state.py: collapse the triple blank line near line 191. - hermes_cli/status.py no longer imports the private hermes_cli.main._relative_time: the helper moved to a public home (hermes_cli.timefmt.relative_time); main._relative_time stays as a thin back-compat wrapper (sessions_cmd and external patchers keep working).
This commit is contained in:
+9
-15
@@ -944,21 +944,15 @@ def _termux_should_prefetch_update_check() -> bool:
|
||||
|
||||
|
||||
def _relative_time(ts) -> str:
|
||||
"""Format a timestamp as relative time (e.g., '2h ago', 'yesterday')."""
|
||||
if not ts:
|
||||
return "?"
|
||||
delta = _time.time() - ts
|
||||
if delta < 60:
|
||||
return "just now"
|
||||
if delta < 3600:
|
||||
return f"{int(delta / 60)}m ago"
|
||||
if delta < 86400:
|
||||
return f"{int(delta / 3600)}h ago"
|
||||
if delta < 172800:
|
||||
return "yesterday"
|
||||
if delta < 604800:
|
||||
return f"{int(delta / 86400)}d ago"
|
||||
return datetime.fromtimestamp(ts).strftime("%Y-%m-%d")
|
||||
"""Format a timestamp as relative time (e.g., '2h ago', 'yesterday').
|
||||
|
||||
Thin wrapper kept for backward compatibility; the implementation lives
|
||||
in :mod:`hermes_cli.timefmt` so lightweight consumers don't have to
|
||||
import the whole CLI surface.
|
||||
"""
|
||||
from hermes_cli.timefmt import relative_time
|
||||
|
||||
return relative_time(ts)
|
||||
|
||||
|
||||
def _has_any_provider_configured() -> bool:
|
||||
|
||||
@@ -65,9 +65,9 @@ def _format_iso_timestamp(value) -> str:
|
||||
|
||||
def _format_relative_ts(ts: float) -> str:
|
||||
"""Format an epoch timestamp as a short relative age for status output."""
|
||||
from hermes_cli.main import _relative_time
|
||||
from hermes_cli.timefmt import relative_time
|
||||
|
||||
return _relative_time(ts)
|
||||
return relative_time(ts)
|
||||
|
||||
|
||||
def _configured_model_label(config: dict) -> str:
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
"""Small shared time-formatting helpers for CLI output.
|
||||
|
||||
Public home for helpers that used to live as private functions on
|
||||
``hermes_cli.main`` — importing that module drags in the whole CLI
|
||||
surface, which lightweight consumers (``hermes status``, dump tooling)
|
||||
should not pay for.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import time as _time
|
||||
from datetime import datetime
|
||||
|
||||
|
||||
def relative_time(ts) -> str:
|
||||
"""Format a timestamp as relative time (e.g., '2h ago', 'yesterday')."""
|
||||
if not ts:
|
||||
return "?"
|
||||
delta = _time.time() - ts
|
||||
if delta < 60:
|
||||
return "just now"
|
||||
if delta < 3600:
|
||||
return f"{int(delta / 60)}m ago"
|
||||
if delta < 86400:
|
||||
return f"{int(delta / 3600)}h ago"
|
||||
if delta < 172800:
|
||||
return "yesterday"
|
||||
if delta < 604800:
|
||||
return f"{int(delta / 86400)}d ago"
|
||||
return datetime.fromtimestamp(ts).strftime("%Y-%m-%d")
|
||||
Reference in New Issue
Block a user