Skip to content

Open-source LLM knowledge platform: turn raw documents into a queryable RAG, an autonomous reasoning agent, and a self-maintaining Wiki.

fix(ui): 优化对话布局、导航与产物和引用展示 (#3427)

lyingbuga46a3c599678
diff --git a/frontend/src/assets/dropdown-menu.less b/frontend/src/assets/dropdown-menu.less
index 846a96eb1..834bf8ed1 100644
--- a/frontend/src/assets/dropdown-menu.less
+++ b/frontend/src/assets/dropdown-menu.less
@@ -173,6 +173,15 @@
}
}
+ button.card-menu-item {
+ width: 100%;
+ border: 0;
+ background: transparent;
+ text-align: left;
+ white-space: nowrap;
+ box-sizing: border-box;
+ }
+
.card-menu-item {
display: flex;
align-items: center;
diff --git a/frontend/src/components/ChatHeader.vue b/frontend/src/components/ChatHeader.vue
index d987c9d2c..d607cdfae 100644
--- a/frontend/src/components/ChatHeader.vue
+++ b/frontend/src/components/ChatHeader.vue
@@ -24,7 +24,7 @@
@dblclick="startTitleEdit"
>
<t-icon v-if="session?.is_pinned" name="pin" size="12px" class="chat-header__pin" />
- <span class="chat-header__title-text">{{ displayTitle }}</span>
+ <span ref="titleTextRef" class="chat-header__title-text">{{ displayTitle }}</span>
</h1>
<t-popup
v-if="!titleEditing"
@@ -48,50 +48,28 @@
<t-icon v-else name="ellipsis" size="16px" />
</button>
<template #content>
- <div class="chat-header-menu" @click.stop>
+ <div class="card-menu" @click.stop>
<template v-if="menuMode === 'menu'">
- <button type="button" class="chat-header-menu__item" @click="onMenuAction(session?.is_pinned ? 'unpin' : 'pin')">
- <t-icon class="chat-header-menu__icon" :name="session?.is_pinned ? 'pin-filled' : 'pin'" />
- <span>{{ session?.is_pinned ? t('menu.unpin') : t('menu.pin') }}</span>
- </button>
- <button type="button" class="chat-header-menu__item" @click="onMenuAction('rename')">
- <t-icon class="chat-header-menu__icon" name="edit-1" />
+ <button type="button" class="card-menu-item" @click="onMenuAction('rename')">
+ <t-icon class="icon" name="edit-1" />
<span>{{ t('menu.renameSession') }}</span>
</button>
- <div class="chat-header-menu__divider" />
- <button type="button" class="chat-header-menu__item" @click="onMenuAction('copyId')">
- <t-icon class="chat-header-menu__icon" name="copy" />
- <span>{{ t('chatHeader.copySessionId') }}</span>
- </button>
- <button type="button" class="chat-header-menu__item" @click="onMenuAction('copyLink')">
- <t-icon class="chat-header-menu__icon" name="link" />
- <span>{{ t('chatHeader.copyLink') }}</span>
- </button>
- <button type="button" class="chat-header-menu__item" @click="onMenuAction('copyMarkdown')">
- <t-icon class="chat-header-menu__icon" name="file-copy" />
+ <button type="button" class="card-menu-item" @click="onMenuAction('copyMarkdown')">
+ <t-icon class="icon" name="file-copy" />
<span>{{ t('chatHeader.copyMarkdown') }}</span>
</button>
- <button type="button" class="chat-header-menu__item" @click="onMenuAction('openNewWindow')">
- <t-icon class="chat-header-menu__icon" name="browse" />
- <span>{{ t('chatHeader.openNewWindow') }}</span>
- </button>
- <div class="chat-header-menu__divider" />
- <button type="button" class="chat-header-menu__item" @click="enterConfirmMode('clear')">
- <t-icon class="chat-header-menu__icon" name="clear" />
- <span>{{ t('menu.clearMessages') }}</span>
- </button>
- <button type="button" class="chat-header-menu__item is-danger" @click="enterConfirmMode('delete')">
- <t-icon class="chat-header-menu__icon" name="delete" />
+ <button type="button" class="card-menu-item danger" @click="enterConfirmMode('delete')">
+ <t-icon class="icon" name="delete" />
<span>{{ t('chatHeader.deleteSession') }}</span>
</button>
</template>
<div v-else class="chat-header-confirm">
<div class="chat-header-confirm__title">
- {{ menuMode === 'clear' ? t('chatHeader.clearConfirmTitle') : t('chatHeader.deleteConfirmTitle') }}
+ {{ t('chatHeader.deleteConfirmTitle') }}
</div>
<div class="chat-header-confirm__body">
- {{ menuMode === 'clear' ? t('chatHeader.clearConfirmBody') : t('chatHeader.deleteConfirmBody') }}
+ {{ t('chatHeader.deleteConfirmBody') }}
</div>
<div class="chat-header-confirm__footer">
<button type="button" class="chat-header-confirm__btn" :disabled="Boolean(busyAction)" @click="backToMenu">
@@ -101,9 +79,9 @@
type="button"
class="chat-header-confirm__btn is-danger"
:disabled="Boolean(busyAction)"
- @click="menuMode === 'clear' ? submitClearMessages() : submitDeleteSession()"
+ @click="submitDeleteSession()"
>
- {{ menuMode === 'clear' ? t('common.clear') : t('common.delete') }}
+ {{ t('common.delete') }}
</button>
</div>
</div>
@@ -120,13 +98,12 @@ import { MessagePlugin } from 'tdesign-vue-next'
import { copyToClipboard } from '@/utils/clipboard'
import { getMessageList } from '@/api/chat'
import {
- clearSession,
removeSession,
renameSession,
- setSessionPinned,
} from './sessionMutations'
import { normalizeSessionTitleDraft, SESSION_TITLE_MAX_LENGTH } from './sessionTitleEdit'
import { buildSessionMarkdown, collectAllSessionMessages } from '@/utils/sessionMarkdown'
+import { useSessionTitleMotion } from '@/composables/useSessionTitleMotion'
interface ChatHeaderSession {
id: string
@@ -136,7 +113,7 @@ interface ChatHeaderSession {
is_pinned?: boolean
}
-type MenuMode = 'menu' | 'clear' | 'delete'
+type MenuMode = 'menu' | 'delete'
const props = defineProps<{
session: ChatHeaderSession | null
@@ -151,15 +128,17 @@ const titleDraft = ref('')
const titleInputRef = ref<HTMLInputElement | null>(null)
const displayTitle = computed(() => props.session?.title?.trim() || t('menu.newSession'))
+const titleTextRef = ref<HTMLElement | null>(null)
+useSessionTitleMotion(titleTextRef, () => props.session?.id, () => displayTitle.value)
const menuOverlayClass = computed(() => (
- menuMode.value === 'menu' ? 'chat-header-menu-popup' : 'chat-header-menu-popup is-confirm'
+ menuMode.value === 'menu' ? 'card-more chat-header-menu-popup' : 'card-more chat-header-menu-popup is-confirm'
))
function onMenuVisibleChange(visible: boolean): void {
if (!visible) menuMode.value = 'menu'
}
-function enterConfirmMode(mode: 'clear' | 'delete'): void {
+function enterConfirmMode(mode: 'delete'): void {
menuMode.value = mode
}
@@ -175,7 +154,7 @@ function onMenuAction(value: string): void {
return
}
menuVisible.value = false
- handleMenuClick({ value })
+ if (value === 'copyMarkdown') void copyMarkdown()
}
async function copyText(text: string): Promise<void> {
@@ -183,13 +162,6 @@ async function copyText(text: string): Promise<void> {
if (!ok) throw new Error('clipboard unavailable')
}
-function currentSessionLink(): string {
- const url = new URL(window.location.href)
- url.search = ''
- url.hash = ''
- return url.toString()
-}
-
function startTitleEdit(): void {
if (!props.session || busyAction.value) return
menuVisible.value = false
@@ -232,39 +204,6 @@ async function submitTitleEdit(): Promise<void> {
}
}
-async function togglePin(pinned: boolean): Promise<void> {
- const session = props.session
- if (!session || busyAction.value) return
- busyAction.value = 'pin'
- try {
- await setSessionPinned(session.id, pinned)
- MessagePlugin.success(t(pinned ? 'chatHeader.pinSuccess' : 'chatHeader.unpinSuccess'))
- } catch {
- MessagePlugin.error(t(pinned ? 'menu.pinFailed' : 'menu.unpinFailed'))
- } finally {
- busyAction.value = ''
- }
-}
-
-async function copySessionId(): Promise<void> {
- if (!props.session) return
- try {
- await copyText(props.session.id)
- MessagePlugin.success(t('chatHeader.sessionIdCopied'))
- } catch {
- MessagePlugin.error(t('chatHeader.copyFailed'))
- }
-}
-
-async function copyLink(): Promise<void> {
- try {
- await copyText(currentSessionLink())
- MessagePlugin.success(t('chatHeader.linkCopied'))
- } catch {
- MessagePlugin.error(t('chatHeader.copyFailed'))
- }
-}
-
async function copyMarkdown(): Promise<void> {
const session = props.session
if (!session || busyAction.value) return
@@ -303,22 +242,6 @@ async function copyMarkdown(): Promise<void> {
}
}
-async function submitClearMessages(): Promise<void> {
- const session = props.session
- if (!session || busyAction.value) return
- busyAction.value = 'clear'
- try {
- await clearSession(session.id)
- menuVisible.value = false
- menuMode.value = 'menu'
- MessagePlugin.success(t('menu.clearMessagesSuccess'))
- } catch {
- MessagePlugin.error(t('menu.clearMessagesFailed'))
- } finally {
- busyAction.value = ''
- }
-}
-
async function submitDeleteSession(): Promise<void> {
const session = props.session
if (!session || busyAction.value) return
@@ -335,16 +258,6 @@ async function submitDeleteSession(): Promise<void> {
}
}
-function handleMenuClick(data: { value: string }): void {
- switch (data.value) {
- case 'pin': void togglePin(true); break
- case 'unpin': void togglePin(false); break
- case 'copyId': void copySessionId(); break
- case 'copyLink': void copyLink(); break
- case 'copyMarkdown': void copyMarkdown(); break
- case 'openNewWindow': window.open(currentSessionLink(), '_blank', 'noopener,noreferrer'); break
- }
-}
</script>
<style scoped lang="less">
@@ -450,35 +363,10 @@ function handleMenuClick(data: { value: string }): void {
</style>
<style lang="less">
-.chat-header-menu-popup {
- z-index: 99 !important;
-
- .t-popup__content {
- padding: 4px !important;
- margin-top: 2px !important;
- min-width: 168px !important;
- width: max-content !important;
- border-radius: var(--app-radius-md) !important;
- background: var(--td-bg-color-container) !important;
- border: 0.5px solid var(--td-component-stroke) !important;
- box-shadow:
- 0 0 0 0.5px rgba(0, 0, 0, 0.03),
- 0 2px 6px rgba(0, 0, 0, 0.08) !important;
- overflow: hidden;
- }
-
- &.is-confirm .t-popup__content {
- padding: 12px !important;
- width: 260px !important;
- min-width: 260px !important;
- }
-}
-
-.chat-header-menu {
- display: flex;
- flex-direction: column;
- gap: 1px;
- min-width: 160px;
+.card-more.chat-header-menu-popup.is-confirm .t-popup__content {
+ padding: 12px !important;
+ width: 260px !important;
+ min-width: 260px !important;
}
.chat-header-confirm {
@@ -543,58 +431,4 @@ function handleMenuClick(data: { value: string }): void {
}
}
-.chat-header-menu__item {
- display: flex;
- align-items: center;
- gap: 8px;
- width: 100%;
- min-height: 32px;
- padding: 0 12px;
- border: 0;
- border-radius: 5px;
- color: var(--td-text-color-primary);
- background: transparent;
- font-size: var(--app-text-base);
- line-height: 20px;
- text-align: left;
- white-space: nowrap;
- box-sizing: border-box;
- cursor: pointer;
-
- &:hover {
- background: var(--td-bg-color-container-hover);
- }
-
- &.is-danger {
- color: var(--td-error-color-6);
-
- .chat-header-menu__icon {
- color: var(--td-error-color-6);
- }
-
- &:hover {
- background: var(--td-error-color-1);
- }
- }
-}
-
-.chat-header-menu__icon {
- flex: 0 0 auto;
- font-size: var(--app-text-xl);
- color: var(--td-text-color-secondary);
-}
-
-.chat-header-menu__divider {
- height: 1px;
- margin: 2px 6px;
- background: var(--td-component-stroke);
-}
-
-:root[theme-mode='dark'] .chat-header-menu-popup .t-popup__content {
- background: rgba(36, 36, 36, 0.92) !important;
- border-color: rgba(255, 255, 255, 0.08) !important;
- box-shadow:
- 0 0 0 0.5px rgba(255, 255, 255, 0.05),
- 0 2px 6px rgba(0, 0, 0, 0.2) !important;
-}
</style>
diff --git a/frontend/src/components/ChatReferencesDrawer.vue b/frontend/src/components/ChatReferencesDrawer.vue
index 6c8ea81d3..39b982792 100644
--- a/frontend/src/components/ChatReferencesDrawer.vue
+++ b/frontend/src/components/ChatReferencesDrawer.vue
@@ -33,6 +33,7 @@
v-for="section in sections"
:key="section.id"
class="chat-references-panel__section"
+ :class="{ 'chat-references-panel__section--documents': section.id === 'documents' }"
>
<h4 v-if="sections.length > 1" class="chat-references-panel__section-title">
{{ sectionTitle(section.id) }}
@@ -66,10 +67,10 @@
>
<template v-if="item.kind === 'document'">
<div class="reference-item__document">
- <t-icon name="file" class="reference-item__doc-icon" />
+ <ArtifactFileIcon :file-name="item.fileName || item.title" />
<div class="reference-item__document-main">
<div class="reference-item__title-row">
- <h5 class="reference-item__title">{{ item.title }}</h5>
+ <h5 class="reference-item__title" :title="item.title">{{ item.title }}</h5>
<a
v-if="item.knowledgeBaseId && !embeddedMode"
class="reference-item__open"
@@ -139,6 +140,7 @@ import { computed, nextTick, reactive, ref, watch } from 'vue'
import { useI18n } from 'vue-i18n'
import { useRouter } from 'vue-router'
import { useChatReferencesDrawer } from '@/composables/useChatReferencesDrawer'
+import ArtifactFileIcon from '@/views/chat/components/ArtifactFileIcon.vue'
import {
buildReferenceSections,
formatReferenceSnippet,
@@ -430,6 +432,11 @@ watch(visible, (open) => {
margin-top: 16px;
}
+.chat-references-panel__section--documents {
+ gap: 0;
+ padding-top: var(--app-space-2);
+}
+
.chat-references-panel__section-title {
margin: 0 0 8px;
padding: 0 4px;
@@ -466,17 +473,49 @@ watch(visible, (open) => {
.reference-item__document {
display: flex;
- align-items: flex-start;
- gap: 10px;
+ align-items: center;
+ gap: var(--app-space-3);
min-width: 0;
}
-.reference-item__doc-icon {
- flex-shrink: 0;
- width: 18px;
- margin-top: 3px;
- font-size: var(--app-text-xl);
- color: var(--td-text-color-primary);
+.reference-item--document {
+ border-radius: var(--app-radius-md);
+
+ &:hover:not(.is-highlighted) {
+ background: var(--td-bg-color-container-hover);
+ }
+
+ .reference-item__body {
+ padding: 10px var(--app-space-2);
+ border-radius: inherit;
+
+ &:focus-visible {
+ outline: 2px solid var(--td-text-color-secondary);
+ outline-offset: -2px;
+ }
+ }
+
+ .reference-item__title {
+ display: block;
+ font-size: var(--app-text-base);
+ font-weight: 500;
+ white-space: nowrap;
+ text-overflow: ellipsis;
+ }
+
+ .reference-item__snippet {
+ display: block;
+ margin-top: 2px;
+ color: var(--td-text-color-placeholder);
+ font-size: var(--app-text-sm);
+ line-height: 1.3;
+ white-space: nowrap;
+ text-overflow: ellipsis;
+ }
+
+ &:has(.reference-item__content) .reference-item__document {
+ align-items: flex-start;
+ }
}
.reference-item__document-main {
@@ -543,6 +582,7 @@ watch(visible, (open) => {
}
.reference-item:hover .reference-item__open,
+.reference-item:focus-within .reference-item__open,
.reference-item.is-highlighted .reference-item__open {
opacity: 1;
}
diff --git a/frontend/src/components/Input-field.vue b/frontend/src/components/Input-field.vue
index 9488a93cf..fa46e0ca7 100644
--- a/frontend/src/components/Input-field.vue
+++ b/frontend/src/components/Input-field.vue
@@ -724,35 +724,6 @@ const modelDropdownStyle = ref<Record<string, string>>({});
const displayedKbs = computed(() => selectedKbs.value.slice(0, 2));
const remainingCount = computed(() => Math.max(0, selectedKbs.value.length - 2));
-// 根据不同状态组合计算输入框的 placeholder
-const inputPlaceholder = computed(() => {
- // 如果选择了自定义智能体
- if (isCustomAgent.value && selectedAgent.value) {
- // 有描述时显示描述,否则显示"向 [名称] 提问"
- if (selectedAgent.value.description) {
- return selectedAgent.value.description;
- }
- return t('input.placeholderAgent', { name: selectedAgent.value.name });
- }
-
- const hasKnowledge = allSelectedItems.value.length > 0;
- const hasWebSearch = isWebSearchEnabled.value && isWebSearchConfigured.value;
-
- if (hasKnowledge && hasWebSearch) {
- // 有知识库 + 有网络搜索
- return t('input.placeholderKbAndWeb');
- } else if (hasKnowledge) {
- // 有知识库 + 无网络搜索
- return t('input.placeholderWithContext');
- } else if (hasWebSearch) {
- // 无知识库 + 有网络搜索
- return t('input.placeholderWebOnly');
- } else {
- // 无知识库 + 无网络搜索(纯模型对话)
- return t('input.placeholder');
- }
-});
-
// 加载知识库列表(自己的 + 共享的,用于 @ 提及等)
const loadKnowledgeBases = async (force = false) => {
try {
@@ -2705,7 +2676,7 @@ defineExpose({
</div>
<!-- 实际输入框 -->
- <t-textarea ref="textareaRef" v-model="query" :placeholder="inputPlaceholder" name="description" :autosize="true"
+ <t-textarea ref="textareaRef" v-model="query" :placeholder="t('input.placeholder')" name="description" :autosize="true"
@keydown="onKeydown" @input="onInput" @compositionstart="onCompositionStart" @compositionend="onCompositionEnd"
@paste="onPaste" />
diff --git a/frontend/src/components/PanelResizeHandle.vue b/frontend/src/components/PanelResizeHandle.vue
new file mode 100644
index 000000000..436587808
--- /dev/null
+++ b/frontend/src/components/PanelResizeHandle.vue
@@ -0,0 +1,115 @@
+<template>
+ <div class="panel-resize-handle" :class="[`panel-resize-handle--${edge}`, { 'is-dragging': dragging }]"
+ role="separator" aria-orientation="vertical" :aria-label="label" tabindex="0"
+ :aria-valuenow="value" :aria-valuemin="min" :aria-valuemax="max"
+ @pointerdown="start" @pointermove="move" @pointerup="finish" @pointercancel="finish"
+ @lostpointercapture="finish" @keydown="onKeydown">
+ <span class="panel-resize-handle__grip" aria-hidden="true" />
+ </div>
+</template>
+
+<script setup lang="ts">
+import { onBeforeUnmount, ref } from 'vue'
+
+defineProps<{ edge: 'left' | 'right'; label: string; value: number; min: number; max: number }>()
+const emit = defineEmits<{ start: []; resize: [delta: number, keyboard: boolean]; end: [] }>()
+const dragging = ref(false)
+let drag: { element: HTMLElement; pointerId: number; x: number; scale: number; cursor: string; userSelect: string } | null = null
+
+function start(event: PointerEvent) {
+ if (!event.isPrimary || event.button !== 0 || drag) return
+ event.preventDefault()
+ const element = event.currentTarget as HTMLElement
+ element.setPointerCapture(event.pointerId)
+ drag = {
+ element, pointerId: event.pointerId, x: event.clientX,
+ // The app's font-size setting uses CSS zoom; pointer coordinates are visual pixels.
+ scale: element.getBoundingClientRect().width / element.offsetWidth || 1,
+ cursor: document.body.style.cursor, userSelect: document.body.style.userSelect,
+ }
+ document.body.style.cursor = 'col-resize'
+ document.body.style.userSelect = 'none'
+ dragging.value = true
+ emit('start')
+}
+
+function move(event: PointerEvent) {
+ if (!drag || event.pointerId !== drag.pointerId) return
+ emit('resize', (event.clientX - drag.x) / drag.scale, false)
+}
+
+function finish(event?: PointerEvent) {
+ if (!drag || (event && event.pointerId !== drag.pointerId)) return
+ const previous = drag
+ drag = null
+ if (previous.element.hasPointerCapture(previous.pointerId)) previous.element.releasePointerCapture(previous.pointerId)
+ document.body.style.cursor = previous.cursor
+ document.body.style.userSelect = previous.userSelect
+ dragging.value = false
+ emit('end')
+}
+
+function onKeydown(event: KeyboardEvent) {
+ if (drag || !['ArrowLeft', 'ArrowRight'].includes(event.key)) return
+ event.preventDefault()
+ emit('start')
+ emit('resize', event.key === 'ArrowRight' ? 20 : -20, true)
+ emit('end')
+}
+
+onBeforeUnmount(() => finish())
+</script>
+
+<style scoped lang="less">
+.panel-resize-handle {
+ position: absolute;
+ top: 0;
+ bottom: 0;
+ width: 8px;
+ z-index: 10;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ cursor: col-resize;
+ touch-action: none;
+ outline: none;
+
+ &--left { left: 0; --grip-offset: -12px; }
+ &--right { right: 0; --grip-offset: 12px; }
+
+ // Bridge the gap around the floating grip without covering the neighboring
+ // scrollbar along the entire edge.
+ &::before {
+ content: '';
+ position: absolute;
+ top: 50%;
+ left: 50%;
+ width: 52px;
+ height: 80px;
+ transform: translate(-50%, -50%);
+ }
+
+ &__grip {
+ flex-shrink: 0;
+ width: 6px;
+ height: 56px;
+ border-radius: 3px;
+ background: color-mix(in srgb, var(--td-text-color-secondary) 28%, transparent);
+ opacity: 0;
+ transform: translateX(var(--grip-offset)) scale(0.94);
+ transition: opacity var(--app-motion-fast) ease, transform var(--app-motion-fast) ease, background-color var(--app-motion-fast) ease;
+ pointer-events: none;
+ }
+
+ &:hover &__grip,
+ &:focus-visible &__grip,
+ &.is-dragging &__grip {
+ opacity: 1;
+ transform: translateX(var(--grip-offset)) scale(1);
+ }
+
+ &.is-dragging &__grip {
+ background: color-mix(in srgb, var(--td-text-color-secondary) 42%, transparent);
+ }
+}
+</style>
diff --git a/frontend/src/components/SessionSidebarRow.vue b/frontend/src/components/SessionSidebarRow.vue
index 63b7ae648..d5e4be0c6 100644
--- a/frontend/src/components/SessionSidebarRow.vue
+++ b/frontend/src/components/SessionSidebarRow.vue
@@ -4,6 +4,7 @@
!batchMode && activePath === item.path ? 'submenu_item_active' : '',
batchMode && selectedIds.includes(item.id) ? 'submenu_item_selected' : '',
batchMode ? 'submenu_item_batch' : '',
+ menuOpen ? 'submenu_item--menu-open' : '',
]" @mouseenter="emit('hover-in')" @mouseleave="emit('hover-out')"
@click="batchMode ? emit('toggle-select') : emit('navigate')">
<t-checkbox v-if="batchMode" class="batch-checkbox" :checked="selectedIds.includes(item.id)" @click.stop
@@ -17,7 +18,7 @@
<t-tooltip v-if="item.parent_session_id" content="由其他会话分叉而来">
<t-icon name="git-branch" class="submenu_fork_icon" />
</t-tooltip>
- <span class="submenu_title-text">{{ item.title }}</span>
+ <span ref="titleTextRef" class="submenu_title-text">{{ item.title }}</span>
<span v-if="apiOwnerTag" class="session-owner-tag" :class="`session-owner-tag--${apiOwnerTag.kind}`"
:title="apiOwnerTag.full">{{ apiOwnerTag.label }}</span>
</span>
@@ -26,17 +27,17 @@
<div v-if="!batchMode" class="session-row-menu-wrap" @click.stop>
<t-popup v-model:visible="menuOpen" :overlay-class-name="menuOverlayClass" trigger="click" destroy-on-close
placement="bottom-right" @visible-change="onMenuVisibleChange">
- <button type="button" class="menu-more-wrap" aria-haspopup="menu" :aria-expanded="menuOpen" @click.stop>
+ <button type="button" class="menu-more-wrap" :aria-label="t('chatHeader.moreActions')" aria-haspopup="menu" :aria-expanded="menuOpen" @click.stop>
<t-icon name="ellipsis" class="menu-more" />
</button>
<template #content>
- <div class="session-action-menu" @click.stop>
+ <div class="card-menu" @click.stop>
<template v-if="menuMode === 'menu'">
<template v-for="(option, index) in menuOptions" :key="option.value">
<div v-if="shouldShowDividerBefore(option.value, index)" class="session-action-menu__divider" />
- <button type="button" class="session-action-menu__item"
- :class="{ 'is-danger': option.theme === 'error' }" @click="handleMenuClick(option)">
- <component :is="option.prefixIcon" v-if="option.prefixIcon" class="session-action-menu__icon" />
+ <button type="button" class="card-menu-item"
+ :class="{ danger: option.theme === 'error' }" @click="handleMenuClick(option)">
+ <component :is="option.prefixIcon" v-if="option.prefixIcon" class="icon" />
<span>{{ option.content }}</span>
</button>
</template>
@@ -69,6 +70,7 @@
import { computed, nextTick, ref } from 'vue'
import { useI18n } from 'vue-i18n'
import { normalizeSessionTitleDraft, SESSION_TITLE_MAX_LENGTH } from './sessionTitleEdit'
+import { useSessionTitleMotion } from '@/composables/useSessionTitleMotion'
interface SessionMenuOption {
content: string
@@ -106,11 +108,13 @@ const menuMode = ref<MenuMode>('menu')
const titleEditing = ref(false)
const titleDraft = ref('')
const titleInputRef = ref<HTMLInputElement | null>(null)
+const titleTextRef = ref<HTMLElement | null>(null)
+useSessionTitleMotion(titleTextRef, () => props.item.id, () => props.item.title)
const menuOverlayClass = computed(() => (
menuMode.value === 'menu'
- ? 'session-action-menu-popup'
- : 'session-action-menu-popup is-confirm'
+ ? 'card-more session-action-menu-popup'
+ : 'card-more session-action-menu-popup is-confirm'
))
/**
@@ -147,7 +151,7 @@ const backToMenu = (): void => {
const shouldShowDividerBefore = (value: string, index: number): boolean => {
if (index === 0) return false
- return value === 'clearMessages' || value === 'delete'
+ return value === 'clearMessages'
}
const startTitleEdit = (): void => {
@@ -238,7 +242,31 @@ const confirmDangerAction = (): void => {
.session-row-menu-wrap {
position: relative;
- flex: 0 0 auto;
+ flex: 0 0 0;
+ width: 0;
+ min-width: 0;
+ opacity: 0;
+ pointer-events: none;
+}
+
+.submenu_item:hover,
+.submenu_item:focus-within,
+.submenu_item--menu-open {
+ .session-row-menu-wrap {
+ flex-basis: 24px;
+ width: 24px;
+ opacity: 1;
+ pointer-events: auto;
+ }
+}
+
+@media (hover: none) {
+ .session-row-menu-wrap {
+ flex-basis: 24px;
+ width: 24px;
+ opacity: 1;
+ pointer-events: auto;
+ }
}
.session-title-edit {
@@ -311,23 +339,9 @@ const confirmDangerAction = (): void => {
</style>
<style lang="less">
-.session-action-menu-popup {
+.card-more.session-action-menu-popup {
z-index: 3000 !important;
- .t-popup__content {
- padding: 4px !important;
- margin-top: 2px !important;
- min-width: 160px !important;
- width: max-content !important;
- border-radius: var(--app-radius-md) !important;
- background: var(--td-bg-color-container) !important;
- border: 0.5px solid var(--td-component-stroke) !important;
- box-shadow:
- 0 0 0 0.5px rgba(0, 0, 0, 0.03),
- 0 2px 6px rgba(0, 0, 0, 0.08) !important;
- overflow: hidden;
- }
-
&.is-confirm .t-popup__content {
padding: 12px !important;
width: 260px !important;
@@ -335,58 +349,6 @@ const confirmDangerAction = (): void => {
}
}
-.session-action-menu {
- display: flex;
- flex-direction: column;
- gap: 1px;
- min-width: 152px;
-}
-
-.session-action-menu__item {
- display: flex;
- align-items: center;
- gap: 8px;
- width: 100%;
- min-height: 32px;
- padding: 0 12px;
- border: 0;
- border-radius: 5px;
- color: var(--td-text-color-primary);
- background: transparent;
- font-size: var(--app-text-base);
- line-height: 20px;
- text-align: left;
- white-space: nowrap;
- box-sizing: border-box;
- cursor: pointer;
-
- &:hover {
- background: var(--td-bg-color-container-hover);
- }
-
- &.is-danger {
- color: var(--td-error-color-6);
-
- .session-action-menu__icon {
- color: var(--td-error-color-6);
- }
-
- &:hover {
- background: var(--td-error-color-1);
- }
- }
-}
-
-.session-action-menu__icon {
- flex: 0 0 auto;
- display: inline-flex;
- color: var(--td-text-color-secondary);
-
- .t-icon {
- font-size: var(--app-text-xl);
- }
-}
-
.session-action-menu__divider {
height: 1px;
margin: 2px 6px;
@@ -450,11 +412,4 @@ const confirmDangerAction = (): void => {
}
}
-:root[theme-mode='dark'] .session-action-menu-popup .t-popup__content {
- background: rgba(36, 36, 36, 0.92) !important;
- border-color: rgba(255, 255, 255, 0.08) !important;
- box-shadow:
- 0 0 0 0.5px rgba(255, 255, 255, 0.05),
- 0 2px 6px rgba(0, 0, 0, 0.2) !important;
-}
</style>
diff --git a/frontend/src/components/chat/ChatQuestionMinimap.test.ts b/frontend/src/components/chat/ChatQuestionMinimap.test.ts
index 71ab0daa4..8b98c56d2 100644
--- a/frontend/src/components/chat/ChatQuestionMinimap.test.ts
+++ b/frontend/src/components/chat/ChatQuestionMinimap.test.ts
@@ -15,7 +15,7 @@ test('opens a following preview card to the right of the left-side rail', () =>
assert.match(component, /question-minimap__question/)
assert.match(component, /question-minimap__answer/)
assert.doesNotMatch(component, /question-minimap__kicker/)
- assert.match(component, /CLOSE_DELAY_MS = 150/)
+ assert.match(component, /CLOSE_DELAY_MS = 180/)
assert.match(component, /left: var\(--chat-content-inset, 20px\)/)
assert.match(component, /top: `\$\{peakYPx\}px`/)
assert.doesNotMatch(component, /flex-direction: row-reverse/)
@@ -76,9 +76,9 @@ test('does not paint the first question green on hover-open', () => {
test('highlights visible messages without losing them when previewing another tick', () => {
assert.match(component, /peakId/)
- assert.match(component, /highlightedIds\.has\(tick\.id\)/)
- assert.match(component, /new Set\(visibleIds\.value\)/)
- assert.match(composable, /visibleMessageIds\(measured, el\.scrollTop, el\.clientHeight\)/)
+ assert.match(component, /visibleIds\.has\(tick\.id\)/)
+ assert.doesNotMatch(component, /ids\.add\(peakId/)
+ assert.match(composable, /visibleMessageIds\(measured, el\.scrollTop, el\.clientHeight, bottomInset\)/)
})
test('keeps the preview card at 13px instead of inheriting the chat 20px type', () => {
diff --git a/frontend/src/components/chat/ChatQuestionMinimap.vue b/frontend/src/components/chat/ChatQuestionMinimap.vue
index f13fcbbf6..c84d93154 100644
--- a/frontend/src/components/chat/ChatQuestionMinimap.vue
+++ b/frontend/src/components/chat/ChatQuestionMinimap.vue
@@ -7,6 +7,7 @@
:aria-label="t('chat.questionMinimapAriaLabel')"
@mouseenter="handleMouseEnter"
@mouseleave="handleMouseLeave"
+ @focusout="handleFocusOut"
>
<button
class="question-minimap__rail"
@@ -23,10 +24,13 @@
v-for="tick in ticks"
:key="tick.id"
class="question-minimap__tick"
- :class="{ 'question-minimap__tick--active': highlightedIds.has(tick.id) }"
+ :class="{
+ 'question-minimap__tick--active': visibleIds.has(tick.id),
+ 'question-minimap__tick--previewed': panelOpen && peakId === tick.id,
+ }"
:style="{
top: `${tick.yPx}px`,
- transform: `translateY(-50%) scaleX(${tickDisplayScale(tick.yPx, mountainPointerY, highlightedIds.has(tick.id))})`,
+ transform: `translateY(-50%) scaleX(${tickDisplayScale(tick.yPx, mountainPointerY, visibleIds.has(tick.id))})`,
}"
/>
</button>
@@ -43,20 +47,23 @@
role="dialog"
:aria-label="t('chat.questionMinimapTitle')"
:style="{ top: `${peakYPx}px` }"
- @click="handleQuestionClick(peakTurn.id)"
+ @keydown.esc.stop.prevent="closePanel"
>
- <p class="question-minimap__question" :title="questionText(peakTurn)">
- {{ questionText(peakTurn) }}
- </p>
- <p v-if="answerText(peakTurn)" class="question-minimap__answer">
- {{ answerText(peakTurn) }}
- </p>
+ <button type="button" class="question-minimap__preview" @click="handleQuestionClick(peakTurn.id)">
+ <span class="question-minimap__meta">
+ <t-icon name="chat" size="13px" aria-hidden="true" />
+ <span class="question-minimap__position">{{ t('chat.questionMinimapPosition', { current: peakIndex + 1, total: anchoredQuestions.length }) }}</span>
+ <t-icon name="arrow-up" size="14px" class="question-minimap__jump-icon" aria-hidden="true" />
+ </span>
+ <span class="question-minimap__question">{{ questionText(peakTurn) }}</span>
+ <span v-if="answerText(peakTurn)" class="question-minimap__answer">{{ answerText(peakTurn) }}</span>
+ </button>
</section>
</nav>
</template>
<script setup lang="ts">
-import { computed, onBeforeUnmount, onMounted, ref, toRef } from 'vue'
+import { computed, onBeforeUnmount, onMounted, ref, toRef, watch } from 'vue'
import { useI18n } from 'vue-i18n'
import { useChatQuestionMinimap } from '@/composables/useChatQuestionMinimap'
import {
@@ -68,7 +75,8 @@ import {
type OutlineMessage,
} from '@/utils/chatQuestionMinimap'
-const CLOSE_DELAY_MS = 150
+const OPEN_DELAY_MS = 120
+const CLOSE_DELAY_MS = 180
const props = defineProps<{
scrollContainer: HTMLElement | null
@@ -114,11 +122,7 @@ const peakId = computed(() => {
const peakTurn = computed(() => (
questions.value.find((question) => question.id === peakId.value) ?? null
))
-const highlightedIds = computed(() => {
- const ids = new Set(visibleIds.value)
- if ((hoveredId.value || keyboardIndex.value >= 0) && peakId.value) ids.add(peakId.value)
- return ids
-})
+const peakIndex = computed(() => anchoredQuestions.value.findIndex(turn => turn.id === peakId.value))
const peakYPx = computed(() => {
const tick = ticks.value.find((item) => item.id === peakId.value)
return tick?.yPx ?? 0
@@ -129,6 +133,7 @@ const mountainPointerY = computed(() => {
})
let closeTimer: number | null = null
+let openTimer: number | null = null
const questionText = (question: OutlineMessage) => (
question.role === 'assistant'
@@ -147,13 +152,20 @@ const clearCloseTimer = () => {
closeTimer = null
}
+const clearOpenTimer = () => {
+ if (openTimer !== null) window.clearTimeout(openTimer)
+ openTimer = null
+}
+
const openPanel = () => {
+ clearOpenTimer()
clearCloseTimer()
hoverOpen.value = true
keyboardIndex.value = -1
}
const closePanel = () => {
+ clearOpenTimer()
clearCloseTimer()
hoverOpen.value = false
pinnedOpen.value = false
@@ -162,7 +174,12 @@ const closePanel = () => {
keyboardIndex.value = -1
}
+watch(visible, (isVisible) => {
+ if (!isVisible) closePanel()
+})
+
const scheduleClose = () => {
+ clearOpenTimer()
clearCloseTimer()
closeTimer = window.setTimeout(() => {
hoverOpen.value = false
@@ -179,7 +196,9 @@ const syncKeyboardIndexToActive = () => {
const handleMouseEnter = () => {
if (isCoarsePointer.value) return
- openPanel()
+ clearCloseTimer()
+ if (panelOpen.value || openTimer !== null) return
+ openTimer = window.setTimeout(openPanel, OPEN_DELAY_MS)
}
const handleMouseLeave = () => {
@@ -191,23 +210,31 @@ const handleRailPointerMove = (event: PointerEvent) => {
if (isCoarsePointer.value) return
const target = event.currentTarget as HTMLElement
- pointerY.value = event.clientY - target.getBoundingClientRect().top
+ const rect = target.getBoundingClientRect()
+ pointerY.value = (event.clientY - rect.top) * trackHeight.value / (rect.height || 1)
hoveredId.value = nearestTickId(ticks.value, pointerY.value)
+ keyboardIndex.value = -1
}
-const handleRailClick = () => {
+const handleRailClick = (event: MouseEvent) => {
+ const rect = (event.currentTarget as HTMLElement).getBoundingClientRect()
+ const id = event.detail === 0 ? peakId.value : nearestTickId(
+ ticks.value, (event.clientY - rect.top) * trackHeight.value / (rect.height || 1),
+ )
if (!isCoarsePointer.value) {
- const id = peakId.value
if (id) handleQuestionClick(id)
return
}
+ clearOpenTimer()
clearCloseTimer()
- pinnedOpen.value = !pinnedOpen.value
+ pinnedOpen.value = !pinnedOpen.value || hoveredId.value !== id
hoverOpen.value = false
- if (pinnedOpen.value) {
- hoveredId.value = activeId.value ?? questions.value[0]?.id ?? null
- }
+ hoveredId.value = id
+}
+
+const handleFocusOut = (event: FocusEvent) => {
+ if (!rootRef.value?.contains(event.relatedTarget as Node | null)) closePanel()
}
const handleQuestionClick = (id: string) => {
@@ -222,7 +249,10 @@ const moveKeyboard = (direction: 1 | -1) => {
if (anchored.length === 0) return
const wasOpen = panelOpen.value
+ clearOpenTimer()
clearCloseTimer()
+ pointerY.value = null
+ hoveredId.value = null
hoverOpen.value = true
if (!wasOpen) {
syncKeyboardIndexToActive()
@@ -262,12 +292,20 @@ const handleRailKeydown = (event: KeyboardEvent) => {
return
}
- if (event.key === 'Enter') {
+ if (event.key === 'Enter' || event.key === ' ') {
event.preventDefault()
jumpKeyboardQuestion()
return
}
+ if (event.key === 'Home' || event.key === 'End') {
+ event.preventDefault()
+ openPanel()
+ const target = event.key === 'Home' ? anchoredQuestions.value[0] : anchoredQuestions.value.at(-1)
+ keyboardIndex.value = questions.value.findIndex(question => question.id === target?.id)
+ return
+ }
+
if (event.key === 'Escape') {
event.preventDefault()
closePanel()
@@ -275,7 +313,7 @@ const handleRailKeydown = (event: KeyboardEvent) => {
}
const handleDocumentPointerDown = (event: PointerEvent) => {
- if (!isCoarsePointer.value || !panelOpen.value) return
+ if (!panelOpen.value && openTimer === null) return
const target = event.target as Node | null
if (target && rootRef.value?.contains(target)) return
@@ -288,6 +326,7 @@ onMounted(() => {
})
onBeforeUnmount(() => {
+ clearOpenTimer()
clearCloseTimer()
document.removeEventListener('pointerdown', handleDocumentPointerDown)
})
@@ -315,7 +354,7 @@ onBeforeUnmount(() => {
.question-minimap__rail {
position: relative;
- width: 24px;
+ width: 28px;
height: 100%;
padding: 0;
overflow: visible;
@@ -324,7 +363,18 @@ onBeforeUnmount(() => {
cursor: pointer;
}
+.question-minimap__rail::before {
+ content: '';
+ position: absolute;
+ inset: -8px -4px;
+ border-radius: 6px;
+}
+
.question-minimap__rail:focus-visible {
+ outline: none;
+}
+
+.question-minimap__rail:focus-visible::before {
outline: 2px solid var(--td-brand-color);
outline-offset: 2px;
}
@@ -332,7 +382,7 @@ onBeforeUnmount(() => {
.question-minimap__tick {
position: absolute;
left: 0;
- width: 8px;
+ width: 9px;
height: 2px;
border-radius: 1px;
background: var(--td-text-color-secondary);
@@ -342,6 +392,11 @@ onBeforeUnmount(() => {
transition: transform var(--app-motion-instant) ease-out, background var(--app-motion-instant) ease-out, opacity var(--app-motion-instant) ease-out;
}
+.question-minimap__tick--previewed {
+ background: var(--td-text-color-primary);
+ opacity: 0.7;
+}
+
.question-minimap__tick--active {
background: var(--td-brand-color);
opacity: 0.85;
@@ -353,16 +408,18 @@ onBeforeUnmount(() => {
.question-minimap__panel {
position: absolute;
- left: 20px;
- width: 220px;
+ left: 28px;
+ width: 264px;
+ max-width: calc(100vw - 80px);
max-height: min(280px, 40vh);
- padding: 6px 8px;
+ padding: 0;
overflow: hidden;
scrollbar-width: none;
- border: 1px solid var(--td-component-stroke);
- border-radius: var(--app-radius-sm);
+ border: 0.5px solid var(--td-component-stroke);
+ border-radius: var(--app-radius-lg);
background: var(--td-bg-color-container);
- box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
+ box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04), 0 6px 20px rgba(0, 0, 0, 0.08);
+ transition: top var(--app-motion-fast) ease-out;
transform: translateY(-50%);
cursor: pointer;
}
@@ -371,34 +428,67 @@ onBeforeUnmount(() => {
display: none;
}
+.question-minimap__preview {
+ display: block;
+ width: 100%;
+ padding: 12px 14px;
+ border: 0;
+ text-align: left;
+ font-family: var(--app-font-family);
+ background: transparent;
+ cursor: pointer;
+ transition: background-color var(--app-motion-fast) ease;
+
+ &:hover { background: var(--td-bg-color-container-hover); }
+ &:focus-visible { outline: 2px solid var(--td-brand-color); outline-offset: -3px; border-radius: var(--app-radius-lg); }
+}
+
+.question-minimap__meta {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ margin-bottom: 8px;
+ font-size: var(--app-text-xs);
+ color: var(--td-text-color-placeholder);
+}
+
+.question-minimap__position {
+ font-variant-numeric: tabular-nums;
+}
+
+.question-minimap__jump-icon { margin-left: auto; transform: rotate(-45deg); }
+
.question-minimap__question,
.question-minimap__answer {
margin: 0;
font-size: var(--app-text-md);
font-weight: 400;
- line-height: 1.45;
+ line-height: 1.6;
}
.question-minimap__question {
+ display: -webkit-box;
overflow: hidden;
color: var(--td-text-color-primary);
font-weight: 500;
- text-overflow: ellipsis;
- white-space: nowrap;
+ -webkit-box-orient: vertical;
+ -webkit-line-clamp: 2;
+ overflow-wrap: anywhere;
}
.question-minimap__answer {
display: -webkit-box;
- margin-top: 4px;
+ margin-top: 6px;
overflow: hidden;
color: var(--td-text-color-secondary);
-webkit-box-orient: vertical;
-webkit-line-clamp: 3;
- opacity: 0.8;
+ overflow-wrap: anywhere;
}
@media (prefers-reduced-motion: reduce) {
- .question-minimap__tick {
+ .question-minimap__tick,
+ .question-minimap__panel {
transition: none;
}
}
diff --git a/frontend/src/components/chat/SandboxSidePanel.vue b/frontend/src/components/chat/SandboxSidePanel.vue
index 0a24f2794..1a168aed9 100644
--- a/frontend/src/components/chat/SandboxSidePanel.vue
+++ b/frontend/src/components/chat/SandboxSidePanel.vue
@@ -9,11 +9,9 @@
:aria-label="t('chat.sandbox.panelTitle')"
>
<!-- 左缘拖拽把手:按住向左/右拖动调整面板宽度。 -->
- <div
- class="chat-sandbox-panel__resize-handle"
- :aria-hidden="true"
- @mousedown.prevent="startResize"
- />
+ <PanelResizeHandle edge="left" :label="t('knowledgeStages.resizeDrawer')"
+ :value="panel.width.value" :min="SANDBOX_PANEL_MIN_WIDTH" :max="SANDBOX_PANEL_MAX_WIDTH"
+ @start="startResize" @resize="resizePanel" @end="resizing = false" />
<div class="chat-sandbox-panel__tabs">
<div class="chat-sandbox-panel__tablist" role="tablist">
<button
@@ -105,6 +103,7 @@ import {
import SandboxTerminal from '@/views/chat/components/SandboxTerminal.vue'
import SandboxDesktop from '@/views/chat/components/SandboxDesktop.vue'
import ChatArtifactsPanel from '@/views/chat/components/ChatArtifactsPanel.vue'
+import PanelResizeHandle from '@/components/PanelResizeHandle.vue'
import { useChatResourcesStore } from '@/stores/chatResources'
import type { SessionArtifactItem } from '@/utils/sessionArtifacts'
@@ -221,31 +220,16 @@ watch(
// --- 左缘拖拽调宽 -------------------------------------------------------
const resizing = ref(false)
-// 与面板样式一致:仅宽视口(≥1400px)且参考面板同开时才整体左移 420px。
-const dragBaseOffset = () =>
- props.shifted && typeof window !== 'undefined' && window.innerWidth >= 1400 ? 420 : 0
-
-function startResize(event: MouseEvent) {
+let resizeStartWidth = 0
+function startResize() {
if (!panel) return
+ resizeStartWidth = panel.width.value
resizing.value = true
- // 拖拽期间禁用全局文本选择,避免 mousemove 命中 iframe / 文本。
- document.body.style.userSelect = 'none'
- document.body.style.cursor = 'col-resize'
-
- const onMove = (moveEvent: MouseEvent) => {
- const next = window.innerWidth - moveEvent.clientX - dragBaseOffset()
- panel.setWidth(Math.min(SANDBOX_PANEL_MAX_WIDTH, Math.max(SANDBOX_PANEL_MIN_WIDTH, next)))
- }
- const cleanup = () => {
- document.removeEventListener('mousemove', onMove)
- document.removeEventListener('mouseup', cleanup)
- document.body.style.userSelect = ''
- document.body.style.cursor = ''
- resizing.value = false
- }
- document.addEventListener('mousemove', onMove)
- document.addEventListener('mouseup', cleanup)
}
+function resizePanel(delta: number) {
+ panel?.setWidth(resizeStartWidth - delta)
+}
+
</script>
<style scoped lang="less">
@@ -281,33 +265,6 @@ function startResize(event: MouseEvent) {
}
}
-// 左缘拖拽把手:一条贴边的窄热区,hover 时显示视觉提示。
-.chat-sandbox-panel__resize-handle {
- position: absolute;
- top: 0;
- left: -3px;
- bottom: 0;
- width: 7px;
- z-index: 3;
- cursor: col-resize;
-
- &::after {
- content: '';
- position: absolute;
- top: 0;
- left: 3px;
- bottom: 0;
- width: 1px;
- background: transparent;
- transition: background-color var(--app-motion-fast) ease;
- }
-
- &:hover::after,
- .is-resizing &::after {
- background: var(--td-brand-color);
- }
-}
-
.chat-sandbox-panel__close {
border: 0;
background: var(--td-bg-color-secondarycontainer);
diff --git a/frontend/src/components/css/artifact-filter-tabs.less b/frontend/src/components/css/artifact-filter-tabs.less
new file mode 100644
index 000000000..a7c7371d3
--- /dev/null
+++ b/frontend/src/components/css/artifact-filter-tabs.less
@@ -0,0 +1,36 @@
+.artifact-filter-tabs() {
+ display: inline-flex;
+ flex-wrap: wrap;
+ gap: 2px;
+ padding: 3px;
+ border-radius: var(--app-radius-md);
+ background: var(--td-bg-color-secondarycontainer);
+
+ button {
+ padding: 5px 12px;
+ border: 0;
+ border-radius: var(--app-radius-sm);
+ background: transparent;
+ color: var(--td-text-color-secondary);
+ font: inherit;
+ font-size: var(--app-text-md);
+ cursor: pointer;
+ transition: background var(--app-motion-fast) ease, color var(--app-motion-fast) ease;
+
+ &:hover {
+ color: var(--td-text-color-primary);
+ }
+
+ &[aria-selected='true'],
+ &[aria-pressed='true'] {
+ background: var(--td-bg-color-container);
+ color: var(--td-brand-color);
+ box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
+ }
+
+ &:focus-visible {
+ outline: 2px solid var(--td-brand-color);
+ outline-offset: 2px;
+ }
+ }
+}
diff --git a/frontend/src/components/document-preview.vue b/frontend/src/components/document-preview.vue
index baf906c5d..ded9ad8ac 100644
--- a/frontend/src/components/document-preview.vue
+++ b/frontend/src/components/document-preview.vue
@@ -1018,7 +1018,7 @@ onUnmounted(() => {
// ── Deep styles (v-html / third-party components) ──
// Shared table mixin for v-html content
-.preview-table() {
+.preview-table(@header-bg: @accent-bg; @hover-bg: @accent-bg) {
width: 100%;
border-collapse: collapse;
font-size: var(--app-text-md);
@@ -1028,12 +1028,12 @@ onUnmounted(() => {
text-align: left;
}
th {
- background: @accent-bg;
+ background: @header-bg;
font-weight: 600;
color: @text-primary;
}
tr:hover td {
- background: @accent-bg;
+ background: @hover-bg;
transition: @transition;
}
}
@@ -1058,14 +1058,17 @@ onUnmounted(() => {
blockquote {
margin: 12px 0;
padding: 8px 16px;
- border-left: 4px solid @accent;
+ border-left: 4px solid @border-color;
background: @bg-subtle;
color: var(--td-text-color-secondary);
}
ul, ol { padding-left: 24px; margin: 8px 0; }
li { margin: 4px 0; }
- table { .preview-table(); margin: 12px 0; }
+ table {
+ .preview-table(@bg-muted; var(--td-bg-color-container-hover));
+ margin: 12px 0;
+ }
pre {
margin: 12px 0;
diff --git a/frontend/src/components/menu.vue b/frontend/src/components/menu.vue
index 38f9166b0..4b5418c04 100644
--- a/frontend/src/components/menu.vue
+++ b/frontend/src/components/menu.vue
@@ -1,5 +1,5 @@
<template>
- <div class="aside_box" :class="{ 'aside_box--collapsed': uiStore.sidebarCollapsed }">
+ <div class="aside_box" :class="{ 'aside_box--collapsed': uiStore.sidebarCollapsed, 'aside_box--resizing': uiStore.sidebarResizing }">
<!-- 展开时:Logo + 搜索/折叠按钮同行 -->
<div class="logo_row" v-if="!uiStore.sidebarCollapsed">
<div class="logo_box" @click="router.push('/platform/knowledge-bases')" style="cursor: pointer;">
@@ -52,8 +52,10 @@
<!-- 空间选择器:仅在用户可切换空间时显示 -->
<TenantSelector v-if="canAccessAllTenants && !uiStore.sidebarCollapsed" />
- <!-- 折叠时右侧拖拽展开手柄 -->
- <div v-if="uiStore.sidebarCollapsed" class="sidebar-drag-handle" @mousedown="onDragHandleMouseDown" />
+ <!-- 侧栏边缘拖拽调宽,拖窄时自动收缩 -->
+ <PanelResizeHandle edge="right" :label="t('knowledgeStages.resizeDrawer')"
+ :value="uiStore.sidebarDisplayWidth" :min="SIDEBAR_COLLAPSED_WIDTH" :max="SIDEBAR_MAX_WIDTH"
+ @start="startSidebarResize" @resize="resizeSidebar" @end="uiStore.sidebarResizing = false" />
<!-- 上半部分:新对话吸顶 + 知识库/智能体/共享空间/历史会话随滚动一起滚走 -->
<div class="menu_top" ref="scrollContainer" @scroll="handleScroll">
@@ -206,6 +208,8 @@ import { getSessionsList, batchDelSessions, deleteAllSessions, getSession } from
import { useChatResourcesStore } from '@/stores/chatResources';
import { listAllIMChannels } from '@/api/agent/index';
import SessionSidebarRow from './SessionSidebarRow.vue';
+import PanelResizeHandle from './PanelResizeHandle.vue';
+import { SIDEBAR_COLLAPSED_WIDTH, SIDEBAR_MIN_WIDTH, SIDEBAR_MAX_WIDTH } from '@/utils/sidebarWidth';
import {
clearSession,
removeSession,
@@ -650,20 +654,20 @@ const buildSessionMenuOptions = (item: any) => {
options.push({
content: t('menu.unpin'),
value: 'unpin',
- prefixIcon: () => h(TIcon, { name: 'pin-filled', size: '16px' }),
+ prefixIcon: () => h(TIcon, { name: 'pin-filled' }),
});
} else {
options.push({
content: t('menu.pin'),
value: 'pin',
- prefixIcon: () => h(TIcon, { name: 'pin', size: '16px' }),
+ prefixIcon: () => h(TIcon, { name: 'pin' }),
});
}
options.push(
- { content: t('menu.renameSession'), value: 'rename', prefixIcon: () => h(TIcon, { name: 'edit-1', size: '16px' }) },
- { content: t('menu.clearMessages'), value: 'clearMessages', prefixIcon: () => h(TIcon, { name: 'clear', size: '16px' }) },
- { content: t('menu.batchManage'), value: 'batchManage', prefixIcon: () => h(TIcon, { name: 'queue', size: '16px' }) },
- { content: t('upload.deleteRecord'), value: 'delete', theme: 'error', prefixIcon: () => h(TIcon, { name: 'delete', size: '16px' }) },
+ { content: t('menu.renameSession'), value: 'rename', prefixIcon: () => h(TIcon, { name: 'edit-1' }) },
+ { content: t('menu.clearMessages'), value: 'clearMessages', prefixIcon: () => h(TIcon, { name: 'clear' }) },
+ { content: t('menu.batchManage'), value: 'batchManage', prefixIcon: () => h(TIcon, { name: 'queue' }) },
+ { content: t('upload.deleteRecord'), value: 'delete', theme: 'error', prefixIcon: () => h(TIcon, { name: 'delete' }) },
);
return options;
};
@@ -1193,24 +1197,19 @@ const mouseenteMenu = (path: string) => {
const mouseleaveMenu = (path: string) => {
}
-const onDragHandleMouseDown = (e: MouseEvent) => {
- e.preventDefault()
- const startX = e.clientX
- const expandThreshold = 40
-
- const onMouseMove = (ev: MouseEvent) => {
- if (ev.clientX - startX > expandThreshold) {
- uiStore.expandSidebar()
- cleanup()
- }
- }
- const onMouseUp = () => cleanup()
- const cleanup = () => {
- document.removeEventListener('mousemove', onMouseMove)
- document.removeEventListener('mouseup', onMouseUp)
+let sidebarResizeStartWidth = 0
+const startSidebarResize = () => {
+ sidebarResizeStartWidth = uiStore.sidebarDisplayWidth
+ uiStore.sidebarResizing = true
+}
+const resizeSidebar = (delta: number, keyboard: boolean) => {
+ if (keyboard && uiStore.sidebarCollapsed && delta > 0) {
+ uiStore.expandSidebar()
+ } else if (keyboard && uiStore.sidebarWidth === SIDEBAR_MIN_WIDTH && delta < 0) {
+ uiStore.collapseSidebar()
+ } else {
+ uiStore.resizeSidebar(sidebarResizeStartWidth + delta)
}
- document.addEventListener('mousemove', onMouseMove)
- document.addEventListener('mouseup', onMouseUp)
}
@@ -1224,8 +1223,9 @@ const onDragHandleMouseDown = (e: MouseEvent) => {
--sidebar-icon-gap: 8px;
--sidebar-text-inset: calc(var(--sidebar-inset-x) + var(--sidebar-icon-size) + var(--sidebar-icon-gap)); // 40px
- min-width: 260px;
- width: 260px;
+ min-width: 0;
+ width: var(--sidebar-width, 260px);
+ flex-shrink: 0;
padding: 8px 6px 6px;
background: var(--td-bg-color-sidebar);
box-sizing: border-box;
@@ -1234,7 +1234,7 @@ const onDragHandleMouseDown = (e: MouseEvent) => {
scaled, so at "large" the sidebar would extend past the window. The
ancestor chain (html/body/#app/.main) is already height: 100%. */
height: 100%;
- overflow: hidden;
+ overflow: visible;
display: flex;
flex-direction: column;
border-right: 1px solid var(--td-component-stroke);
@@ -1247,6 +1247,10 @@ const onDragHandleMouseDown = (e: MouseEvent) => {
padding-top: 30px;
}
+ &--resizing {
+ transition: none;
+ }
+
&--collapsed {
min-width: 60px;
width: 60px;
@@ -1305,20 +1309,6 @@ const onDragHandleMouseDown = (e: MouseEvent) => {
}
}
- .sidebar-drag-handle {
- position: absolute;
- top: 0;
- right: -3px;
- width: 6px;
- height: 100%;
- cursor: ew-resize;
- z-index: 10;
-
- &:hover {
- background: var(--td-brand-color-light);
- }
- }
-
.logo_box {
display: flex;
align-items: center;
@@ -1623,6 +1613,7 @@ const onDragHandleMouseDown = (e: MouseEvent) => {
&.session-chat-row .session-list-row {
min-height: 30px;
+ padding-right: 6px;
border-radius: var(--app-radius-sm);
transition: background var(--app-motion-fast) ease, color var(--app-motion-fast) ease;
}
@@ -1653,10 +1644,6 @@ const onDragHandleMouseDown = (e: MouseEvent) => {
:deep(.menu-more) {
color: var(--td-text-color-primary);
}
-
- :deep(.menu-more-wrap) {
- opacity: 1;
- }
}
&.session-chat-row--selected .session-list-row {
@@ -1702,7 +1689,6 @@ const onDragHandleMouseDown = (e: MouseEvent) => {
}
.menu-more-wrap {
- opacity: 0;
transition: opacity var(--app-motion-base) ease;
flex-shrink: 0;
}
diff --git a/frontend/src/composables/useChatQuestionMinimap.ts b/frontend/src/composables/useChatQuestionMinimap.ts
index 74d04f2fb..dba15da37 100644
--- a/frontend/src/composables/useChatQuestionMinimap.ts
+++ b/frontend/src/composables/useChatQuestionMinimap.ts
@@ -11,6 +11,7 @@ import {
import {
activeQuestionId,
collectOutlineMessages,
+ groupOutlineBounds,
isChatOverflowing,
mapQuestionTicks,
offsetFromScrollContent,
@@ -47,9 +48,10 @@ export function useChatQuestionMinimap(options: {
const anchoredIds = ref<Set<string>>(new Set())
const scrollbarGutterPx = ref(0)
const trackHeight = ref(0)
+ const availableGutter = ref(0)
const visible = computed(() => (
- shouldShowQuestionMinimap(overflowing.value, questions.value.length)
+ shouldShowQuestionMinimap(overflowing.value, questions.value.length, availableGutter.value)
))
let resizeObserver: ResizeObserver | null = null
@@ -66,6 +68,7 @@ export function useChatQuestionMinimap(options: {
anchoredIds.value = new Set()
scrollbarGutterPx.value = 0
trackHeight.value = 0
+ availableGutter.value = 0
}
const disconnectObserver = () => {
@@ -84,35 +87,38 @@ export function useChatQuestionMinimap(options: {
overflowing.value = isChatOverflowing(el.scrollHeight, el.clientHeight)
const anchors = Array.from(el.querySelectorAll<HTMLElement>('[data-message-id]'))
- const anchorByMessageId = new Map<string, HTMLElement>()
- for (const anchor of anchors) {
- const messageId = anchor.dataset.messageId
- if (messageId) anchorByMessageId.set(messageId, anchor)
- }
- const containerTop = el.getBoundingClientRect().top
+ const containerRect = el.getBoundingClientRect()
+ const containerTop = containerRect.top
+ const containerStyle = window.getComputedStyle(el)
+ const messageList = el.querySelector<HTMLElement>('.msg_list')
+ // Use the actual gutter, so opening/resizing either panel also hides the
+ // outline before its hit area overlaps the answer. Account for CSS zoom.
+ const scale = containerRect.width / el.offsetWidth || 1
+ const railInset = parseFloat(containerStyle.getPropertyValue('--chat-content-inset')) || 20
+ availableGutter.value = messageList
+ ? (messageList.getBoundingClientRect().left - containerRect.left) / scale
+ + (parseFloat(window.getComputedStyle(messageList).paddingLeft) || 0) - railInset
+ : 0
scrollbarGutterPx.value = Math.max(0, el.offsetWidth - el.clientWidth)
- const measured = questions.value.flatMap((question) => {
- const anchor = anchorByMessageId.get(question.id)
- if (!anchor) return []
+ const messageBounds = anchors.flatMap(anchor => {
+ const id = anchor.dataset.messageId
const rect = anchor.getBoundingClientRect()
- if (rect.height <= 0) return []
-
+ if (!id || rect.height <= 0) return []
return [{
- id: question.id,
- offsetTop: offsetFromScrollContent(
- rect.top,
- containerTop,
- el.scrollTop,
- ),
+ id,
+ offsetTop: offsetFromScrollContent(rect.top, containerTop, el.scrollTop),
offsetBottom: offsetFromScrollContent(rect.bottom, containerTop, el.scrollTop),
}]
})
+ const measured = groupOutlineBounds(questions.value, messageBounds)
trackHeight.value = questionMinimapTrackHeight(measured.length, el.clientHeight)
ticks.value = mapQuestionTicks(measured, trackHeight.value)
viewport.value = viewportBand(el.scrollTop, el.clientHeight, el.scrollHeight, trackHeight.value)
activeId.value = activeQuestionId(measured, el.scrollTop)
- visibleIds.value = visibleMessageIds(measured, el.scrollTop, el.clientHeight)
+ // The sticky composer is inside the scroll viewport but obscures its bottom.
+ const bottomInset = parseFloat(containerStyle.scrollPaddingBottom) || 0
+ visibleIds.value = visibleMessageIds(measured, el.scrollTop, el.clientHeight, bottomInset)
anchoredIds.value = new Set(measured.map((item) => item.id))
}
diff --git a/frontend/src/composables/useSessionTitleMotion.ts b/frontend/src/composables/useSessionTitleMotion.ts
new file mode 100644
index 000000000..165573f5d
--- /dev/null
+++ b/frontend/src/composables/useSessionTitleMotion.ts
@@ -0,0 +1,28 @@
+import { onScopeDispose, watch, type Ref } from 'vue'
+
+/** Animate live title changes, while keeping initial loads and session switches still. */
+export function useSessionTitleMotion(
+ element: Ref<HTMLElement | null>,
+ sessionId: () => string | undefined,
+ title: () => string,
+) {
+ let animation: Animation | undefined
+
+ watch([sessionId, title], ([id, text], [previousId, previousText]) => {
+ animation?.cancel()
+ animation = undefined
+
+ if (!id || id !== previousId || !text.trim() || text.trim() === previousText.trim()) return
+ if (typeof window === 'undefined' || window.matchMedia('(prefers-reduced-motion: reduce)').matches) return
+
+ animation = element.value?.animate?.(
+ [
+ { opacity: 0, transform: 'translateY(5px)' },
+ { opacity: 1, transform: 'translateY(0)' },
+ ],
+ { duration: 360, easing: 'cubic-bezier(0.22, 1, 0.36, 1)' },
+ )
+ }, { flush: 'post' })
+
+ onScopeDispose(() => animation?.cancel())
+}
diff --git a/frontend/src/composables/useStickyBottomOnResize.test.ts b/frontend/src/composables/useStickyBottomOnResize.test.ts
index 5aabefbcb..664bd0780 100644
--- a/frontend/src/composables/useStickyBottomOnResize.test.ts
+++ b/frontend/src/composables/useStickyBottomOnResize.test.ts
@@ -37,12 +37,12 @@ test('keeps a trailing steer bubble at the live edge before each streaming frame
const originalRequest = globalThis.requestAnimationFrame
const originalCancel = globalThis.cancelAnimationFrame
let onResize!: ResizeObserverCallback
- let observed: Element | undefined
+ const observed: Element[] = []
let disconnected = false
let deferredFrames = 0
globalThis.ResizeObserver = class {
constructor(callback: ResizeObserverCallback) { onResize = callback }
- observe(target: Element) { observed = target }
+ observe(target: Element) { observed.push(target) }
unobserve() {}
disconnect() { disconnected = true }
} as typeof ResizeObserver
@@ -51,7 +51,7 @@ test('keeps a trailing steer bubble at the live edge before each streaming frame
const chat = mountChat()
const resize = () => onResize([], {} as ResizeObserver)
try {
- assert.equal(observed, chat.messageList)
+ assert.deepEqual(observed, [chat.element, chat.messageList])
// ResizeObserver runs after layout and before paint. An rAF requested here
// runs in the NEXT frame, exposing the pushed-down bubble in this frame.
for (let frame = 0; frame < 120; frame++) {
@@ -63,10 +63,24 @@ test('keeps a trailing steer bubble at the live edge before each streaming frame
}
assert.equal(deferredFrames, 0, 'resize follow must finish before the current paint')
+ // A taller composer (e.g. after opening the drawer) reduces the viewport
+ // without necessarily changing the message list's dimensions.
+ const contentHeight = chat.element.scrollHeight
+ chat.element.clientHeight -= 120
+ resize()
+ assert.equal(chat.element.scrollHeight, contentHeight)
+ assert.equal(chat.element.scrollHeight - chat.element.scrollTop, chat.element.clientHeight,
+ 'viewport shrink must keep the last message reachable above the composer')
+ chat.element.clientHeight += 80
+ resize()
+ assert.equal(chat.element.scrollHeight - chat.element.scrollTop, chat.element.clientHeight,
+ 'viewport expansion must keep following the bottom')
+
chat.detached.value = true
chat.element.scrollTop -= 200
const readingPosition = chat.element.scrollTop
chat.element.scrollHeight += 100
+ chat.element.clientHeight -= 60
resize()
assert.equal(chat.element.scrollTop, readingPosition, 'preserve intentional upward scrolling')
diff --git a/frontend/src/composables/useStickyBottomOnResize.ts b/frontend/src/composables/useStickyBottomOnResize.ts
index 7c735ff8e..b16b5b529 100644
--- a/frontend/src/composables/useStickyBottomOnResize.ts
+++ b/frontend/src/composables/useStickyBottomOnResize.ts
@@ -5,7 +5,8 @@ import { onMounted, onUnmounted, type Ref } from 'vue'
*
* Streaming text already requests scrolling when chunks arrive, but images,
* Mermaid diagrams, and other rich content can change height later. Observe the
- * message list itself so all delayed layout changes share the same behavior.
+ * content wrapper and scroll viewport so delayed content, drawer resizing, and
+ * composer height changes share the same behavior.
* A user who has intentionally scrolled up is never pulled back down.
*/
export function useStickyBottomOnResize(
@@ -22,16 +23,17 @@ export function useStickyBottomOnResize(
// ResizeObserver runs after layout, before paint. Deferring to rAF here
// paints one frame with a trailing steer bubble displaced by the growing
// answer, then snaps it back on the next frame. Correct the scroll offset
- // now; changing scrollTop does not resize the observed message list.
+ // now; changing scrollTop does not resize the observed content wrapper.
container.scrollTop = container.scrollHeight
}
onMounted(() => {
- const messageList = scrollContainer.value?.firstElementChild
- if (!messageList || typeof ResizeObserver === 'undefined') return
+ const container = scrollContainer.value
+ if (!container || typeof ResizeObserver === 'undefined') return
resizeObserver = new ResizeObserver(followResize)
- resizeObserver.observe(messageList)
+ resizeObserver.observe(container)
+ if (container.firstElementChild) resizeObserver.observe(container.firstElementChild)
})
onUnmounted(() => {
diff --git a/frontend/src/i18n/locales/en-US.ts b/frontend/src/i18n/locales/en-US.ts
index fe93bafae..1a60b716f 100755
--- a/frontend/src/i18n/locales/en-US.ts
+++ b/frontend/src/i18n/locales/en-US.ts
@@ -2626,11 +2626,7 @@ export default {
},
input: {
addModel: 'Add Model',
- placeholder: 'Ask questions directly to the model',
- placeholderWithContext: 'Enter your question, will answer based on selected knowledge bases/files above',
- placeholderWebOnly: 'Enter your question, will answer with web search',
- placeholderKbAndWeb: 'Enter your question, will answer based on knowledge base and web search',
- placeholderAgent: 'Ask {name}',
+ placeholder: 'Ask a question or describe a task…',
agentMode: 'Smart Reasoning',
normalMode: 'Quick Answer',
normalModeDesc: 'Knowledge base RAG Q&A',
@@ -3680,6 +3676,7 @@ export default {
authRevoked: 'Your session is no longer valid, so the terminal was disconnected. Sign in again, then reconnect.',
},
questionMinimapTitle: 'Q&A',
+ questionMinimapPosition: 'Turn {current} of {total}',
questionMinimapAriaLabel: 'Question outline',
questionMinimapAttachmentPlaceholder: '(Attachment)',
referenceChunkCount: '{count} chunk(s)',
diff --git a/frontend/src/i18n/locales/ja-JP.ts b/frontend/src/i18n/locales/ja-JP.ts
index d41dee86f..2ccf3af38 100644
--- a/frontend/src/i18n/locales/ja-JP.ts
+++ b/frontend/src/i18n/locales/ja-JP.ts
@@ -2626,11 +2626,7 @@ export default {
},
input: {
addModel: 'モデルを追加',
- placeholder: 'モデルに直接質問できます',
- placeholderWithContext: '質問を入力してください。上で選択したナレッジベース/ファイルに基づいて回答します',
- placeholderWebOnly: '質問を入力してください。Web検索に基づいて回答します',
- placeholderKbAndWeb: '質問を入力してください。ナレッジベースとWeb検索に基づいて回答します',
- placeholderAgent: '{name}に質問',
+ placeholder: '質問や依頼内容を入力…',
agentMode: 'スマート推論',
normalMode: 'クイック回答',
normalModeDesc: 'ナレッジベースに基づくRAG Q&A',
@@ -3680,6 +3676,7 @@ export default {
authRevoked: 'ログイン状態が無効になったため、ターミナルが切断されました。再度サインインしてから接続してください。',
},
questionMinimapTitle: 'Q&A',
+ questionMinimapPosition: '全 {total} ターン中 {current} ターン目',
questionMinimapAriaLabel: '質問一覧',
questionMinimapAttachmentPlaceholder: '(添付ファイル)',
referenceChunkCount: '{count}件のチャンク',
diff --git a/frontend/src/i18n/locales/ko-KR.ts b/frontend/src/i18n/locales/ko-KR.ts
index d0449bb74..2cf4c98eb 100755
--- a/frontend/src/i18n/locales/ko-KR.ts
+++ b/frontend/src/i18n/locales/ko-KR.ts
@@ -3822,6 +3822,7 @@ export default {
authRevoked: '로그인 상태가 더 이상 유효하지 않아 터미널 연결이 끊어졌습니다. 다시 로그인한 뒤 재연결하세요.',
},
questionMinimapTitle: '질문',
+ questionMinimapPosition: '전체 {total}턴 중 {current}턴',
questionMinimapAriaLabel: '질문 목차',
questionMinimapAttachmentPlaceholder: '(첨부)',
referenceChunkCount: '{count}개 청크',
@@ -4855,11 +4856,7 @@ export default {
},
input: {
addModel: '모델 추가',
- placeholder: '모델에 직접 질문',
- placeholderWithContext: '질문을 입력하면 위에서 선택한 지식베이스/파일을 기반으로 답변합니다',
- placeholderWebOnly: '질문을 입력하면 웹 검색을 결합하여 답변합니다',
- placeholderKbAndWeb: '질문을 입력하면 지식베이스와 웹 검색을 기반으로 답변합니다',
- placeholderAgent: '{name} 질문하기',
+ placeholder: '질문이나 작업 내용을 입력하세요…',
agentMode: 'Agent 모드',
normalMode: '일반 모드',
normalModeDesc: '지식베이스 기반 RAG Q&A',
diff --git a/frontend/src/i18n/locales/ru-RU.ts b/frontend/src/i18n/locales/ru-RU.ts
index d2a680b3c..51f709490 100755
--- a/frontend/src/i18n/locales/ru-RU.ts
+++ b/frontend/src/i18n/locales/ru-RU.ts
@@ -3822,6 +3822,7 @@ export default {
authRevoked: 'Сессия больше не действительна, терминал отключён. Войдите снова и переподключитесь.',
},
questionMinimapTitle: 'Вопросы',
+ questionMinimapPosition: 'Реплика {current} из {total}',
questionMinimapAriaLabel: 'Содержание вопросов',
questionMinimapAttachmentPlaceholder: '(Вложение)',
referenceChunkCount: '{count} фрагмент(ов)',
@@ -4855,11 +4856,7 @@ export default {
},
input: {
addModel: 'Добавить модель',
- placeholder: 'Задайте вопрос напрямую модели',
- placeholderWithContext: 'Введите вопрос, ответ будет основан на выбранных выше базах знаний/файлах',
- placeholderWebOnly: 'Введите вопрос, ответ будет основан на веб-поиске',
- placeholderKbAndWeb: 'Введите вопрос, ответ будет основан на базе знаний и веб-поиске',
- placeholderAgent: 'Спросить {name}',
+ placeholder: 'Задайте вопрос или опишите задачу…',
agentMode: 'Умный анализ',
normalMode: 'Быстрый ответ',
normalModeDesc: 'RAG-вопросы и ответы по базе знаний',
diff --git a/frontend/src/i18n/locales/zh-CN.ts b/frontend/src/i18n/locales/zh-CN.ts
index 67b26ec1c..434de9f2c 100755
--- a/frontend/src/i18n/locales/zh-CN.ts
+++ b/frontend/src/i18n/locales/zh-CN.ts
@@ -3824,6 +3824,7 @@ export default {
authRevoked: '登录状态已失效,终端已断开。请重新登录后再连接。',
},
questionMinimapTitle: '问答',
+ questionMinimapPosition: '第 {current} 轮 · 共 {total} 轮',
questionMinimapAriaLabel: '提问目录',
questionMinimapAttachmentPlaceholder: '(附件)',
referenceChunkCount: '{count}个片段',
@@ -4857,11 +4858,7 @@ export default {
},
input: {
addModel: '添加模型',
- placeholder: '直接向模型提问',
- placeholderWithContext: '输入问题,将基于上方选中的知识库/文件回答',
- placeholderWebOnly: '输入问题,将结合网络搜索回答',
- placeholderKbAndWeb: '输入问题,将基于知识库和网络搜索回答',
- placeholderAgent: '向 {name} 提问',
+ placeholder: '输入问题或描述任务…',
agentMode: '智能推理',
normalMode: '快速问答',
normalModeDesc: '基于知识库的 RAG 问答',
diff --git a/frontend/src/stores/ui.ts b/frontend/src/stores/ui.ts
index 218c10115..61e002312 100644
--- a/frontend/src/stores/ui.ts
+++ b/frontend/src/stores/ui.ts
@@ -1,4 +1,5 @@
import { defineStore } from 'pinia'
+import { clampSidebarWidth, SIDEBAR_COLLAPSED_WIDTH, SIDEBAR_COLLAPSE_THRESHOLD } from '../utils/sidebarWidth'
export const useUIStore = defineStore('ui', {
state: () => ({
@@ -20,9 +21,15 @@ export const useUIStore = defineStore('ui', {
manualEditorInitialContent: '',
manualEditorInitialStatus: 'draft' as 'draft' | 'publish',
manualEditorOnSuccess: null as null | ((payload: { kbId: string; knowledgeId: string; status: 'draft' | 'publish' }) => void),
- sidebarCollapsed: localStorage.getItem('sidebar_collapsed') === 'true'
+ sidebarCollapsed: localStorage.getItem('sidebar_collapsed') === 'true',
+ sidebarWidth: clampSidebarWidth(Number(localStorage.getItem('sidebar_width'))),
+ sidebarResizing: false,
}),
+ getters: {
+ sidebarDisplayWidth: (state) => state.sidebarCollapsed ? SIDEBAR_COLLAPSED_WIDTH : state.sidebarWidth,
+ },
+
actions: {
openSettings(section?: string, subSection?: string) {
this.settingsInitialSection = section || null
@@ -125,6 +132,17 @@ export const useUIStore = defineStore('ui', {
localStorage.setItem('sidebar_collapsed', String(this.sidebarCollapsed))
},
+ resizeSidebar(width: number) {
+ if (!Number.isFinite(width)) return
+ if (width < SIDEBAR_COLLAPSE_THRESHOLD) {
+ this.collapseSidebar()
+ return
+ }
+ this.sidebarWidth = clampSidebarWidth(width)
+ localStorage.setItem('sidebar_width', String(this.sidebarWidth))
+ this.expandSidebar()
+ },
+
collapseSidebar() {
this.sidebarCollapsed = true
localStorage.setItem('sidebar_collapsed', 'true')
@@ -136,4 +154,3 @@ export const useUIStore = defineStore('ui', {
}
}
})
-
diff --git a/frontend/src/stores/uiSidebar.test.ts b/frontend/src/stores/uiSidebar.test.ts
new file mode 100644
index 000000000..1aef25ac8
--- /dev/null
+++ b/frontend/src/stores/uiSidebar.test.ts
@@ -0,0 +1,49 @@
+import assert from 'node:assert/strict'
+import test from 'node:test'
+import { createPinia, setActivePinia } from 'pinia'
+import { useUIStore } from './ui.ts'
+
+test('sidebar drag bounds, collapse, button restore, and saved width stay consistent', () => {
+ const originalStorage = Object.getOwnPropertyDescriptor(globalThis, 'localStorage')
+ const storage = new Map<string, string>()
+ Object.defineProperty(globalThis, 'localStorage', {
+ configurable: true,
+ value: {
+ getItem: (key: string) => storage.get(key) ?? null,
+ setItem: (key: string, value: string) => storage.set(key, value),
+ },
+ })
+ try {
+ setActivePinia(createPinia())
+ const ui = useUIStore()
+ assert.equal(ui.sidebarDisplayWidth, 260)
+ ui.resizeSidebar(900)
+ assert.equal(ui.sidebarDisplayWidth, 280)
+ ui.resizeSidebar(195)
+ assert.equal(ui.sidebarDisplayWidth, 220)
+ ui.resizeSidebar(270)
+ ui.resizeSidebar(179)
+ assert.equal(ui.sidebarCollapsed, true)
+ assert.equal(ui.sidebarDisplayWidth, 60)
+ ui.toggleSidebar()
+ assert.equal(ui.sidebarDisplayWidth, 270, 'collapse keeps the last expanded width')
+ ui.collapseSidebar()
+ ui.resizeSidebar(240)
+ assert.equal(ui.sidebarCollapsed, false, 'drag can reopen the collapsed sidebar')
+ assert.equal(ui.sidebarDisplayWidth, 240)
+
+ setActivePinia(createPinia())
+ assert.equal(useUIStore().sidebarDisplayWidth, 240, 'reload restores the chosen width')
+ storage.set('sidebar_width', '420')
+ setActivePinia(createPinia())
+ assert.equal(useUIStore().sidebarDisplayWidth, 280, 'old saved widths respect the reduced maximum')
+ for (const invalid of ['NaN', '-1', '0', '']) {
+ storage.set('sidebar_width', invalid)
+ setActivePinia(createPinia())
+ assert.equal(useUIStore().sidebarDisplayWidth, 260)
+ }
+ } finally {
+ if (originalStorage) Object.defineProperty(globalThis, 'localStorage', originalStorage)
+ else Reflect.deleteProperty(globalThis, 'localStorage')
+ }
+})
diff --git a/frontend/src/utils/chatQuestionMinimap.test.ts b/frontend/src/utils/chatQuestionMinimap.test.ts
index 2f23c74a6..5dc379b49 100644
--- a/frontend/src/utils/chatQuestionMinimap.test.ts
+++ b/frontend/src/utils/chatQuestionMinimap.test.ts
@@ -11,6 +11,7 @@ import {
activeQuestionId,
answerPreviewText,
collectOutlineMessages,
+ groupOutlineBounds,
isChatOverflowing,
mapQuestionTicks,
nearestTickId,
@@ -42,14 +43,17 @@ test('questionMinimapTrackHeight still caps a long cluster to the centered rail'
assert.equal(questionMinimapTrackHeight(100, 400), 200)
})
-test('shouldShowQuestionMinimap requires overflow and at least two questions', () => {
- assert.equal(shouldShowQuestionMinimap(true, 1), false)
- assert.equal(shouldShowQuestionMinimap(true, 2), true)
- assert.equal(shouldShowQuestionMinimap(true, 0), false)
- assert.equal(shouldShowQuestionMinimap(false, 4), false)
+test('shouldShowQuestionMinimap requires overflow, a turn, and room beside the messages', () => {
+ assert.equal(shouldShowQuestionMinimap(true, 1, 60), true)
+ assert.equal(shouldShowQuestionMinimap(true, 2, 44), true)
+ assert.equal(shouldShowQuestionMinimap(true, 0, 60), false)
+ assert.equal(shouldShowQuestionMinimap(false, 4, 60), false)
+ assert.equal(shouldShowQuestionMinimap(true, 4, 43), false)
+ assert.equal(shouldShowQuestionMinimap(true, 4, 0), false)
+ assert.equal(shouldShowQuestionMinimap(true, 4, -20), false)
})
-test('collectOutlineMessages includes both user and assistant messages in order', () => {
+test('collectOutlineMessages groups each query and its answers into one turn', () => {
const questions = collectOutlineMessages([
{ role: 'assistant', id: 'a1', content: 'hi' },
{ role: 'user', content: 'no id yet' },
@@ -62,11 +66,11 @@ test('collectOutlineMessages includes both user and assistant messages in order'
[
{ id: 'a1', hasAttachments: false, answerContent: '' },
{ id: 'u1', hasAttachments: true, answerContent: 'answer one' },
- { id: 'a2', hasAttachments: false, answerContent: '' },
{ id: 'u2', hasAttachments: true, answerContent: '' },
],
)
- assert.deepEqual(questions.map(q => q.role), ['assistant', 'user', 'assistant', 'user'])
+ assert.deepEqual(questions.map(q => q.role), ['assistant', 'user', 'user'])
+ assert.deepEqual(questions.map(q => q.messageIds), [['a1'], ['u1', 'a2'], ['u2']])
})
test('all messages intersecting the viewport are highlighted, including partial and long answers', () => {
@@ -85,6 +89,20 @@ test('all messages intersecting the viewport are highlighted, including partial
assert.equal(visibleMessageIds(items, 100, 0).size, 0)
})
+test('messages hidden under the sticky composer are not highlighted', () => {
+ const items = [
+ { id: 'query-above', offsetTop: 0, offsetBottom: 80 },
+ { id: 'long-answer', offsetTop: 80, offsetBottom: 340 },
+ { id: 'query-under-composer', offsetTop: 400, offsetBottom: 440 },
+ { id: 'answer-under-composer', offsetTop: 450, offsetBottom: 800 },
+ ]
+ assert.deepEqual([...visibleMessageIds(items, 100, 500, 200)], ['long-answer'])
+ assert.deepEqual([...visibleMessageIds(items, 300, 500, 200)],
+ ['long-answer', 'query-under-composer', 'answer-under-composer'])
+ assert.deepEqual([...visibleMessageIds(items, 450, 500, 200)], ['answer-under-composer'])
+ assert.equal(visibleMessageIds(items, 100, 200, 250).size, 0)
+})
+
test('answerPreviewText strips markdown and stays empty when there is no answer yet', () => {
assert.equal(
answerPreviewText('## Hello\n**world** and [link](https://x)'),
@@ -194,3 +212,32 @@ test('activeQuestionId picks the last question at or above the top offset', () =
assert.equal(activeQuestionId(items, 900), 'u3')
assert.equal(activeQuestionId([], 0), null)
})
+
+
+test('one turn tick stays highlighted for either query or any assistant segment', () => {
+ const turns = collectOutlineMessages([
+ { role: 'user', id: 'u1', content: 'question' },
+ { role: 'assistant', id: 'a1', content: 'first segment' },
+ { role: 'tool', id: 'tool' },
+ { role: 'assistant', id: 'a2', content: 'continued answer' },
+ { role: 'user', id: 'u2', content: 'next question' },
+ { role: 'assistant', id: 'a3', content: 'next answer' },
+ ])
+ assert.deepEqual(turns.map(turn => turn.id), ['u1', 'u2'])
+ assert.equal(turns[0].answerContent, 'first segment\n\ncontinued answer')
+ const bounds = groupOutlineBounds(turns, [
+ { id: 'u1', offsetTop: 0, offsetBottom: 60 },
+ { id: 'a1', offsetTop: 80, offsetBottom: 500 },
+ { id: 'a2', offsetTop: 520, offsetBottom: 1000 },
+ { id: 'u2', offsetTop: 1020, offsetBottom: 1080 },
+ { id: 'a3', offsetTop: 1100, offsetBottom: 1800 },
+ ])
+ assert.equal(mapQuestionTicks(bounds, 100).length, 2)
+ for (const top of [0, 100, 600]) {
+ assert.deepEqual([...visibleMessageIds(bounds, top, 100)], ['u1'])
+ }
+ assert.deepEqual([...visibleMessageIds(bounds, 900, 200)], ['u1', 'u2'])
+ assert.deepEqual([...visibleMessageIds(bounds, 1300, 200)], ['u2'])
+ assert.equal(visibleMessageIds(bounds, 60, 20).size, 0, 'the gap alone is not visible content')
+ assert.equal(groupOutlineBounds(turns, []).length, 0, 'unrendered messages do not create ticks')
+})
diff --git a/frontend/src/utils/chatQuestionMinimap.ts b/frontend/src/utils/chatQuestionMinimap.ts
index 0f1dcde5f..678074193 100644
--- a/frontend/src/utils/chatQuestionMinimap.ts
+++ b/frontend/src/utils/chatQuestionMinimap.ts
@@ -1,11 +1,13 @@
export const QUESTION_TICK_INSET_PX = 8
export const QUESTION_TICK_GAP_PX = 8
-export const QUESTION_TICK_MOUNTAIN_GAIN = 1.5
-export const CURRENT_TICK_SCALE = 1.7
+export const QUESTION_TICK_MOUNTAIN_GAIN = 0.8
+export const CURRENT_TICK_SCALE = 1.55
export const ACTIVE_QUESTION_TOP_OFFSET_PX = 72
export const VIEWPORT_BAND_MIN_HEIGHT_PX = 16
export const QUESTION_MINIMAP_TRACK_MAX_PX = 360
export const QUESTION_MINIMAP_TRACK_RATIO = 0.5
+// 28px rail + 4px hit-area extension + 12px clearance from message content.
+export const QUESTION_MINIMAP_MIN_GUTTER_PX = 44
export function questionMinimapTrackHeight(
questionCount: number,
@@ -36,6 +38,7 @@ export type OutlineMessage = {
content: string
hasAttachments: boolean
answerContent: string
+ messageIds: string[]
}
export type QuestionTick = {
@@ -53,51 +56,77 @@ export function isChatOverflowing(scrollHeight: number, clientHeight: number): b
return scrollHeight > clientHeight
}
-export function shouldShowQuestionMinimap(overflowing: boolean, questionCount: number): boolean {
- return overflowing && questionCount >= 2
+export function shouldShowQuestionMinimap(overflowing: boolean, questionCount: number, availableGutter: number): boolean {
+ return overflowing && questionCount >= 1 && availableGutter >= QUESTION_MINIMAP_MIN_GUTTER_PX
}
export function collectOutlineMessages(messages: ChatMessageLike[]): OutlineMessage[] {
const questions: OutlineMessage[] = []
- for (let index = 0; index < messages.length; index++) {
- const message = messages[index]
+ let current: OutlineMessage | undefined
+ for (const message of messages) {
+ if (message.role === 'user') current = undefined
if ((message.role !== 'user' && message.role !== 'assistant') || !message.id) continue
- let answerContent = ''
- for (let next = index + 1; message.role === 'user' && next < messages.length; next++) {
- const following = messages[next]
- if (following.role === 'user') break
- if (following.role === 'assistant') {
- answerContent = following.content ?? ''
- break
+ if (message.role === 'assistant' && current) {
+ current.messageIds.push(message.id)
+ if (message.content) {
+ current.answerContent = [current.answerContent, message.content].filter(Boolean).join('\n\n')
}
+ continue
}
- questions.push({
+ current = {
id: message.id,
role: message.role,
content: message.content ?? '',
hasAttachments:
(message.images?.length ?? 0) > 0 || (message.attachments?.length ?? 0) > 0,
- answerContent,
- })
+ answerContent: '',
+ messageIds: [message.id],
+ }
+ questions.push(current)
}
return questions
}
+type MessageBounds = { id: string; offsetTop: number; offsetBottom: number }
+
+/** One rail tick per turn, retaining each message's bounds for visibility. */
+export function groupOutlineBounds(
+ turns: OutlineMessage[],
+ messages: MessageBounds[],
+): Array<MessageBounds & { ranges: MessageBounds[] }> {
+ const byId = new Map(messages.map(message => [message.id, message]))
+ return turns.flatMap(turn => {
+ const ranges = turn.messageIds.flatMap(id => {
+ const bounds = byId.get(id)
+ return bounds && bounds.offsetBottom > bounds.offsetTop ? [bounds] : []
+ })
+ if (!ranges.length) return []
+ return [{
+ id: turn.id,
+ offsetTop: Math.min(...ranges.map(range => range.offsetTop)),
+ offsetBottom: Math.max(...ranges.map(range => range.offsetBottom)),
+ ranges,
+ }]
+ })
+}
+
/** Include partially visible messages and long answers spanning the viewport. */
export function visibleMessageIds(
- items: Array<{ id: string; offsetTop: number; offsetBottom: number }>,
+ items: Array<MessageBounds & { ranges?: MessageBounds[] }>,
scrollTop: number,
clientHeight: number,
+ bottomInset: number = 0,
): Set<string> {
- if (clientHeight <= 0) return new Set()
- const bottom = scrollTop + clientHeight
- return new Set(items.filter(item => (
- item.offsetBottom > item.offsetTop && item.offsetBottom > scrollTop && item.offsetTop < bottom
- )).map(item => item.id))
+ const visibleHeight = Math.max(0, clientHeight - bottomInset)
+ if (visibleHeight <= 0) return new Set()
+ const bottom = scrollTop + visibleHeight
+ return new Set(items.filter(item => (item.ranges ?? [item]).some(range => (
+ range.offsetBottom > range.offsetTop && range.offsetBottom > scrollTop && range.offsetTop < bottom
+ ))).map(item => item.id))
}
export function questionDisplayText(
diff --git a/frontend/src/utils/referenceSources.ts b/frontend/src/utils/referenceSources.ts
index 7f24e01b5..3b1e97620 100644
--- a/frontend/src/utils/referenceSources.ts
+++ b/frontend/src/utils/referenceSources.ts
@@ -18,6 +18,7 @@ export type ReferenceListItem = {
kind: ReferenceItemKind
index: number
title: string
+ fileName?: string
url?: string
domain?: string
faviconUrl?: string
@@ -168,6 +169,7 @@ function buildDocumentItem(item: KnowledgeReferenceLike, index: number): Referen
return {
key: `doc:${documentKey}`,
kind: 'document',
+ fileName: item.knowledge_filename,
index,
title,
chunkId,
diff --git a/frontend/src/utils/sidebarWidth.ts b/frontend/src/utils/sidebarWidth.ts
new file mode 100644
index 000000000..fddc6459e
--- /dev/null
+++ b/frontend/src/utils/sidebarWidth.ts
@@ -0,0 +1,10 @@
+export const SIDEBAR_DEFAULT_WIDTH = 260
+export const SIDEBAR_MIN_WIDTH = 220
+export const SIDEBAR_MAX_WIDTH = 280
+export const SIDEBAR_COLLAPSED_WIDTH = 60
+export const SIDEBAR_COLLAPSE_THRESHOLD = 180
+
+export function clampSidebarWidth(width: number): number {
+ if (!Number.isFinite(width) || width <= 0) return SIDEBAR_DEFAULT_WIDTH
+ return Math.min(SIDEBAR_MAX_WIDTH, Math.max(SIDEBAR_MIN_WIDTH, Math.round(width)))
+}
diff --git a/frontend/src/views/artifacts/ArtifactLibrary.vue b/frontend/src/views/artifacts/ArtifactLibrary.vue
index ac4036b71..d55aded4d 100644
--- a/frontend/src/views/artifacts/ArtifactLibrary.vue
+++ b/frontend/src/views/artifacts/ArtifactLibrary.vue
@@ -383,6 +383,8 @@ onBeforeUnmount(() => {
</script>
<style scoped lang="less">
+@import '@/components/css/artifact-filter-tabs.less';
+
.artifact-library {
flex: 1;
min-width: 0;
@@ -436,39 +438,7 @@ onBeforeUnmount(() => {
}
.category-tabs {
- display: inline-flex;
- flex-wrap: wrap;
- gap: 2px;
- padding: 3px;
- border-radius: var(--app-radius-md);
- background: var(--td-bg-color-secondarycontainer);
-
- button {
- padding: 5px 12px;
- border: 0;
- border-radius: var(--app-radius-sm);
- background: transparent;
- color: var(--td-text-color-secondary);
- font: inherit;
- font-size: var(--app-text-md);
- cursor: pointer;
- transition: background var(--app-motion-fast) ease, color var(--app-motion-fast) ease;
-
- &:hover {
- color: var(--td-text-color-primary);
- }
-
- &[aria-selected='true'] {
- background: var(--td-bg-color-container);
- color: var(--td-brand-color);
- box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
- }
-
- &:focus-visible {
- outline: 2px solid var(--td-brand-color);
- outline-offset: 2px;
- }
- }
+ .artifact-filter-tabs();
}
.search-input {
diff --git a/frontend/src/views/chat/components/ChatArtifactsPanel.vue b/frontend/src/views/chat/components/ChatArtifactsPanel.vue
index 370190d4c..cd60e8da5 100644
--- a/frontend/src/views/chat/components/ChatArtifactsPanel.vue
+++ b/frontend/src/views/chat/components/ChatArtifactsPanel.vue
@@ -302,6 +302,8 @@ async function handleDownload(item: SessionArtifactItem) {
</script>
<style scoped lang="less">
+@import '@/components/css/artifact-filter-tabs.less';
+
.chat-artifacts-panel {
flex: 1;
min-height: 0;
@@ -421,40 +423,18 @@ async function handleDownload(item: SessionArtifactItem) {
}
.artifact-scope {
- display: inline-flex;
+ .artifact-filter-tabs();
align-self: flex-start;
- gap: 2px;
- padding: 3px;
- border-radius: var(--app-radius-md);
- background: var(--td-bg-color-secondarycontainer);
button {
display: inline-flex;
align-items: center;
gap: 8px;
- padding: 5px 10px;
- border: 0;
- border-radius: 5px;
- background: transparent;
- color: var(--td-text-color-secondary);
- font: inherit;
- font-size: var(--app-text-sm);
- cursor: pointer;
-
- &[aria-pressed='true'] {
- background: var(--td-bg-color-container);
- color: var(--td-text-color-primary);
- box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
- }
-
- &:focus-visible {
- outline: 2px solid var(--td-brand-color);
- outline-offset: 2px;
- }
span {
- color: var(--td-text-color-placeholder);
- font-size: var(--app-text-xs);
+ color: inherit;
+ opacity: 0.7;
+ font-size: var(--app-text-sm);
font-variant-numeric: tabular-nums;
}
}
diff --git a/frontend/src/views/chat/index.vue b/frontend/src/views/chat/index.vue
index 60162c957..7944c9ce2 100644
--- a/frontend/src/views/chat/index.vue
+++ b/frontend/src/views/chat/index.vue
@@ -1,7 +1,6 @@
<template>
<div class="chat" :class="{
'is-embedded': embeddedMode,
- 'is-sidebar-collapsed': uiStore.sidebarCollapsed,
'has-references-panel': referencesDrawerVisible,
'has-sandbox-panel': sandboxPanel.visible.value,
}" :style="{ '--sandbox-panel-width': `${sandboxPanel.width.value}px` }">
@@ -23,149 +22,155 @@
</t-tooltip>
</div>
</div>
- <div class="chat_thread">
+ <div class="chat_thread" :style="{ '--chat-composer-height': `${composerHeight}px` }">
<div ref="scrollContainer" class="chat_scroll_box" @scroll="handleScroll">
- <div class="msg_list" :class="{ 'is-embedded': embeddedMode }">
- <!-- 消息列表骨架屏 -->
- <div v-if="historyLoading && messagesList.length === 0" class="msg-skeleton-list">
- <div class="msg-skeleton msg-skeleton-user">
- <t-skeleton animation="gradient"
- :row-col="[{ width: '45%', height: '36px', type: 'rect' }]" />
- </div>
- <div class="msg-skeleton msg-skeleton-bot">
- <t-skeleton animation="gradient"
- :row-col="[{ width: '80%', height: '16px' }, { width: '100%', height: '16px' }, { width: '60%', height: '16px' }]" />
- </div>
- <div class="msg-skeleton msg-skeleton-user">
- <t-skeleton animation="gradient"
- :row-col="[{ width: '35%', height: '36px', type: 'rect' }]" />
- </div>
- <div class="msg-skeleton msg-skeleton-bot">
- <t-skeleton animation="gradient"
- :row-col="[{ width: '70%', height: '16px' }, { width: '90%', height: '16px' }]" />
- </div>
- </div>
- <!-- 推荐问题卡片 - 仅在新会话(无消息)时展示 -->
- <div v-if="!embeddedMode && messagesList.length === 0 && !loading"
- class="suggested-questions-container"
- :class="{ 'has-questions': suggestedQuestions.length > 0 || suggestedQuestionsLoading }">
- <!-- 骨架屏占位 -->
- <div v-if="suggestedQuestionsLoading && suggestedQuestions.length === 0"
- class="suggested-questions-inner">
- <div class="suggested-questions-title"><t-skeleton animation="gradient"
- :row-col="[{ width: '120px', height: '14px' }]" /></div>
- <div class="suggested-questions-grid">
- <div v-for="n in 6" :key="'sq-skel-' + n"
- class="suggested-question-card sq-card-skeleton">
- <t-skeleton animation="gradient"
- :row-col="[{ width: '100%', height: '14px', type: 'rect' }]" />
- </div>
+ <div class="chat_scroll_content">
+ <div class="msg_list" :class="{ 'is-embedded': embeddedMode }">
+ <!-- 消息列表骨架屏 -->
+ <div v-if="historyLoading && messagesList.length === 0" class="msg-skeleton-list">
+ <div class="msg-skeleton msg-skeleton-user">
+ <t-skeleton animation="gradient"
+ :row-col="[{ width: '45%', height: '36px', type: 'rect' }]" />
+ </div>
+ <div class="msg-skeleton msg-skeleton-bot">
+ <t-skeleton animation="gradient"
+ :row-col="[{ width: '80%', height: '16px' }, { width: '100%', height: '16px' }, { width: '60%', height: '16px' }]" />
+ </div>
+ <div class="msg-skeleton msg-skeleton-user">
+ <t-skeleton animation="gradient"
+ :row-col="[{ width: '35%', height: '36px', type: 'rect' }]" />
+ </div>
+ <div class="msg-skeleton msg-skeleton-bot">
+ <t-skeleton animation="gradient"
+ :row-col="[{ width: '70%', height: '16px' }, { width: '90%', height: '16px' }]" />
</div>
</div>
- <transition v-else appear name="sq-fade">
- <div v-if="suggestedQuestions.length > 0" class="suggested-questions-inner">
- <div class="suggested-questions-title-row">
- <p class="suggested-questions-caption">
- <span class="suggested-questions-title">{{ t('chat.suggestedQuestions')
- }}</span>
- <button type="button" class="suggested-questions-refresh"
- :disabled="suggestedQuestionsLoading"
- :title="t('chat.refreshSuggestedQuestions')"
- :aria-label="t('chat.refreshSuggestedQuestions')"
- @click="fetchSuggestedQuestions">
- <t-icon :name="suggestedQuestionsLoading ? 'loading' : 'refresh'"
- :class="{ 'sq-refresh-spin': suggestedQuestionsLoading }" />
- </button>
- </p>
- </div>
+ <!-- 推荐问题卡片 - 仅在新会话(无消息)时展示 -->
+ <div v-if="!embeddedMode && messagesList.length === 0 && !loading"
+ class="suggested-questions-container"
+ :class="{ 'has-questions': suggestedQuestions.length > 0 || suggestedQuestionsLoading }">
+ <!-- 骨架屏占位 -->
+ <div v-if="suggestedQuestionsLoading && suggestedQuestions.length === 0"
+ class="suggested-questions-inner">
+ <div class="suggested-questions-title"><t-skeleton animation="gradient"
+ :row-col="[{ width: '120px', height: '14px' }]" /></div>
<div class="suggested-questions-grid">
- <div v-for="(item, index) in suggestedQuestions" :key="item.question"
- class="suggested-question-card"
- @click="handleSuggestedQuestionClick(item)">
- <span class="suggested-question-text">{{ item.question }}</span>
- <span v-if="item.source === 'faq'"
- class="suggested-question-badge faq">FAQ</span>
+ <div v-for="n in 6" :key="'sq-skel-' + n"
+ class="suggested-question-card sq-card-skeleton">
+ <t-skeleton animation="gradient"
+ :row-col="[{ width: '100%', height: '14px', type: 'rect' }]" />
</div>
</div>
</div>
- </transition>
- </div>
- <!--
- 关键:必须用 session.id 作为 key,不能用 v-for 的索引。
- 向上滚动加载历史时会插入一批消息(push/unshift)到列表,
- 若用索引作 key 会让所有已渲染消息的 key 漂移,触发整个列表的销毁重建
- (botmsg / AgentStreamDisplay 全部重新挂载、markdown 重新渲染),
- 这是历史加载时白屏 + layout shift 蔓延到 session 列表的根因。
- 仅对极少数尚未拿到 id 的本地占位消息 fallback 到 role+created_at+index。
- -->
- <div v-for="(session, index) in messagesList"
- :key="session.id || `${session.role}-${session.created_at}-${index}`" class="msg-item-wrapper"
- :class="{ 'is-steer-prefix': session.steerForked, 'is-empty-segment': session.role === 'assistant' && !shouldRenderAssistantMessage(session) }">
- <MessageTimestamp v-if="shouldShowConversationTimestamp(messagesList, index)"
- :value="session.created_at" />
-
- <div v-if="session.role == 'user'" class="message-row"
- :data-message-id="session.id || undefined"
- :class="{ 'is-minimap-target': session.id && session.id === minimapTargetId }">
- <usermsg :content="session.content" :mentioned_items="session.mentioned_items"
- :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)"
- @remove-steer="handleRemoveSteer(session.steer_id)"
- @fork="handleFork">
- </usermsg>
+ <transition v-else appear name="sq-fade">
+ <div v-if="suggestedQuestions.length > 0" class="suggested-questions-inner">
+ <div class="suggested-questions-title-row">
+ <p class="suggested-questions-caption">
+ <span class="suggested-questions-title">{{ t('chat.suggestedQuestions')
+ }}</span>
+ <button type="button" class="suggested-questions-refresh"
+ :disabled="suggestedQuestionsLoading"
+ :title="t('chat.refreshSuggestedQuestions')"
+ :aria-label="t('chat.refreshSuggestedQuestions')"
+ @click="fetchSuggestedQuestions">
+ <t-icon :name="suggestedQuestionsLoading ? 'loading' : 'refresh'"
+ :class="{ 'sq-refresh-spin': suggestedQuestionsLoading }" />
+ </button>
+ </p>
+ </div>
+ <div class="suggested-questions-grid">
+ <div v-for="(item, index) in suggestedQuestions" :key="item.question"
+ class="suggested-question-card"
+ @click="handleSuggestedQuestionClick(item)">
+ <span class="suggested-question-text">{{ item.question }}</span>
+ <span v-if="item.source === 'faq'"
+ class="suggested-question-badge faq">FAQ</span>
+ </div>
+ </div>
+ </div>
+ </transition>
+ </div>
+ <!--
+ 关键:必须用 session.id 作为 key,不能用 v-for 的索引。
+ 向上滚动加载历史时会插入一批消息(push/unshift)到列表,
+ 若用索引作 key 会让所有已渲染消息的 key 漂移,触发整个列表的销毁重建
+ (botmsg / AgentStreamDisplay 全部重新挂载、markdown 重新渲染),
+ 这是历史加载时白屏 + layout shift 蔓延到 session 列表的根因。
+ 仅对极少数尚未拿到 id 的本地占位消息 fallback 到 role+created_at+index。
+ -->
+ <div v-for="(session, index) in messagesList"
+ :key="session.id || `${session.role}-${session.created_at}-${index}`" class="msg-item-wrapper"
+ :class="{ 'is-steer-prefix': session.steerForked, 'is-empty-segment': session.role === 'assistant' && !shouldRenderAssistantMessage(session) }">
+ <MessageTimestamp v-if="shouldShowConversationTimestamp(messagesList, index)"
+ :value="session.created_at" />
+
+ <div v-if="session.role == 'user'" class="message-row"
+ :data-message-id="session.id || undefined">
+ <usermsg :content="session.content" :mentioned_items="session.mentioned_items"
+ :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)"
+ @remove-steer="handleRemoveSteer(session.steer_id)"
+ @fork="handleFork">
+ </usermsg>
+ </div>
+ <div v-if="session.role == 'assistant' && shouldRenderAssistantMessage(session)"
+ class="message-row"
+ :data-message-id="session.id || undefined">
+ <botmsg :content="session.content" :session="session" :session-id="session_id"
+ :user-query="getUserQuery(index)" @scroll-bottom="scrollToBottom"
+ :isFirstEnter="isFirstEnter" :embeddedMode="embeddedMode"
+ :follow-up-loading="Boolean(session.suggestionLoading && !session.suggestionSet?.questions?.length)"
+ :can-fork="!embeddedMode && forkAffordanceOf(session.id).canFork"
+ @fork="handleFork"
+ @render-complete-change="(ready) => handleAnswerRenderComplete(session, ready)">
+ </botmsg>
+ <FollowUpSuggestions v-if="session.answerFullyRendered && !session.steerForked && !session.suggestionsDismissed"
+ :suggestion-set="session.suggestionSet"
+ :loading="session.suggestionLoading"
+ :allow-regenerate="session.suggestionSet?.allow_regenerate"
+ @select="(item) => handleFollowUpSelect(session, item)"
+ @regenerate="loadFollowUpSuggestions(session, true, true)"
+ @impression="(set) => recordSuggestionEvent(session, set, 'impression')"
+ @dismiss="(set) => dismissSuggestions(session, set)" />
+ </div>
</div>
- <div v-if="session.role == 'assistant' && shouldRenderAssistantMessage(session)"
- class="message-row">
- <botmsg :content="session.content" :session="session" :session-id="session_id"
- :user-query="getUserQuery(index)" @scroll-bottom="scrollToBottom"
- :isFirstEnter="isFirstEnter" :embeddedMode="embeddedMode"
- :follow-up-loading="Boolean(session.suggestionLoading && !session.suggestionSet?.questions?.length)"
- :can-fork="!embeddedMode && forkAffordanceOf(session.id).canFork"
- @fork="handleFork"
- @render-complete-change="(ready) => handleAnswerRenderComplete(session, ready)">
- </botmsg>
- <FollowUpSuggestions v-if="session.answerFullyRendered && !session.steerForked && !session.suggestionsDismissed"
- :suggestion-set="session.suggestionSet"
- :loading="session.suggestionLoading"
- :allow-regenerate="session.suggestionSet?.allow_regenerate"
- @select="(item) => handleFollowUpSelect(session, item)"
- @regenerate="loadFollowUpSuggestions(session, true, true)"
- @impression="(set) => recordSuggestionEvent(session, set, 'impression')"
- @dismiss="(set) => dismissSuggestions(session, set)" />
+ <div v-if="showGlobalTypingIndicator" class="chat-global-wait" role="status"
+ :aria-label="t('chat.thinkingAlt')">
+ <span class="chat-global-wait__spinner" aria-hidden="true"></span>
</div>
</div>
- <div v-if="showGlobalTypingIndicator" class="chat-global-wait" role="status"
- :aria-label="t('chat.thinkingAlt')">
- <span class="chat-global-wait__spinner" aria-hidden="true"></span>
+ <div ref="composerElement" class="chat_composer">
+ <div class="input-container" :class="{ 'is-embedded': embeddedMode }">
+ <transition name="scroll-btn-fade">
+ <div v-show="userHasScrolledUp" class="scroll-to-bottom-btn" @click="onClickScrollToBottom">
+ <t-icon name="chevron-down" size="18px" />
+ </div>
+ </transition>
+ <InputField ref="inputFieldRef" :auto-focus="focusComposerOnMount" :compact="!embeddedMode"
+ @send-msg="(query, modelId, mentionedItems, imageFiles, attachmentFiles, options) => sendMsg(query, modelId, mentionedItems, imageFiles, attachmentFiles, options)"
+ @steer-msg="(query, mentionedItems, delivery) => handleSteerMsg(query, mentionedItems, delivery)"
+ @promote-steer="handlePromoteSteer"
+ @remove-steer="handleRemoveSteer"
+ @retry-steer="handleRetrySteer"
+ @stop-generation="handleStopGeneration"
+ @stop-confirmed="handleStopConfirmed"
+ @stop-failed="handleStopFailed" :isReplying="isReplying" :sessionId="session_id"
+ :assistantMessageId="currentAssistantMessageId" :embeddedMode="embeddedMode"
+ :queuedSteers="steerQueue.filter(item => item.delivery === 'after')" :canSteer="isAgentStreamSession()"></InputField>
+ </div>
</div>
</div>
</div>
- <BrowserTaskPreview v-if="!embeddedMode && session_id" :key="session_id" :session-id="session_id" />
- <ChatQuestionMinimap v-if="!embeddedMode" :scroll-container="scrollContainer" :messages="messagesList"
- @jump="jumpToQuestion" />
- </div>
- <div class="input-container" :class="{ 'is-embedded': embeddedMode }">
- <transition name="scroll-btn-fade">
- <div v-show="userHasScrolledUp" class="scroll-to-bottom-btn" @click="onClickScrollToBottom">
- <t-icon name="chevron-down" size="18px" />
- </div>
- </transition>
- <InputField ref="inputFieldRef" :auto-focus="focusComposerOnMount" :compact="!embeddedMode"
- @send-msg="(query, modelId, mentionedItems, imageFiles, attachmentFiles, options) => sendMsg(query, modelId, mentionedItems, imageFiles, attachmentFiles, options)"
- @steer-msg="(query, mentionedItems, delivery) => handleSteerMsg(query, mentionedItems, delivery)"
- @promote-steer="handlePromoteSteer"
- @remove-steer="handleRemoveSteer"
- @retry-steer="handleRetrySteer"
- @stop-generation="handleStopGeneration"
- @stop-confirmed="handleStopConfirmed"
- @stop-failed="handleStopFailed" :isReplying="isReplying" :sessionId="session_id"
- :assistantMessageId="currentAssistantMessageId" :embeddedMode="embeddedMode"
- :queuedSteers="steerQueue.filter(item => item.delivery === 'after')" :canSteer="isAgentStreamSession()"></InputField>
+ <div v-if="!embeddedMode" class="chat_overlays">
+ <BrowserTaskPreview v-if="session_id" :key="session_id" :session-id="session_id" />
+ <ChatQuestionMinimap :scroll-container="scrollContainer" :messages="messagesList"
+ @jump="jumpToQuestion" />
+ </div>
</div>
</div>
<KnowledgeBaseEditorModal :visible="uiStore.showKBEditorModal" :mode="uiStore.kbEditorMode"
@@ -448,10 +453,20 @@ watch(historyLoading, (loading) => {
}, { flush: 'post' })
let fullContent = ref('')
const scrollContainer = ref(null)
+const composerElement = ref(null)
+const composerHeight = ref(0)
+// Keep floating previews above the sticky composer, including when its controls
+// wrap after a drawer opens or the user adds multiple lines/attachments.
+watch(composerElement, (element, _, onCleanup) => {
+ if (!element) return
+ const measure = () => { composerHeight.value = element.offsetHeight }
+ measure()
+ const observer = new ResizeObserver(measure)
+ observer.observe(element)
+ onCleanup(() => observer.disconnect())
+}, { flush: 'post' })
const userHasScrolledUp = ref(false)
const SCROLL_BOTTOM_THRESHOLD = 80
-const minimapTargetId = ref('')
-let minimapFlashTimer = null
const isNearBottom = () => {
if (!scrollContainer.value) return true;
@@ -459,14 +474,6 @@ const isNearBottom = () => {
return scrollHeight - scrollTop - clientHeight < SCROLL_BOTTOM_THRESHOLD;
}
-const clearMinimapFlash = () => {
- if (minimapFlashTimer) {
- clearTimeout(minimapFlashTimer)
- minimapFlashTimer = null
- }
- minimapTargetId.value = ''
-}
-
const jumpToQuestion = (id) => {
const root = scrollContainer.value
if (!root || !id) return
@@ -479,12 +486,6 @@ const jumpToQuestion = (id) => {
el.scrollIntoView({ block: 'start', behavior: 'smooth' })
- minimapTargetId.value = id
- if (minimapFlashTimer) clearTimeout(minimapFlashTimer)
- minimapFlashTimer = setTimeout(() => {
- minimapTargetId.value = ''
- minimapFlashTimer = null
- }, 1200)
}
const handleKBEditorSuccess = (kbId) => {
@@ -1574,7 +1575,6 @@ const clearData = () => {
referencesDrawer.close();
isReplying.value = false;
fullContent.value = '';
- clearMinimapFlash();
// Stop any IM-reply recovery poll for the session we're leaving/switching.
if (recoverPollTimer) { clearTimeout(recoverPollTimer); recoverPollTimer = null; }
isImRecovering.value = false;
@@ -1583,7 +1583,6 @@ onUnmounted(() => {
if (!props.embeddedMode) sessionActivity.detach(activitySessionId.value);
activitySessionId.value = '';
window.removeEventListener(SESSION_MUTATION_EVENT, handleSessionMutation);
- clearMinimapFlash();
if (recoverPollTimer) { clearTimeout(recoverPollTimer); recoverPollTimer = null; }
});
onBeforeRouteLeave((to, from, next) => {
@@ -1603,26 +1602,21 @@ onBeforeRouteUpdate((to, from, next) => {
.chat {
// 水平方向不留 padding,让滚动条贴到内容区最右缘;
// 消息列与输入列各自用 --chat-content-inset 做左右对称的留白(窄屏时才可见)。
- padding: 0 0 max(8px, env(safe-area-inset-bottom)) 0;
+ padding: 0;
--chat-content-inset: 20px;
box-sizing: border-box;
flex: 1;
// The parent .platform-route-outlet is a flex column with min-height:0
// and overflow:hidden — we also need min-height:0 here so that our
- // own flex:1 child (.chat_thread) can shrink below its content
- // height and keep the input container in view.
+ // own flex:1 child (.chat_thread) can shrink below its content height.
min-height: 0;
position: relative;
display: flex;
flex-direction: column;
align-items: center;
- max-width: calc(100vw - 260px);
+ max-width: 100%;
min-width: 400px;
- &.is-sidebar-collapsed {
- max-width: calc(100vw - 60px);
- }
-
&.is-embedded {
max-width: 100%;
min-width: 100%;
@@ -1754,26 +1748,68 @@ onBeforeRouteUpdate((to, from, next) => {
flex: 1;
min-height: 0;
width: 100%;
- padding-top: 8px;
+ padding: 8px 0 0;
box-sizing: border-box;
overflow-y: auto;
- // 使用系统原生滚动条(macOS 滚动时自动显示 overlay 滚动条,类似 ChatGPT)
- scrollbar-width: auto;
- scrollbar-color: auto;
-}
+ overscroll-behavior-y: contain;
+ scroll-padding-bottom: var(--chat-composer-height, 0px);
+ scrollbar-gutter: stable;
+ scrollbar-width: thin;
+ scrollbar-color: var(--td-component-stroke) transparent;
-// 深色模式下 theme.css 对 * 做了 webkit 滚动条着色,这里恢复为系统默认
-:global(:root[theme-mode="dark"]) .chat_scroll_box {
- &::-webkit-scrollbar-thumb {
- background-color: initial !important;
+ &:hover,
+ &:focus-within {
+ scrollbar-color: var(--td-scrollbar-color) transparent;
}
- &::-webkit-scrollbar-thumb:hover {
- background-color: initial !important;
+ &::-webkit-scrollbar {
+ width: 6px;
}
&::-webkit-scrollbar-track {
- background-color: initial !important;
+ background: transparent;
+ }
+
+ &::-webkit-scrollbar-thumb {
+ border-radius: 6px;
+ background: var(--td-component-stroke);
+ }
+
+ &:hover::-webkit-scrollbar-thumb,
+ &:focus-within::-webkit-scrollbar-thumb {
+ background: var(--td-scrollbar-color);
+ }
+}
+
+// One scroll viewport spans the messages and composer, so the scrollbar reaches
+// the bottom of the chat column. The composer stays in flow to reserve its own
+// height, and sticks to the bottom while reading earlier messages.
+.chat_scroll_content {
+ display: flex;
+ flex-direction: column;
+ min-height: 100%;
+}
+
+.chat_composer {
+ position: sticky;
+ bottom: 0;
+ z-index: 12;
+ flex-shrink: 0;
+ padding: 16px 0 max(8px, env(safe-area-inset-bottom));
+ background: var(--td-bg-color-container);
+}
+
+.is-embedded .chat_composer {
+ padding: 0;
+}
+
+.chat_overlays {
+ position: absolute;
+ inset: 0 0 var(--chat-composer-height, 0px);
+ pointer-events: none;
+
+ :deep(.browser-task-preview) {
+ pointer-events: auto;
}
}
@@ -1914,9 +1950,6 @@ onBeforeRouteUpdate((to, from, next) => {
flex-direction: column;
width: 100%;
- &.is-minimap-target {
- animation: minimap-target-flash 1.2s ease;
- }
}
.botanswer_laoding_gif {
@@ -1943,16 +1976,6 @@ onBeforeRouteUpdate((to, from, next) => {
}
}
-@keyframes minimap-target-flash {
- 0% {
- background: color-mix(in srgb, var(--td-brand-color) 18%, transparent);
- }
-
- 100% {
- background: transparent;
- }
-}
-
@media (prefers-reduced-motion: reduce) {
.chat-global-wait__spinner {
animation: none;
diff --git a/frontend/src/views/platform/index.vue b/frontend/src/views/platform/index.vue
index 6072f8827..cc10a2428 100644
--- a/frontend/src/views/platform/index.vue
+++ b/frontend/src/views/platform/index.vue
@@ -1,5 +1,5 @@
<template>
- <div class="main" ref="dropzone">
+ <div class="main" ref="dropzone" :style="{ '--sidebar-width': `${uiStore.sidebarDisplayWidth}px` }">
<Menu></Menu>
<div v-if="isRouterAlive" class="platform-route-outlet">
<RouterView />