From 06a15a8056d2bc9075232c41d620b8df19ff8600 Mon Sep 17 00:00:00 2001 From: kartik Date: Wed, 26 Aug 2026 19:15:06 +0530 Subject: [PATCH] title search/analyze conversations with the biomodel name instead of the first message --- frontend/app/analyze/[id]/page.tsx | 1 + frontend/app/search/[bmid]/page.tsx | 1 + frontend/components/ChatBox.tsx | 7 +++++++ frontend/hooks/use-chat-history.tsx | 8 +++++++- 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/frontend/app/analyze/[id]/page.tsx b/frontend/app/analyze/[id]/page.tsx index d177d35..aa3ddf5 100644 --- a/frontend/app/analyze/[id]/page.tsx +++ b/frontend/app/analyze/[id]/page.tsx @@ -389,6 +389,7 @@ export default function AnalysisResultsPage({ surface="analyze" contextId={id} conversationId={conversationId} + conversationTitle={biomodelData?.name || `Biomodel ${id}`} onConversationSaved={(newId) => router.replace(`/analyze/${id}?c=${newId}`) } diff --git a/frontend/app/search/[bmid]/page.tsx b/frontend/app/search/[bmid]/page.tsx index 3cd916b..eff28da 100644 --- a/frontend/app/search/[bmid]/page.tsx +++ b/frontend/app/search/[bmid]/page.tsx @@ -527,6 +527,7 @@ export default function BiomodelDetailPage() { surface="search" contextId={data.bmKey} conversationId={conversationId} + conversationTitle={data.name} onConversationSaved={(id) => router.replace(`/search/${data.bmKey}?c=${id}`) } diff --git a/frontend/components/ChatBox.tsx b/frontend/components/ChatBox.tsx index c452993..9a4c832 100644 --- a/frontend/components/ChatBox.tsx +++ b/frontend/components/ChatBox.tsx @@ -59,6 +59,10 @@ interface ChatBoxProps { surface: ConversationSurface; contextId?: string; conversationId?: string | null; + // Title for a newly-created conversation (e.g. the biomodel name on the + // search/analyze surfaces). Falls back to the user's first message when + // omitted, as on plain /chat. + conversationTitle?: string; onConversationSaved?: (id: string) => void; } @@ -111,6 +115,7 @@ export const ChatBox: React.FC = ({ surface, contextId, conversationId, + conversationTitle, onConversationSaved, }) => { const chatHistory = useChatHistory(); @@ -259,6 +264,7 @@ export const ChatBox: React.FC = ({ contextId, seedMessages: existingId ? [] : localSeedMessages.map(toStoredMessage), userContent: msg, + title: conversationTitle, fetcher: (token, signal) => fetch(`${process.env.NEXT_PUBLIC_API_URL}/query`, { method: "POST", @@ -296,6 +302,7 @@ export const ChatBox: React.FC = ({ contextId, seedMessages: existingId ? [] : localSeedMessages.map(toStoredMessage), userContent: displayText, + title: conversationTitle, fetcher: (token, signal) => fetch( `${process.env.NEXT_PUBLIC_API_URL}/query/faq/${faqId}?${new URLSearchParams( diff --git a/frontend/hooks/use-chat-history.tsx b/frontend/hooks/use-chat-history.tsx index 43ef994..3902075 100644 --- a/frontend/hooks/use-chat-history.tsx +++ b/frontend/hooks/use-chat-history.tsx @@ -32,6 +32,9 @@ interface SendMessageParams { // (e.g. the welcome text) alongside the new user turn. seedMessages: StoredMessage[]; userContent: string; + // Only used when conversationId is null, as the new conversation's title. + // Falls back to the user's message when omitted (e.g. plain /chat). + title?: string; fetcher: ( token: string | undefined, signal: AbortSignal, @@ -141,7 +144,10 @@ export function ChatHistoryProvider({ const conversation = buildConversation({ surface: params.surface, contextId: params.contextId, - title: params.userContent.trim() || "New conversation", + title: + params.title?.trim() || + params.userContent.trim() || + "New conversation", messages: [...params.seedMessages, userMessage], }); id = conversation.id;