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
fix(web): 支持 TUI 会话前缀并改进时间戳解析,修复 #1479
ray_lef812e5190fbb
diff --git a/jiuwenswarm/channels/web/frontend/src/components/SessionsPanel/index.tsx b/jiuwenswarm/channels/web/frontend/src/components/SessionsPanel/index.tsxindex b13938ce0f..7de6943d6e 100644--- a/jiuwenswarm/channels/web/frontend/src/components/SessionsPanel/index.tsx+++ b/jiuwenswarm/channels/web/frontend/src/components/SessionsPanel/index.tsx@@ -83,8 +83,8 @@ function parseSessionDisplayLabel(sessionId: string, t: (key: string, options?:return `${wechatLabel}-${shortenDiscordIDForLabel(idPart)}`;}- // 处理以 sess_、cron_、feishu_、wechat_、xiaoyi_、dingtalk_ 开头的会话ID- const prefixes = ['sess_', 'cron_', 'feishu_', 'wechat_', 'xiaoyi_', 'dingtalk_', 'wecom_'];+ // 处理以 sess_、cron_、feishu_、wechat_、xiaoyi_、dingtalk_、tui_ 开头的会话ID+ const prefixes = ['sess_', 'cron_', 'feishu_', 'wechat_', 'xiaoyi_', 'dingtalk_', 'wecom_', 'tui_'];const prefixMap: Record<string, string> = {'sess_': t('sessions.prefixes.session'),'cron_': t('sessions.prefixes.cron'),@@ -92,17 +92,24 @@ function parseSessionDisplayLabel(sessionId: string, t: (key: string, options?:'wechat_': t('sessions.prefixes.wechat'),'xiaoyi_': t('sessions.prefixes.xiaoyi'),'dingtalk_': t('sessions.prefixes.dingtalk'),- 'wecom_': t('sessions.prefixes.wecom')+ 'wecom_': t('sessions.prefixes.wecom'),+ 'tui_': t('sessions.prefixes.tui')};-+for (const prefix of prefixes) {if (sessionId.startsWith(prefix)) {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);+ const raw = Number.parseInt(hexTs, 16);+ if (Number.isFinite(raw)) {+ // 先尝试将 hex 解析为毫秒+ let date = new Date(raw);+ if (!Number.isNaN(date.getTime()) && isPlausibleDate(date)) {+ return `${prefixMap[prefix]}-${formatDateTime(date)}`;+ }+ // 若毫秒解析失败(如 TUI 会话使用秒级时间戳),尝试将 hex 解析为秒后转毫秒+ date = new Date(raw * 1000);if (!Number.isNaN(date.getTime()) && isPlausibleDate(date)) {return `${prefixMap[prefix]}-${formatDateTime(date)}`;}diff --git a/jiuwenswarm/channels/web/frontend/src/i18n/locales/en.json b/jiuwenswarm/channels/web/frontend/src/i18n/locales/en.jsonindex ed8fd36d36..43223d6453 100644--- a/jiuwenswarm/channels/web/frontend/src/i18n/locales/en.json+++ b/jiuwenswarm/channels/web/frontend/src/i18n/locales/en.json@@ -385,6 +385,7 @@"wechat": "WeChat","discord": "Discord","heartbeat": "Heartbeat",+ "tui": "TUI","unknown": "Unknown"},"errors": {diff --git a/jiuwenswarm/channels/web/frontend/src/i18n/locales/zh.json b/jiuwenswarm/channels/web/frontend/src/i18n/locales/zh.jsonindex 182d719a55..9c790f718a 100644--- a/jiuwenswarm/channels/web/frontend/src/i18n/locales/zh.json+++ b/jiuwenswarm/channels/web/frontend/src/i18n/locales/zh.json@@ -385,6 +385,7 @@"wechat": "微信","discord": "Discord","heartbeat": "心跳",+ "tui": "TUI","unknown": "未知"},"errors": {