Files
Hermes-ui/packages/client/src/shared/session-display.ts
T
Zhicheng Han 3f88553765 feat(web-ui): add pinned sessions and live monitor in Chat (#118)
* feat: add single-page live session monitor and chat pinning

* fix: restore full test green after main merge

* fix: use Array.from instead of Set spread for ts-node compatibility

[...new Set()] requires downlevelIteration which isn't enabled in
ts-node dev mode, causing sonic-boom crash on startup.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: ekko <fqsy1416@gmail.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-22 08:09:58 +08:00

39 lines
1010 B
TypeScript

const SOURCE_LABELS: Record<string, string> = {
telegram: 'Telegram',
api_server: 'API Server',
cli: 'CLI',
discord: 'Discord',
slack: 'Slack',
matrix: 'Matrix',
whatsapp: 'WhatsApp',
signal: 'Signal',
email: 'Email',
sms: 'SMS',
dingtalk: 'DingTalk',
feishu: 'Feishu',
wecom: 'WeCom',
weixin: 'WeChat',
bluebubbles: 'iMessage',
mattermost: 'Mattermost',
cron: 'Cron',
}
export function getSourceLabel(source?: string): string {
if (!source) return ''
return SOURCE_LABELS[source] || source
}
export function formatTimestampMs(timestamp: number): string {
if (!timestamp) return ''
const date = new Date(timestamp)
const now = new Date()
if (date.toDateString() === now.toDateString()) {
return date.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })
}
return date.toLocaleDateString([], { month: 'short', day: 'numeric' })
}
export function formatTimestampSeconds(timestamp: number): string {
return formatTimestampMs(timestamp * 1000)
}