An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:sparkles: Support single-node mind map summaries https://github.com/siyuan-note/siyuan/issues/20803
Daniel76d901a0754d
diff --git a/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-h361q1i/20200924093441-ft2rhps.sy b/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-h361q1i/20200924093441-ft2rhps.syindex 6438fcb89a..b5454a43e6 100644--- a/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-h361q1i/20200924093441-ft2rhps.sy+++ b/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-h361q1i/20200924093441-ft2rhps.sy@@ -8,7 +8,7 @@"title": "Formatting elements","title-img": "background-color:#269;background-image: linear-gradient(white 2px, transparent 2px),linear-gradient(90deg, white 2px, transparent 2px),linear-gradient(rgba(255,255,255,.3) 1px, transparent 1px),linear-gradient(90deg, rgba(255,255,255,.3) 1px, transparent 1px);background-size: 100px 100px, 100px 100px, 20px 20px, 20px 20px;background-position:-2px -2px, -2px -2px, -1px -1px, -1px -1px;","type": "doc",- "updated": "20261023003049"+ "updated": "20261024124323"},"Children": [{@@ -1961,7 +1961,7 @@"HeadingLevel": 2,"Properties": {"id": "20210104091509-v1x69oc",- "updated": "20261023003049"+ "updated": "20261024124323"},"Children": [{@@ -3764,12 +3764,12 @@"Type": "NodeParagraph","Properties": {"id": "20260926151827-kkcg79g",- "updated": "20261022235541"+ "updated": "20261024124323"},"Children": [{"Type": "NodeText",- "Data": "Select at least two nodes, then click "+ "Data": "Select one or more nodes, then click "},{"Type": "NodeTextMark",diff --git a/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20200924100950-9op5xi1.sy b/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20200924100950-9op5xi1.syindex 6b4960f5a6..acd1dcbe29 100644--- a/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20200924100950-9op5xi1.sy+++ b/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20200924100950-9op5xi1.sy@@ -7,7 +7,7 @@"id": "20200924100950-9op5xi1","title": "Shortcuts","type": "doc",- "updated": "20261023003049"+ "updated": "20261024124323"},"Children": [{@@ -4365,7 +4365,7 @@"HeadingLevel": 2,"Properties": {"id": "20210106154056-koo4wdj",- "updated": "20261020181700"+ "updated": "20261024124323"},"Children": [{@@ -13115,7 +13115,7 @@"Type": "NodeHeading","Properties": {"id": "20260921105011-4zeuyl4",- "updated": "20261023003049"+ "updated": "20261024124323"},"HeadingLevel": 3,"Children": [@@ -13960,12 +13960,12 @@"Type": "NodeParagraph","Properties": {"id": "20260926152753-8trdt10",- "updated": "20261023003049"+ "updated": "20261024124323"},"Children": [{"Type": "NodeText",- "Data": "Select at least two nodes, then activate "+ "Data": "Select one or more nodes, then activate "},{"Type": "NodeTextMark",diff --git a/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180320-abz7w6k/20200825162036-4dx365o.sy b/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180320-abz7w6k/20200825162036-4dx365o.syindex 9e723956cc..137f7854af 100644--- a/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180320-abz7w6k/20200825162036-4dx365o.sy+++ b/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180320-abz7w6k/20200825162036-4dx365o.sy@@ -8,7 +8,7 @@"title": "排版元素","title-img": "background-color: hsl(2, 57%, 40%);background-image: repeating-linear-gradient(transparent, transparent 50px, rgba(0,0,0,.4) 50px, rgba(0,0,0,.4) 53px, transparent 53px, transparent 63px, rgba(0,0,0,.4) 63px, rgba(0,0,0,.4) 66px, transparent 66px, transparent 116px, rgba(0,0,0,.5) 116px, rgba(0,0,0,.5) 166px, rgba(255,255,255,.2) 166px, rgba(255,255,255,.2) 169px, rgba(0,0,0,.5) 169px, rgba(0,0,0,.5) 179px, rgba(255,255,255,.2) 179px, rgba(255,255,255,.2) 182px, rgba(0,0,0,.5) 182px, rgba(0,0,0,.5) 232px, transparent 232px),repeating-linear-gradient(270deg, transparent, transparent 50px, rgba(0,0,0,.4) 50px, rgba(0,0,0,.4) 53px, transparent 53px, transparent 63px, rgba(0,0,0,.4) 63px, rgba(0,0,0,.4) 66px, transparent 66px, transparent 116px, rgba(0,0,0,.5) 116px, rgba(0,0,0,.5) 166px, rgba(255,255,255,.2) 166px, rgba(255,255,255,.2) 169px, rgba(0,0,0,.5) 169px, rgba(0,0,0,.5) 179px, rgba(255,255,255,.2) 179px, rgba(255,255,255,.2) 182px, rgba(0,0,0,.5) 182px, rgba(0,0,0,.5) 232px, transparent 232px),repeating-linear-gradient(125deg, transparent, transparent 2px, rgba(0,0,0,.2) 2px, rgba(0,0,0,.2) 3px, transparent 3px, transparent 5px, rgba(0,0,0,.2) 5px);","type": "doc",- "updated": "20261023003125"+ "updated": "20261024124323"},"Children": [{@@ -1964,7 +1964,7 @@"HeadingLevel": 2,"Properties": {"id": "20210104091228-wdpx6ev",- "updated": "20261023003125"+ "updated": "20261024124323"},"Children": [{@@ -3734,12 +3734,12 @@"Type": "NodeParagraph","Properties": {"id": "20260926151827-8wl1iml",- "updated": "20261022235541"+ "updated": "20261024124323"},"Children": [{"Type": "NodeText",- "Data": "选中至少两个节点后,点击底部节点菜单中的 "+ "Data": "选中一个或多个节点后,点击底部节点菜单中的 "},{"Type": "NodeTextMark",diff --git a/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180321-hbvl5c2/20200813004551-gm0pbn1.sy b/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180321-hbvl5c2/20200813004551-gm0pbn1.syindex 2a9df2caec..6015813ac6 100644--- a/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180321-hbvl5c2/20200813004551-gm0pbn1.sy+++ b/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180321-hbvl5c2/20200813004551-gm0pbn1.sy@@ -7,7 +7,7 @@"id": "20200813004551-gm0pbn1","title": "快捷键","type": "doc",- "updated": "20261023003125"+ "updated": "20261024124323"},"Children": [{@@ -4363,7 +4363,7 @@"HeadingLevel": 2,"Properties": {"id": "20201227133317-rkh4bji",- "updated": "20261020181700"+ "updated": "20261024124323"},"Children": [{@@ -13097,7 +13097,7 @@"Type": "NodeHeading","Properties": {"id": "20260921105011-hmrchvc",- "updated": "20261023003125"+ "updated": "20261024124323"},"HeadingLevel": 3,"Children": [@@ -14030,12 +14030,12 @@"Type": "NodeParagraph","Properties": {"id": "20260926152753-tamny2o",- "updated": "20261023003125"+ "updated": "20261024124323"},"Children": [{"Type": "NodeText",- "Data": "选中至少两个节点后,激活底部节点菜单中的 "+ "Data": "选中一个或多个节点后,激活底部节点菜单中的 "},{"Type": "NodeTextMark",diff --git a/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226120854-dr1jfx2/20211226121319-emrk2yy.sy b/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226120854-dr1jfx2/20211226121319-emrk2yy.syindex a0b1e0455e..d71febd34c 100644--- a/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226120854-dr1jfx2/20211226121319-emrk2yy.sy+++ b/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226120854-dr1jfx2/20211226121319-emrk2yy.sy@@ -8,7 +8,7 @@"title": "排版元素","title-img": "background-color: hsl(2, 57%, 40%);background-image: repeating-linear-gradient(transparent, transparent 50px, rgba(0,0,0,.4) 50px, rgba(0,0,0,.4) 53px, transparent 53px, transparent 63px, rgba(0,0,0,.4) 63px, rgba(0,0,0,.4) 66px, transparent 66px, transparent 116px, rgba(0,0,0,.5) 116px, rgba(0,0,0,.5) 166px, rgba(255,255,255,.2) 166px, rgba(255,255,255,.2) 169px, rgba(0,0,0,.5) 169px, rgba(0,0,0,.5) 179px, rgba(255,255,255,.2) 179px, rgba(255,255,255,.2) 182px, rgba(0,0,0,.5) 182px, rgba(0,0,0,.5) 232px, transparent 232px),repeating-linear-gradient(270deg, transparent, transparent 50px, rgba(0,0,0,.4) 50px, rgba(0,0,0,.4) 53px, transparent 53px, transparent 63px, rgba(0,0,0,.4) 63px, rgba(0,0,0,.4) 66px, transparent 66px, transparent 116px, rgba(0,0,0,.5) 116px, rgba(0,0,0,.5) 166px, rgba(255,255,255,.2) 166px, rgba(255,255,255,.2) 169px, rgba(0,0,0,.5) 169px, rgba(0,0,0,.5) 179px, rgba(255,255,255,.2) 179px, rgba(255,255,255,.2) 182px, rgba(0,0,0,.5) 182px, rgba(0,0,0,.5) 232px, transparent 232px),repeating-linear-gradient(125deg, transparent, transparent 2px, rgba(0,0,0,.2) 2px, rgba(0,0,0,.2) 3px, transparent 3px, transparent 5px, rgba(0,0,0,.2) 5px);","type": "doc",- "updated": "20261023003125"+ "updated": "20261024124323"},"Children": [{@@ -1962,7 +1962,7 @@"HeadingLevel": 2,"Properties": {"id": "20211226122008-731sqd6",- "updated": "20261023003125"+ "updated": "20261024124323"},"Children": [{@@ -3732,12 +3732,12 @@"Type": "NodeParagraph","Properties": {"id": "20260926151827-6pycwgr",- "updated": "20261022235541"+ "updated": "20261024124323"},"Children": [{"Type": "NodeText",- "Data": "選取至少兩個節點後,點選底部節點選單中的 "+ "Data": "選取一個或多個節點後,點選底部節點選單中的 "},{"Type": "NodeTextMark",diff --git a/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121203-rjjngpz/20211226122549-jktxego.sy b/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121203-rjjngpz/20211226122549-jktxego.syindex 95cb0010bb..c9af96af47 100644--- a/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121203-rjjngpz/20211226122549-jktxego.sy+++ b/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121203-rjjngpz/20211226122549-jktxego.sy@@ -7,7 +7,7 @@"id": "20211226122549-jktxego","title": "快捷鍵","type": "doc",- "updated": "20261023003125"+ "updated": "20261024124323"},"Children": [{@@ -4357,7 +4357,7 @@"HeadingLevel": 2,"Properties": {"id": "20211226122652-htptsmh",- "updated": "20261020181700"+ "updated": "20261024124323"},"Children": [{@@ -13103,7 +13103,7 @@"Type": "NodeHeading","Properties": {"id": "20260921105011-z0oyw36",- "updated": "20261023003125"+ "updated": "20261024124323"},"HeadingLevel": 3,"Children": [@@ -13948,12 +13948,12 @@"Type": "NodeParagraph","Properties": {"id": "20260926152753-0k1m0f6",- "updated": "20261023003125"+ "updated": "20261024124323"},"Children": [{"Type": "NodeText",- "Data": "選取至少兩個節點後,啟動底部節點選單中的 "+ "Data": "選取一個或多個節點後,啟動底部節點選單中的 "},{"Type": "NodeTextMark",diff --git a/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-g3ugxml/20240530101000-xsbxokr.sy b/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-g3ugxml/20240530101000-xsbxokr.syindex f575b92c31..039a230627 100644--- a/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-g3ugxml/20240530101000-xsbxokr.sy+++ b/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-g3ugxml/20240530101000-xsbxokr.sy@@ -9,7 +9,7 @@"id": "20240530101000-xsbxokr","title": "ショートカット","type": "doc",- "updated": "20261023003241"+ "updated": "20261024124323"},"Children": [{@@ -4311,7 +4311,7 @@"Properties": {"ID": "20240530101000-twmuxke","id": "20240530101000-675gu9g",- "updated": "20261018200107"+ "updated": "20261024124323"},"Children": [{@@ -13053,7 +13053,7 @@"Type": "NodeHeading","Properties": {"id": "20260921105011-icqlkb6",- "updated": "20261023003241"+ "updated": "20261024124323"},"HeadingLevel": 3,"Children": [@@ -13880,12 +13880,12 @@"Type": "NodeParagraph","Properties": {"id": "20260926152753-5vwcnw1",- "updated": "20261023003241"+ "updated": "20261024124323"},"Children": [{"Type": "NodeText",- "Data": "2 つ以上のノードを選択してから、下部のノードメニューで "+ "Data": "1 つ以上のノードを選択してから、下部のノードメニューで "},{"Type": "NodeTextMark",diff --git a/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-hnu6o79/20240530101000-3qhz7br.sy b/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-hnu6o79/20240530101000-3qhz7br.syindex 54a0776098..fef54164a9 100644--- a/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-hnu6o79/20240530101000-3qhz7br.sy+++ b/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-hnu6o79/20240530101000-3qhz7br.sy@@ -9,7 +9,7 @@"title": "書式要素","title-img": "background-color:#269;background-image: linear-gradient(white 2px, transparent 2px),linear-gradient(90deg, white 2px, transparent 2px),linear-gradient(rgba(255,255,255,.3) 1px, transparent 1px),linear-gradient(90deg, rgba(255,255,255,.3) 1px, transparent 1px);background-size: 100px 100px, 100px 100px, 20px 20px, 20px 20px;background-position:-2px -2px, -2px -2px, -1px -1px, -1px -1px;","type": "doc",- "updated": "20261023003125"+ "updated": "20261024124323"},"Children": [{@@ -2090,7 +2090,7 @@"Properties": {"ID": "20240530101000-ch5e4vh","id": "20240530101000-1ev7xub",- "updated": "20261023003125"+ "updated": "20261024124323"},"Children": [{@@ -3858,12 +3858,12 @@"Type": "NodeParagraph","Properties": {"id": "20260926151827-vknoaqd",- "updated": "20261022235541"+ "updated": "20261024124323"},"Children": [{"Type": "NodeText",- "Data": "2 つ以上のノードを選択してから、下部のノードメニューで "+ "Data": "1 つ以上のノードを選択してから、下部のノードメニューで "},{"Type": "NodeTextMark",diff --git a/app/src/protyle/render/listMindmap/model.test.ts b/app/src/protyle/render/listMindmap/model.test.tsindex 9c5594806e..fe437e93b3 100644--- a/app/src/protyle/render/listMindmap/model.test.ts+++ b/app/src/protyle/render/listMindmap/model.test.ts@@ -4759,13 +4759,53 @@ const browserCases = async (sourceCode: string, css: string, taskSource: string,await settle();summaryView.focusNode(summaryIds[0]);const summaryButton = summaryHost.querySelector<HTMLButtonElement>('.mindmap-view__inspector [aria-label="listMindmapSummary"]');- for (const id of [summaryModel.root.id, summaryIds[0]]) {+ for (const id of [summaryModel.root.id, summaryIds[0], summaryIds[1]]) {summaryView.focusNode(id);check.equal(summaryButton.hidden, false, "the node menu keeps the summary action in a stable position");- check.equal(summaryButton.disabled, true, "a single selected node cannot create a summary");+ check.equal(summaryButton.disabled, false, "a single real node can create a summary");+ check.equal(api.readListMindmap(summaryList).metadata.summaries?.length || 0, 0,+ "selecting a single node does not create a summary automatically");+ if (id === summaryIds[0]) {+ await require("electron").ipcRenderer.invoke("mindmap-view-native-touch", [+ {type: "touchStart", touchPoints: [{id: 1, ...centerPoint(summaryButton)}]},+ {type: "touchEnd", touchPoints: []},+ ]);+ await settle();+ } else {+ await clickMouse(summaryButton);+ }+ check.deepEqual(api.readListMindmap(summaryList).metadata.summaries[0].nodeIds, [id]);+ const editor = summaryHost.querySelector<HTMLInputElement>(".mindmap-view__summary-editor");+ check.ok(editor, "single-node creation opens summary text editing");+ check.equal(document.activeElement, editor);+ editor.value = "Single node summary";+ editor.dispatchEvent(new KeyboardEvent("keydown", {key: "Enter", bubbles: true}));+ await settle();+ check.equal(api.readListMindmap(summaryList).metadata.summaries[0].label, "Single node summary");+ summaryView.focusNode(id);+ check.equal(summaryButton.disabled, true, "an identical single-node summary cannot be created twice");summaryButton.click();- check.equal(api.readListMindmap(summaryList).metadata.summaries?.length || 0, 0);+ check.equal(api.readListMindmap(summaryList).metadata.summaries.length, 1);+ const resetSingleSummary = api.readListMindmap(summaryList);+ resetSingleSummary.metadata.summaries = [];+ api.writeListMindmapMetadata(summaryList, resetSingleSummary.metadata);+ summaryView.update(api.readListMindmap(summaryList));}+ const virtualSummaryList = reset("- First\n- Second\n");+ const virtualSummaryModel = api.readListMindmap(virtualSummaryList);+ const virtualSummaryHost = document.createElement("div");+ document.body.append(virtualSummaryHost);+ const virtualSummaryView = new api.ListMindmapView({host: virtualSummaryHost, model: virtualSummaryModel,+ labels: new Proxy({}, {get: (_target, key) => String(key)}), onExit: () => {},+ onSummaryBatchAdd: async (): Promise<string[]> => { check.fail("virtual centers cannot create summaries"); return []; }});+ await settle();+ virtualSummaryView.focusNode(virtualSummaryModel.root.id);+ const virtualSummaryButton = virtualSummaryHost.querySelector<HTMLButtonElement>('.mindmap-view__inspector [aria-label="listMindmapSummary"]');+ check.equal(virtualSummaryButton.disabled, true, "virtual centers retain their existing restriction");+ virtualSummaryButton.click();+ virtualSummaryView.destroy();+ virtualSummaryHost.remove();+ summaryView.focusNode(summaryIds[0]);summaryView.draw();const singleSelectionCanvas = summaryHost.querySelector<HTMLCanvasElement>("canvas").toDataURL();for (const id of summaryIds.slice(1)) {@@ -5220,7 +5260,7 @@ const browserCases = async (sourceCode: string, css: string, taskSource: string,test("list mindmap mutations preserve block data in the real DOM and Lute", {skip: process.platform === "linux" && !process.env.DISPLAY && !process.env.WAYLAND_DISPLAY,- timeout: 45000,+ timeout: 90000,}, async () => {const temporary = mkdtempSync(path.join(tmpdir(), "siyuan-mindmap-view-test-"));const script = path.join(temporary, "run.cjs");diff --git a/app/src/protyle/render/listMindmap/summaryView.test.ts b/app/src/protyle/render/listMindmap/summaryView.test.tsindex 9444d4821e..16edb8a086 100644--- a/app/src/protyle/render/listMindmap/summaryView.test.ts+++ b/app/src/protyle/render/listMindmap/summaryView.test.ts@@ -90,11 +90,25 @@ test("summary creation consumes the current selection once and retains the snapsassert.equal(calls.length, 1, "identical ranges do not submit again");});-test("single, invalid, crossing, duplicate and read-only summary selections never submit", async () => {- for (const mode of ["single", "empty", "virtual", "crossing", "duplicate", "readonly", "locked", "export"]) {+test("a single node creates an editable summary and cannot create the same range twice", async () => {+ const {view, model, calls, frames, edited, select} = create();+ select(["a"]);+ const expected = getListMindmapSummarySnapshot(model);+ await view.createSummary();+ assert.deepEqual(calls, [{ranges: [{parentId: "root", nodeIds: ["a"]}], expected}]);+ assert.equal(model.metadata.version, 1, "a single-node summary retains the existing format");+ assert.deepEqual(model.metadata.summaries[0].nodeIds, ["a"]);+ frames.forEach(action => action());+ assert.deepEqual(edited, ["new"]);+ await view.createSummary();+ assert.equal(calls.length, 1, "duplicate single-node ranges are rejected");+});++test("invalid, crossing, duplicate and read-only summary selections never submit", async () => {+ for (const mode of ["empty", "missing", "virtual", "crossing", "duplicate", "readonly", "locked", "export"]) {const {view, model, calls, select} = create();- if (mode === "single") { select(["a"]); }if (mode === "empty") { select([]); }+ if (mode === "missing") { select(["missing"]); }if (mode === "virtual") { select(["root"]); }if (mode === "crossing" || mode === "duplicate") {addListMindmapSummaryRanges(model, [{parentId: "root", nodeIds: ["a", "b"]}], () => "old", "Old");diff --git a/app/src/protyle/render/listMindmap/view.ts b/app/src/protyle/render/listMindmap/view.tsindex c1157d8ab6..1440efb58e 100644--- a/app/src/protyle/render/listMindmap/view.ts+++ b/app/src/protyle/render/listMindmap/view.ts@@ -1345,7 +1345,7 @@ export class ListMindmapView {return;}const selected = this.getSelectedIds();- if (selected.length < 2) {+ if (!selected.length) {return;}const {ranges, conflict} = getListMindmapSummarySelection(this.model, new Set(selected));@@ -2091,7 +2091,7 @@ export class ListMindmapView {const {ranges, conflict} = getListMindmapSummarySelection(this.model, new Set(this.getSelectedIds()));const disabled: Record<string, boolean> = {relation: !node || node.virtual || this.getSelectedIds().length > 1,- summary: this.readOnly || this.summaryPending || this.getSelectedIds().length < 2 ||+ summary: this.readOnly || this.summaryPending ||conflict || !ranges.length || !this.options.onSummaryBatchAdd,style: !node && !this.selectedRelation && !this.selectedEdge,};