新增: 跨会话召回四层架构与脉络卡
- 会话终态提炼: 删除前+停靠双挂点,快照与清水位同临界区 - 目标快照: 恢复引导按最终有效意图生成,旧目标不复活 - 知识检索项目维度软排序,WorkingContext 持久化迁移 - 脉络卡: published 知识按项目聚合纯读侧,带入上下文经输入框显式注入 - 压缩与缓存能力在主循环/子代理/提示词三面接线 - 两份专项设计文档与看板销账
This commit is contained in:
@@ -0,0 +1,152 @@
|
||||
<template>
|
||||
<!-- 脉络卡:同项目近期决策摘要,纯读侧。用户点「带入上下文」向输入框投递追加文本,
|
||||
由用户编辑后自行发送——注入决策权在用户,不触碰 L3 召回铁律。 -->
|
||||
<div class="ctx-briefs">
|
||||
<button
|
||||
class="ctx-briefs-toggle"
|
||||
:title="t('aiChat.contextBriefsToggle')"
|
||||
@click="toggle"
|
||||
>
|
||||
<svg
|
||||
aria-hidden="true" width="11" height="11" viewBox="0 0 24 24" fill="none"
|
||||
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"
|
||||
:style="{ transform: expanded ? 'rotate(90deg)' : 'none', transition: 'transform .15s' }"
|
||||
><polyline points="9 18 15 12 9 6"/></svg>
|
||||
<span>{{ t('aiChat.contextBriefsTitle') }}</span>
|
||||
<span v-if="!expanded && totalBriefs > 0" class="ctx-briefs-count">{{ totalBriefs }}</span>
|
||||
</button>
|
||||
<div v-if="expanded" class="ctx-briefs-body">
|
||||
<div v-if="loading" class="ctx-briefs-empty">{{ t('aiChat.contextBriefsLoading') }}</div>
|
||||
<div v-else-if="groups.length === 0" class="ctx-briefs-empty">{{ t('aiChat.contextBriefsEmpty') }}</div>
|
||||
<div v-for="g in groups" v-else :key="g.source_project" class="ctx-briefs-group">
|
||||
<div class="ctx-briefs-project">{{ g.source_project }}</div>
|
||||
<div v-for="b in g.briefs" :key="g.source_project + b.title" class="ctx-briefs-item">
|
||||
<div class="ctx-briefs-item-title">{{ b.title }}</div>
|
||||
<div class="ctx-briefs-item-summary">{{ b.summary }}</div>
|
||||
<button
|
||||
class="ctx-briefs-bring"
|
||||
:title="t('aiChat.contextBriefsBringIn')"
|
||||
@click="bringIn(g, b)"
|
||||
>{{ t('aiChat.contextBriefsBringIn') }}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, computed } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { aiApi } from '../../api/ai'
|
||||
import { useAiStore } from '../../stores/ai'
|
||||
import { pushConvDraftAppend } from '../../composables/ai/aiShared'
|
||||
|
||||
interface ContextBrief {
|
||||
title: string
|
||||
summary: string
|
||||
source_ref: string | null
|
||||
source_project: string | null
|
||||
reuse_count: number
|
||||
}
|
||||
interface ProjectBriefs {
|
||||
source_project: string
|
||||
briefs: ContextBrief[]
|
||||
}
|
||||
|
||||
const { t } = useI18n()
|
||||
const store = useAiStore()
|
||||
|
||||
const expanded = ref(false)
|
||||
const loading = ref(false)
|
||||
const groups = ref<ProjectBriefs[]>([])
|
||||
|
||||
const totalBriefs = computed(() => groups.value.reduce((n, g) => n + g.briefs.length, 0))
|
||||
|
||||
async function toggle() {
|
||||
expanded.value = !expanded.value
|
||||
if (expanded.value && groups.value.length === 0) {
|
||||
loading.value = true
|
||||
try {
|
||||
groups.value = await aiApi.listContextBriefs()
|
||||
} catch {
|
||||
groups.value = []
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** 「带入上下文」= 向当前会话输入框投递追加文本(ChatInput 以实时内容为基底合并),
|
||||
* 用户编辑确认后自行发送——注入决策权在用户,不触碰 L3 召回铁律 */
|
||||
function bringIn(g: ProjectBriefs, b: ContextBrief) {
|
||||
const convId = store.state.activeConversationId
|
||||
if (!convId) return
|
||||
pushConvDraftAppend(convId, `参考项目「${g.source_project}」的既有结论「${b.title}」:${b.summary}`)
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.ctx-briefs {
|
||||
border-bottom: 1px solid var(--border, #e0e0e0);
|
||||
padding: 4px 10px;
|
||||
font-size: 12px;
|
||||
}
|
||||
.ctx-briefs-toggle {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 5px;
|
||||
width: 100%;
|
||||
padding: 3px 2px;
|
||||
border: none;
|
||||
background: none;
|
||||
color: var(--text-secondary, #666);
|
||||
cursor: pointer;
|
||||
font-size: 12px;
|
||||
}
|
||||
.ctx-briefs-count {
|
||||
background: var(--accent-soft, rgba(64, 128, 255, 0.15));
|
||||
color: var(--accent, #4080ff);
|
||||
border-radius: 8px;
|
||||
padding: 0 6px;
|
||||
font-size: 11px;
|
||||
}
|
||||
.ctx-briefs-body {
|
||||
max-height: 220px;
|
||||
overflow-y: auto;
|
||||
padding-bottom: 4px;
|
||||
}
|
||||
.ctx-briefs-empty {
|
||||
color: var(--text-tertiary, #999);
|
||||
padding: 6px 2px;
|
||||
}
|
||||
.ctx-briefs-project {
|
||||
font-weight: 600;
|
||||
color: var(--text-primary, #333);
|
||||
padding: 5px 2px 2px;
|
||||
}
|
||||
.ctx-briefs-item {
|
||||
padding: 4px 2px;
|
||||
border-top: 1px dashed var(--border, #eee);
|
||||
}
|
||||
.ctx-briefs-item-title {
|
||||
font-weight: 500;
|
||||
color: var(--text-primary, #333);
|
||||
}
|
||||
.ctx-briefs-item-summary {
|
||||
color: var(--text-secondary, #666);
|
||||
margin: 2px 0;
|
||||
line-height: 1.4;
|
||||
}
|
||||
.ctx-briefs-bring {
|
||||
border: 1px solid var(--border, #ddd);
|
||||
background: none;
|
||||
color: var(--accent, #4080ff);
|
||||
border-radius: 4px;
|
||||
padding: 1px 8px;
|
||||
font-size: 11px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.ctx-briefs-bring:hover {
|
||||
background: var(--accent-soft, rgba(64, 128, 255, 0.1));
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user