Repository navigation
fix: Talk Page Disclaimer #7815
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| <script setup lang="ts"> | ||
| import { computed } from 'vue' | ||
| import { useShareLinkStoreOptional } from '../../components/message-list/share/index' | ||
| import PortalHeader from '../../components/header/portal/index.vue' | ||
| import MessageList from '../../components/message-list/index.vue' | ||
|
|
@@ -16,6 +17,11 @@ const portalList = usePortalConversationListStore() | |
|
|
||
| // 拖拽到面板任意处 → 交给 message-input 接收文件 | ||
| const handleDrop = (e: DragEvent) => input.addFiles(e.dataTransfer?.files) | ||
|
|
||
| // 当前智能体开启免责声明时在输入框下方居中显示,与显示设置预览一致 | ||
| const disclaimerText = computed(() => | ||
| portalList.currentApplicationId.value && list.appInfo.value?.disclaimer ? list.appInfo.value.disclaimer_value : '', | ||
| ) | ||
| </script> | ||
| <template> | ||
| <!-- 门户对话主面板:header + message-list + message-input --> | ||
|
|
@@ -27,6 +33,9 @@ const handleDrop = (e: DragEvent) => input.addFiles(e.dataTransfer?.files) | |
| <div v-else class="flex-center min-h-0 flex-1"> | ||
| <MkEmpty v-if="portalList.isApplicationGroupsLoaded.value" description="暂无可用智能体" /> | ||
| </div> | ||
| <footer v-if="!list.isShared.value" class="mk-conversation-content flex-center shrink-0 p-4"><MessageInput /></footer> | ||
| <footer v-if="!list.isShared.value" class="mk-conversation-content flex-col-center shrink-0 gap-2 p-4"> | ||
| <MessageInput /> | ||
| <p v-if="disclaimerText" class="wrap-anywhere text-center text-sm text-N500 -mb-1">{{ disclaimerText }}</p> | ||
| </footer> | ||
| </main> | ||
| </template> | ||
|
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. Review1. Logic / correctness
2. Template / CSS
3. Readability / minor
Suggested versionconst disclaimerText = computed(() => {
const info = list.appInfo.value
if (!portalList.currentApplicationId.value || !info?.disclaimer) return ''
return info.disclaimer_value?.trim() ?? ''
})<footer
v-if="!list.isShared.value"
class="mk-conversation-content flex-col-center shrink-0 gap-2 px-4 pt-4 pb-3"
>
<MessageInput class="w-full" />
<p
v-if="disclaimerText"
class="wrap-anywhere text-center text-sm text-N500 whitespace-pre-line"
role="note"
>
{{ disclaimerText }}
</p>
</footer>Main risks to verify before merging: the |
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Review
1. Correctness / Type safety
disclaimerTextcomputed is fragiledisclaimeris truthy butdisclaimer_valueisnull/undefined, the computed returnsundefined(type becomesstring | undefined), not''. Add?? ''.0/1or"true"; truthiness may not match intent. Normalize explicitly if the API is not strictly boolean.v-if. Trim..disclaimerbut not on.disclaimer_value— TS narrowing happens to cover this today, but it's brittle if the expression is refactored.Suggested:
Duplicated business rule — the comment says this must match the “display settings preview”. That rule now lives in two places and will drift. Extract it into a shared helper/composable (e.g.
useDisclaimerText()/getDisclaimerText(appInfo)) and reuse it in the preview component.2. Template / store access
list.appInfo.value?.…andlist.currentChatId.valueare used in the template. That only works iflistis a plain object holding refs. Iflistis ever converted to a Pinia/composable store with auto-unwrapped refs, all of these silently break (.valuebecomesundefined). Consider consistently exposing plain computed values instead, e.g.const backgroundImage = computed(...).:stylerunsJSON.stringify(...)on every render. Cheap, but acomputedis cleaner and gives you one place to sanitize.JSON.stringifyis not a CSS sanitizer.url(${JSON.stringify(url)})will produce invalid CSS for URLs containing newlines/CRs (JSON escapes them to\n, which CSS interprets as a literaln). Prefer validating/encoding:background-imagevalue coming from server data is a mild CSS-injection surface; restricting tohttp(s):/data:imageis safer.<MessageList ...></MessageList>can be self-closed for brevity.3. Layout / UX
flex-col-centerexists in your utility layer. If it doesn't (or resolves todisplay:flex; align-items:center; justify-content:centerwithoutflex-direction: column), the input and disclaimer will sit side by side.justify-centeron the footer would center the input vertically — check thatflex-col-centerdoesn't unintentionally add vertical centering now that the footer has two children.text-N500over a user-providedchat_backgroundimage may have poor contrast. Consider a subtle backdrop (bg-surface/60, a blur, or a text-shadow) for readability.-mb-1is a magic offset to counteractp-4; if the padding changes, the alignment breaks. Prefer adjusting the footer padding or using explicit spacing.select-texton the<p>if the disclaimer contains links/legal text users may want to copy, androle="note"for semantics.{{ disclaimerText }}is auto-escaped — good. If the content is ever meant to be rich text (markdown/HTML), do not switch tov-htmlwithout sanitizing.<main @drop>, so dropping a file on the disclaimer also adds an attachment. Probably intended, but worth confirming.4. Code style / minor
import { computed } from 'vue'— fine, unless the project usesunplugin-auto-import; then this import is redundant and may fail the lint rule. Check sibling components for consistency.:styleline exceeds typical prettier width; a computed would also fix readability.disclaimer_valueis snake_case (backend shape) mixed with camelCase locals. Consider mapping to camelCase at the store boundary.Suggested revision