Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions frontend/app/analyze/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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}`)
}
Expand Down
1 change: 1 addition & 0 deletions frontend/app/search/[bmid]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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}`)
}
Expand Down
7 changes: 7 additions & 0 deletions frontend/components/ChatBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -111,6 +115,7 @@ export const ChatBox: React.FC<ChatBoxProps> = ({
surface,
contextId,
conversationId,
conversationTitle,
onConversationSaved,
}) => {
const chatHistory = useChatHistory();
Expand Down Expand Up @@ -259,6 +264,7 @@ export const ChatBox: React.FC<ChatBoxProps> = ({
contextId,
seedMessages: existingId ? [] : localSeedMessages.map(toStoredMessage),
userContent: msg,
title: conversationTitle,
fetcher: (token, signal) =>
fetch(`${process.env.NEXT_PUBLIC_API_URL}/query`, {
method: "POST",
Expand Down Expand Up @@ -296,6 +302,7 @@ export const ChatBox: React.FC<ChatBoxProps> = ({
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(
Expand Down
8 changes: 7 additions & 1 deletion frontend/hooks/use-chat-history.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand Down
Loading