Skip to content

fix: correct reasoning animation and skill execution toggle - #8190

Merged
wangdan-fit2cloud merged 1 commit into
v3from
pr@v3@fix_reasoning
Nov 26, 2026
Merged

wangdan-fit2cloud merged 1 commit into
v3from
pr@v3@fix_reasoning

Conversation

@shaohuzhang1

Copy link
Copy Markdown
Contributor

fix: correct reasoning animation and skill execution toggle

@wangdan-fit2cloud
wangdan-fit2cloud merged commit 84e5df0 into v3 Nov 26, 2026
3 of 4 checks passed
<span class="-mx-1" :class="{ 'mk-dotting': content.status === 'RUNNING' && messageList?.streamLoading.value }">
{{ content.status === 'RUNNING' ? t('chat.message.thinking') : t('chat.message.thinkingCompleted') }}
</span>
</template>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is the analysis of the code change:

1. Potential Issue: Direct .value Access on Injected Ref

Issue: messageList?.streamLoading.value
If MESSAGE_LIST_KEY injects a Vue Ref<boolean>, accessing it directly via .value in the template logic within <script setup> or the class binding requires careful handling.

  • If streamLoading is a Ref, in the template itself (inside the :class), you typically do not need .value (Vue automatically unwraps refs in templates). However, since this expression is likely being evaluated within the render function context generated by the template compiler, behavior can sometimes be ambiguous depending on how messageList is typed and structured.
  • Better Approach: Ensure streamLoading is correctly unwrapped. If messageList is an object containing a ref streamLoading, you should probably use messageList.streamLoading in the template if Vue's auto-unwrapping applies, or messageList.streamLoading.value if explicitly accessing the ref value outside of standard template binding evaluation (which is rare, but possible here).
    • Recommendation: Test if messageList?.streamLoading (without .value) works. If streamLoading is just a boolean property on the injected object, remove .value entirely. If it is a Ref, keeping .value might be necessary if auto-unwrapping doesn't catch nested properties correctly in this specific context, but it's cleaner to expose a computed isStreaming property from the injected context instead.

2. Logic Clarity & Edge Case: Null Safety vs. Intended Behavior

Current Logic: content.status === 'RUNNING' && messageList?.streamLoading.value

  • Implication: The "thinking" dotting animation only shows if the specific message's status is running AND the global/streaming list indicator is active.
  • Potential Problem: If messageList is null (injected default null), the condition fails silently. This is good for safety, but ensure that messageList is always expected to exist in this component's tree. If messageList is missing, the UI will behave as if the message is completed immediately after the stream ends locally, which might cause flicker or inconsistent UX if the injection fails temporarily.
  • Suggestion: Consider adding a default fallback for messageList to avoid optional chaining in multiple places if the dependency is strict. Alternatively, document why streamLoading (global state) is combined with status (local state).

3. Optimization: Computed Property for Complex Conditions

The class binding contains a somewhat complex boolean expression involving injections and local props.
Suggestion: Extract this into a computed property for better readability, testability, and reactivity tracking.

const showThinkingDots = computed(() => {
    // Adjust .value access based on actual structure of messageList.streamLoading
    const isGlobalStreaming = messageList?.streamLoading ?? false; 
    return content.status === 'RUNNING' && isGlobalStreaming;
});

Then in template:

:class="{ 'mk-dotting': showThinkingDots }"

Note: If streamLoading is a Ref inside messageList, you'd write messageList?.streamLoading.value inside the computed property. Vue tracks dependencies correctly in computed.

4. Code Style/Naming

  • useTemplateRef<HTMLElement>('reasoningScrollRef'): This is fine.
  • Class name mk-dotting: Ensure this utility class exists in your CSS framework.

