mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 20:00:42 +00:00
fix memory wiki empty related blocks (#78399)
Co-authored-by: Alex Knight <15041791+amknight@users.noreply.github.com>
This commit is contained in:
@@ -170,6 +170,24 @@ describe("compileMemoryWikiVault", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("does not rewrite empty source pages into related-only stubs", async () => {
|
||||
const { rootDir, config } = await createVault({
|
||||
rootDir: nextCaseRoot(),
|
||||
initialize: true,
|
||||
});
|
||||
const emptySourcePath = path.join(rootDir, "sources", "empty.md");
|
||||
const whitespaceSourcePath = path.join(rootDir, "sources", "whitespace.md");
|
||||
await fs.writeFile(emptySourcePath, "", "utf8");
|
||||
await fs.writeFile(whitespaceSourcePath, " \n\t", "utf8");
|
||||
|
||||
const result = await compileMemoryWikiVault(config);
|
||||
|
||||
await expect(fs.readFile(emptySourcePath, "utf8")).resolves.toBe("");
|
||||
await expect(fs.readFile(whitespaceSourcePath, "utf8")).resolves.toBe(" \n\t");
|
||||
expect(result.updatedFiles).not.toContain(emptySourcePath);
|
||||
expect(result.updatedFiles).not.toContain(whitespaceSourcePath);
|
||||
});
|
||||
|
||||
it("does not relate every page through a broad shared source", async () => {
|
||||
const { rootDir, config } = await createVault({
|
||||
rootDir: nextCaseRoot(),
|
||||
|
||||
@@ -776,6 +776,9 @@ async function refreshPageRelatedBlocks(params: {
|
||||
continue;
|
||||
}
|
||||
const original = await root.readText(page.relativePath);
|
||||
if (original.trim().length === 0) {
|
||||
continue;
|
||||
}
|
||||
const updated = withTrailingNewline(
|
||||
replaceManagedMarkdownBlock({
|
||||
original,
|
||||
|
||||
Reference in New Issue
Block a user