fix: ignore generic user session titles (#1288)
This commit is contained in:
@@ -33,6 +33,7 @@ export interface ProviderProfileOption {
|
|||||||
export const RECENT_DRAFTS_STORAGE_KEY = "hwlab.workbench.recentDrafts.v1";
|
export const RECENT_DRAFTS_STORAGE_KEY = "hwlab.workbench.recentDrafts.v1";
|
||||||
export const RECENT_DRAFTS_LIMIT = 8;
|
export const RECENT_DRAFTS_LIMIT = 8;
|
||||||
const OBJECT_OBJECT_TEXT = "[object Object]";
|
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_ORDER = Object.freeze(["deepseek", "dsflash-go", "codex-api", "minimax-m3"]);
|
||||||
const BUILTIN_PROVIDER_PROFILE_LABELS: Readonly<Record<string, string>> = Object.freeze({
|
const BUILTIN_PROVIDER_PROFILE_LABELS: Readonly<Record<string, string>> = Object.freeze({
|
||||||
@@ -99,7 +100,6 @@ export function conversationToSessionTab(conversation: ConversationRecord, activ
|
|||||||
conversation.userPreview,
|
conversation.userPreview,
|
||||||
userMessage?.text,
|
userMessage?.text,
|
||||||
userMessage?.content,
|
userMessage?.content,
|
||||||
userMessage?.title,
|
|
||||||
conversation.title,
|
conversation.title,
|
||||||
conversation.name
|
conversation.name
|
||||||
);
|
);
|
||||||
@@ -244,7 +244,7 @@ function readableSentence(value: unknown): string | null {
|
|||||||
|
|
||||||
function firstSentenceFromText(value: string): 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();
|
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 = [
|
const candidates = [
|
||||||
sentenceBoundary(normalized, /[。!?!?]/u, 1),
|
sentenceBoundary(normalized, /[。!?!?]/u, 1),
|
||||||
sentenceBoundary(normalized, /\.(?=\s|$)/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");
|
].filter((index): index is number => typeof index === "number");
|
||||||
const end = candidates.length > 0 ? Math.min(...candidates) : normalized.length;
|
const end = candidates.length > 0 ? Math.min(...candidates) : normalized.length;
|
||||||
const text = normalized.slice(0, end).replace(/\s+/gu, " ").trim();
|
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 {
|
function sentenceBoundary(value: string, pattern: RegExp, offset: number): number | null {
|
||||||
|
|||||||
Reference in New Issue
Block a user