Open-source LLM knowledge platform: turn raw documents into a queryable RAG, an autonomous reasoning agent, and a self-maintaining Wiki.
Go agentagenticaichatbotdsh-pluginembeddingsevaluationgenerative-aigolangknowledge-basellmmulti-tenantollamaopenaiquestion-answeringragrerankingsemantic-searchvector-searchwiki
fix(chat): refine fork feedback and user message actions
wizardchenb3d3851ca175
diff --git a/frontend/src/components/menu.vue b/frontend/src/components/menu.vueindex 40b966612..bc8cc62a7 100644--- a/frontend/src/components/menu.vue+++ b/frontend/src/components/menu.vue@@ -140,9 +140,10 @@</span></div><div v-for="subitem in group.items" :key="subitem.id"- class="submenu_item_p session-chat-row" :class="{+ class="submenu_item_p session-chat-row" :data-session-id="subitem.id" :class="{'session-chat-row--active': !batchMode && subitem.path === currentSecondpath,'session-chat-row--selected': batchMode && batchSelectedIds.includes(subitem.id),+ 'session-chat-row--revealed': revealedSessionId === subitem.id,}"><div class="session-list-row session-list-row--flat"><div class="session-list-row__body">@@ -485,6 +486,45 @@ const filteredGroupedSessions = computed(() => {);});+// Only a locally created fork requests attention; loading history and switching+// between existing sessions must not replay the entrance animation.+const pendingForkRevealId = ref('');+const revealedSessionId = ref('');+let forkRevealTimer: ReturnType<typeof setTimeout> | undefined;+usemenuStore.$onAction(({ name, args, after }) => {+ if (name !== 'updataMenuChildren' || !args[0]?.parent_session_id) return;+ const sessionId = String(args[0].id);+ after(() => { pendingForkRevealId.value = sessionId; });+});++watch(+ () => {+ const id = pendingForkRevealId.value;+ return id && !uiStore.sidebarCollapsed && currentSecondpath.value === `chat/${id}`+ && filteredGroupedSessions.value.some((group) => group.items.some((item) => item.id === id))+ ? id : '';+ },+ (id) => {+ if (!id) return;+ const container = scrollContainer.value;+ const row = Array.from(container?.querySelectorAll<HTMLElement>('[data-session-id]') ?? [])+ .find((element) => element.dataset.sessionId === id);+ if (!container || !row) return;++ // Reveal within the sidebar only, without moving the conversation pane.+ const bounds = container.getBoundingClientRect();+ const rowBounds = row.getBoundingClientRect();+ if (rowBounds.top < bounds.top) container.scrollTop += rowBounds.top - bounds.top;+ else if (rowBounds.bottom > bounds.bottom) container.scrollTop += rowBounds.bottom - bounds.bottom;++ clearTimeout(forkRevealTimer);+ revealedSessionId.value = id;+ pendingForkRevealId.value = '';+ forkRevealTimer = setTimeout(() => { revealedSessionId.value = ''; }, 350);+ },+ { flush: 'post' },+);+const refreshSessionListScrollability = async () => {await nextTick();const container = scrollContainer.value;@@ -1010,6 +1050,7 @@ onMounted(async () => {onUnmounted(() => {clearInterval(sessionActivityTimer);+ clearTimeout(forkRevealTimer);sessionActivity.clear();window.removeEventListener(SESSION_MUTATION_EVENT, handleSessionMutation);});@@ -1627,6 +1668,10 @@ const onDragHandleMouseDown = (e: MouseEvent) => {transition: background 0.15s ease, color 0.15s ease;}+ &.session-chat-row--revealed {+ animation: session-fork-enter 280ms ease-out both;+ }+&.session-chat-row:hover .session-list-row {background: var(--td-bg-color-container-hover);@@ -1911,6 +1956,17 @@ const onDragHandleMouseDown = (e: MouseEvent) => {.menu_box {position: relative;}++@keyframes session-fork-enter {+ from { opacity: 0; transform: translateX(-10px); }+ to { opacity: 1; transform: translateX(0); }+}++@media (prefers-reduced-motion: reduce) {+ .aside_box .submenu_item_p.session-chat-row--revealed {+ animation: none;+ }+}</style><style lang="less">// Dark mode: invert dark logo to lightdiff --git a/frontend/src/views/chat/components/botmsg.vue b/frontend/src/views/chat/components/botmsg.vueindex 74a730ad4..ced655f1c 100644--- a/frontend/src/views/chat/components/botmsg.vue+++ b/frontend/src/views/chat/components/botmsg.vue@@ -388,7 +388,7 @@ const handleCopyAnswer = async () => {return;}- await copyWithToast(content, 'chat.copySuccess', 'chat.copyFailed');+ await copyWithToast(content, 'common.copySuccess', 'common.copyFailed');};// 添加到知识库diff --git a/frontend/src/views/chat/components/usermsg.vue b/frontend/src/views/chat/components/usermsg.vueindex 4357bde34..e713283f2 100644--- a/frontend/src/views/chat/components/usermsg.vue+++ b/frontend/src/views/chat/components/usermsg.vue@@ -43,17 +43,22 @@<div class="user_msg">{{ content }}</div>- <div v-if="canFork" class="user_msg_actions">- <t-tooltip :content="forkTooltip">- <t-button- variant="text"- size="small"- class="user_msg_action"- @click="emit('fork', messageId)"- >- <t-icon name="git-branch" />- </t-button>- </t-tooltip>+ <div v-if="timestamp || content || canFork" class="user_msg_meta">+ <time v-if="timestamp" class="user_msg_time" :datetime="timestamp.datetime" :title="fullTimestamp">+ {{ timestamp.time }}+ </time>+ <div v-if="content || canFork" class="user_msg_actions">+ <t-tooltip v-if="content" :content="t('agent.copy')">+ <button type="button" class="user_msg_action" :aria-label="t('agent.copy')" @click="handleCopy">+ <t-icon name="copy" />+ </button>+ </t-tooltip>+ <t-tooltip v-if="canFork" :content="forkTooltip">+ <button type="button" class="user_msg_action" :aria-label="forkTooltip" @click="emit('fork', messageId)">+ <t-icon name="git-branch" />+ </button>+ </t-tooltip>+ </div></div><div v-if="steerFailed" class="steer-failure" role="status"><span>{{ t('input.messages.steerFailed') }}</span>@@ -71,6 +76,8 @@ import { useI18n } from 'vue-i18n';import { useChatAttachmentPreviewDrawer } from '@/composables/useChatAttachmentPreviewDrawer';import { isPreviewableAttachment, resolveAttachmentFileType } from '@/utils/attachmentPreview';import { SKILL_ICON } from '@/types/mention';+import { copyWithToast } from '@/utils/clipboard';+import { formatMessageTimestamp, getConversationTimestampModel } from '@/utils/messageTimestamp';const emit = defineEmits(['retry-steer', 'remove-steer', 'fork']);const { t } = useI18n();@@ -125,6 +132,10 @@ const props = defineProps({type: String,default: ''},+ createdAt: {+ type: String,+ default: ''+ },canFork: {type: Boolean,default: false@@ -133,6 +144,9 @@ const props = defineProps({const canFork = computed(() => props.canFork === true && !props.embeddedMode);const forkTooltip = '从这里分叉出新会话';+const timestamp = computed(() => getConversationTimestampModel(props.createdAt));+const fullTimestamp = computed(() => formatMessageTimestamp(props.createdAt));+const handleCopy = () => copyWithToast(props.content, 'common.copySuccess', 'common.copyFailed');const attachmentPreviewDrawer = useChatAttachmentPreviewDrawer();@@ -395,9 +409,72 @@ html[theme-mode="dark"] {.steer-failure button { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; border: 0; border-radius: 6px; background: transparent; color: inherit; cursor: pointer; }.steer-failure button:hover { background: var(--td-bg-color-secondarycontainer); }-.user_msg_actions {+.user_msg_meta {display: flex;+ align-items: center;justify-content: flex-end;- padding-top: 2px;+ gap: 8px;+ min-height: 28px;+ padding-right: 4px;+ color: var(--td-text-color-placeholder);+ opacity: 0;+ pointer-events: none;+ transition: opacity 140ms ease;+}++.user_msg_time {+ font-size: 12px;+ font-variant-numeric: tabular-nums;+ line-height: 20px;+}++.user_msg_actions {+ display: flex;+ align-items: center;+ gap: 2px;+}++.user_msg_container:hover .user_msg_meta,+.user_msg_container:focus-within .user_msg_meta {+ opacity: 1;+ pointer-events: auto;+}++.user_msg_action {+ display: inline-flex;+ align-items: center;+ justify-content: center;+ width: 28px;+ height: 28px;+ padding: 0;+ border: 0;+ border-radius: 6px;+ background: transparent;+ color: inherit;+ font-size: 16px;+ cursor: pointer;+}++.user_msg_action:hover {+ color: var(--td-text-color-secondary);+ background: var(--td-bg-color-container-hover);+}++.user_msg_action:focus-visible {+ outline: 2px solid var(--td-text-color-secondary);+ outline-offset: 2px;+}++@media (hover: none) {+ .user_msg_meta {+ opacity: 1;+ pointer-events: auto;+ }+}++@media (prefers-reduced-motion: reduce) {+ .user_msg_meta {+ transition: none;+ }}</style>diff --git a/frontend/src/views/chat/index.vue b/frontend/src/views/chat/index.vueindex 7721bf3ff..c257c7781 100644--- a/frontend/src/views/chat/index.vue+++ b/frontend/src/views/chat/index.vue@@ -110,6 +110,7 @@:images="session.images" :attachments="session.attachments" :embeddedMode="embeddedMode":session-id="session_id":message-id="session.id"+ :created-at="session.created_at":can-fork="!embeddedMode && forkAffordanceOf(session.id).canFork":steer-failed="Boolean(session._steerFailed)"@retry-steer="handleRetrySteer(session.steer_id)"