Skip to content

AI-native knowledge base & Evernote/Obsidian alternative with instant sync & native MCP. Free on Cloudflare or self-hosted via Docker.

Use source title when merging memos

yoma13e3e2f233c9
diff --git a/apps/api/src/index.ts b/apps/api/src/index.ts
index 8837d8a8..4f86ea32 100644
--- a/apps/api/src/index.ts
+++ b/apps/api/src/index.ts
@@ -3621,7 +3621,7 @@ const mergeMemosRecord = async (
.map((memoId) => rows.results.find((row) => row.id === memoId))
.filter((row): row is MemoDetailRow => Boolean(row));
const notebookId = input.notebookId ?? ordered[0].notebook_id;
- const title = input.title || `合并笔记 ${new Date().toLocaleDateString("zh-CN")}`;
+ const title = resolveMergedMemoTitle(input.title, ordered);
const mergedMarkdown = ordered.map((memo) => memo.content_markdown).join("\n\n---\n\n");
const contentJson = markdownToDoc(mergedMarkdown);
const contentText = docToText(contentJson);
@@ -4056,6 +4056,20 @@ const normalizeMemoTitle = (value: string | null | undefined) => {
return title || DEFAULT_MEMO_TITLE;
};
+const isCustomMemoTitle = (value: string | null | undefined) => {
+ const title = value?.trim();
+ return Boolean(title && title !== DEFAULT_MEMO_TITLE);
+};
+
+const resolveMergedMemoTitle = (inputTitle: string | undefined, sourceMemos: Array<{ title: string | null }>) => {
+ const title = inputTitle?.trim();
+ if (title) {
+ return title;
+ }
+
+ return sourceMemos.find((memo) => isCustomMemoTitle(memo.title))?.title?.trim() ?? `合并笔记 ${new Date().toLocaleDateString("zh-CN")}`;
+};
+
const normalizeMemoListSort = (value: string | undefined): MemoListSortMode =>
value === "created-desc" || value === "title-asc" ? value : "updated-desc";