feat(knowledge): 图谱跟随删除 + 笔记页展示实体 + 标签美化

图谱不随删除变化的根因:实体/关系删除时从不清理,build_graph 又把所有实体
都当节点,导致已删笔记的实体(六福珠宝/COMEX/CM助手…)永久残留。

- build_graph 只保留被「活笔记」提及的实体,孤儿实体节点不再出现(render 层兜底,
  历史脏数据无需迁移即生效)
- delete_note 删除时 clear_note_relations + prune_orphan_entities,DB 同步收敛
- get_note 返回 entities(repo.list_note_entities),笔记详情页展示实体
- 前端:实体按类型彩色 chip 展示(人物/机构/概念/产品/技术/地区…),标签改为 pill 样式
- 测试:get_note 返回实体 + 删除后图谱与实体表同步收敛

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
AdministratorandClaude Opus 4.8 committed 2026-06-08 23:39:25 +08:00
1 parent 70bb2783b9
commit b70ed38d51
5 files changed
+119 -12

No files matched your search

+6
View File
@@ -20,6 +20,11 @@ export interface KnowledgeSource {
created_at?: string | null;
}
export interface KnowledgeEntity {
name: string;
entity_type?: string | null;
}
export interface KnowledgeNote {
id: string;
title: string;
@@ -37,6 +42,7 @@ export interface KnowledgeNote {
created_at?: string | null;
updated_at?: string | null;
tags: string[];
entities?: KnowledgeEntity[];
sources?: KnowledgeSource[];
}