From 57c34a324c03566bc971b09912a801457c76c99a Mon Sep 17 00:00:00 2001 From: Tyler Yust Date: Fri, 30 Jan 2026 14:59:08 -0800 Subject: [PATCH] UI: introduce active minutes constant for chat sessions and enhance session display names --- ui/src/ui/app-chat.ts | 6 +++++- ui/src/ui/app-gateway.ts | 6 ++++-- ui/src/ui/app-render.helpers.ts | 26 +++++++++++++++++++++++--- 3 files changed, 32 insertions(+), 6 deletions(-) diff --git a/ui/src/ui/app-chat.ts b/ui/src/ui/app-chat.ts index 8d3262c5c..835f01a15 100644 --- a/ui/src/ui/app-chat.ts +++ b/ui/src/ui/app-chat.ts @@ -24,6 +24,8 @@ type ChatHost = { refreshSessionsAfterChat: Set; }; +export const CHAT_SESSIONS_ACTIVE_MINUTES = 10; + export function isChatBusy(host: ChatHost) { return host.chatSending || Boolean(host.chatRunId); } @@ -180,7 +182,9 @@ export async function handleSendChat( export async function refreshChat(host: ChatHost) { await Promise.all([ loadChatHistory(host as unknown as OpenClawApp), - loadSessions(host as unknown as OpenClawApp, { activeMinutes: 0 }), + loadSessions(host as unknown as OpenClawApp, { + activeMinutes: CHAT_SESSIONS_ACTIVE_MINUTES, + }), refreshChatAvatar(host), ]); scheduleChatScroll(host as unknown as Parameters[0], true); diff --git a/ui/src/ui/app-gateway.ts b/ui/src/ui/app-gateway.ts index fe156470a..1d0a5142e 100644 --- a/ui/src/ui/app-gateway.ts +++ b/ui/src/ui/app-gateway.ts @@ -9,7 +9,7 @@ import type { AgentsListResult, PresenceEntry, HealthSnapshot, StatusSummary } f import type { Tab } from "./navigation"; import type { UiSettings } from "./storage"; import { handleAgentEvent, resetToolStream, type AgentEventPayload } from "./app-tool-stream"; -import { flushChatQueueForEvent } from "./app-chat"; +import { CHAT_SESSIONS_ACTIVE_MINUTES, flushChatQueueForEvent } from "./app-chat"; import { applySettings, loadCron, @@ -200,7 +200,9 @@ function handleGatewayEventUnsafe(host: GatewayHost, evt: GatewayEventFrame) { if (runId && host.refreshSessionsAfterChat.has(runId)) { host.refreshSessionsAfterChat.delete(runId); if (state === "final") { - void loadSessions(host as unknown as OpenClawApp, { activeMinutes: 0 }); + void loadSessions(host as unknown as OpenClawApp, { + activeMinutes: CHAT_SESSIONS_ACTIVE_MINUTES, + }); } } } diff --git a/ui/src/ui/app-render.helpers.ts b/ui/src/ui/app-render.helpers.ts index c2190e1c9..8ea2e7b04 100644 --- a/ui/src/ui/app-render.helpers.ts +++ b/ui/src/ui/app-render.helpers.ts @@ -156,6 +156,17 @@ function resolveMainSessionKey( return null; } +function resolveSessionDisplayName( + key: string, + row?: SessionsListResult["sessions"][number], +) { + const label = row?.label?.trim(); + if (label) return `${label} (${key})`; + const displayName = row?.displayName?.trim(); + if (displayName) return displayName; + return key; +} + function resolveSessionOptions( sessionKey: string, sessions: SessionsListResult | null, @@ -171,13 +182,19 @@ function resolveSessionOptions( // Add main session key first if (mainSessionKey) { seen.add(mainSessionKey); - options.push({ key: mainSessionKey, displayName: resolvedMain?.displayName }); + options.push({ + key: mainSessionKey, + displayName: resolveSessionDisplayName(mainSessionKey, resolvedMain), + }); } // Add current session key next if (!seen.has(sessionKey)) { seen.add(sessionKey); - options.push({ key: sessionKey, displayName: resolvedCurrent?.displayName }); + options.push({ + key: sessionKey, + displayName: resolveSessionDisplayName(sessionKey, resolvedCurrent), + }); } // Add sessions from the result @@ -185,7 +202,10 @@ function resolveSessionOptions( for (const s of sessions.sessions) { if (!seen.has(s.key)) { seen.add(s.key); - options.push({ key: s.key, displayName: s.displayName }); + options.push({ + key: s.key, + displayName: resolveSessionDisplayName(s.key, s), + }); } } }