diff --git a/frontend/src/components/WorkspaceChat/ChatContainer/ChatHistory/StatusResponse/index.jsx b/frontend/src/components/WorkspaceChat/ChatContainer/ChatHistory/StatusResponse/index.jsx
new file mode 100644
index 0000000000..c06fb35ad1
--- /dev/null
+++ b/frontend/src/components/WorkspaceChat/ChatContainer/ChatHistory/StatusResponse/index.jsx
@@ -0,0 +1,113 @@
+import React, { useState } from "react";
+import {
+ CaretDown,
+ CircleNotch,
+ Check,
+ CheckCircle,
+} from "@phosphor-icons/react";
+
+export default function StatusResponse({
+ messages = [],
+ isThinking = false,
+ showCheckmark = false,
+}) {
+ const [isExpanded, setIsExpanded] = useState(false);
+ const currentThought = messages[messages.length - 1];
+ const previousThoughts = messages.slice(0, -1);
+
+ function handleExpandClick() {
+ if (!previousThoughts.length > 0) return;
+ setIsExpanded(!isExpanded);
+ }
+
+ return (
+
- {history.map((props, index) => {
- const isLastBotReply =
- index === history.length - 1 && props.role === "assistant";
-
- if (props?.type === "statusResponse" && !!props.content) {
- return
;
- }
-
- if (props.type === "rechartVisualize" && !!props.content) {
- return (
-
- );
- }
-
- if (isLastBotReply && props.animate) {
- return (
-
- );
- }
-
- return (
-
- );
- })}
+ {compiledHistory.map((item, index) =>
+ Array.isArray(item) ? renderStatusResponse(item, index) : item
+ )}
{showing && (
)}
@@ -253,21 +244,13 @@ export default function ChatHistory({
);
}
-function StatusResponse({ props }) {
- return (
-
-
-
-
- {props.content}
-
-
-
-
- );
-}
+const getLastMessageInfo = (history) => {
+ const lastMessage = history?.[history.length - 1] || {};
+ return {
+ isAnimating: lastMessage?.animate,
+ isStatusResponse: lastMessage?.type === "statusResponse",
+ };
+};
function WorkspaceChatSuggestions({ suggestions = [], sendSuggestion }) {
if (suggestions.length === 0) return null;
@@ -286,3 +269,78 @@ function WorkspaceChatSuggestions({ suggestions = [], sendSuggestion }) {
);
}
+
+/**
+ * Builds the history of messages for the chat.
+ * This is mostly useful for rendering the history in a way that is easy to understand.
+ * as well as compensating for agent thinking and other messages that are not part of the history, but
+ * are still part of the chat.
+ *
+ * @param {Object} param0 - The parameters for building the messages.
+ * @param {Array} param0.history - The history of messages.
+ * @param {Object} param0.workspace - The workspace object.
+ * @param {Function} param0.regenerateAssistantMessage - The function to regenerate the assistant message.
+ * @param {Function} param0.saveEditedMessage - The function to save the edited message.
+ * @param {Function} param0.forkThread - The function to fork the thread.
+ * @returns {Array} The compiled history of messages.
+ */
+function buildMessages({
+ history,
+ workspace,
+ regenerateAssistantMessage,
+ saveEditedMessage,
+ forkThread,
+}) {
+ return history.reduce((acc, props, index) => {
+ const isLastBotReply =
+ index === history.length - 1 && props.role === "assistant";
+
+ if (props?.type === "statusResponse" && !!props.content) {
+ if (acc.length > 0 && Array.isArray(acc[acc.length - 1])) {
+ acc[acc.length - 1].push(props);
+ } else {
+ acc.push([props]);
+ }
+ return acc;
+ }
+
+ if (props.type === "rechartVisualize" && !!props.content) {
+ acc.push(
+