feat(trace): enable direct access to trace drawer from card menu

This commit introduces a new method to open the trace drawer directly from the card menu, enhancing user experience by allowing immediate access to trace details without navigating through the document detail drawer. The implementation includes updates to the `handleViewTrace` function to ensure the correct knowledge ID and parse status are set before opening the trace drawer. Additionally, minor adjustments were made to the UI for better consistency and clarity.
This commit is contained in:
wizardchen
2026-05-28 00:23:37 +08:00
committed by lyingbug
parent df3b72c0fe
commit e697eee07f
4 changed files with 779 additions and 582 deletions
+209 -154
View File
@@ -93,6 +93,11 @@ function closeTimeline() {
timelineDrawerVisible.value = false; timelineDrawerVisible.value = false;
} }
// Exposed so the parent's three-dot menu can jump straight into the
// trace drawer for a card without forcing the user to click the
// detail drawer header link manually.
defineExpose({ openTimeline });
marked.use({ marked.use({
breaks: true, // 启用单行换行转 <br> breaks: true, // 启用单行换行转 <br>
gfm: true, // 启用 GitHub Flavored Markdown gfm: true, // 启用 GitHub Flavored Markdown
@@ -233,7 +238,7 @@ const checkImage = (url) => {
img.src = url; img.src = url;
}); });
}; };
renderer.image = function ({href, title, text}) { renderer.image = function ({ href, title, text }) {
if (!isValidImageURL(href)) { if (!isValidImageURL(href)) {
return `<p>${t('error.invalidImageLink')}</p>`; return `<p>${t('error.invalidImageLink')}</p>`;
} }
@@ -246,7 +251,7 @@ renderer.image = function ({href, title, text}) {
}; };
// 自定义代码块渲染器,只显示语言标签 // 自定义代码块渲染器,只显示语言标签
renderer.code = function ({text, lang}) { renderer.code = function ({ text, lang }) {
// 空值校验:防止 text 为 undefined 或 null // 空值校验:防止 text 为 undefined 或 null
if (!text || typeof text !== 'string') { if (!text || typeof text !== 'string') {
text = ''; text = '';
@@ -807,7 +812,8 @@ const handleDetailsScroll = () => {
</script> </script>
<template> <template>
<div class="doc_content" ref="mdContentWrap"> <div class="doc_content" ref="mdContentWrap">
<t-drawer :visible="visible" :zIndex="2000" size="654px" attach="body" :closeBtn="true" :footer="false" @close="handleClose"> <t-drawer :visible="visible" :zIndex="2000" size="654px" attach="body" :closeBtn="true" :footer="false"
@close="handleClose">
<template #header> <template #header>
<div class="drawer-header"> <div class="drawer-header">
<span class="header-title">{{ getDisplayTitle() }}</span> <span class="header-title">{{ getDisplayTitle() }}</span>
@@ -819,28 +825,18 @@ const handleDetailsScroll = () => {
felt out of place above 文件名/摘要 — keeps the doc body felt out of place above 文件名/摘要 — keeps the doc body
focused on document content and treats trace inspection focused on document content and treats trace inspection
as a secondary action discoverable from the header. --> as a secondary action discoverable from the header. -->
<button <button v-if="details.id && hasTimelineSpans" type="button" class="kp-trace-link"
v-if="details.id && hasTimelineSpans" :class="['kp-trace-link-' + (timelineSummary.status || 'unknown')]" :title="$t('knowledgeStages.viewTrace')"
type="button" @click="openTimeline">
class="kp-trace-link" <span class="kp-trace-link-icon">
:class="['kp-trace-link-' + (timelineSummary.status || 'unknown')]" <t-icon name="chart-bar" size="14px" />
:title="$t('knowledgeStages.viewTrace')" </span>
@click="openTimeline" <span class="kp-trace-link-dot" :class="['kp-trace-link-dot-' + (timelineSummary.status || 'unknown')]" />
> <span class="kp-trace-link-text">Trace</span>
<span <span v-if="timelineSummary.totalMs > 0" class="kp-trace-link-meta">{{
class="kp-trace-link-dot" formatTimelineDuration(timelineSummary.totalMs) }}</span>
:class="['kp-trace-link-dot-' + (timelineSummary.status || 'unknown')]" <span v-else-if="timelineSummary.stageTotal > 0" class="kp-trace-link-meta">{{ timelineSummary.stageIndex
/> }}/{{ timelineSummary.stageTotal }}</span>
<span class="kp-trace-link-text">{{ $t('knowledgeStages.viewTrace') }}</span>
<span
v-if="timelineSummary.totalMs > 0"
class="kp-trace-link-meta"
>{{ formatTimelineDuration(timelineSummary.totalMs) }}</span>
<span
v-else-if="timelineSummary.stageTotal > 0"
class="kp-trace-link-meta"
>{{ timelineSummary.stageIndex }}/{{ timelineSummary.stageTotal }}</span>
<t-icon name="chevron-right" size="14px" class="kp-trace-link-arrow" />
</button> </button>
</div> </div>
</template> </template>
@@ -849,47 +845,28 @@ const handleDetailsScroll = () => {
link's status dot / duration stays live even before the user link's status dot / duration stays live even before the user
opens the secondary drawer. --> opens the secondary drawer. -->
<div class="kp-trigger-shadow" aria-hidden="true"> <div class="kp-trigger-shadow" aria-hidden="true">
<KnowledgeProcessingTimeline <KnowledgeProcessingTimeline v-if="details.id" :knowledge-id="details.id" :parse-status="details.parse_status"
v-if="details.id" :compact="true" @update:has-spans="hasTimelineSpans = $event" @update:summary="timelineSummary = $event" />
:knowledge-id="details.id"
:parse-status="details.parse_status"
:compact="true"
@update:has-spans="hasTimelineSpans = $event"
@update:summary="timelineSummary = $event"
/>
</div> </div>
<!-- 二级抽屉:完整 Langfuse-style waterfall --> <!-- 二级抽屉:完整 Langfuse-style waterfall -->
<t-drawer <t-drawer :visible="timelineDrawerVisible" :zIndex="2100" size="820px" attach="body" :closeBtn="false"
:visible="timelineDrawerVisible" :footer="false" :header="false" :showOverlay="true" :closeOnOverlayClick="true" placement="right"
:zIndex="2100" class="kp-secondary-drawer" @close="closeTimeline">
size="820px"
attach="body"
:closeBtn="false"
:footer="false"
:header="false"
:showOverlay="true"
:closeOnOverlayClick="true"
placement="right"
class="kp-secondary-drawer"
@close="closeTimeline"
>
<div class="kp-drawer-shell"> <div class="kp-drawer-shell">
<div class="kp-drawer-titlebar"> <div class="kp-drawer-titlebar">
<div class="kp-drawer-titlebar-left"> <div class="kp-drawer-titlebar-left">
<span class="kp-drawer-titlebar-kind">trace</span> <span class="kp-drawer-titlebar-kind">trace</span>
<span class="kp-drawer-titlebar-title">{{ $t('knowledgeStages.title') }}</span> <span class="kp-drawer-titlebar-title">{{ $t('knowledgeStages.title') }}</span>
</div> </div>
<button type="button" class="kp-drawer-titlebar-close" @click="closeTimeline" :aria-label="$t('knowledgeStages.close')"> <button type="button" class="kp-drawer-titlebar-close" @click="closeTimeline"
:aria-label="$t('knowledgeStages.close')">
<t-icon name="close" size="16px" /> <t-icon name="close" size="16px" />
</button> </button>
</div> </div>
<div class="kp-drawer-body"> <div class="kp-drawer-body">
<KnowledgeProcessingTimeline <KnowledgeProcessingTimeline v-if="details.id && timelineDrawerVisible" :knowledge-id="details.id"
v-if="details.id && timelineDrawerVisible" :parse-status="details.parse_status" />
:knowledge-id="details.id"
:parse-status="details.parse_status"
/>
</div> </div>
</div> </div>
</t-drawer> </t-drawer>
@@ -910,7 +887,8 @@ const handleDetailsScroll = () => {
<div v-else-if="details.type === 'url'" class="url_box"> <div v-else-if="details.type === 'url'" class="url_box">
<span class="label">{{ $t('knowledgeBase.urlSource') }}</span> <span class="label">{{ $t('knowledgeBase.urlSource') }}</span>
<div class="url_link_box"> <div class="url_link_box">
<a :href="isValidURL(details.source) ? details.source : 'javascript:void(0)'" :target="isValidURL(details.source) ? '_blank' : undefined" class="url_link"> <a :href="isValidURL(details.source) ? details.source : 'javascript:void(0)'"
:target="isValidURL(details.source) ? '_blank' : undefined" class="url_link">
<t-icon name="link" size="14px" /> <t-icon name="link" size="14px" />
<span class="url_text">{{ details.source }}</span> <span class="url_text">{{ details.source }}</span>
<t-icon name="jump" size="14px" class="jump-icon" /> <t-icon name="jump" size="14px" class="jump-icon" />
@@ -934,14 +912,19 @@ const handleDetailsScroll = () => {
<!-- 文档摘要 --> <!-- 文档摘要 -->
<div v-if="details.description" class="summary_box"> <div v-if="details.description" class="summary_box">
<span class="label">{{ $t('knowledgeBase.documentSummary') }}</span> <span class="label">{{ $t('knowledgeBase.documentSummary') }}</span>
<div class="summary_wrapper" :class="{ 'summary_clickable': summaryOverflow || summaryExpanded }" @click="(summaryOverflow || summaryExpanded) && (summaryExpanded = !summaryExpanded)"> <div class="summary_wrapper" :class="{ 'summary_clickable': summaryOverflow || summaryExpanded }"
<div ref="summaryRef" :class="['summary_content', { 'summary_collapsed': !summaryExpanded }]">{{ details.description }}</div> @click="(summaryOverflow || summaryExpanded) && (summaryExpanded = !summaryExpanded)">
<div v-if="(summaryOverflow && !summaryExpanded) || summaryExpanded" class="summary_fade" :class="{ 'summary_fade_expanded': summaryExpanded }"> <div ref="summaryRef" :class="['summary_content', { 'summary_collapsed': !summaryExpanded }]">{{
details.description
}}</div>
<div v-if="(summaryOverflow && !summaryExpanded) || summaryExpanded" class="summary_fade"
:class="{ 'summary_fade_expanded': summaryExpanded }">
<t-icon :name="summaryExpanded ? 'chevron-up' : 'chevron-down'" size="14px" class="summary_fade_icon" /> <t-icon :name="summaryExpanded ? 'chevron-up' : 'chevron-down'" size="14px" class="summary_fade_icon" />
</div> </div>
</div> </div>
</div> </div>
<div v-else-if="details.summary_status === 'pending' || details.summary_status === 'processing'" class="summary_box"> <div v-else-if="details.summary_status === 'pending' || details.summary_status === 'processing'"
class="summary_box">
<span class="label">{{ $t('knowledgeBase.documentSummary') }}</span> <span class="label">{{ $t('knowledgeBase.documentSummary') }}</span>
<div class="summary_loading"> <div class="summary_loading">
<t-loading size="small" /> <t-loading size="small" />
@@ -960,38 +943,25 @@ const handleDetailsScroll = () => {
<div class="meta-row"> <div class="meta-row">
<div class="meta-left"> <div class="meta-left">
<span class="time"> {{ getTimeLabel() }}:{{ details.time }} </span> <span class="time"> {{ getTimeLabel() }}:{{ details.time }} </span>
<t-tag v-if="details.channel && details.channel !== 'web'" size="small" variant="light" theme="warning" class="channel-tag"> <t-tag v-if="details.channel && details.channel !== 'web'" size="small" variant="light" theme="warning"
class="channel-tag">
{{ getChannelLabel(details.channel) }} {{ getChannelLabel(details.channel) }}
</t-tag> </t-tag>
</div> </div>
<div class="view-mode-buttons"> <div class="view-mode-buttons">
<t-button <t-button v-if="canPreview()" size="small" :variant="viewMode === 'preview' ? 'base' : 'outline'"
v-if="canPreview()" :theme="viewMode === 'preview' ? 'primary' : 'default'" @click="viewMode = 'preview'"
size="small" class="view-mode-btn">
:variant="viewMode === 'preview' ? 'base' : 'outline'"
:theme="viewMode === 'preview' ? 'primary' : 'default'"
@click="viewMode = 'preview'"
class="view-mode-btn"
>
{{ $t('preview.tab') }} {{ $t('preview.tab') }}
</t-button> </t-button>
<t-button <t-button v-if="!canPreview()" size="small" :variant="viewMode === 'merged' ? 'base' : 'outline'"
v-if="!canPreview()" :theme="viewMode === 'merged' ? 'primary' : 'default'" @click="viewMode = 'merged'"
size="small" class="view-mode-btn">
:variant="viewMode === 'merged' ? 'base' : 'outline'"
:theme="viewMode === 'merged' ? 'primary' : 'default'"
@click="viewMode = 'merged'"
class="view-mode-btn"
>
{{ $t('knowledgeBase.viewMerged') }} {{ $t('knowledgeBase.viewMerged') }}
</t-button> </t-button>
<t-button <t-button size="small" :variant="viewMode === 'chunks' ? 'base' : 'outline'"
size="small" :theme="viewMode === 'chunks' ? 'primary' : 'default'" @click="viewMode = 'chunks'"
:variant="viewMode === 'chunks' ? 'base' : 'outline'" class="view-mode-btn">
:theme="viewMode === 'chunks' ? 'primary' : 'default'"
@click="viewMode = 'chunks'"
class="view-mode-btn"
>
{{ $t('knowledgeBase.viewChunks') }} {{ $t('knowledgeBase.viewChunks') }}
</t-button> </t-button>
</div> </div>
@@ -1020,27 +990,14 @@ const handleDetailsScroll = () => {
<div v-else-if="viewMode === 'chunks'"> <div v-else-if="viewMode === 'chunks'">
<div v-if="!processedChunks.length" class="no_content">{{ $t('common.noData') }}</div> <div v-if="!processedChunks.length" class="no_content">{{ $t('common.noData') }}</div>
<div v-else class="chunk-list"> <div v-else class="chunk-list">
<div class="chunk-item" <div class="chunk-item" v-for="(chunk, index) in processedChunks" :key="index">
v-for="(chunk, index) in processedChunks"
:key="index"
>
<div class="chunk-header"> <div class="chunk-header">
<span class="chunk-index">{{ $t('knowledgeBase.segment') }} {{ index + 1 }}</span> <span class="chunk-index">{{ $t('knowledgeBase.segment') }} {{ index + 1 }}</span>
<div class="chunk-header-right"> <div class="chunk-header-right">
<t-tag <t-tag v-if="chunk.hasParent" size="small" theme="primary" variant="light">
v-if="chunk.hasParent"
size="small"
theme="primary"
variant="light"
>
{{ $t('knowledgeBase.childChunk') }} {{ $t('knowledgeBase.childChunk') }}
</t-tag> </t-tag>
<t-tag <t-tag v-if="chunk.questions.length > 0" size="small" theme="success" variant="light">
v-if="chunk.questions.length > 0"
size="small"
theme="success"
variant="light"
>
{{ $t('knowledgeBase.questions') }} {{ chunk.questions.length }} {{ $t('knowledgeBase.questions') }} {{ chunk.questions.length }}
</t-tag> </t-tag>
<span class="chunk-meta">{{ chunk.meta }}</span> <span class="chunk-meta">{{ chunk.meta }}</span>
@@ -1051,7 +1008,8 @@ const handleDetailsScroll = () => {
<!-- 父 Chunk 上下文展开 --> <!-- 父 Chunk 上下文展开 -->
<div v-if="chunk.hasParent" class="parent-context-section"> <div v-if="chunk.hasParent" class="parent-context-section">
<div class="parent-context-toggle" @click="toggleParentContext(chunk.original, index)"> <div class="parent-context-toggle" @click="toggleParentContext(chunk.original, index)">
<t-icon v-if="!parentContextLoading.has(index)" :name="isParentExpanded(index) ? 'chevron-down' : 'chevron-right'" size="14px" /> <t-icon v-if="!parentContextLoading.has(index)"
:name="isParentExpanded(index) ? 'chevron-down' : 'chevron-right'" size="14px" />
<t-loading v-else size="small" style="width: 14px; height: 14px;" /> <t-loading v-else size="small" style="width: 14px; height: 14px;" />
<span>{{ $t('knowledgeBase.viewParentContext') }}</span> <span>{{ $t('knowledgeBase.viewParentContext') }}</span>
</div> </div>
@@ -1067,22 +1025,12 @@ const handleDetailsScroll = () => {
<span>{{ $t('knowledgeBase.generatedQuestions') }} ({{ chunk.questions.length }})</span> <span>{{ $t('knowledgeBase.generatedQuestions') }} ({{ chunk.questions.length }})</span>
</div> </div>
<div v-show="isExpanded(index)" class="questions-list"> <div v-show="isExpanded(index)" class="questions-list">
<div <div v-for="question in chunk.questions" :key="question.id" class="question-item">
v-for="question in chunk.questions"
:key="question.id"
class="question-item"
>
<t-icon name="help-circle" size="14px" class="question-icon" /> <t-icon name="help-circle" size="14px" class="question-icon" />
<span class="question-text">{{ question.question }}</span> <span class="question-text">{{ question.question }}</span>
<t-button <t-button v-if="canDeleteGeneratedQuestion" theme="default" variant="text" size="small"
v-if="canDeleteGeneratedQuestion" class="delete-question-btn" :loading="isDeleting(index, question.id)"
theme="default" @click.stop="handleDeleteQuestion(chunk.original, index, question)">
variant="text"
size="small"
class="delete-question-btn"
:loading="isDeleting(index, question.id)"
@click.stop="handleDeleteQuestion(chunk.original, index, question)"
>
<template #icon> <template #icon>
<t-icon name="delete" size="14px" /> <t-icon name="delete" size="14px" />
</template> </template>
@@ -1096,12 +1044,8 @@ const handleDetailsScroll = () => {
<!-- 文档预览视图 --> <!-- 文档预览视图 -->
<div v-else-if="viewMode === 'preview'"> <div v-else-if="viewMode === 'preview'">
<DocumentPreview <DocumentPreview :knowledgeId="details.id" :fileType="details.file_type" :fileName="details.title"
:knowledgeId="details.id" :active="viewMode === 'preview'" />
:fileType="details.file_type"
:fileName="details.title"
:active="viewMode === 'preview'"
/>
</div> </div>
</t-drawer> </t-drawer>
@@ -1124,7 +1068,7 @@ const handleDetailsScroll = () => {
border-radius: 6px; border-radius: 6px;
background: var(--td-bg-color-container); background: var(--td-bg-color-container);
overflow: hidden; overflow: hidden;
box-shadow: 0 1px 2px rgba(0,0,0,0.05); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
.code-block-header { .code-block-header {
display: flex; display: flex;
@@ -1144,6 +1088,7 @@ const handleDetailsScroll = () => {
overflow: auto; overflow: auto;
font-size: 13px; font-size: 13px;
line-height: 1.5; line-height: 1.5;
code { code {
background: transparent; background: transparent;
padding: 0; padding: 0;
@@ -1185,7 +1130,9 @@ const handleDetailsScroll = () => {
margin-bottom: 16px; margin-bottom: 16px;
} }
.doc_box, .url_box, .manual_box { .doc_box,
.url_box,
.manual_box {
.info_panel(); .info_panel();
} }
@@ -1198,33 +1145,48 @@ const handleDetailsScroll = () => {
} }
/* ============== Trace entry (header inline link) ============== /* ============== Trace entry (header inline link) ==============
Compact, lives in the drawer titlebar next to the file-type tag. Sits in the drawer titlebar next to the file-type tag. Status-aware
Replaces the previous big card-style trigger which dominated the tinted pill: success-green when the trace finished cleanly,
doc body. Reads as a quiet secondary action — colored dot + label amber-stripe when still in flight, error-red on failure. The
+ duration + chevron — at the same visual weight as a t-link or duration is shown in mono digits to the right; the trace icon
the file-type t-tag, so it doesn't compete with 文件名 / 摘要. */ anchors the meaning so the button reads as "open the trace" even
without the word "查看". */
.kp-trace-link { .kp-trace-link {
display: inline-flex; display: inline-flex;
align-items: center; align-items: center;
gap: 6px; gap: 6px;
height: 24px; height: 26px;
padding: 0 10px; padding: 0 10px 0 8px;
border: 1px solid var(--td-component-stroke); border: 1px solid var(--td-component-stroke);
border-radius: 999px; border-radius: var(--td-radius-default);
background: transparent; background: var(--td-bg-color-container);
color: var(--td-text-color-secondary); color: var(--td-text-color-secondary);
font-family: var(--app-font-family); font-family: var(--app-font-family);
font-size: 12px; font-size: 12px;
line-height: 1;
cursor: pointer; cursor: pointer;
transition: border-color 150ms ease, color 150ms ease, background 150ms ease; transition: border-color 150ms ease, color 150ms ease,
background 150ms ease, box-shadow 150ms ease;
} }
.kp-trace-link:hover { .kp-trace-link:hover {
border-color: var(--td-brand-color); border-color: var(--td-text-color-secondary);
color: var(--td-brand-color); color: var(--td-text-color-primary);
background: var(--td-brand-color-light); background: var(--td-bg-color-container-hover);
}
.kp-trace-link-icon {
display: inline-flex;
align-items: center;
justify-content: center;
color: var(--td-text-color-placeholder);
margin-right: -2px;
transition: color 150ms ease;
}
.kp-trace-link:hover .kp-trace-link-icon {
color: var(--td-text-color-secondary);
} }
.kp-trace-link:hover .kp-trace-link-arrow { transform: translateX(2px); }
.kp-trace-link-dot { .kp-trace-link-dot {
width: 6px; width: 6px;
@@ -1233,37 +1195,130 @@ const handleDetailsScroll = () => {
background: var(--td-text-color-placeholder); background: var(--td-text-color-placeholder);
flex-shrink: 0; flex-shrink: 0;
} }
.kp-trace-link-dot-done,
.kp-trace-link-dot-completed { background: var(--td-success-color); }
.kp-trace-link-dot-failed { background: var(--td-error-color); }
.kp-trace-link-dot-running,
.kp-trace-link-dot-processing,
.kp-trace-link-dot-pending {
background: var(--td-brand-color);
animation: kpTriggerPulse 1.6s ease-in-out infinite;
}
.kp-trace-link-text { font-weight: 500; } .kp-trace-link-text {
font-weight: 500;
letter-spacing: 0.02em;
}
.kp-trace-link-meta { .kp-trace-link-meta {
font-family: var(--app-font-family-mono); font-family: var(--app-font-family-mono);
font-size: 11px; font-size: 11px;
color: var(--td-text-color-placeholder); color: var(--td-text-color-placeholder);
font-weight: 500;
padding-left: 2px;
border-left: 1px solid var(--td-component-stroke);
margin-left: 2px;
padding-left: 8px;
letter-spacing: 0; letter-spacing: 0;
} }
.kp-trace-link-arrow { /* Status tints — done / failed / running each get a soft palette
color: var(--td-text-color-placeholder); pull. Lets a glance at the pill tell you the trace's outcome
transition: transform 150ms ease, color 150ms ease; without needing to look at the colored dot. */
margin-left: 2px; .kp-trace-link-done,
.kp-trace-link-completed {
border-color: var(--td-success-color-3);
background: var(--td-success-color-1);
color: var(--td-success-color-7);
} }
.kp-trace-link:hover .kp-trace-link-arrow {
color: var(--td-brand-color); .kp-trace-link-done .kp-trace-link-dot,
.kp-trace-link-completed .kp-trace-link-dot {
background: var(--td-success-color);
}
.kp-trace-link-done .kp-trace-link-icon,
.kp-trace-link-completed .kp-trace-link-icon {
color: var(--td-success-color-6);
}
.kp-trace-link-done .kp-trace-link-meta,
.kp-trace-link-completed .kp-trace-link-meta {
color: var(--td-success-color-7);
border-color: var(--td-success-color-3);
}
.kp-trace-link-done:hover,
.kp-trace-link-completed:hover {
border-color: var(--td-success-color-5);
background: var(--td-success-color-2);
color: var(--td-success-color-8);
}
.kp-trace-link-failed {
border-color: var(--td-error-color-3);
background: var(--td-error-color-1);
color: var(--td-error-color-7);
}
.kp-trace-link-failed .kp-trace-link-dot {
background: var(--td-error-color);
}
.kp-trace-link-failed .kp-trace-link-icon {
color: var(--td-error-color-6);
}
.kp-trace-link-failed .kp-trace-link-meta {
color: var(--td-error-color-7);
border-color: var(--td-error-color-3);
}
.kp-trace-link-failed:hover {
border-color: var(--td-error-color-5);
background: var(--td-error-color-2);
color: var(--td-error-color-8);
}
.kp-trace-link-running,
.kp-trace-link-processing,
.kp-trace-link-pending {
border-color: var(--td-warning-color-3);
background: var(--td-warning-color-1);
color: var(--td-warning-color-7);
}
.kp-trace-link-running .kp-trace-link-dot,
.kp-trace-link-processing .kp-trace-link-dot,
.kp-trace-link-pending .kp-trace-link-dot {
background: var(--td-warning-color);
animation: kpTriggerPulse 1.4s ease-in-out infinite;
}
.kp-trace-link-running .kp-trace-link-icon,
.kp-trace-link-processing .kp-trace-link-icon,
.kp-trace-link-pending .kp-trace-link-icon {
color: var(--td-warning-color-6);
}
.kp-trace-link-running .kp-trace-link-meta,
.kp-trace-link-processing .kp-trace-link-meta,
.kp-trace-link-pending .kp-trace-link-meta {
color: var(--td-warning-color-7);
border-color: var(--td-warning-color-3);
}
.kp-trace-link-running:hover,
.kp-trace-link-processing:hover,
.kp-trace-link-pending:hover {
border-color: var(--td-warning-color-5);
background: var(--td-warning-color-2);
color: var(--td-warning-color-8);
} }
@keyframes kpTriggerPulse { @keyframes kpTriggerPulse {
0%, 100% { box-shadow: 0 0 0 0 var(--td-brand-color-light); }
50% { box-shadow: 0 0 0 4px transparent; } 0%,
100% {
transform: scale(1);
opacity: 1;
}
50% {
transform: scale(0.6);
opacity: 0.5;
}
} }
/* Hidden mount keeps fetcher live without showing UI */ /* Hidden mount keeps fetcher live without showing UI */
@@ -1351,7 +1406,7 @@ const handleDetailsScroll = () => {
position: relative; position: relative;
} }
.kp-drawer-body > :deep(.kp-timeline) { .kp-drawer-body> :deep(.kp-timeline) {
width: 100%; width: 100%;
height: 100%; height: 100%;
} }
File diff suppressed because it is too large Load Diff
+37 -26
View File
@@ -1695,6 +1695,28 @@ const handleManualEdit = (index: number, item: KnowledgeCard) => {
}); });
}; };
// Opens ONLY the trace drawer for this card — does NOT pop the
// document detail drawer behind it. The trace drawer attaches to
// body so it renders independent of its host's visibility; we just
// need `details` populated so the timeline component knows which
// knowledge_id to fetch. getCardDetails resets details synchronously
// then fills asynchronously, so we re-stamp the id/parse_status
// right after the call to avoid the brief empty-id window that
// would otherwise prevent the drawer from mounting.
const docContentRef = ref<any>(null);
const handleViewTrace = (index: number, item: KnowledgeCard) => {
if (cardList.value[index]) {
cardList.value[index].isMore = false;
}
moreIndex.value = -1;
getCardDetails(item);
details.id = item.id;
details.parse_status = item.parse_status;
nextTick(() => {
docContentRef.value?.openTimeline?.();
});
};
const handleKnowledgeReparse = (index: number, item: KnowledgeCard) => { const handleKnowledgeReparse = (index: number, item: KnowledgeCard) => {
if (isFAQ.value) return; if (isFAQ.value) return;
if (!canEdit.value) return; if (!canEdit.value) return;
@@ -1973,12 +1995,8 @@ async function createNewSession(value: string): Promise<void> {
{{ $t('menu.knowledgeBase') }} {{ $t('menu.knowledgeBase') }}
</button> </button>
<t-icon name="chevron-right" class="breadcrumb-separator" /> <t-icon name="chevron-right" class="breadcrumb-separator" />
<KBSwitcherDropdown <KBSwitcherDropdown v-if="knowledgeList.length" :kb-list="knowledgeList" :current-kb-id="kbId"
v-if="knowledgeList.length" @select="(id) => handleKnowledgeDropdownSelect({ value: id })">
:kb-list="knowledgeList"
:current-kb-id="kbId"
@select="(id) => handleKnowledgeDropdownSelect({ value: id })"
>
<button type="button" class="breadcrumb-link dropdown" :disabled="!kbId"> <button type="button" class="breadcrumb-link dropdown" :disabled="!kbId">
<template v-if="!kbInfo"> <template v-if="!kbInfo">
<t-skeleton animation="gradient" :row-col="[{ width: '120px', height: '20px' }]" /> <t-skeleton animation="gradient" :row-col="[{ width: '120px', height: '20px' }]" />
@@ -2024,11 +2042,8 @@ async function createNewSession(value: string): Promise<void> {
</h2> </h2>
<!-- 标题行右侧的动作锚点:聚拢"信息"和"设置"两个圆形按钮。 --> <!-- 标题行右侧的动作锚点:聚拢"信息"和"设置"两个圆形按钮。 -->
<div class="kb-title-actions"> <div class="kb-title-actions">
<KBInfoPopover <KBInfoPopover v-if="kbInfo && !authStore.isLiteMode" :kb-info="kbInfo"
v-if="kbInfo && !authStore.isLiteMode" :supported-file-types="[...supportedFileTypes]" />
:kb-info="kbInfo"
:supported-file-types="[...supportedFileTypes]"
/>
<t-tooltip v-if="canManage" :content="$t('knowledgeBase.settings')" placement="top"> <t-tooltip v-if="canManage" :content="$t('knowledgeBase.settings')" placement="top">
<button type="button" class="kb-settings-button" :disabled="!kbId" @click="handleOpenKBSettings"> <button type="button" class="kb-settings-button" :disabled="!kbId" @click="handleOpenKBSettings">
<t-icon name="setting" size="16px" /> <t-icon name="setting" size="16px" />
@@ -2042,7 +2057,7 @@ async function createNewSession(value: string): Promise<void> {
<span>{{$t('knowledgeBase.unsupportedTypesHint', { <span>{{$t('knowledgeBase.unsupportedTypesHint', {
types: unsupportedFileTypes.map(t => '.' + t).join('、') types: unsupportedFileTypes.map(t => '.' + t).join('、')
}) })
}}</span> }}</span>
<span class="parser-hint-link">{{ $t('knowledgeBase.goToParserSettings') }} →</span> <span class="parser-hint-link">{{ $t('knowledgeBase.goToParserSettings') }} →</span>
</p> </p>
<p v-if="missingStorageEngine" class="storage-engine-warning" @click="handleOpenKBSettings"> <p v-if="missingStorageEngine" class="storage-engine-warning" @click="handleOpenKBSettings">
@@ -2280,6 +2295,10 @@ async function createNewSession(value: string): Promise<void> {
<t-icon class="icon" name="edit" /> <t-icon class="icon" name="edit" />
<span>{{ t('knowledgeBase.editDocument') }}</span> <span>{{ t('knowledgeBase.editDocument') }}</span>
</div> </div>
<div class="card-menu-item" @click.stop="handleViewTrace(index, item)">
<t-icon class="icon" name="chart-bar" />
<span>{{ t('knowledgeStages.viewTrace') }}</span>
</div>
<div class="card-menu-item" @click.stop="handleKnowledgeReparse(index, item)"> <div class="card-menu-item" @click.stop="handleKnowledgeReparse(index, item)">
<t-icon class="icon" name="refresh" /> <t-icon class="icon" name="refresh" />
<span>{{ t('knowledgeBase.rebuildDocument') }}</span> <span>{{ t('knowledgeBase.rebuildDocument') }}</span>
@@ -2441,20 +2460,12 @@ async function createNewSession(value: string): Promise<void> {
<div <div
v-if="hoveredCardItem.parse_status === 'processing' || hoveredCardItem.parse_status === 'pending'" v-if="hoveredCardItem.parse_status === 'processing' || hoveredCardItem.parse_status === 'pending'"
class="card-popover-status parsing"> class="card-popover-status parsing">
<KnowledgeProcessingTimeline <KnowledgeProcessingTimeline :knowledge-id="hoveredCardItem.id"
:knowledge-id="hoveredCardItem.id" :parse-status="hoveredCardItem.parse_status" :auto-poll="false" :compact="true" />
:parse-status="hoveredCardItem.parse_status"
:auto-poll="false"
:compact="true"
/>
</div> </div>
<div v-else-if="hoveredCardItem.parse_status === 'failed'" class="card-popover-status failure"> <div v-else-if="hoveredCardItem.parse_status === 'failed'" class="card-popover-status failure">
<KnowledgeProcessingTimeline <KnowledgeProcessingTimeline :knowledge-id="hoveredCardItem.id"
:knowledge-id="hoveredCardItem.id" :parse-status="hoveredCardItem.parse_status" :auto-poll="false" :compact="true" />
:parse-status="hoveredCardItem.parse_status"
:auto-poll="false"
:compact="true"
/>
</div> </div>
<div v-else-if="hoveredCardItem.parse_status === 'draft'" class="card-popover-status draft"> <div v-else-if="hoveredCardItem.parse_status === 'draft'" class="card-popover-status draft">
{{ t('knowledgeBase.draft') }} {{ t('knowledgeBase.draft') }}
@@ -2596,8 +2607,8 @@ async function createNewSession(value: string): Promise<void> {
</template> </template>
<!-- DocContent drawer (shared by documents tab and wiki source refs) --> <!-- DocContent drawer (shared by documents tab and wiki source refs) -->
<DocContent :visible="isCardDetails" :details="details" :canEditKB="canEdit" @closeDoc="closeDoc" <DocContent ref="docContentRef" :visible="isCardDetails" :details="details" :canEditKB="canEdit"
@getDoc="getDoc"> @closeDoc="closeDoc" @getDoc="getDoc">
</DocContent> </DocContent>
</div> </div>
</template> </template>
@@ -998,6 +998,13 @@ func (s *knowledgeService) ProcessSummaryGeneration(ctx context.Context, t *asyn
summary, err := s.getSummary(ctx, chatModel, knowledge, textChunks) summary, err := s.getSummary(ctx, chatModel, knowledge, textChunks)
if err != nil { if err != nil {
logger.Errorf(ctx, "Failed to generate summary for knowledge %s: %v", payload.KnowledgeID, err) logger.Errorf(ctx, "Failed to generate summary for knowledge %s: %v", payload.KnowledgeID, err)
// Surface the underlying LLM/IO error on the span so the trace UI
// can explain "why did this stage take 60s and then fall back?"
// without forcing the operator to grep worker logs. We also capture
// the error type to disambiguate timeouts from upstream HTTP errors
// (deadline exceeded vs unexpected EOF vs 5xx, etc.).
summaryOut["error"] = previewText(err.Error(), 500)
summaryOut["error_type"] = fmt.Sprintf("%T", err)
// For the insufficient-content case (scanned PDF without OCR, etc.) // For the insufficient-content case (scanned PDF without OCR, etc.)
// we deliberately do NOT fall back to the first chunk's raw content, // we deliberately do NOT fall back to the first chunk's raw content,
// since that chunk is typically just a bare markdown image reference // since that chunk is typically just a bare markdown image reference