[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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user