Repository navigation
fix: Whether to display execution details depends on the configuration. #7820
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -71,7 +71,7 @@ const showUserAvatar = computed(() => appInfo.value?.show_user_avatar) | |
| <!-- 助手消息结束后显示底部信息栏(知识来源/执行详情/tokens/耗时) --> | ||
| <MessageFooter | ||
| class="mt-3" | ||
| v-if="!isShared && msg.role === 'ASSISTANT' && (msg.write_ed || msg.record)" | ||
| v-if="(!isShared && msg.role === 'ASSISTANT' && (msg.write_ed || msg.record))&&!streamLoading" | ||
| :message="msg" | ||
| @resize="scrollRef?.followBottom()" | ||
| /> | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here is an analysis of the code snippet provided: 1. Irregularities & Issues
2. Optimization SuggestionsOption A: Extract to a Computed Property (Recommended)Move the complex boolean logic into a computed property for better performance, testability, and readability. // Script setup
const shouldShowFooter = computed(() => {
if (isShared.value) return false;
if (streamLoading.value) return false;
if (msg.role !== 'ASSISTANT') return false; // Assuming 'msg' is available in scope
return !!msg.write_ed || !!msg.record; // Ensure explicit boolean check if needed
});<!-- Template -->
<MessageFooter
v-if="shouldShowFooter"
class="mt-3"
:message="msg"
@resize="scrollRef?.followBottom()"
/>Option B: Use
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is a review of the code changes with identified issues and optimization suggestions:
1. Code Style & Formatting
const show_exec=computed(...)lacks spacing around the equals sign and arrow function. It should beconst showExec = computed(() => ...).show_execuses snake_case. Vue/JS conventions typically prefer camelCase for variables (showExec). Additionally,execis an ambiguous abbreviation;executionDetailsVisibleorcanViewExecutionwould be clearer.useMessageListStorebut do not seem to use it in the diff. If unused, remove it to prevent lint errors and confusion.2. Logic & Safety Issues
v-if="show_exec"will evaluate asfalseifmessageListis null or undefined. This is safe, but ensure that the intent is to hide the button when data isn't ready, rather than hiding it due to a missing provider.messageList?.appInfois truly reactive. IfappInfois assigned once and doesn't change, accessing.valueinside the computed property getter might cause unnecessary dependency tracking if not handled carefully. However, sincemessageListis injected, this is likely correct provideduseMessageListStorereturns reactive refs.3. Optimization Suggestions
computedpropertyshow_execis defined aftercanShare. Group related states together for better readability.v-if="show_exec"relies entirely on the state ofmessageList. IfuseShowShare()or other external factors affect visibility, consider combining them:.lengthcheck ifshow_execis already a boolean flag).Recommended Refactored Code Snippet
Summary of Actions:
useMessageListStore.show_exectoshowExec(camelCase).=and arrows.v-ifbut ensure the variable name clearly indicates its boolean nature.