Summary of Recommendations

  1. Verify Ref Unwrapping: Check if messageList.streamLoading is a Ref. If so, using .value in the template :class directive might be unnecessary or incorrect depending on Vue version/compiler behavior. Moving logic to a computed property is safer and clearer.
  2. Use Computed Property: Move the boolean logic into a computed variable named isThinkingActive or similar.
  3. Null Handling: Confirm that inject(MESSAGE_LIST_KEY, null) returning null is an acceptable state where animations stop. If not, provide a more robust default structure for messageList.

Optimized Version Example

<script setup lang="ts">
import { computed, inject, ref, useTemplateRef } from 'vue'
import { useI18n } from 'vue-i18n'
import { useBottomFollow } from '@/conversation-panel/core/bottom-follow'
import { MESSAGE_LIST_KEY } from '../../message-list'

defineOptions({ name: 'ConversationReasoningContent' })

// Use defineModel for props if content changes frequently, otherwise current defineProps is fine
defineProps<{ content: { content?: string | null; status?: string } }>()

const { t } = useI18n({ useScope: 'global' })
const messageList = inject(MESSAGE_LIST_KEY, null)

// Default collapsed, show status text even while thinking, manual expand reveals content
const isExpanded = ref(false)

// Extract complex condition to computed
const showDottedLine = computed(() => {
  // Assuming streamLoading is a Ref inside messageList object:
  const isStreamingGlobally = messageList?.streamLoading?.value ?? false
  // If streamLoading is plain boolean: const isStreamingGlobally = messageList?.streamLoading ?? false
  return content.status === 'RUNNING' && isStreamingGlobally
})

useBottomFollow(useTemplateRef<HTMLElement>('reasoningScrollRef'))
</script>

<template>
  <!-- ... -->
  <span 
    class="-mx-1" 
    :class="{ 'mk-dotting': showDottedLine }"
  >
    {{ content.status === 'RUNNING' ? t('chat.message.thinking') : t('chat.message.thinkingCompleted') }}
  </span>
  <!-- ... -->
</template>

@wangdan-fit2cloud
wangdan-fit2cloud deleted the pr@v3@fix_reasoning branch November 26, 2026 10:39
<el-checkbox v-model="formData.mcp_output_enable">{{ t('application.skills.outputExecution') }}</el-checkbox>
</div>
<div class="mk-white-card w-full">
<ResourceSetting :setting="formData" @update="updateNodeData" />

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here are the findings and suggestions for the provided code diff:

1. Functional Issue (High Priority)

Problem: In the original line, :model-value="formData.mcp_output_enable" creates a one-way binding from state to view. Unless there is an external @change or @update:model-value handler (which is not shown and likely missing given the context of changing to v-model), the checkbox will not update the formData.mcp_output_enable state when clicked. It appears read-only or broken.

Fix: The change to v-model="formData.mcp_output_enable" is correct and necessary to establish two-way binding. This ensures that checking/unchecking the box updates the underlying data object.

2. Reactivity Concern (Vue 3/Composition API)

Check: Ensure that formData is defined as a reactive object (e.g., using ref, reactive, or shallowRef).

  • If formData is a plain object assigned in setup(), modifying nested properties like formData.mcp_output_enable might not trigger re-renders depending on how Vue's reactivity system tracks it.
  • Recommendation: If formData comes from pinia or reactive(), you are safe. If it's a shallow ref object, ensure the property exists initially or use optional chaining if necessary (though v-model usually handles this reasonably well).

3. Code Style & Readability

Suggestion: The added HTML comment <!-- 控制是否展示技能执行过程 --> is good for internal team understanding. However, consider if this behavior is obvious enough from the label t('application.skills.outputExecution'). If the project enforces strict cleanup of temporary comments before PR merge, remember to remove it. Otherwise, keeping it is fine for clarity.

4. Component Logic Assumption

Note: The el-checkbox is used here. Element Plus checkboxes work with v-model. Your change aligns with Element Plus documentation best practices. No further changes needed for the component usage itself.

Summary

The diff fixes a potential bug where the checkbox state didn't sync back to the data model. The change from :model-value to v-model is correct and recommended.

Final Verdict: ✅ Good fix. Just verify that formData is properly reactive.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants