fix(webui): name temporary chats from first message

This commit is contained in:
chengyongru authored and Xubin Ren committed 2026-08-08 23:20:59 +08:00
1 parent 516ae11c33
commit 8e04f12720
5 files changed
+20 -6

No files matched your search

+9
View File
@@ -2,6 +2,15 @@ import type { ChatSummary } from "./types";
const WEBSOCKET_SESSION_KEY_PREFIX = "websocket:";
export function deriveTemporaryChatTitle(
firstMessage: string | undefined,
fallback: string,
): string {
const oneLine = firstMessage?.replace(/\s+/g, " ").trim() ?? "";
if (!oneLine) return fallback;
return oneLine.length > 60 ? `${oneLine.slice(0, 57)}…` : oneLine;
}
export function createTemporaryChatSession(chatId: string): ChatSummary {
const now = new Date().toISOString();
return {