From b9b312f27b76d6d503e16fad77b38b0a20d3432b Mon Sep 17 00:00:00 2001 From: Lyon <88232613+pikasTech@users.noreply.github.com> Date: Mon, 15 Jun 2026 22:29:33 +0800 Subject: [PATCH] fix: ignore generic user session titles (#1288) --- web/hwlab-cloud-web/src/stores/workbench-session.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/web/hwlab-cloud-web/src/stores/workbench-session.ts b/web/hwlab-cloud-web/src/stores/workbench-session.ts index 37d8d13e..3620e025 100644 --- a/web/hwlab-cloud-web/src/stores/workbench-session.ts +++ b/web/hwlab-cloud-web/src/stores/workbench-session.ts @@ -33,6 +33,7 @@ export interface ProviderProfileOption { export const RECENT_DRAFTS_STORAGE_KEY = "hwlab.workbench.recentDrafts.v1"; export const RECENT_DRAFTS_LIMIT = 8; const OBJECT_OBJECT_TEXT = "[object Object]"; +const GENERIC_USER_TITLE_TEXT = "用户"; const BUILTIN_PROVIDER_PROFILE_ORDER = Object.freeze(["deepseek", "dsflash-go", "codex-api", "minimax-m3"]); const BUILTIN_PROVIDER_PROFILE_LABELS: Readonly> = Object.freeze({ @@ -99,7 +100,6 @@ export function conversationToSessionTab(conversation: ConversationRecord, activ conversation.userPreview, userMessage?.text, userMessage?.content, - userMessage?.title, conversation.title, conversation.name ); @@ -244,7 +244,7 @@ function readableSentence(value: unknown): string | null { function firstSentenceFromText(value: string): string | null { const normalized = value.replace(/\u0000/gu, " ").replace(/\r\n|\r/gu, "\n").replace(/[\t\f\v ]+/gu, " ").trim(); - if (!normalized || normalized === OBJECT_OBJECT_TEXT) return null; + if (!normalized || normalized === OBJECT_OBJECT_TEXT || normalized === GENERIC_USER_TITLE_TEXT) return null; const candidates = [ sentenceBoundary(normalized, /[。!?!?]/u, 1), sentenceBoundary(normalized, /\.(?=\s|$)/u, 1), @@ -252,7 +252,7 @@ function firstSentenceFromText(value: string): string | null { ].filter((index): index is number => typeof index === "number"); const end = candidates.length > 0 ? Math.min(...candidates) : normalized.length; const text = normalized.slice(0, end).replace(/\s+/gu, " ").trim(); - return text && text !== OBJECT_OBJECT_TEXT ? text : null; + return text && text !== OBJECT_OBJECT_TEXT && text !== GENERIC_USER_TITLE_TEXT ? text : null; } function sentenceBoundary(value: string, pattern: RegExp, offset: number): number | null {