|
|
|
|
@ -28,11 +28,7 @@ import { useChatManagement } from "./hooks/useChatManagement";
@@ -28,11 +28,7 @@ import { useChatManagement } from "./hooks/useChatManagement";
|
|
|
|
|
import { TTDChatPanel } from "./components/TTDChatPanel"; |
|
|
|
|
import { TTDPreviewPanel } from "./components/TTDPreviewPanel"; |
|
|
|
|
|
|
|
|
|
import { |
|
|
|
|
addMessages, |
|
|
|
|
getLastAssistantMessage, |
|
|
|
|
updateAssistantContent, |
|
|
|
|
} from "./utils/chat"; |
|
|
|
|
import { addMessages, getLastAssistantMessage } from "./utils/chat"; |
|
|
|
|
|
|
|
|
|
import type { ChatMessageType } from "../Chat"; |
|
|
|
|
|
|
|
|
|
@ -113,34 +109,6 @@ const TextToDiagramContent = ({
@@ -113,34 +109,6 @@ const TextToDiagramContent = ({
|
|
|
|
|
setChatHistory, |
|
|
|
|
]); |
|
|
|
|
|
|
|
|
|
// TODO:: just for testing
|
|
|
|
|
const onReplay = async () => { |
|
|
|
|
const { default: mockChunks } = await import("./mock"); |
|
|
|
|
|
|
|
|
|
setChatHistory((prev) => { |
|
|
|
|
return updateAssistantContent(prev, { |
|
|
|
|
isGenerating: true, |
|
|
|
|
content: "", |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
for (const chunk of mockChunks) { |
|
|
|
|
setChatHistory((prev) => { |
|
|
|
|
const lastAssistantMessage = getLastAssistantMessage(prev); |
|
|
|
|
return updateAssistantContent(prev, { |
|
|
|
|
content: lastAssistantMessage.content + chunk, |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
const delay = Math.floor(Math.random() * 5) + 1; |
|
|
|
|
await new Promise((resolve) => setTimeout(resolve, delay)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
setChatHistory((prev) => |
|
|
|
|
updateAssistantContent(prev, { |
|
|
|
|
isGenerating: false, |
|
|
|
|
}), |
|
|
|
|
); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
const onViewAsMermaid = () => { |
|
|
|
|
if (typeof lastAssistantMessage?.content === "string") { |
|
|
|
|
saveMermaidDataToStorage(lastAssistantMessage.content); |
|
|
|
|
@ -284,7 +252,6 @@ const TextToDiagramContent = ({
@@ -284,7 +252,6 @@ const TextToDiagramContent = ({
|
|
|
|
|
error={error} |
|
|
|
|
loaded={mermaidToExcalidrawLib.loaded} |
|
|
|
|
onInsert={handleInsertToEditor} |
|
|
|
|
onReplay={onReplay} |
|
|
|
|
isReplayDisabled={lastAssistantMessage?.isGenerating ?? false} |
|
|
|
|
/> |
|
|
|
|
)} |
|
|
|
|
|