From 09f9e446616c222046ec0971527fba3889e4b86d Mon Sep 17 00:00:00 2001 From: Abeautifulsnow Date: Tue, 7 Jul 2026 13:36:53 +0800 Subject: [PATCH] fix(ai): make reasoning expand/collapse consistent across messages fix(ai): make reasoning expand/collapse consistent across messages Replace per-message expandedReasoning Set with a global reasoningExpanded boolean ref so all messages share the same toggle state. Default to collapsed. This avoids the flip-flop where reasoning auto-expands during streaming and collapses afterward, requiring repeated manual toggles. - Replace expandedReasoning (Set) with reasoningExpanded (boolean) - Remove per-index toggleReasoning; use global flip instead - Template uses reasoningExpanded instead of expandedReasoning.has(i) || msg.isThinking @ --- .../src/components/editor/AiAssistant.vue | 20 +++++++------------ 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/apps/desktop/src/components/editor/AiAssistant.vue b/apps/desktop/src/components/editor/AiAssistant.vue index d34bfb33cf..726fe2b581 100644 --- a/apps/desktop/src/components/editor/AiAssistant.vue +++ b/apps/desktop/src/components/editor/AiAssistant.vue @@ -511,7 +511,7 @@ function appendAssistantReasoning(assistantIdx: number, delta: string) { scrollToBottom(); } -const expandedReasoning = ref>(new Set()); +const reasoningExpanded = ref(false); const expandedSteps = ref>(new Set()); function toggleStep(key: string) { @@ -626,14 +626,8 @@ function agentEventToStep(event: AgentEvent, index: number): AiAgentStepItem | u }; } -function toggleReasoning(index: number) { - const next = new Set(expandedReasoning.value); - if (next.has(index)) { - next.delete(index); - } else { - next.add(index); - } - expandedReasoning.value = next; +function toggleReasoning() { + reasoningExpanded.value = !reasoningExpanded.value; } function scrollToBottom() { @@ -1324,16 +1318,16 @@ async function openExternalUrl(url: string) {
-