feat(chat): refactor agent stream display and tool result rendering
Add RagPipelineProgress timeline, simplify AgentStreamDisplay structure, group grep hits per document, and add KnowledgeChunksList tool result UI.
This commit is contained in:
@@ -0,0 +1,80 @@
|
||||
import assert from 'node:assert/strict'
|
||||
import { readFileSync } from 'node:fs'
|
||||
import { dirname, join } from 'node:path'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import test from 'node:test'
|
||||
|
||||
const here = dirname(fileURLToPath(import.meta.url))
|
||||
const source = readFileSync(join(here, 'AgentStreamDisplay.vue'), 'utf8')
|
||||
|
||||
test('agent steps use compact muted timeline styling', () => {
|
||||
assert.match(source, /--agent-step-text-size:\s*14px/)
|
||||
assert.match(source, /--agent-step-summary-size:\s*13px/)
|
||||
assert.match(source, /--agent-step-icon-color:\s*var\(--td-text-color-placeholder\)/)
|
||||
assert.match(source, /max-height:\s*none/)
|
||||
assert.match(source, /overflow-y:\s*visible/)
|
||||
assert.match(source, /\.tree-root \.action-name\s*\{[\s\S]*font-size:\s*14px/)
|
||||
assert.match(source, /\.tree-child \.action-title-icon\s*\{[\s\S]*position:\s*absolute/)
|
||||
assert.match(source, /function maskIconStyle\(src: string, size = 18\)/)
|
||||
assert.match(source, /\.icon-mask\s*\{[\s\S]*background-color:\s*var\(--agent-step-icon-color\)/)
|
||||
assert.doesNotMatch(source, /\.action-title \.action-title-icon,\s*\n\s*\.icon-mask\s*\{/)
|
||||
})
|
||||
|
||||
test('expanded agent step log hides raw thinking narration', () => {
|
||||
assert.match(source, /visibleIntermediateEvents\s*=\s*computed/)
|
||||
assert.match(source, /e\.type === 'thinking'\)\s*return false/)
|
||||
assert.match(source, /e\.type === 'tool_call' && e\.tool_name === 'thinking'\)\s*return false/)
|
||||
assert.match(source, /v-for="\(event, index\) in visibleIntermediateEvents"/)
|
||||
})
|
||||
|
||||
test('streaming log also hides raw thinking narration', () => {
|
||||
assert.match(source, /if \(!isConversationDone\.value\)\s*\{\s*return result\.filter/)
|
||||
assert.match(source, /e\.type === 'thinking'\) return false/)
|
||||
assert.match(source, /e\.type === 'tool_call' && e\.tool_name === 'thinking'\) return false/)
|
||||
assert.doesNotMatch(source, /if \(!isConversationDone\.value\)\s*\{\s*return result;\s*\}/)
|
||||
})
|
||||
|
||||
test('streaming tool log uses the same timeline structure', () => {
|
||||
assert.match(source, /'is-streaming-timeline': showStreamingTimeline/)
|
||||
assert.match(source, /'tree-child': isStreamingTimelineEvent\(event\)/)
|
||||
assert.match(source, /class="tree-child tree-child-last streaming-loading-node"/)
|
||||
assert.match(source, /chat-timeline-loading\.less/)
|
||||
assert.match(source, /lastStreamingTimelineEventIndex\s*=\s*computed/)
|
||||
})
|
||||
|
||||
test('final done row uses an existing common translation key', () => {
|
||||
assert.match(source, /t\('common\.finish'\)/)
|
||||
assert.doesNotMatch(source, /\$t\('common\.done'\)/)
|
||||
assert.match(source, /'tree-child-last': !isConversationDone && index === visibleIntermediateEvents\.length - 1/)
|
||||
})
|
||||
|
||||
test('tool rows use line icon names instead of legacy asset masks', () => {
|
||||
assert.match(source, /getAgentToolIconName/)
|
||||
assert.match(source, /:name="getToolIconName\(event\.tool_name\)"/)
|
||||
assert.match(source, /wiki_read_source_doc: 'agentStream\.tools\.wikiReadSourceDoc'/)
|
||||
assert.match(source, /toolName === 'get_document_content' \|\| toolName === 'wiki_read_source_doc'/)
|
||||
assert.doesNotMatch(source, /getToolIcon\(event\.tool_name\)/)
|
||||
})
|
||||
|
||||
test('rag mode delegates pre-answer loading to pipeline and keeps dots while answer streams', () => {
|
||||
assert.match(source, /if \(props\.ragMode\) return hasAnswerStarted\.value/)
|
||||
assert.match(source, /v-if="!ragMode \|\| displayEvents\.length > 0 \|\| showAgentActivityIndicator"/)
|
||||
})
|
||||
|
||||
test('only the collapsed root summary shows an expand chevron', () => {
|
||||
assert.match(source, /tree-root-summary[\s\S]*class="action-show-icon"/)
|
||||
assert.match(source, /showIntermediateSteps \? 'chevron-down' : 'chevron-right'/)
|
||||
assert.doesNotMatch(source, /isEventExpanded\(event\.tool_call_id\) \? 'chevron/)
|
||||
assert.doesNotMatch(source, /isEventExpanded\(event\.event_id\) \? 'chevron/)
|
||||
})
|
||||
|
||||
test('pending tool rows do not render an extra axis dot', () => {
|
||||
assert.doesNotMatch(source, /&\.action-pending\s*\{[\s\S]*&::after/)
|
||||
})
|
||||
|
||||
test('agent mode keeps gray timeline dots for the full turn', () => {
|
||||
assert.match(source, /if \(isConversationDone\.value\) return false/)
|
||||
assert.match(source, /if \(props\.ragMode\) return false/)
|
||||
assert.match(source, /return true;\s*\}\);/)
|
||||
assert.match(source, /chat-timeline-loading\.less/)
|
||||
})
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,67 @@
|
||||
import assert from 'node:assert/strict'
|
||||
import { readFileSync } from 'node:fs'
|
||||
import { dirname, join } from 'node:path'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import test from 'node:test'
|
||||
|
||||
const here = dirname(fileURLToPath(import.meta.url))
|
||||
const source = readFileSync(join(here, 'RagPipelineProgress.vue'), 'utf8')
|
||||
|
||||
test('rag pipeline uses agent-style timeline structure', () => {
|
||||
assert.match(source, /class="tree-children"/)
|
||||
assert.match(source, /class="tree-child/)
|
||||
assert.match(source, /getAgentToolIconName/)
|
||||
assert.match(source, /name="check-circle"/)
|
||||
assert.match(source, /streaming-loading-node/)
|
||||
assert.match(source, /@import ['"]@\/components\/css\/chat-timeline-loading\.less['"]/)
|
||||
assert.match(source, /search-results-summary-fixed/)
|
||||
})
|
||||
|
||||
test('rag pipeline persists and collapses after the answer arrives', () => {
|
||||
assert.match(source, /showCollapsedRoot/)
|
||||
assert.match(source, /tree-root-summary/)
|
||||
assert.match(source, /collapsedSummaryHtml/)
|
||||
assert.match(source, /visible = computed\(\(\) => steps\.value\.length > 0 \|\| showPrePipelineWait\.value\)/)
|
||||
})
|
||||
|
||||
test('rag pipeline toggles expand and collapse from the root header', () => {
|
||||
assert.match(source, /class="action-card tree-root" @click="toggleExpanded"/)
|
||||
assert.match(source, /showExpandedTimeline \? 'chevron-down' : 'chevron-right'/)
|
||||
assert.doesNotMatch(source, /refsExpanded \? 'chevron/)
|
||||
assert.doesNotMatch(source, /tree-collapse-bar/)
|
||||
})
|
||||
|
||||
test('only the collapsed root summary shows an expand chevron', () => {
|
||||
assert.match(source, /tree-root-summary[\s\S]*class="action-show-icon"/)
|
||||
assert.equal((source.match(/class="action-show-icon"/g) || []).length, 1)
|
||||
})
|
||||
|
||||
test('rag pipeline embeds references in the timeline instead of a separate card', () => {
|
||||
assert.match(source, /timeline-mode/)
|
||||
assert.match(source, /content-only/)
|
||||
assert.match(source, /rag-ref-step[\s\S]*name="file-search"/)
|
||||
})
|
||||
|
||||
test('rag pipeline keeps loading inside the timeline without duplicate dots', () => {
|
||||
assert.match(source, /showPrePipelineWait/)
|
||||
assert.match(source, /showActivityIndicator = computed\(\s*\(\) => steps\.value\.length > 0 && !hasAnswer\.value/)
|
||||
assert.match(source, /showPrePipelineWait = computed/)
|
||||
})
|
||||
|
||||
test('rag pipeline places references before the done row', () => {
|
||||
const refsIndex = source.indexOf('class="tree-child rag-ref-step"')
|
||||
const doneIndex = source.indexOf('agent-step-done')
|
||||
assert.ok(refsIndex > -1 && doneIndex > -1)
|
||||
assert.ok(refsIndex < doneIndex)
|
||||
})
|
||||
|
||||
test('clickable timeline headers use pointer cursor', () => {
|
||||
assert.match(source, /\.tool-event \{[\s\S]*\.action-header \{[\s\S]*cursor: pointer/)
|
||||
assert.match(source, /\.action-header \{[\s\S]*&\.no-results \{[\s\S]*cursor: default/)
|
||||
assert.match(source, /\.tree-root \{[\s\S]*cursor: pointer/)
|
||||
})
|
||||
|
||||
test('collapsed summary uses the same title-to-answer spacing as agent', () => {
|
||||
assert.match(source, /\.tree-container \{\s*margin: 0 0 16px;/)
|
||||
assert.match(source, /\.rag-pipeline-progress \{[\s\S]*margin: 0;/)
|
||||
})
|
||||
@@ -0,0 +1,534 @@
|
||||
<template>
|
||||
<div v-if="visible" class="rag-pipeline-progress">
|
||||
<div v-if="showPrePipelineWait" class="tree-children">
|
||||
<div class="tree-child tree-child-last streaming-loading-node">
|
||||
<div class="tree-branch" />
|
||||
<div class="tree-child-content">
|
||||
<div class="loading-indicator">
|
||||
<div class="loading-typing">
|
||||
<span />
|
||||
<span />
|
||||
<span />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-else-if="!showCollapsedRoot" class="tree-children">
|
||||
<div v-for="(step, index) in steps" :key="step.id" class="tree-child" :class="{
|
||||
'tree-child-last':
|
||||
!showActivityIndicator
|
||||
&& !showDoneRow
|
||||
&& !hasReferences
|
||||
&& index === steps.length - 1,
|
||||
}">
|
||||
<div class="tree-branch" />
|
||||
<div class="tree-child-content">
|
||||
<div class="tool-event">
|
||||
<div class="action-card">
|
||||
<div class="action-header no-results">
|
||||
<div class="action-title">
|
||||
<t-icon class="action-title-icon" :name="step.iconName" />
|
||||
<span class="action-name">{{ step.title }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="step.summaryHtml" class="search-results-summary-fixed">
|
||||
<div class="results-summary-text" v-html="step.summaryHtml" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="hasReferences" class="tree-child rag-ref-step"
|
||||
:class="{ 'tree-child-last': !showDoneRow && !showActivityIndicator }">
|
||||
<div class="tree-branch" />
|
||||
<div class="tree-child-content">
|
||||
<div class="tool-event">
|
||||
<div class="action-card">
|
||||
<div class="action-header" @click="toggleReferences">
|
||||
<div class="action-title">
|
||||
<t-icon class="action-title-icon" name="file-search" />
|
||||
<span class="action-name">{{ referencesHeaderText }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<DocInfo v-show="refsExpanded" :session="session" :embedded-mode="embeddedMode" timeline-mode
|
||||
content-only />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="showDoneRow" class="tree-child agent-step-done" :class="{ 'tree-child-last': !showActivityIndicator }">
|
||||
<div class="tree-branch" />
|
||||
<div class="tree-child-content">
|
||||
<div class="tool-event">
|
||||
<div class="action-card">
|
||||
<div class="action-header no-results">
|
||||
<div class="action-title">
|
||||
<t-icon class="action-title-icon" name="check-circle" />
|
||||
<span class="action-name">{{ t('common.finish') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="showActivityIndicator" class="tree-child tree-child-last streaming-loading-node">
|
||||
<div class="tree-branch" />
|
||||
<div class="tree-child-content">
|
||||
<div class="loading-indicator">
|
||||
<div class="loading-typing">
|
||||
<span />
|
||||
<span />
|
||||
<span />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-else class="tree-container">
|
||||
<div class="tool-event">
|
||||
<div class="action-card tree-root" @click="toggleExpanded">
|
||||
<div class="action-header">
|
||||
<div class="action-title">
|
||||
<span class="action-name tree-root-summary" v-html="collapsedSummaryHtml" />
|
||||
<div class="action-show-icon">
|
||||
<t-icon :name="showExpandedTimeline ? 'chevron-down' : 'chevron-right'" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="showExpandedTimeline" class="tree-children tree-children-expanded">
|
||||
<div v-for="(step, index) in steps" :key="step.id" class="tree-child"
|
||||
:class="{ 'tree-child-last': index === steps.length - 1 && !hasReferences && !showDoneRow }">
|
||||
<div class="tree-branch" />
|
||||
<div class="tree-child-content">
|
||||
<div class="tool-event">
|
||||
<div class="action-card">
|
||||
<div class="action-header no-results">
|
||||
<div class="action-title">
|
||||
<t-icon class="action-title-icon" :name="step.iconName" />
|
||||
<span class="action-name">{{ step.title }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="step.summaryHtml" class="search-results-summary-fixed">
|
||||
<div class="results-summary-text" v-html="step.summaryHtml" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="hasReferences" class="tree-child rag-ref-step" :class="{ 'tree-child-last': !showDoneRow }">
|
||||
<div class="tree-branch" />
|
||||
<div class="tree-child-content">
|
||||
<div class="tool-event">
|
||||
<div class="action-card">
|
||||
<div class="action-header" @click="toggleReferences">
|
||||
<div class="action-title">
|
||||
<t-icon class="action-title-icon" name="file-search" />
|
||||
<span class="action-name">{{ referencesHeaderText }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<DocInfo v-show="refsExpanded" :session="session" :embedded-mode="embeddedMode" timeline-mode
|
||||
content-only />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="showDoneRow" class="tree-child agent-step-done tree-child-last">
|
||||
<div class="tree-branch" />
|
||||
<div class="tree-child-content">
|
||||
<div class="tool-event">
|
||||
<div class="action-card">
|
||||
<div class="action-header no-results">
|
||||
<div class="action-title">
|
||||
<t-icon class="action-title-icon" name="check-circle" />
|
||||
<span class="action-name">{{ t('common.finish') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, ref } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import DocInfo from './docInfo.vue'
|
||||
import { getAgentToolIconName } from '@/utils/agent-tool-icons'
|
||||
import {
|
||||
getKnowledgeSearchSummaryHtml,
|
||||
getRagPipelineStepTitle,
|
||||
} from '@/utils/agent-tool-display'
|
||||
import { RAG_PIPELINE_TOOL_NAMES } from '@/utils/rag-pipeline-history'
|
||||
|
||||
const props = defineProps<{
|
||||
session?: {
|
||||
agentEventStream?: Array<Record<string, unknown>>
|
||||
content?: string
|
||||
knowledge_references?: Array<{ chunk_type?: string; knowledge_id?: string; knowledge_title?: string }>
|
||||
is_completed?: boolean
|
||||
}
|
||||
embeddedMode?: boolean
|
||||
}>()
|
||||
|
||||
const { t } = useI18n()
|
||||
const userExpanded = ref(false)
|
||||
const refsExpanded = ref(false)
|
||||
|
||||
const hasAnswer = computed(() => {
|
||||
const sessionContent = props.session?.content
|
||||
if (typeof sessionContent === 'string' && sessionContent.trim().length > 0) return true
|
||||
|
||||
const stream = props.session?.agentEventStream
|
||||
if (!stream?.length) return false
|
||||
return stream.some((event) => {
|
||||
if (event.type !== 'answer' || event.superseded) return false
|
||||
const content = event.content
|
||||
return typeof content === 'string' && content.trim().length > 0
|
||||
})
|
||||
})
|
||||
|
||||
const hasReferences = computed(
|
||||
() => (props.session?.knowledge_references?.length ?? 0) > 0,
|
||||
)
|
||||
|
||||
const steps = computed(() => {
|
||||
const stream = props.session?.agentEventStream
|
||||
if (!stream?.length) return []
|
||||
|
||||
return stream
|
||||
.filter((event) => {
|
||||
return (
|
||||
event.type === 'tool_call' &&
|
||||
typeof event.tool_name === 'string' &&
|
||||
RAG_PIPELINE_TOOL_NAMES.has(event.tool_name)
|
||||
)
|
||||
})
|
||||
.map((event) => {
|
||||
const toolName = String(event.tool_name)
|
||||
const pending = event.pending === true
|
||||
const toolData =
|
||||
event.tool_data && typeof event.tool_data === 'object'
|
||||
? (event.tool_data as Record<string, unknown>)
|
||||
: null
|
||||
|
||||
const isSearchTool = toolName === 'knowledge_search' || toolName === 'search_knowledge'
|
||||
const summaryHtml =
|
||||
!pending && isSearchTool && toolData
|
||||
? getKnowledgeSearchSummaryHtml(t, toolData)
|
||||
: ''
|
||||
|
||||
return {
|
||||
id: String(event.tool_call_id || `${toolName}-${event.timestamp || 0}`),
|
||||
pending,
|
||||
iconName: getAgentToolIconName(toolName),
|
||||
title: getRagPipelineStepTitle(t, {
|
||||
tool_name: toolName,
|
||||
pending,
|
||||
success: event.success as boolean | undefined,
|
||||
arguments: event.arguments,
|
||||
tool_data: toolData,
|
||||
}),
|
||||
summaryHtml,
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
const allStepsDone = computed(
|
||||
() => steps.value.length > 0 && steps.value.every((step) => !step.pending),
|
||||
)
|
||||
|
||||
const showCollapsedRoot = computed(
|
||||
() => (hasAnswer.value || Boolean(props.session?.is_completed)) && steps.value.length > 0,
|
||||
)
|
||||
|
||||
const showExpandedTimeline = computed(() => {
|
||||
if (!showCollapsedRoot.value) return true
|
||||
return userExpanded.value
|
||||
})
|
||||
|
||||
const showDoneRow = computed(() => allStepsDone.value)
|
||||
|
||||
const showPrePipelineWait = computed(
|
||||
() => !hasAnswer.value && !props.session?.is_completed && steps.value.length === 0,
|
||||
)
|
||||
|
||||
// Trailing dots on the timeline axis while pipeline steps are running or waiting for the answer.
|
||||
const showActivityIndicator = computed(
|
||||
() => steps.value.length > 0 && !hasAnswer.value && !props.session?.is_completed,
|
||||
)
|
||||
|
||||
const visible = computed(() => steps.value.length > 0 || showPrePipelineWait.value)
|
||||
|
||||
const referenceDocCount = computed(() => {
|
||||
const refs = props.session?.knowledge_references ?? []
|
||||
const keys = new Set<string>()
|
||||
for (const item of refs) {
|
||||
if (item.chunk_type === 'web_search') continue
|
||||
keys.add(item.knowledge_id || item.knowledge_title || 'doc')
|
||||
}
|
||||
return keys.size
|
||||
})
|
||||
|
||||
const referenceWebCount = computed(() => {
|
||||
const refs = props.session?.knowledge_references ?? []
|
||||
return refs.filter((item) => item.chunk_type === 'web_search').length
|
||||
})
|
||||
|
||||
const referencesHeaderText = computed(() => {
|
||||
const docCount = referenceDocCount.value
|
||||
const webCount = referenceWebCount.value
|
||||
const total = props.session?.knowledge_references?.length ?? 0
|
||||
|
||||
if (docCount > 0 && webCount > 0) {
|
||||
return t('chat.referencesDocAndWebCount', { docCount, webCount })
|
||||
}
|
||||
if (docCount > 0) {
|
||||
return t('chat.referencesDocCount', { count: docCount })
|
||||
}
|
||||
return t('chat.referencesTitle', { count: total })
|
||||
})
|
||||
|
||||
const collapsedSummaryHtml = computed(() => {
|
||||
const parts: string[] = [t('agentStream.ragPipeline.searchDone')]
|
||||
const docCount = referenceDocCount.value
|
||||
const webCount = referenceWebCount.value
|
||||
|
||||
if (docCount > 0 && webCount > 0) {
|
||||
parts.push(
|
||||
t('agentStream.ragPipeline.referencedDocAndWeb', {
|
||||
docCount: `<strong>${docCount}</strong>`,
|
||||
webCount: `<strong>${webCount}</strong>`,
|
||||
}),
|
||||
)
|
||||
} else if (docCount > 0) {
|
||||
parts.push(
|
||||
t('agentStream.ragPipeline.referencedDocs', {
|
||||
count: `<strong>${docCount}</strong>`,
|
||||
}),
|
||||
)
|
||||
} else if (webCount > 0) {
|
||||
parts.push(
|
||||
t('agentStream.ragPipeline.referencedWebs', {
|
||||
count: `<strong>${webCount}</strong>`,
|
||||
}),
|
||||
)
|
||||
}
|
||||
|
||||
return parts.join(t('agent.stepSummarySeparator'))
|
||||
})
|
||||
|
||||
function toggleExpanded() {
|
||||
userExpanded.value = !userExpanded.value
|
||||
}
|
||||
|
||||
function toggleReferences() {
|
||||
refsExpanded.value = !refsExpanded.value
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="less">
|
||||
@import '@/components/css/chat-timeline-loading.less';
|
||||
|
||||
.rag-pipeline-progress {
|
||||
--agent-step-text-size: 14px;
|
||||
--agent-step-summary-size: 13px;
|
||||
--agent-step-line-color: color-mix(in srgb, var(--td-text-color-primary) 16%, transparent);
|
||||
--agent-step-icon-color: var(--td-text-color-placeholder);
|
||||
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.tree-container {
|
||||
margin: 0 0 16px;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.tree-root {
|
||||
cursor: pointer;
|
||||
color: var(--td-text-color-secondary);
|
||||
margin-bottom: 0;
|
||||
|
||||
.action-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
min-height: 24px;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.action-title {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
flex: 0 1 auto;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.tree-root-summary {
|
||||
font-size: 14px;
|
||||
line-height: 1.55;
|
||||
color: var(--td-text-color-secondary);
|
||||
|
||||
:deep(strong) {
|
||||
font-weight: 600;
|
||||
color: var(--td-text-color-primary);
|
||||
}
|
||||
}
|
||||
|
||||
.action-show-icon {
|
||||
color: var(--td-text-color-placeholder);
|
||||
font-size: 14px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.tree-children {
|
||||
position: relative;
|
||||
padding-left: 0;
|
||||
margin-top: 0;
|
||||
margin-left: 10px;
|
||||
}
|
||||
|
||||
.tree-children-expanded {
|
||||
margin-top: 14px;
|
||||
}
|
||||
|
||||
.tree-child {
|
||||
position: relative;
|
||||
padding-left: 42px;
|
||||
padding-bottom: 0;
|
||||
margin-bottom: 18px;
|
||||
|
||||
&::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
left: 9px;
|
||||
top: 22px;
|
||||
bottom: -18px;
|
||||
width: 0;
|
||||
border-left: 1px solid var(--agent-step-line-color);
|
||||
}
|
||||
|
||||
.tree-branch {
|
||||
display: none;
|
||||
}
|
||||
|
||||
&.tree-child-last {
|
||||
margin-bottom: 0;
|
||||
|
||||
&::before {
|
||||
content: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.rag-ref-step {
|
||||
.action-header {
|
||||
width: 100%;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.action-title {
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.action-show-icon {
|
||||
color: var(--td-text-color-placeholder);
|
||||
font-size: 14px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
:deep(.refer-timeline.refer) {
|
||||
margin-top: 4px;
|
||||
padding-left: 0;
|
||||
}
|
||||
|
||||
:deep(.refer-timeline .doc-group-chunks) {
|
||||
padding-left: 18px;
|
||||
}
|
||||
}
|
||||
|
||||
.tool-event {
|
||||
.action-card {
|
||||
position: relative;
|
||||
background: transparent;
|
||||
border: 0;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.action-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
min-height: 24px;
|
||||
padding: 0;
|
||||
cursor: pointer;
|
||||
user-select: none;
|
||||
|
||||
&.no-results {
|
||||
cursor: default;
|
||||
}
|
||||
}
|
||||
|
||||
.action-title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
position: relative;
|
||||
flex: 0 1 auto;
|
||||
min-width: 0;
|
||||
|
||||
.action-show-icon {
|
||||
flex-shrink: 0;
|
||||
margin-left: 2px;
|
||||
}
|
||||
}
|
||||
|
||||
.action-title-icon {
|
||||
position: absolute;
|
||||
left: -42px;
|
||||
top: 3px;
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
flex-shrink: 0;
|
||||
color: var(--agent-step-icon-color);
|
||||
}
|
||||
|
||||
.action-name {
|
||||
font-size: var(--agent-step-text-size);
|
||||
line-height: 1.55;
|
||||
font-weight: 400;
|
||||
color: var(--td-text-color-secondary);
|
||||
word-break: break-word;
|
||||
max-width: min(680px, 100%);
|
||||
}
|
||||
}
|
||||
|
||||
.search-results-summary-fixed {
|
||||
padding: 2px 0 0 0;
|
||||
|
||||
.results-summary-text {
|
||||
font-size: var(--agent-step-summary-size);
|
||||
font-weight: 400;
|
||||
color: var(--td-text-color-secondary);
|
||||
line-height: 1.5;
|
||||
|
||||
:deep(strong) {
|
||||
color: var(--td-text-color-secondary);
|
||||
font-weight: 500;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1,84 +1,51 @@
|
||||
<template>
|
||||
<div class="tool-result-renderer">
|
||||
<!-- Search Results -->
|
||||
<SearchResults
|
||||
v-if="displayType === 'search_results'"
|
||||
:data="toolData as SearchResultsData"
|
||||
:arguments="toolArguments"
|
||||
/>
|
||||
|
||||
<SearchResults v-if="displayType === 'search_results'" :data="toolData as SearchResultsData"
|
||||
:arguments="toolArguments" />
|
||||
|
||||
<!-- Chunk Detail -->
|
||||
<ChunkDetail
|
||||
v-else-if="displayType === 'chunk_detail'"
|
||||
:data="toolData as ChunkDetailData"
|
||||
/>
|
||||
|
||||
<ChunkDetail v-else-if="displayType === 'chunk_detail'" :data="toolData as ChunkDetailData" />
|
||||
|
||||
<!-- Related Chunks -->
|
||||
<RelatedChunks
|
||||
v-else-if="displayType === 'related_chunks'"
|
||||
:data="toolData as RelatedChunksData"
|
||||
/>
|
||||
|
||||
<RelatedChunks v-else-if="displayType === 'related_chunks'" :data="toolData as RelatedChunksData" />
|
||||
|
||||
<!-- Knowledge Base List -->
|
||||
<KnowledgeBaseList
|
||||
v-else-if="displayType === 'knowledge_base_list'"
|
||||
:data="toolData as KnowledgeBaseListData"
|
||||
/>
|
||||
|
||||
<KnowledgeBaseList v-else-if="displayType === 'knowledge_base_list'" :data="toolData as KnowledgeBaseListData" />
|
||||
|
||||
<!-- Document Info -->
|
||||
<DocumentInfo
|
||||
v-else-if="displayType === 'document_info'"
|
||||
:data="toolData as DocumentInfoData"
|
||||
/>
|
||||
|
||||
<DocumentInfo v-else-if="displayType === 'document_info'" :data="toolData as DocumentInfoData" />
|
||||
|
||||
<!-- Graph Query Results -->
|
||||
<GraphQueryResults
|
||||
v-else-if="displayType === 'graph_query_results'"
|
||||
:data="toolData as GraphQueryResultsData"
|
||||
/>
|
||||
|
||||
<GraphQueryResults v-else-if="displayType === 'graph_query_results'" :data="toolData as GraphQueryResultsData" />
|
||||
|
||||
<!-- Thinking Display -->
|
||||
<ThinkingDisplay
|
||||
v-else-if="displayType === 'thinking'"
|
||||
:data="toolData as ThinkingData"
|
||||
/>
|
||||
|
||||
<ThinkingDisplay v-else-if="displayType === 'thinking'" :data="toolData as ThinkingData" />
|
||||
|
||||
<!-- Plan Display -->
|
||||
<PlanDisplay
|
||||
v-else-if="displayType === 'plan'"
|
||||
:data="toolData as PlanData"
|
||||
/>
|
||||
|
||||
<PlanDisplay v-else-if="displayType === 'plan'" :data="toolData as PlanData" />
|
||||
|
||||
<!-- Database Query Display -->
|
||||
<DatabaseQuery
|
||||
v-else-if="displayType === 'database_query'"
|
||||
:data="toolData as DatabaseQueryData"
|
||||
/>
|
||||
|
||||
<DatabaseQuery v-else-if="displayType === 'database_query'" :data="toolData as DatabaseQueryData" />
|
||||
|
||||
<!-- Web Search Results Display -->
|
||||
<WebSearchResults
|
||||
v-else-if="displayType === 'web_search_results'"
|
||||
:data="toolData as WebSearchResultsData"
|
||||
/>
|
||||
|
||||
<WebSearchResults v-else-if="displayType === 'web_search_results'" :data="toolData as WebSearchResultsData" />
|
||||
|
||||
<!-- Web Fetch Results Display -->
|
||||
<WebFetchResults
|
||||
v-else-if="displayType === 'web_fetch_results'"
|
||||
:data="toolData as WebFetchResultsData"
|
||||
/>
|
||||
|
||||
<WebFetchResults v-else-if="displayType === 'web_fetch_results'" :data="toolData as WebFetchResultsData" />
|
||||
|
||||
<!-- Grep Results Display -->
|
||||
<GrepResults
|
||||
v-else-if="displayType === 'grep_results'"
|
||||
:data="toolData as GrepResultsData"
|
||||
/>
|
||||
|
||||
<GrepResults v-else-if="displayType === 'grep_results'" :data="toolData as GrepResultsData" />
|
||||
|
||||
<!-- Knowledge Chunks List -->
|
||||
<KnowledgeChunksList v-else-if="displayType === 'knowledge_chunks_list'"
|
||||
:data="toolData as KnowledgeChunksListData" />
|
||||
|
||||
<!-- Wiki Edit Results Display -->
|
||||
<WikiEditResult
|
||||
v-else-if="displayType === 'wiki_write_page' || displayType === 'wiki_replace_text' || displayType === 'wiki_rename_page' || displayType === 'wiki_delete_page'"
|
||||
:data="toolData as WikiEditData"
|
||||
/>
|
||||
|
||||
:data="toolData as WikiEditData" />
|
||||
|
||||
<!-- Fallback: Display raw output -->
|
||||
<div v-else class="fallback-output">
|
||||
<div class="fallback-header">
|
||||
@@ -93,7 +60,7 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { defineProps, computed } from 'vue';
|
||||
import type {
|
||||
import type {
|
||||
DisplayType,
|
||||
SearchResultsData,
|
||||
ChunkDetailData,
|
||||
@@ -107,6 +74,7 @@ import type {
|
||||
WebSearchResultsData,
|
||||
WebFetchResultsData,
|
||||
GrepResultsData,
|
||||
KnowledgeChunksListData,
|
||||
WikiEditData
|
||||
} from '@/types/tool-results';
|
||||
|
||||
@@ -122,6 +90,7 @@ import DatabaseQuery from './tool-results/DatabaseQuery.vue';
|
||||
import WebSearchResults from './tool-results/WebSearchResults.vue';
|
||||
import WebFetchResults from './tool-results/WebFetchResults.vue';
|
||||
import GrepResults from './tool-results/GrepResults.vue';
|
||||
import KnowledgeChunksList from './tool-results/KnowledgeChunksList.vue';
|
||||
import WikiEditResult from './tool-results/WikiEditResult.vue';
|
||||
|
||||
interface Props {
|
||||
@@ -147,13 +116,13 @@ const toolArguments = computed(() => props.arguments || {});
|
||||
.fallback-output {
|
||||
margin: 12px 0;
|
||||
padding: 0;
|
||||
|
||||
|
||||
.fallback-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-bottom: 10px;
|
||||
padding: 0 4px;
|
||||
|
||||
|
||||
.fallback-label {
|
||||
font-size: 12px;
|
||||
color: var(--td-text-color-secondary);
|
||||
@@ -161,7 +130,7 @@ const toolArguments = computed(() => props.arguments || {});
|
||||
line-height: 1.5;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
.detail-output-wrapper {
|
||||
position: relative;
|
||||
background: var(--td-bg-color-secondarycontainer);
|
||||
@@ -170,7 +139,7 @@ const toolArguments = computed(() => props.arguments || {});
|
||||
overflow: hidden;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
|
||||
|
||||
.detail-output {
|
||||
font-family: var(--app-font-family-mono);
|
||||
font-size: 12px;
|
||||
@@ -185,22 +154,22 @@ const toolArguments = computed(() => props.arguments || {});
|
||||
overflow-x: auto;
|
||||
background: var(--td-bg-color-container);
|
||||
display: block;
|
||||
|
||||
|
||||
// 滚动条样式
|
||||
&::-webkit-scrollbar {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
}
|
||||
|
||||
|
||||
&::-webkit-scrollbar-track {
|
||||
background: var(--td-bg-color-secondarycontainer);
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
|
||||
&::-webkit-scrollbar-thumb {
|
||||
background: var(--td-component-border);
|
||||
border-radius: 4px;
|
||||
|
||||
|
||||
&:hover {
|
||||
background: var(--td-text-color-placeholder);
|
||||
}
|
||||
@@ -209,4 +178,3 @@ const toolArguments = computed(() => props.arguments || {});
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
import assert from 'node:assert/strict'
|
||||
import { readFileSync } from 'node:fs'
|
||||
import { dirname, join } from 'node:path'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import test from 'node:test'
|
||||
|
||||
const here = dirname(fileURLToPath(import.meta.url))
|
||||
const source = readFileSync(join(here, 'docInfo.vue'), 'utf8')
|
||||
|
||||
test('timeline references neutralize brand colors via local css variables', () => {
|
||||
assert.match(source, /&\.refer-timeline \{[\s\S]*--td-brand-color:\s*var\(--td-text-color-placeholder\)/)
|
||||
assert.match(source, /\.doc-chunk-item \.doc-chunk-text:hover/)
|
||||
})
|
||||
|
||||
test('doc header uses right/down chevron on the outer title only', () => {
|
||||
assert.match(source, /showReferBox \? 'chevron-down' : 'chevron-right'/)
|
||||
assert.doesNotMatch(source, /class="doc-group-arrow"/)
|
||||
})
|
||||
@@ -1,36 +1,32 @@
|
||||
<template>
|
||||
<div class="refer" v-if="session.knowledge_references && session.knowledge_references.length">
|
||||
<div class="refer_header" @click="referBoxSwitch">
|
||||
<div class="refer" :class="{ 'refer-timeline': timelineMode }"
|
||||
v-if="session.knowledge_references && session.knowledge_references.length">
|
||||
<div class="refer_header" v-if="!contentOnly" @click="referBoxSwitch">
|
||||
<div class="refer_title">
|
||||
<span class="refer-title-icon icon-mask" aria-hidden="true" />
|
||||
<t-icon v-if="!timelineMode" name="file" class="refer-title-icon" />
|
||||
<span>{{ headerText }}</span>
|
||||
</div>
|
||||
<div class="refer_show_icon">
|
||||
<t-icon :name="showReferBox ? 'chevron-up' : 'chevron-down'" />
|
||||
<div class="refer_show_icon">
|
||||
<t-icon :name="showReferBox ? 'chevron-down' : 'chevron-right'" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="refer_box" v-show="showReferBox">
|
||||
<div class="refer_box" v-show="contentOnly || showReferBox">
|
||||
<!-- Web search references (ungrouped) -->
|
||||
<div v-for="(item, index) in webSearchRefs" :key="'web-' + index">
|
||||
<a
|
||||
:href="getWebSearchUrl(item)"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
class="doc doc-web"
|
||||
@click.stop
|
||||
>
|
||||
{{ webSearchRefs.length < 2 ? getWebSearchDisplayText(item) : `${index + 1}. ${getWebSearchDisplayText(item)}` }}
|
||||
</a>
|
||||
<a :href="getWebSearchUrl(item)" target="_blank" rel="noopener noreferrer" class="doc doc-web"
|
||||
@click.stop>
|
||||
{{ webSearchRefs.length < 2 ? getWebSearchDisplayText(item) : `${index + 1}.
|
||||
${getWebSearchDisplayText(item)}` }} </a>
|
||||
</div>
|
||||
|
||||
<!-- Knowledge references grouped by document -->
|
||||
<div v-for="(group, gIdx) in groupedKnowledgeRefs" :key="'grp-' + gIdx" class="doc-group">
|
||||
<div class="doc-group-header" @click="toggleGroup(group.key)">
|
||||
<div class="doc-group-left">
|
||||
<t-icon :name="expandedGroups[group.key] ? 'chevron-down' : 'chevron-right'" size="14px" class="doc-group-arrow" />
|
||||
<t-icon name="file" size="14px" class="doc-group-icon" />
|
||||
<span class="doc-group-title" :title="group.title">{{ group.title }}</span>
|
||||
<span class="doc-group-count">{{ $t('chat.referenceChunkCount', { count: group.chunks.length }) }}</span>
|
||||
<span class="doc-group-count">{{ $t('chat.referenceChunkCount', { count: group.chunks.length })
|
||||
}}</span>
|
||||
</div>
|
||||
<div class="doc-group-actions" v-if="!embeddedMode && group.knowledgeBaseId" @click.stop>
|
||||
<t-tooltip :content="$t('chat.navigateToDocument')">
|
||||
@@ -42,7 +38,8 @@
|
||||
</div>
|
||||
<div class="doc-group-chunks" v-show="expandedGroups[group.key]">
|
||||
<div v-for="(chunk, cIdx) in group.chunks" :key="'chunk-' + cIdx" class="doc-chunk-item">
|
||||
<t-popup overlayClassName="refer-to-layer" placement="bottom-left" width="400" :showArrow="false" trigger="click">
|
||||
<t-popup overlayClassName="refer-to-layer" placement="bottom-left" width="400"
|
||||
:showArrow="false" trigger="click">
|
||||
<template #content>
|
||||
<ContentPopup :content="safeProcessContent(chunk.content)" :is-html="true" />
|
||||
</template>
|
||||
@@ -79,6 +76,14 @@ const props = defineProps({
|
||||
embeddedMode: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
timelineMode: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
contentOnly: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
});
|
||||
|
||||
@@ -211,17 +216,97 @@ const getWebSearchDisplayText = (item) => {
|
||||
transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
margin-bottom: 8px;
|
||||
|
||||
&.refer-timeline {
|
||||
--td-brand-color: var(--td-text-color-placeholder);
|
||||
--embed-primary: var(--td-text-color-placeholder);
|
||||
--refer-brand-4: color-mix(in srgb, var(--td-text-color-primary) 4%, transparent);
|
||||
--refer-brand-8: color-mix(in srgb, var(--td-text-color-primary) 6%, transparent);
|
||||
--refer-brand-12: color-mix(in srgb, var(--td-text-color-primary) 8%, transparent);
|
||||
|
||||
width: 100%;
|
||||
border-radius: 0;
|
||||
background-color: transparent;
|
||||
border: 0;
|
||||
box-shadow: none;
|
||||
margin-bottom: 0;
|
||||
font-size: 13px;
|
||||
|
||||
.refer_header {
|
||||
padding: 0;
|
||||
font-weight: 400;
|
||||
color: var(--td-text-color-secondary);
|
||||
|
||||
.refer_title span {
|
||||
font-size: 14px;
|
||||
white-space: normal;
|
||||
}
|
||||
}
|
||||
|
||||
.refer_header:hover {
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
.refer_show_icon {
|
||||
color: var(--td-text-color-placeholder);
|
||||
}
|
||||
|
||||
.refer_box {
|
||||
padding: 2px 0 0 0;
|
||||
border-top: 0;
|
||||
}
|
||||
|
||||
.doc-group {
|
||||
margin-top: 2px;
|
||||
}
|
||||
|
||||
.doc-group-header {
|
||||
padding: 2px 0;
|
||||
}
|
||||
|
||||
.doc-group-title {
|
||||
color: var(--td-text-color-secondary);
|
||||
font-weight: 400;
|
||||
font-size: 13px;
|
||||
max-width: min(520px, 100%);
|
||||
}
|
||||
|
||||
.doc-group-count,
|
||||
.doc-chunk-text,
|
||||
.doc-chunk-index {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.doc-group-icon {
|
||||
color: var(--td-text-color-placeholder);
|
||||
}
|
||||
|
||||
.doc-group-navigate {
|
||||
color: var(--td-text-color-placeholder);
|
||||
}
|
||||
|
||||
.doc {
|
||||
color: var(--td-text-color-secondary);
|
||||
border-bottom-color: color-mix(in srgb, var(--td-text-color-secondary) 30%, transparent);
|
||||
}
|
||||
|
||||
.doc-chunk-item .doc-chunk-text:hover {
|
||||
background-color: var(--refer-brand-4);
|
||||
color: var(--td-text-color-secondary);
|
||||
}
|
||||
}
|
||||
|
||||
.refer_header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 6px 14px;
|
||||
color: var(--td-text-color-primary);
|
||||
font-weight: 500;
|
||||
|
||||
.refer_title {
|
||||
display: flex;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
min-width: 0;
|
||||
|
||||
span {
|
||||
white-space: nowrap;
|
||||
@@ -233,6 +318,7 @@ const getWebSearchDisplayText = (item) => {
|
||||
font-size: 14px;
|
||||
padding: 0 2px 1px 2px;
|
||||
color: var(--td-brand-color);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -248,24 +334,12 @@ const getWebSearchDisplayText = (item) => {
|
||||
}
|
||||
}
|
||||
|
||||
.icon-mask {
|
||||
display: inline-block;
|
||||
flex-shrink: 0;
|
||||
background-color: var(--embed-primary, var(--td-brand-color));
|
||||
mask-size: contain;
|
||||
mask-repeat: no-repeat;
|
||||
mask-position: center;
|
||||
-webkit-mask-size: contain;
|
||||
-webkit-mask-repeat: no-repeat;
|
||||
-webkit-mask-position: center;
|
||||
}
|
||||
|
||||
.refer-title-icon {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
margin-right: 8px;
|
||||
mask-image: url('@/assets/img/ziliao.svg');
|
||||
-webkit-mask-image: url('@/assets/img/ziliao.svg');
|
||||
flex-shrink: 0;
|
||||
color: var(--embed-primary, var(--td-brand-color));
|
||||
}
|
||||
|
||||
.doc {
|
||||
@@ -320,7 +394,7 @@ const getWebSearchDisplayText = (item) => {
|
||||
.doc-group-arrow {
|
||||
color: var(--td-text-color-placeholder);
|
||||
flex-shrink: 0;
|
||||
margin-right: 2px;
|
||||
margin-left: 4px;
|
||||
}
|
||||
|
||||
.doc-group-icon {
|
||||
|
||||
@@ -1,20 +1,11 @@
|
||||
<template>
|
||||
<div class="grep-results">
|
||||
<div v-if="rows.length" class="results-list">
|
||||
<ResultRow
|
||||
v-for="(result, index) in rows"
|
||||
:key="result.key"
|
||||
:index="index + 1"
|
||||
:title="result.title"
|
||||
:meta="result.meta"
|
||||
:popup-key="result.key"
|
||||
:show-popup="!!result.snippet"
|
||||
:content="result.snippet"
|
||||
:chunk-id="result.chunkId"
|
||||
:knowledge-id="result.knowledgeId"
|
||||
:highlight="searchPattern"
|
||||
:regex="true"
|
||||
/>
|
||||
<ResultRow v-for="(result, index) in rows" :key="result.key" :index="index + 1" :title="result.title"
|
||||
:meta="result.meta" :popup-key="result.key" :show-popup="result.chunks.length > 0 || !!result.snippet"
|
||||
:content="result.chunks.length === 1 ? result.snippet : undefined"
|
||||
:chunks="result.chunks.length > 1 ? result.chunks : undefined" :chunk-id="result.chunkId"
|
||||
:knowledge-id="result.knowledgeId" :highlight="searchPattern" :regex="true" />
|
||||
</div>
|
||||
|
||||
<div v-else class="empty-state">
|
||||
@@ -28,7 +19,8 @@ import { computed } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { cleanSnippet } from './contentClean';
|
||||
import ResultRow from './ResultRow.vue';
|
||||
import type { GrepChunkResult, GrepKnowledgeResult, GrepResultsData } from '@/types/tool-results';
|
||||
import { groupGrepChunkResults } from '@/utils/grepResultsGroup';
|
||||
import type { GrepKnowledgeResult, GrepResultsData } from '@/types/tool-results';
|
||||
|
||||
const props = defineProps<{
|
||||
data: GrepResultsData;
|
||||
@@ -43,6 +35,7 @@ type GrepRow = {
|
||||
title: string;
|
||||
meta: string;
|
||||
snippet: string;
|
||||
chunks: { content: string; chunk_id: string; knowledge_id: string }[];
|
||||
chunkId?: string;
|
||||
knowledgeId?: string;
|
||||
};
|
||||
@@ -63,28 +56,32 @@ const formatKnowledgeMeta = (result: GrepKnowledgeResult): string => {
|
||||
return parts.join(' · ');
|
||||
};
|
||||
|
||||
const rowFromChunk = (result: GrepChunkResult): GrepRow => {
|
||||
const isFAQ = !!result.faq_id || result.chunk_type === 'faq';
|
||||
const title = result.faq_question || result.knowledge_title || t('knowledge.untitledDocument');
|
||||
const meta = isFAQ
|
||||
const rowFromGroupedChunk = (group: ReturnType<typeof groupGrepChunkResults>[number]): GrepRow => {
|
||||
const title = group.title || t('knowledge.untitledDocument');
|
||||
const meta = group.is_faq
|
||||
? t('agentStream.grepResults.faqEntry')
|
||||
: formatKnowledgeMeta({
|
||||
knowledge_id: result.knowledge_id,
|
||||
knowledge_base_id: result.knowledge_base_id,
|
||||
knowledge_title: result.knowledge_title,
|
||||
chunk_hit_count: 1,
|
||||
total_pattern_hits: 1,
|
||||
distinct_patterns: 1,
|
||||
pattern_counts: {},
|
||||
title_match: !!result.title_match,
|
||||
});
|
||||
knowledge_id: group.knowledge_id,
|
||||
knowledge_base_id: '',
|
||||
knowledge_title: title,
|
||||
chunk_hit_count: group.chunk_hit_count,
|
||||
total_pattern_hits: group.chunk_hit_count,
|
||||
distinct_patterns: 1,
|
||||
pattern_counts: {},
|
||||
title_match: group.title_match,
|
||||
});
|
||||
return {
|
||||
key: result.faq_id || result.chunk_id || String(result.index ?? '') || result.knowledge_id,
|
||||
key: group.key,
|
||||
title,
|
||||
meta,
|
||||
snippet: cleanSnippet(result.match_snippet ?? ''),
|
||||
chunkId: result.faq_id || result.chunk_id,
|
||||
knowledgeId: result.knowledge_id,
|
||||
snippet: cleanSnippet(group.match_snippet),
|
||||
chunks: group.chunks.map((chunk) => ({
|
||||
content: cleanSnippet(chunk.content),
|
||||
chunk_id: chunk.chunk_id,
|
||||
knowledge_id: chunk.knowledge_id,
|
||||
})),
|
||||
chunkId: group.chunks.length === 1 ? group.chunks[0].chunk_id : undefined,
|
||||
knowledgeId: group.knowledge_id,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -93,13 +90,20 @@ const rowFromKnowledge = (result: GrepKnowledgeResult): GrepRow => ({
|
||||
title: result.faq_question || result.knowledge_title || t('knowledge.untitledDocument'),
|
||||
meta: formatKnowledgeMeta(result),
|
||||
snippet: cleanSnippet(result.match_snippet ?? ''),
|
||||
chunks: result.match_snippet
|
||||
? [{
|
||||
content: cleanSnippet(result.match_snippet ?? ''),
|
||||
chunk_id: '',
|
||||
knowledge_id: result.knowledge_id,
|
||||
}]
|
||||
: [],
|
||||
knowledgeId: result.knowledge_id,
|
||||
});
|
||||
|
||||
const rows = computed((): GrepRow[] => {
|
||||
const chunkRows = props.data.chunk_results;
|
||||
if (chunkRows?.length) {
|
||||
return chunkRows.map(rowFromChunk);
|
||||
return groupGrepChunkResults(chunkRows).map(rowFromGroupedChunk);
|
||||
}
|
||||
return (props.data.knowledge_results ?? []).map(rowFromKnowledge);
|
||||
});
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
<template>
|
||||
<!-- Fallback for ToolResultRenderer when used outside AgentStreamDisplay. -->
|
||||
<div class="knowledge-chunks-list">
|
||||
<div v-if="summaryHtml" class="results-summary-text" v-html="summaryHtml" />
|
||||
<div v-else class="empty-state">{{ $t('chat.noMatchFound') }}</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { getKnowledgeChunksSummaryHtml } from '@/utils/knowledgeChunksDisplay';
|
||||
import type { KnowledgeChunksListData } from '@/types/tool-results';
|
||||
|
||||
const props = defineProps<{
|
||||
data: KnowledgeChunksListData;
|
||||
}>();
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
const summaryHtml = computed(() => getKnowledgeChunksSummaryHtml(t, props.data));
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.knowledge-chunks-list {
|
||||
.results-summary-text {
|
||||
font-size: var(--agent-step-summary-size, 12px);
|
||||
font-weight: 400;
|
||||
color: var(--td-text-color-secondary);
|
||||
line-height: 1.5;
|
||||
|
||||
:deep(strong) {
|
||||
color: var(--td-text-color-secondary);
|
||||
font-weight: 500;
|
||||
}
|
||||
}
|
||||
|
||||
.empty-state {
|
||||
font-size: 13px;
|
||||
color: var(--td-text-color-placeholder);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -2,14 +2,9 @@
|
||||
<div class="user_msg_container" ref="containerRef" :class="{ 'is-embedded': embeddedMode }">
|
||||
<!-- 显示@的知识库和文件 -->
|
||||
<div v-if="mentioned_items && mentioned_items.length > 0" class="mentioned_items">
|
||||
<span
|
||||
v-for="item in mentioned_items"
|
||||
:key="item.id"
|
||||
class="mentioned_tag"
|
||||
:class="[
|
||||
item.type === 'kb' ? (item.kb_type === 'faq' ? 'faq-tag' : 'kb-tag') : 'file-tag'
|
||||
]"
|
||||
>
|
||||
<span v-for="item in mentioned_items" :key="item.id" class="mentioned_tag" :class="[
|
||||
item.type === 'kb' ? (item.kb_type === 'faq' ? 'faq-tag' : 'kb-tag') : 'file-tag'
|
||||
]">
|
||||
<span class="tag_icon">
|
||||
<t-icon v-if="item.type === 'kb'" :name="item.kb_type === 'faq' ? 'chat-bubble-help' : 'folder'" />
|
||||
<t-icon v-else name="file" />
|
||||
@@ -19,30 +14,26 @@
|
||||
</div>
|
||||
<!-- 显示上传的图片 -->
|
||||
<div v-if="hasImages" class="user_images">
|
||||
<img
|
||||
v-for="(img, idx) in props.images"
|
||||
:key="idx"
|
||||
:src="img.url"
|
||||
class="user_image_thumb"
|
||||
@click="previewImage($event)"
|
||||
/>
|
||||
<img v-for="(img, idx) in props.images" :key="idx" :src="img.url" class="user_image_thumb"
|
||||
@click="previewImage($event)" />
|
||||
</div>
|
||||
<!-- 显示上传的附件 -->
|
||||
<div v-if="hasAttachments" class="user_attachments">
|
||||
<div v-for="(att, idx) in props.attachments" :key="idx" class="user_attachment_card">
|
||||
<div class="attachment_card_icon">
|
||||
<svg viewBox="0 0 40 48" fill="none" xmlns="http://www.w3.org/2000/svg" width="36" height="44">
|
||||
<rect width="40" height="48" rx="4" fill="#4A90D9"/>
|
||||
<path d="M8 6h16l8 8v28a2 2 0 01-2 2H8a2 2 0 01-2-2V8a2 2 0 012-2z" fill="#5BA3E8"/>
|
||||
<path d="M24 6l8 8h-6a2 2 0 01-2-2V6z" fill="#3A7BC8"/>
|
||||
<rect x="10" y="20" width="20" height="2" rx="1" fill="white" fill-opacity="0.9"/>
|
||||
<rect x="10" y="26" width="20" height="2" rx="1" fill="white" fill-opacity="0.9"/>
|
||||
<rect x="10" y="32" width="14" height="2" rx="1" fill="white" fill-opacity="0.9"/>
|
||||
<rect width="40" height="48" rx="4" fill="#4A90D9" />
|
||||
<path d="M8 6h16l8 8v28a2 2 0 01-2 2H8a2 2 0 01-2-2V8a2 2 0 012-2z" fill="#5BA3E8" />
|
||||
<path d="M24 6l8 8h-6a2 2 0 01-2-2V6z" fill="#3A7BC8" />
|
||||
<rect x="10" y="20" width="20" height="2" rx="1" fill="white" fill-opacity="0.9" />
|
||||
<rect x="10" y="26" width="20" height="2" rx="1" fill="white" fill-opacity="0.9" />
|
||||
<rect x="10" y="32" width="14" height="2" rx="1" fill="white" fill-opacity="0.9" />
|
||||
</svg>
|
||||
</div>
|
||||
<div class="attachment_card_info">
|
||||
<div class="attachment_card_name">{{ att.file_name }}</div>
|
||||
<div class="attachment_card_meta">{{ getFileExt(att.file_name) }}<span v-if="att.file_size"> · {{ formatFileSize(att.file_size) }}</span></div>
|
||||
<div class="attachment_card_meta">{{ getFileExt(att.file_name) }}<span
|
||||
v-if="att.file_size"> · {{ formatFileSize(att.file_size) }}</span></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -242,7 +233,7 @@ const closePreImg = () => {
|
||||
background: #8CE97F;
|
||||
margin-left: auto;
|
||||
color: #000000e6;
|
||||
font-size: 15px;
|
||||
font-size: 16px;
|
||||
text-align: justify;
|
||||
word-break: break-all;
|
||||
box-sizing: border-box;
|
||||
|
||||
@@ -8,36 +8,46 @@
|
||||
<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' }]" />
|
||||
<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' }]" />
|
||||
<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="!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: '18px' }]" /></div>
|
||||
<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: '18px' }]" /></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 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 v-else appear name="sq-fade">
|
||||
<div v-if="suggestedQuestions.length > 0" class="suggested-questions-inner">
|
||||
<div class="suggested-questions-title">{{ t('chat.suggestedQuestions') }}</div>
|
||||
<div class="suggested-questions-title-row">
|
||||
<div class="suggested-questions-title">{{ t('chat.suggestedQuestions') }}</div>
|
||||
<t-button variant="text" shape="square" size="small" class="suggested-questions-refresh"
|
||||
:loading="suggestedQuestionsLoading" :title="t('chat.refreshSuggestedQuestions')"
|
||||
@click="fetchSuggestedQuestions">
|
||||
<template #icon><t-icon name="refresh" /></template>
|
||||
</t-button>
|
||||
</div>
|
||||
<div class="suggested-questions-grid">
|
||||
<div
|
||||
v-for="(item, index) in suggestedQuestions"
|
||||
:key="item.question"
|
||||
<div v-for="(item, index) in suggestedQuestions" :key="item.question"
|
||||
class="suggested-question-card"
|
||||
@click="handleSuggestedQuestionClick(item.question)"
|
||||
>
|
||||
@click="handleSuggestedQuestionClick(item.question)">
|
||||
<span class="suggested-question-text">{{ item.question }}</span>
|
||||
<span v-if="item.source === 'faq'" class="suggested-question-badge faq">FAQ</span>
|
||||
</div>
|
||||
@@ -53,14 +63,13 @@
|
||||
这是历史加载时白屏 + 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"
|
||||
>
|
||||
<div v-for="(session, index) in messagesList"
|
||||
:key="session.id || `${session.role}-${session.created_at}-${index}`" class="msg-item-wrapper">
|
||||
|
||||
<div v-if="session.role == 'user'">
|
||||
<usermsg :content="session.content" :mentioned_items="session.mentioned_items" :images="session.images" :attachments="session.attachments" :embeddedMode="embeddedMode"></usermsg>
|
||||
<usermsg :content="session.content" :mentioned_items="session.mentioned_items"
|
||||
:images="session.images" :attachments="session.attachments" :embeddedMode="embeddedMode">
|
||||
</usermsg>
|
||||
</div>
|
||||
<div v-if="session.role == 'assistant' && shouldRenderAssistantMessage(session)">
|
||||
<botmsg :content="session.content" :session="session" :session-id="session_id"
|
||||
@@ -68,7 +77,7 @@
|
||||
:isFirstEnter="isFirstEnter" :embeddedMode="embeddedMode"></botmsg>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="loading || isImRecovering"
|
||||
<div v-if="showGlobalTypingIndicator"
|
||||
style="height: 41px;display: flex;align-items: center;padding-left: 4px;">
|
||||
<div class="loading-typing">
|
||||
<span></span>
|
||||
@@ -84,29 +93,19 @@
|
||||
</div>
|
||||
</transition>
|
||||
<div class="input-container" :class="{ 'is-embedded': embeddedMode }">
|
||||
<InputField
|
||||
ref="inputFieldRef"
|
||||
<InputField ref="inputFieldRef"
|
||||
@send-msg="(query, modelId, mentionedItems, imageFiles, attachmentFiles) => sendMsg(query, modelId, mentionedItems, imageFiles, attachmentFiles)"
|
||||
@stop-generation="handleStopGeneration"
|
||||
:isReplying="isReplying"
|
||||
:sessionId="session_id"
|
||||
:assistantMessageId="currentAssistantMessageId"
|
||||
:embeddedMode="embeddedMode"
|
||||
></InputField>
|
||||
@stop-generation="handleStopGeneration" :isReplying="isReplying" :sessionId="session_id"
|
||||
:assistantMessageId="currentAssistantMessageId" :embeddedMode="embeddedMode"></InputField>
|
||||
</div>
|
||||
</div>
|
||||
<KnowledgeBaseEditorModal
|
||||
:visible="uiStore.showKBEditorModal"
|
||||
:mode="uiStore.kbEditorMode"
|
||||
:kb-id="uiStore.currentKBId || undefined"
|
||||
:initial-type="uiStore.kbEditorType"
|
||||
@update:visible="(val) => val ? null : uiStore.closeKBEditor()"
|
||||
@success="handleKBEditorSuccess"
|
||||
/>
|
||||
<KnowledgeBaseEditorModal :visible="uiStore.showKBEditorModal" :mode="uiStore.kbEditorMode"
|
||||
:kb-id="uiStore.currentKBId || undefined" :initial-type="uiStore.kbEditorType"
|
||||
@update:visible="(val) => val ? null : uiStore.closeKBEditor()" @success="handleKBEditorSuccess" />
|
||||
</template>
|
||||
<script setup>
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { ref, onMounted, onBeforeMount, onUnmounted, nextTick, watch, reactive, defineProps } from 'vue';
|
||||
import { ref, onMounted, onBeforeMount, onUnmounted, nextTick, watch, reactive, defineProps, computed } from 'vue';
|
||||
import { useRoute, onBeforeRouteLeave, onBeforeRouteUpdate } from 'vue-router';
|
||||
import InputField from '../../components/Input-field.vue';
|
||||
import botmsg from './components/botmsg.vue';
|
||||
@@ -122,12 +121,13 @@ import { useUIStore } from '@/stores/ui';
|
||||
import KnowledgeBaseEditorModal from '@/views/knowledge/KnowledgeBaseEditorModal.vue';
|
||||
import { useKnowledgeBaseCreationNavigation } from '@/hooks/useKnowledgeBaseCreationNavigation';
|
||||
import { useChatStreamHandler } from '@/composables/useChatStreamHandler';
|
||||
import { clearCitationChunkCache } from '@/utils/citationChunkCache';
|
||||
|
||||
const props = defineProps({
|
||||
session_id: { type: String, default: '' },
|
||||
agentId: { type: String, default: '' },
|
||||
kbIds: { type: Array, default: () => [] },
|
||||
embeddedMode: { type: Boolean, default: false },
|
||||
session_id: { type: String, default: '' },
|
||||
agentId: { type: String, default: '' },
|
||||
kbIds: { type: Array, default: () => [] },
|
||||
embeddedMode: { type: Boolean, default: false },
|
||||
});
|
||||
|
||||
const usemenuStore = useMenuStore();
|
||||
@@ -350,7 +350,8 @@ watch([() => route.params], async (newvalue) => {
|
||||
}
|
||||
messagesList.splice(0);
|
||||
session_id.value = newvalue[0].chatid;
|
||||
|
||||
clearCitationChunkCache();
|
||||
|
||||
// 切换会话时,重置状态
|
||||
historyLoading.value = true;
|
||||
historyLoadingMore.value = false;
|
||||
@@ -418,6 +419,7 @@ const fetchMessageList = (data) => getMessageList(data);
|
||||
const {
|
||||
findLastMessage,
|
||||
shouldRenderAssistantMessage,
|
||||
shouldShowGlobalTypingIndicator,
|
||||
handleMsgList,
|
||||
processStreamChunk,
|
||||
} = useChatStreamHandler({
|
||||
@@ -481,6 +483,10 @@ const {
|
||||
},
|
||||
});
|
||||
|
||||
const showGlobalTypingIndicator = computed(() =>
|
||||
shouldShowGlobalTypingIndicator(messagesList, loading.value, isImRecovering.value),
|
||||
);
|
||||
|
||||
const getmsgList = (data, isScrollType = false, scrollHeight) => {
|
||||
if (isScrollType) {
|
||||
if (historyLoadingMore.value || !hasMoreHistory.value) return;
|
||||
@@ -585,23 +591,23 @@ const sendMsg = async (value, modelId = '', mentionedItems = [], imageFiles = []
|
||||
}
|
||||
|
||||
// 将@提及的知识库和文件信息存入用户消息
|
||||
messagesList.push({ content: value, role: 'user', mentioned_items: mentionedItems, images: userImages, attachments: attachmentFiles.map(a => ({ file_name: a.name, file_size: a.size, file_type: '.' + a.name.split('.').pop()?.toLowerCase() })), channel: 'web' });
|
||||
messagesList.push({ content: value, role: 'user', mentioned_items: mentionedItems, images: userImages, attachments: attachmentFiles.map(a => ({ file_name: a.name, file_size: a.size, file_type: '.' + a.name.split('.').pop()?.toLowerCase() })), channel: 'web' });
|
||||
userHasScrolledUp.value = false;
|
||||
scrollToBottom(true);
|
||||
|
||||
|
||||
// Get agent mode status from settings store
|
||||
const agentEnabled = props.embeddedMode ? (props.agentId && props.agentId !== 'builtin-quick-answer') : useSettingsStoreInstance.isAgentEnabled;
|
||||
|
||||
|
||||
// Get web search status from settings store
|
||||
const webSearchEnabled = props.embeddedMode ? false : useSettingsStoreInstance.isWebSearchEnabled;
|
||||
|
||||
|
||||
// Memory toggle is now a server-side per-user preference (see PUT
|
||||
// /auth/me/preferences). For the normal logged-in chat we leave the
|
||||
// field unset so the backend reads `user.preferences.enable_memory`;
|
||||
// for embedded widgets we still send an explicit `false` so a user's
|
||||
// personal "memory on" setting doesn't leak into a KB-embed context.
|
||||
const enableMemoryOverride = props.embeddedMode ? false : undefined;
|
||||
|
||||
|
||||
// Get knowledge_base_ids from settings store (selected by user via KnowledgeBaseSelector)
|
||||
// Merge @mentioned KB/file IDs so retrieval uses the same targets user @mentioned (including shared KBs)
|
||||
const sidebarKbIds = props.embeddedMode ? props.kbIds : (useSettingsStoreInstance.settings.selectedKnowledgeBases || []);
|
||||
@@ -609,12 +615,12 @@ const sendMsg = async (value, modelId = '', mentionedItems = [], imageFiles = []
|
||||
const kbIdSet = new Set(sidebarKbIds);
|
||||
const fileIdSet = new Set(sidebarFileIds);
|
||||
for (const item of mentionedItems || []) {
|
||||
if (!item?.id) continue;
|
||||
if (item.type === 'kb' && !kbIdSet.has(item.id)) {
|
||||
kbIdSet.add(item.id);
|
||||
} else if (item.type === 'file' && !fileIdSet.has(item.id)) {
|
||||
fileIdSet.add(item.id);
|
||||
}
|
||||
if (!item?.id) continue;
|
||||
if (item.type === 'kb' && !kbIdSet.has(item.id)) {
|
||||
kbIdSet.add(item.id);
|
||||
} else if (item.type === 'file' && !fileIdSet.has(item.id)) {
|
||||
fileIdSet.add(item.id);
|
||||
}
|
||||
}
|
||||
const kbIds = [...kbIdSet];
|
||||
const knowledgeIds = [...fileIdSet];
|
||||
@@ -626,9 +632,9 @@ const sendMsg = async (value, modelId = '', mentionedItems = [], imageFiles = []
|
||||
|
||||
// Get selected MCP services from settings store (if available)
|
||||
const mcpServiceIds = props.embeddedMode ? [] : (useSettingsStoreInstance.settings.selectedMCPServices || []);
|
||||
|
||||
await startStream({
|
||||
session_id: session_id.value,
|
||||
|
||||
await startStream({
|
||||
session_id: session_id.value,
|
||||
knowledge_base_ids: kbIds,
|
||||
knowledge_ids: knowledgeIds,
|
||||
agent_enabled: agentEnabled,
|
||||
@@ -640,8 +646,8 @@ const sendMsg = async (value, modelId = '', mentionedItems = [], imageFiles = []
|
||||
mentioned_items: mentionedItems,
|
||||
images: imageAttachments.length > 0 ? imageAttachments : undefined,
|
||||
attachment_uploads: attachmentUploads.length > 0 ? attachmentUploads : undefined,
|
||||
query: value,
|
||||
method: 'POST',
|
||||
query: value,
|
||||
method: 'POST',
|
||||
url: endpoint,
|
||||
});
|
||||
}
|
||||
@@ -940,6 +946,7 @@ onBeforeRouteUpdate((to, from, next) => {
|
||||
.scroll-btn-fade-leave-active {
|
||||
transition: opacity 0.2s ease, transform 0.2s ease;
|
||||
}
|
||||
|
||||
.scroll-btn-fade-enter-from,
|
||||
.scroll-btn-fade-leave-to {
|
||||
opacity: 0;
|
||||
@@ -947,8 +954,15 @@ onBeforeRouteUpdate((to, from, next) => {
|
||||
}
|
||||
|
||||
@keyframes contentFadeIn {
|
||||
from { opacity: 0; transform: translateY(6px); }
|
||||
to { opacity: 1; transform: translateY(0); }
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translateY(6px);
|
||||
}
|
||||
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
|
||||
.msg-skeleton-list {
|
||||
@@ -959,10 +973,12 @@ onBeforeRouteUpdate((to, from, next) => {
|
||||
padding: 16px 0;
|
||||
animation: contentFadeIn 0.3s ease-out;
|
||||
}
|
||||
|
||||
.msg-skeleton-user {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.msg-skeleton-bot {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
@@ -975,11 +991,10 @@ onBeforeRouteUpdate((to, from, next) => {
|
||||
// Keep the input visible when messages overflow: without flex-shrink: 0
|
||||
// a tall .chat_scroll_box can squeeze this container down to 0 height.
|
||||
flex-shrink: 0;
|
||||
margin: 16px auto 4px;
|
||||
margin: 0 auto;
|
||||
width: 100%;
|
||||
max-width: 800px;
|
||||
box-sizing: border-box;
|
||||
padding-right: 20px;
|
||||
|
||||
&.is-embedded {
|
||||
max-width: 100%;
|
||||
@@ -1022,27 +1037,27 @@ onBeforeRouteUpdate((to, from, next) => {
|
||||
height: 18px;
|
||||
margin-left: 16px;
|
||||
}
|
||||
|
||||
|
||||
.loading-typing {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
|
||||
|
||||
span {
|
||||
width: 6px;
|
||||
height: 6px;
|
||||
border-radius: 50%;
|
||||
background: var(--td-brand-color);
|
||||
background: var(--td-text-color-placeholder);
|
||||
animation: typingBounce 1.4s ease-in-out infinite;
|
||||
|
||||
|
||||
&:nth-child(1) {
|
||||
animation-delay: 0s;
|
||||
}
|
||||
|
||||
|
||||
&:nth-child(2) {
|
||||
animation-delay: 0.2s;
|
||||
}
|
||||
|
||||
|
||||
&:nth-child(3) {
|
||||
animation-delay: 0.4s;
|
||||
}
|
||||
@@ -1051,9 +1066,13 @@ onBeforeRouteUpdate((to, from, next) => {
|
||||
}
|
||||
|
||||
@keyframes typingBounce {
|
||||
0%, 60%, 100% {
|
||||
|
||||
0%,
|
||||
60%,
|
||||
100% {
|
||||
transform: translateY(0);
|
||||
}
|
||||
|
||||
30% {
|
||||
transform: translateY(-8px);
|
||||
}
|
||||
@@ -1087,18 +1106,35 @@ onBeforeRouteUpdate((to, from, next) => {
|
||||
.sq-fade-leave-active {
|
||||
transition: opacity 0.25s ease;
|
||||
}
|
||||
|
||||
.sq-fade-enter-from,
|
||||
.sq-fade-leave-to {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.suggested-questions-title-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 2px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.suggested-questions-title {
|
||||
font-size: 14px;
|
||||
color: var(--td-text-color-secondary);
|
||||
margin-bottom: 16px;
|
||||
margin-bottom: 0;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.suggested-questions-refresh {
|
||||
flex-shrink: 0;
|
||||
color: var(--td-text-color-secondary);
|
||||
|
||||
&:hover:not(.t-is-disabled) {
|
||||
color: var(--td-text-color-primary);
|
||||
}
|
||||
}
|
||||
|
||||
.suggested-questions-grid {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
@@ -1128,19 +1164,38 @@ onBeforeRouteUpdate((to, from, next) => {
|
||||
:deep(.t-skeleton) {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
:deep(.t-skeleton__row) {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
:deep(.t-skeleton__col) {
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
&:nth-child(1) { width: 132px; }
|
||||
&:nth-child(2) { width: 168px; }
|
||||
&:nth-child(3) { width: 116px; }
|
||||
&:nth-child(4) { width: 152px; }
|
||||
&:nth-child(5) { width: 124px; }
|
||||
&:nth-child(6) { width: 144px; }
|
||||
&:nth-child(1) {
|
||||
width: 132px;
|
||||
}
|
||||
|
||||
&:nth-child(2) {
|
||||
width: 168px;
|
||||
}
|
||||
|
||||
&:nth-child(3) {
|
||||
width: 116px;
|
||||
}
|
||||
|
||||
&:nth-child(4) {
|
||||
width: 152px;
|
||||
}
|
||||
|
||||
&:nth-child(5) {
|
||||
width: 124px;
|
||||
}
|
||||
|
||||
&:nth-child(6) {
|
||||
width: 144px;
|
||||
}
|
||||
}
|
||||
|
||||
&:not(.sq-card-skeleton):hover {
|
||||
|
||||
Reference in New Issue
Block a user