JiuwenSwarm is an intelligent AI Agent built on openJiuwen. It extends the powerful capabilities of large language models directly to your fingertips through various communication apps you use daily.
Python
feat: 心跳id显示时间
Haowei_Du59fd4944ca4b
diff --git a/jiuwenclaw/gateway/heartbeat.py b/jiuwenclaw/gateway/heartbeat.pyindex 443a2759c2..b819ce3ec2 100644--- a/jiuwenclaw/gateway/heartbeat.py+++ b/jiuwenclaw/gateway/heartbeat.py@@ -10,6 +10,7 @@ import timefrom abc import ABC, abstractmethodfrom dataclasses import dataclassfrom typing import TYPE_CHECKING+import secretslogger = logging.getLogger(__name__)@@ -175,8 +176,10 @@ class GatewayHeartbeatService(IHeartbeat):)return- request_id = f"heartbeat-{time.monotonic_ns()}"- session_id = f"heartbeat_{time.monotonic_ns()}"+ ts = format(int(time.time() * 1000), "x")+ suffix = secrets.token_hex(3)+ request_id = f"heartbeat-{ts}_{suffix}"+ session_id = f"heartbeat_{ts}_{suffix}"envelope = e2a_from_agent_fields(request_id=request_id,channel_id=self._config.channel_id,diff --git a/jiuwenclaw/web/src/components/SessionsPanel/index.tsx b/jiuwenclaw/web/src/components/SessionsPanel/index.tsxindex 6a34621f72..125794f5d4 100644--- a/jiuwenclaw/web/src/components/SessionsPanel/index.tsx+++ b/jiuwenclaw/web/src/components/SessionsPanel/index.tsx@@ -108,8 +108,19 @@ function parseSessionDisplayLabel(sessionId: string, t: (key: string, options?:}if (sessionId.startsWith('heartbeat_')) {- const rawBody = sessionId.slice('heartbeat_'.length);- return rawBody ? `${t('sessions.prefixes.heartbeat')}-${rawBody}` : t('sessions.prefixes.heartbeat');+ // heartbeat_{hex_ms}_{suffix}+ const parts = sessionId.split('_');+ const hexTs = parts[1] ?? '';+ if (/^[0-9a-fA-F]+$/.test(hexTs)) {+ const ms = Number.parseInt(hexTs, 16);+ if (Number.isFinite(ms)) {+ const date = new Date(ms);+ if (!Number.isNaN(date.getTime()) && isPlausibleDate(date)) {+ return `${t('sessions.prefixes.heartbeat')}-${formatDateTime(date)}`;+ }+ }+ }+ return `${t('sessions.prefixes.heartbeat')}-${t('sessions.unknownTime')}`;}// discord_{channel_id}_{user_id} from Discord Channel (not hex timestamps)