Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
2 changes: 1 addition & 1 deletion backend/backend/application/context/llm_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ def process_prompt(self, sid: str, channel_id: str, chat_id: str, chat_message_i
check_oss_api_key_configured()

self.persist_prompt_status(chat_message_id=chat_message_id, status=ChatMessageStatus.RUNNING)
content = "Preparing database information..."
content = "Gathering context..."
self.send_and_persist_thought_chain(
sid=sid,
channel_id=channel_id,
Expand Down
68 changes: 16 additions & 52 deletions frontend/src/ide/chat-ai/Conversation.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import PropTypes from "prop-types";
import { Alert, Divider, Space } from "antd";

import { PromptInfo } from "./PromptInfo";
import { EnhancedPromptInfo } from "./EnhancedPromptInfo";
import { MarkdownView } from "./MarkdownView";
import { UserPrompt } from "./UserPrompt";
import { useUserStore } from "../../store/user-store";
Expand Down Expand Up @@ -67,36 +66,11 @@ const Conversation = memo(function Conversation({
return null;
}, [detectedAction]);

// Derive display names from IDs
const llmModelDisplayName = useMemo(() => {
return llmModels.find((m) => m?.model === message?.llm_model_architect)
?.display_name;
}, [llmModels, message?.llm_model_architect]);

const coderLlmModelDisplayName = useMemo(() => {
return llmModels.find((m) => m?.model === message?.llm_model_developer)
?.display_name;
}, [llmModels, message?.llm_model_developer]);

const chatIntentName = useMemo(() => {
return chatIntents.find(
(intent) => intent?.chat_intent_id === message?.chat_intent
)?.name;
}, [chatIntents, message?.chat_intent]);

// Check if we have any "thought chain" data
const isThoughtChainReceived = useMemo(() => {
return !!(message?.response?.length && message.response[0]?.length);
}, [message?.response]);

// Check if transformation is in progress
const isTransformRunning = useMemo(() => {
return message?.transformation_status === "RUNNING";
}, [message?.transformation_status]);

// Feature flag: Use enhanced UI components (can be toggled)
const useEnhancedUI = true; // Set to false to use legacy components

/** --------------------------------------------------------------------
* Derive the intent once; re-computes only when its deps change.
* ------------------------------------------------------------------- */
Expand All @@ -108,6 +82,15 @@ const Conversation = memo(function Conversation({
[chatIntents, message?.chat_intent]
);

// Memoize errorDetails to prevent unnecessary re-renders of PromptInfo
const errorDetailsMemo = useMemo(
() => ({
transformation_error_message: message?.transformation_error_message,
prompt_error_message: message?.prompt_error_message,
}),
[message?.transformation_error_message, message?.prompt_error_message]
);

return (
<div>
{/* PROMPT */}
Expand Down Expand Up @@ -141,33 +124,14 @@ const Conversation = memo(function Conversation({
</div>
)}

{/* Thought Chain - Enhanced or Legacy */}
{/* Thought Chain */}
<div className="chat-ai-conversation chat-ai-existing-chat-response-pad">
{useEnhancedUI ? (
<EnhancedPromptInfo
isThoughtChainReceived={isThoughtChainReceived}
shouldStream={isPromptRunning && isLastConversation}
thoughtChain={message?.thought_chain || []}
llmModel={llmModelDisplayName}
coderLlmModel={coderLlmModelDisplayName}
chatIntent={chatIntentName}
errorState={message?.error_state}
errorDetails={{
transformation_error_message:
message?.transformation_error_message,
prompt_error_message: message?.prompt_error_message,
}}
/>
) : (
<PromptInfo
isThoughtChainReceived={isThoughtChainReceived}
shouldStream={isPromptRunning && isLastConversation}
thoughtChain={message?.thought_chain || []}
llmModel={llmModelDisplayName}
coderLlmModel={coderLlmModelDisplayName}
chatIntent={chatIntentName}
/>
)}
<PromptInfo
shouldStream={isPromptRunning && isLastConversation}
thoughtChain={message?.thought_chain || []}
errorState={message?.error_state}
errorDetails={errorDetailsMemo}
/>
</div>

<div className="chat-ai-existing-chat-response-pad">
Expand Down
Loading
Loading