@@ -4456,109 +4435,6 @@ function renderArchiveResultDetails(value) {
`;
}
-function renderLivingMemoryPreview(report = {}) {
- const candidates = Array.isArray(report.candidates) ? report.candidates : [];
- if (!candidates.length) {
- return `
-
-
- 未找到 LivingMemory 数据库
- 可以填写数据库路径后重新预览。
-
- ${renderArchiveResultDetails(report)}
-
- `;
- }
- const primary = candidates[0] || {};
- const tables = Array.isArray(primary.tables) ? primary.tables : [];
- const importableRows = sumLivingMemoryRows(tables, true);
- const skippedRows = sumLivingMemoryRows(tables, false);
- const importableTables = tables.filter((table) => table.importable);
- const skippedTables = tables.filter((table) => !table.importable);
- return `
-
-
- LivingMemory 预览
- ${escapeHtml(primary.path || "未记录来源路径")}
-
-
- ${archiveResultCard("可导入", `${importableRows} 条`, `${importableTables.length} 张表`, "teal")}
- ${archiveResultCard("将跳过", `${skippedRows} 条`, "派生碎片或空表", "gold")}
- ${archiveResultCard("候选库", `${candidates.length} 个`, candidates.length > 1 ? "默认导入第一项" : "已锁定来源", "blue")}
-
- ${importableTables.length ? `
-
- 将导入的表
- ${importableTables.slice(0, 6).map((table) => `
- ${escapeHtml(table.name || "-")}${escapeHtml(table.count || 0)} 行
- `).join("")}
-
- ` : `没有可导入的完整摘要表。
`}
- ${skippedTables.length ? `
-
- 跳过的碎片
- ${skippedTables.slice(0, 6).map((table) => `
- ${escapeHtml(table.name || "-")}${escapeHtml(table.note || "not_importable")}
- `).join("")}
-
- ` : ""}
- ${renderArchiveResultDetails(report)}
-
- `;
-}
-
-function renderLivingMemoryImportResult(result = {}) {
- if (result.reason && !result.source_path) {
- return `
-
-
- 导入未执行
- ${escapeHtml(result.reason)}
-
- ${renderArchiveResultDetails(result)}
-
- `;
- }
- return `
-
-
- LivingMemory 导入完成
- ${escapeHtml(result.source_path || "未记录来源路径")}
-
-
- ${archiveResultCard("已导入", `${result.imported || 0} 条`, result.batch_id ? `批次 ${shortId(result.batch_id)}` : "", "teal")}
- ${archiveResultCard("异常跳过", `${result.skipped || 0} 条`, "空内容或无法识别", Number(result.skipped || 0) ? "gold" : "blue")}
- ${archiveResultCard("审核状态", `${result.default_review_status || "auto"}`, "导入策略", "violet")}
-
- ${Array.isArray(result.importable_tables) && result.importable_tables.length ? `
-
- 导入明细
- ${result.importable_tables.slice(0, 8).map((table) => `
- ${escapeHtml(table.name || "-")}${escapeHtml(table.imported || 0)} / ${escapeHtml(table.count || 0)}
- `).join("")}
-
- ` : ""}
- ${renderArchiveResultDetails(result)}
-
- `;
-}
-
-function renderLivingMemoryRepairResult(result = {}) {
- return `
-
-
- 内容修复结果
- ${escapeHtml(result.source_path || result.reason || "未记录来源路径")}
-
-
- ${archiveResultCard("已修复", `${result.updated || 0} 条`, "旧编号内容已替换", "teal")}
- ${archiveResultCard("跳过", `${result.skipped || 0} 条`, result.error || "没有匹配内容", Number(result.skipped || 0) ? "gold" : "blue")}
-
- ${renderArchiveResultDetails(result)}
-
- `;
-}
-
function renderGenericArchiveResult(value = {}, title = "执行结果") {
const entries = Object.entries(value || {}).filter(([, item]) => typeof item !== "object");
return `
@@ -4581,15 +4457,7 @@ function showArchiveResult(value, kind = "generic", host = "#importResult") {
const box = typeof host === "string" ? $(host) : host;
if (!box) return;
box.hidden = false;
- if (kind === "preview") {
- box.innerHTML = renderLivingMemoryPreview(value);
- } else if (kind === "import") {
- box.innerHTML = renderLivingMemoryImportResult(value);
- } else if (kind === "repair") {
- box.innerHTML = renderLivingMemoryRepairResult(value);
- } else {
- box.innerHTML = renderGenericArchiveResult(value, kind === "maintenance" ? "维护结果" : "执行结果");
- }
+ box.innerHTML = renderGenericArchiveResult(value, kind === "maintenance" ? "维护结果" : "执行结果");
}
function showInlineConfirmation({
@@ -5567,13 +5435,6 @@ async function rollbackHistoricalChatImport() {
showToast("历史对话导入已回滚");
}
-async function repairLivingMemoryContent() {
- const path = livingMemoryPathValue();
- const data = await apiPost("/maintenance/repair_livingmemory_content", { path });
- await refreshAll();
- showArchiveResult(data.result, "repair");
- showToast(`已修复 ${data.result?.updated || 0} 条 LivingMemory 内容`);
-}
async function clearAllMemoryData() {
const box = $("#importResult");
@@ -5738,35 +5599,6 @@ async function clearCurrentScopedMemory(scope) {
showScopedClearConfirm(payload, counts);
}
-async function previewImport() {
- const path = livingMemoryPathValue();
- const params = new URLSearchParams();
- if (path) params.set("path", path);
- const data = await apiGet(`/import/livingmemory/preview?${params.toString()}`);
- showArchiveResult(data.report, "preview");
- showToast("预览已生成");
-}
-
-async function runImport() {
- const path = livingMemoryPathValue();
- showInlineConfirmation({
- host: "#importResult",
- title: "导入 LivingMemory",
- message: path
- ? `将从 ${path} 导入完整摘要,跳过派生碎片;执行前会自动备份当前数据库。`
- : "将从自动发现的 LivingMemory 数据库导入完整摘要,跳过派生碎片;执行前会自动备份当前数据库。",
- confirmLabel: "执行导入",
- busyText: "正在导入 LivingMemory...",
- onConfirm: () => executeLivingMemoryImport(path),
- });
-}
-
-async function executeLivingMemoryImport(path) {
- const data = await apiPost("/import/livingmemory/run", { path });
- await refreshAll();
- showArchiveResult(data.result, "import");
- showToast("导入已完成");
-}
async function refreshAll() {
await loadCompanionAvailability();
@@ -5925,13 +5757,10 @@ function bindActions() {
$("#historicalChatFile")?.click();
}
});
- $("#repairLivingMemoryBtn").addEventListener("click", () => withBusy("正在修复 LivingMemory 内容...", repairLivingMemoryContent));
$("#clearAllMemoryBtn").addEventListener("click", clearAllMemoryData);
$("#clearCurrentGroupMemoryBtn")?.addEventListener("click", () => withBusy("正在预览范围清理...", () => clearCurrentScopedMemory("group")));
$("#clearGroupMemberMemoryBtn")?.addEventListener("click", () => withBusy("正在预览群成员记忆清理...", () => clearCurrentScopedMemory("group_member")));
$("#clearCurrentPrivateMemoryBtn")?.addEventListener("click", () => withBusy("正在预览范围清理...", () => clearCurrentScopedMemory("private")));
- $("#previewImportBtn").addEventListener("click", () => withBusy("正在扫描 LivingMemory...", previewImport));
- $("#runImportBtn").addEventListener("click", () => withBusy("正在导入 LivingMemory...", runImport));
$("#globalSearch").addEventListener("keydown", (event) => {
if (event.key === "Enter") loadActiveView();
});
diff --git a/pages/记忆面板/index.html b/pages/记忆面板/index.html
index 4684c9c..656e241 100644
--- a/pages/记忆面板/index.html
+++ b/pages/记忆面板/index.html
@@ -261,7 +261,7 @@
维护 / 迁移 / 配置
-
执行维护、LivingMemory 迁移、清理和导入修复。
+
执行维护、可移植数据导入、清理和导入修复。
-
-
- 6. 维护检查
+ 4. 维护检查
修复索引、刷新统计并整理数据库状态。适合导入、清理或配置调整后手动执行一次。
- 7. 危险清理
+ 5. 危险清理
清空会先备份数据库,再删除记忆、权限规则、时间线、关系、身份、注入日志和导入批次。
diff --git a/tests/test_panel_regressions.py b/tests/test_panel_regressions.py
index b98dae3..002b753 100644
--- a/tests/test_panel_regressions.py
+++ b/tests/test_panel_regressions.py
@@ -11,11 +11,17 @@ ROOT = Path(__file__).resolve().parents[1]
class PanelRegressionTests(unittest.TestCase):
def test_webview_actions_do_not_depend_on_native_dialogs(self) -> None:
script = (ROOT / "pages" / "记忆面板" / "app.js").read_text(encoding="utf-8")
+ page = (ROOT / "pages" / "记忆面板" / "index.html").read_text(encoding="utf-8")
self.assertIsNone(re.search(r"\b(?:confirm|alert|prompt)\s*\(", script))
self.assertIn("function showInlineConfirmation", script)
- self.assertIn('title: "导入 LivingMemory"', script)
- self.assertIn("executeLivingMemoryImport", script)
+ self.assertNotIn("LivingMemory", script)
+ self.assertNotIn("livingmemory", script.lower())
+ self.assertNotIn("LivingMemory", page)
+ self.assertNotIn("livingmemory-path", page)
+ self.assertNotIn('id="previewImportBtn"', page)
+ self.assertNotIn('id="runImportBtn"', page)
+ self.assertNotIn('id="repairLivingMemoryBtn"', page)
def test_personal_memory_failures_are_visible_and_recoverable(self) -> None:
script = (ROOT / "pages" / "记忆面板" / "app.js").read_text(encoding="utf-8")