From 96abcd12ec59bc017bb8a505ee4cc83cfa3e9515 Mon Sep 17 00:00:00 2001 From: cft0808 Date: Mon, 20 Apr 2026 00:25:18 +0800 Subject: [PATCH] fix: normalize timestamps in SessionsPanel and server lastActive (#278 cherry-pick) Cherry-pick the SessionsPanel.tsx and server.py fixes from PR #278 that were not covered by the merged #282: - SessionsPanel: use shared formatDashboardTime for activity timestamps - server.py: convert lastActive to local timezone in get_task_activity() --- dashboard/server.py | 13 ++++++++++++- edict/frontend/src/components/SessionsPanel.tsx | 3 ++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/dashboard/server.py b/dashboard/server.py index ddd648c..3e7651e 100644 --- a/dashboard/server.py +++ b/dashboard/server.py @@ -1978,13 +1978,24 @@ def get_task_activity(task_id): except Exception: pass + last_active = None + if updated_at: + try: + dt = _parse_iso(updated_at) + if dt: + last_active = dt.astimezone().strftime('%Y-%m-%d %H:%M:%S') + else: + last_active = updated_at[:19].replace('T', ' ') + except Exception: + last_active = updated_at[:19].replace('T', ' ') + result = { 'ok': True, 'taskId': task_id, 'taskMeta': task_meta, 'agentId': agent_id, 'agentLabel': _STATE_LABELS.get(state, state), - 'lastActive': updated_at[:19].replace('T', ' ') if updated_at else None, + 'lastActive': last_active, 'activity': activity, 'activitySource': 'progress+session', 'relatedAgents': sorted(list(related_agents)), diff --git a/edict/frontend/src/components/SessionsPanel.tsx b/edict/frontend/src/components/SessionsPanel.tsx index e295990..01a576f 100644 --- a/edict/frontend/src/components/SessionsPanel.tsx +++ b/edict/frontend/src/components/SessionsPanel.tsx @@ -1,6 +1,7 @@ import { useStore, isEdict, STATE_LABEL, timeAgo } from '../store'; import type { Task } from '../api'; import { useState } from 'react'; +import { formatDashboardTime } from '../time'; // Agent maps built from agentConfig function useAgentMaps() { @@ -231,7 +232,7 @@ function SessionDetailModal({ const kLabel = kind === 'assistant' ? '回复' : kind === 'tool' ? '工具' : kind === 'user' ? '用户' : '事件'; let txt = (a.text || '').replace(/\[\[.*?\]\]/g, '').replace(/\*\*/g, '').trim(); if (txt.length > 200) txt = txt.substring(0, 200) + '…'; - const time = ((a.at as string) || '').substring(11, 19); + const time = formatDashboardTime(a.at as string | number | undefined, { showSeconds: true }); return (