From d53a99359b3f386787caa1223ea6117db30a0055 Mon Sep 17 00:00:00 2001 From: digua Date: Wed, 19 Aug 2026 15:56:47 +0800 Subject: [PATCH] perf(ai): optimize long conversation rendering --- src/components/AIChat/ChatExplorer.vue | 16 +- src/components/AIChat/chat/ChatMessage.vue | 19 +- .../AIChat/composables/useChatScroll.test.ts | 40 ++++ .../AIChat/composables/useChatScroll.ts | 53 ++++- .../useProgressiveChatHistory.test.ts | 72 ++++++ .../composables/useProgressiveChatHistory.ts | 49 ++++ src/i18n/locales/en-US/ai.json | 3 + src/i18n/locales/ja-JP/ai.json | 3 + src/i18n/locales/zh-CN/ai.json | 3 + src/i18n/locales/zh-TW/ai.json | 3 + src/stores/aiChat.ts | 156 +++++++++---- src/stores/aiChatStreamBatcher.test.ts | 74 ++++++ src/stores/aiChatStreamBatcher.ts | 74 ++++++ tests/ai-chat-performance/BenchmarkApp.vue | 216 ++++++++++++++++++ tests/ai-chat-performance/index.html | 15 ++ tests/ai-chat-performance/main.ts | 13 ++ tests/ai-chat-performance/vite.config.mts | 30 +++ 17 files changed, 782 insertions(+), 57 deletions(-) create mode 100644 src/components/AIChat/composables/useChatScroll.test.ts create mode 100644 src/components/AIChat/composables/useProgressiveChatHistory.test.ts create mode 100644 src/components/AIChat/composables/useProgressiveChatHistory.ts create mode 100644 src/stores/aiChatStreamBatcher.test.ts create mode 100644 src/stores/aiChatStreamBatcher.ts create mode 100644 tests/ai-chat-performance/BenchmarkApp.vue create mode 100644 tests/ai-chat-performance/index.html create mode 100644 tests/ai-chat-performance/main.ts create mode 100644 tests/ai-chat-performance/vite.config.mts diff --git a/src/components/AIChat/ChatExplorer.vue b/src/components/AIChat/ChatExplorer.vue index 45c2f89e..b698c80a 100644 --- a/src/components/AIChat/ChatExplorer.vue +++ b/src/components/AIChat/ChatExplorer.vue @@ -23,6 +23,7 @@ import { useSettingsStore } from '@/stores/settings' import { useAssistantStore } from '@/stores/assistant' import { useSkillStore } from '@/stores/skill' import { useChatScroll } from './composables/useChatScroll' +import { useProgressiveChatHistory } from './composables/useProgressiveChatHistory' import { useChatModals } from './composables/useChatModals' import { groupMessagesToQAPairs } from './utils/chatMessages' import type { MentionedMemberContext } from '@/composables/useAIChat' @@ -181,6 +182,8 @@ const assistantBackupName = computed(() => { // QA 对 const qaPairs = computed(() => groupMessagesToQAPairs(messages.value)) +const progressiveHistory = useProgressiveChatHistory(qaPairs, currentAIChatId, chatScroll.messagesContainer) +const { visiblePairs, hasOlderPairs, loadOlderPairs } = progressiveHistory // 检查 LLM 配置 async function checkLLMConfig() { @@ -515,8 +518,19 @@ watch( +
+ +
+ -