chore: update ji local changes

This commit is contained in:
吉鑫升 committed 2026-06-03 18:57:49 +08:00
1 parent f590f672be
commit e2a962de32
9 files changed
+185 -38

No files matched your search

+17 -2
View File
@@ -62,6 +62,21 @@ export function textOfMessage(message: Message) {
return null;
}
export function titleOfThread(thread: AgentThread) {
return thread.values?.title ?? "Untitled";
export function titleOfThread(thread: AgentThread, fallback = "Untitled") {
const title = thread.values?.title;
if (title) return title;
// No title yet (e.g. the very first turn is still streaming, or the backend
// title pass hasn't finished). Derive a sensible display title from the first
// user message so the user never sees a bare "Untitled" placeholder.
const messages = thread.values?.messages;
if (Array.isArray(messages)) {
const firstHuman = messages.find((m) => m.type === "human");
const text = firstHuman ? textOfMessage(firstHuman)?.trim() : null;
if (text) {
return text.length > 50 ? `${text.slice(0, 50).trimEnd()}…` : text;
}
}
return fallback;
}