mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-26 01:01:40 +00:00
fix: normalize imported session timestamps
OpenClaw session imports can leave ISO-8601 timestamps in SessionDB rows. Normalize legacy string timestamps before rendering or comparing session activity so session listing and resume surfaces do not crash on imported history.
This commit is contained in:
parent
88b6eb9ad1
commit
8d922ddadd
4 changed files with 81 additions and 0 deletions
10
tests/hermes_cli/test_relative_time.py
Normal file
10
tests/hermes_cli/test_relative_time.py
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
import time
|
||||
|
||||
from hermes_cli.main import _relative_time
|
||||
|
||||
|
||||
def test_relative_time_accepts_iso_timestamps():
|
||||
ts = time.time() - 7200
|
||||
iso = time.strftime("%Y-%m-%dT%H:%M:%S", time.localtime(ts))
|
||||
|
||||
assert _relative_time(iso) == "2h ago"
|
||||
|
|
@ -1438,6 +1438,22 @@ class TestListSessionsRich:
|
|||
# No messages, so last_active falls back to started_at
|
||||
assert sessions[0]["last_active"] == sessions[0]["started_at"]
|
||||
|
||||
def test_last_active_normalizes_legacy_iso_started_at(self, db):
|
||||
db.create_session("legacy", "cli")
|
||||
db._conn.execute(
|
||||
"UPDATE sessions SET started_at=?, ended_at=? WHERE id=?",
|
||||
("2026-04-09T12:00:00", "2026-04-09T13:00:00", "legacy"),
|
||||
)
|
||||
db._conn.commit()
|
||||
|
||||
sessions = db.list_sessions_rich()
|
||||
legacy = next(s for s in sessions if s["id"] == "legacy")
|
||||
|
||||
assert isinstance(legacy["started_at"], float)
|
||||
assert isinstance(legacy["ended_at"], float)
|
||||
assert isinstance(legacy["last_active"], float)
|
||||
assert legacy["last_active"] == legacy["started_at"]
|
||||
|
||||
def test_rich_list_includes_title(self, db):
|
||||
db.create_session("s1", "cli")
|
||||
db.set_session_title("s1", "refactoring auth")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue