diff --git a/frontend/crawlab-ui/src/components/core/ai/AssistantConsole.vue b/frontend/crawlab-ui/src/components/core/ai/AssistantConsole.vue index 6159660a..d2719144 100644 --- a/frontend/crawlab-ui/src/components/core/ai/AssistantConsole.vue +++ b/frontend/crawlab-ui/src/components/core/ai/AssistantConsole.vue @@ -6,7 +6,7 @@ import { debounce } from 'lodash'; import { useRouter } from 'vue-router'; import useAssistantConsole from './useAssistantConsole'; -defineProps<{ +const props = defineProps<{ visible: boolean; }>(); @@ -35,15 +35,12 @@ const { chatbotConfig, currentConversationTitle, loadConversations, - loadConversationMessages, - loadCurrentConversation, - loadLLMProviders, - loadChatbotConfig, saveChatbotConfig, selectConversation, createNewConversation, sendStreamingRequest, extractErrorMessage, + initializeConversation, } = useAssistantConsole(); // Message handling @@ -105,7 +102,9 @@ const cancelMessage = () => { abortController.value = null; isGenerating.value = false; - const streamingMessageIndex = chatHistory.findIndex((msg: ChatMessage) => msg.isStreaming); + const streamingMessageIndex = chatHistory.findIndex( + (msg: ChatMessage) => msg.isStreaming + ); if (streamingMessageIndex >= 0) { chatHistory.splice(streamingMessageIndex, 1); } @@ -156,19 +155,15 @@ watch(isGenerating, () => { }); // Initialize -onBeforeMount(async () => { - await loadConversations(); - loadChatbotConfig(); - await loadLLMProviders(); - - // Load saved conversation ID from localStorage - const savedConversationId = localStorage.getItem('currentConversationId'); - if (savedConversationId) { - await loadConversationMessages(savedConversationId); - await loadCurrentConversation(savedConversationId); - currentConversationId.value = savedConversationId; +onBeforeMount(initializeConversation); +watch( + () => props.visible, + async () => { + if (props.visible) { + await initializeConversation(); + } } -}); +); defineOptions({ name: 'ClAssistantConsole' }); diff --git a/frontend/crawlab-ui/src/components/core/ai/useAssistantConsole.ts b/frontend/crawlab-ui/src/components/core/ai/useAssistantConsole.ts index dea896cc..e62d5790 100644 --- a/frontend/crawlab-ui/src/components/core/ai/useAssistantConsole.ts +++ b/frontend/crawlab-ui/src/components/core/ai/useAssistantConsole.ts @@ -418,6 +418,19 @@ const useAssistantConsole = () => { }; onMounted(focusInput); + const initializeConversation = async () => { + loadChatbotConfig(); + await loadLLMProviders(); + + // Load saved conversation ID from localStorage + const savedConversationId = localStorage.getItem('currentConversationId'); + if (savedConversationId) { + await loadConversationMessages(savedConversationId); + await loadCurrentConversation(savedConversationId); + currentConversationId.value = savedConversationId; + } + }; + return { // Refs messageListRef, @@ -451,6 +464,7 @@ const useAssistantConsole = () => { createNewConversation, sendStreamingRequest, extractErrorMessage, + initializeConversation, }; }; diff --git a/frontend/crawlab-ui/src/components/core/dependency/DependencyLogsDialog.vue b/frontend/crawlab-ui/src/components/core/dependency/DependencyLogsDialog.vue index b421efdb..a3a728d1 100644 --- a/frontend/crawlab-ui/src/components/core/dependency/DependencyLogsDialog.vue +++ b/frontend/crawlab-ui/src/components/core/dependency/DependencyLogsDialog.vue @@ -15,7 +15,7 @@ const visible = computed(() => state.activeDialogKey === 'logs'); const activeTargetName = computed(() => state.activeTargetName); const activeTargetStatus = computed(() => state.activeTargetStatus); -const content = computed(() => { +const logs = computed(() => { const data: string[] = []; state.activeTargetLogs?.forEach(l => { l.content @@ -25,7 +25,7 @@ const content = computed(() => { data.push(line.trim()); }); }); - return data.join('\n'); + return data; }); const logsViewRef = ref(); @@ -86,9 +86,7 @@ defineOptions({ name: 'ClDependencyLogsDialog' }); {{ t('common.tabs.logs') }} - {{ activeTargetName }} -
-
{{ content }}
-
+ diff --git a/frontend/crawlab-ui/src/components/ui/chat/ChatInput.vue b/frontend/crawlab-ui/src/components/ui/chat/ChatInput.vue index fddea95c..551a02c3 100644 --- a/frontend/crawlab-ui/src/components/ui/chat/ChatInput.vue +++ b/frontend/crawlab-ui/src/components/ui/chat/ChatInput.vue @@ -1,5 +1,5 @@