修复: @任务联想源隔离 store.tasks 污染 + DirAuthDialog 拒绝二次确认 + 看板销账(AC弱模型机制 3/5 已落地核对)

This commit is contained in:
lxy
2026-08-09 21:34:52 +08:00
parent 180d8e339f
commit cad76ffdf2
3 changed files with 48 additions and 12 deletions
+17 -2
View File
@@ -346,6 +346,8 @@ function detectMentionTrigger() {
mentionStart.value = i
mentionOpen.value = true
mentionIndex.value = 0
// P1-g: 用户首次进入 @ 联想即懒加载全量任务候选(幂等,缓存判重;不在 computed 副作用内调用)
void ensureTaskSuggestions()
return
}
// 形如 a@b:前字符非空白 → 不是 mention 触发符,继续向前扫也只会找到更早的 @,
@@ -403,6 +405,19 @@ const pendingMentionSpans = ref<MentionSpan[]>([])
const MENTION_TASK_LIMIT = 50
const projectTasksCache = ref<Map<string, TaskRecord[]>>(new Map())
// P1-g: @任务联想候选源隔离 store.tasks(反映 Tasks 视图筛选+分页子集)。
// 懒加载全量未删任务(taskApi.list() 无参=全量)+ 缓存;首次 @ 触发拉取,失败空数组占位防反复重试。
const taskSuggestionCache = ref<TaskRecord[] | null>(null)
async function ensureTaskSuggestions(): Promise<void> {
if (taskSuggestionCache.value) return
try {
taskSuggestionCache.value = await taskApi.list()
} catch (e) {
taskSuggestionCache.value = []
console.error('[ChatInput] 加载任务联想失败:', e)
}
}
/** 拉取指定项目的任务并缓存(已缓存则跳过);失败静默降级为空数组(不阻塞 enrichment 渲染) */
async function ensureProjectTasks(projectId: string): Promise<void> {
if (projectTasksCache.value.has(projectId)) return
@@ -564,7 +579,7 @@ const mentionQuery = computed(() => {
const mentionItems = computed<MentionItem[]>(() => {
const q = mentionQuery.value.trim().toLowerCase()
const projects = (projectsStore.projects || []) as ProjectRecord[]
const tasks = (projectsStore.tasks || []) as TaskRecord[]
const tasks = (taskSuggestionCache.value ?? []) as TaskRecord[]
const match = (s: string) => !q || s.toLowerCase().includes(q)
const projectItems: MentionItem[] = projects
.filter(p => match(p.name) || match(p.description || ''))
@@ -606,7 +621,7 @@ const mentionItems = computed<MentionItem[]>(() => {
/** 联想候选总数(未过滤,用于区分"无匹配" vs "空") */
const mentionTotal = computed(() =>
((projectsStore.projects || []) as ProjectRecord[]).length
+ ((projectsStore.tasks || []) as TaskRecord[]).length
+ (taskSuggestionCache.value?.length ?? 0)
+ ((projectsStore.ideas || []) as IdeaRecord[]).length,
)