From 028b8986d17561d07fe2fb5ca04d85f25063eac9 Mon Sep 17 00:00:00 2001 From: "Bingxi Zhao (Frank)" <13051345080@163.com> Date: Mon, 31 Aug 2026 18:20:13 +0800 Subject: [PATCH] fix(web): reuse shared localized session title formatter --- web/components/chat/MyAgentsPicker.tsx | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/web/components/chat/MyAgentsPicker.tsx b/web/components/chat/MyAgentsPicker.tsx index 128452afd..9e12c8031 100644 --- a/web/components/chat/MyAgentsPicker.tsx +++ b/web/components/chat/MyAgentsPicker.tsx @@ -1,6 +1,6 @@ "use client"; -import { useEffect, useMemo, useState } from "react"; +import { useCallback, useEffect, useMemo, useState } from "react"; import { ArrowLeft, Bot, @@ -39,7 +39,7 @@ import { readImportMeta, } from "@/lib/chat-import/attribution"; import { normalizeMessageContent, truncateText } from "@/lib/message-content"; -import { isPlaceholderSessionTitle } from "@/lib/session-title"; +import { displaySessionTitle } from "@/lib/session-title"; interface MyAgentsPickerProps { open: boolean; @@ -107,10 +107,6 @@ function isoMs(value: string | undefined): number { return Number.isNaN(ms) ? 0 : ms; } -function formatSessionRowTitle(title: string, placeholderLabel: string): string { - return isPlaceholderSessionTitle(title) ? placeholderLabel : title.trim(); -} - /** * Reference picker for agent conversations. Two sources feed one unified list: * imported Claude Code / Codex conversations (stored as normal sessions, so a @@ -130,8 +126,10 @@ export default function MyAgentsPicker({ // Backend writes the English sentinel "New conversation" until the LLM title // lands; mirror SessionList with a localized "New chat" label. const placeholderLabel = t("New chat"); - const formatRowTitle = (title: string) => - formatSessionRowTitle(title, placeholderLabel); + const formatRowTitle = useCallback( + (title: string) => displaySessionTitle(title, placeholderLabel), + [placeholderLabel], + ); const [sessions, setSessions] = useState< Awaited> >([]); @@ -343,13 +341,13 @@ export default function MyAgentsPicker({ map.set(row.groupKey, group); } return Array.from(map.values()).sort((a, b) => b.latest - a.latest); - }, [rows, activeAgent, query, placeholderLabel]); + }, [rows, activeAgent, query, formatRowTitle]); const titleById = useMemo(() => { const map = new Map(); for (const row of rows) map.set(row.id, formatRowTitle(row.title)); return map; - }, [rows, placeholderLabel]); + }, [rows, formatRowTitle]); const toggleSession = (id: string) => setSelectedIds((prev) => @@ -703,7 +701,7 @@ function PreviewPane({
- {formatSessionRowTitle(row.title, placeholderLabel)} + {displaySessionTitle(row.title, placeholderLabel)}
{row.messageCount || visible.length} {t("messages")}