[verified] fix: emit UTC-offset last_active so the app can sort by recency

Session-store updated_at values are naive local datetimes; passing them
through without an offset broke Instant.parse() on the client, dropping
last_active and leaving the chat list unsorted after restart.
This commit is contained in:
2026-09-10 05:44:02 +00:00
parent aa705f7dd0
commit 416095a7f1
2 changed files with 29 additions and 0 deletions
+10
View File
@@ -210,6 +210,16 @@ def _iso(value: Any) -> Optional[str]:
try:
if isinstance(value, (int, float)):
return dt.datetime.fromtimestamp(value, tz=dt.timezone.utc).isoformat()
if isinstance(value, dt.datetime):
# Session-store timestamps are naive LOCAL datetimes (see
# gateway.session_lifecycle._now). The client parses with
# Instant.parse(), which requires an offset — a bare
# "2026-09-10T05:41:48" fails and last_active is lost, so the
# app can no longer sort by recency. Attach the local offset
# and normalize to UTC.
if value.tzinfo is None:
value = value.astimezone()
return value.astimezone(dt.timezone.utc).isoformat()
return value.isoformat() if value else None
except (AttributeError, OSError, OverflowError, TypeError, ValueError):
return None