An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:bug: Save startup configuration without structuredClone https://github.com/siyuan-note/siyuan/issues/20976
Daniel5b040890c371
diff --git a/app/src/config/util/configApi.test.ts b/app/src/config/util/configApi.test.tsindex 6e625265cf..91afec4cf8 100644--- a/app/src/config/util/configApi.test.ts+++ b/app/src/config/util/configApi.test.ts@@ -12,7 +12,7 @@ const fixture = (failRefresh = false) => {const source = transpileModule(readFileSync("src/config/util/configApi.ts", "utf8"), {compilerOptions: {module: ModuleKind.CommonJS},}).outputText;- runInNewContext(source, {exports, window: {siyuan: {config: memory}}, structuredClone, require: (name: string) => {+ runInNewContext(source, {exports, window: {siyuan: {config: memory}}, require: (name: string) => {if (name === "../../util/fetch") return {fetchSyncPost: (_url: string, body: any) =>new Promise(resolve => requests.push({body, resolve}))};if (name === "./dotPath") return {mergeRecordByDottedPath};@@ -33,6 +33,18 @@ const fixture = (failRefresh = false) => {const settle = () => new Promise<void>(resolve => setImmediate(resolve));+test("startup keymap saves work without structuredClone and preserve their submitted snapshot", async () => {+ const f = fixture();+ const keymap = {general: {newShortcut: {custom: "", default: ""}}, editor: {general: {}}};+ const saved = f.config.set("keymap", keymap);+ keymap.general.newShortcut.custom = "changed after submission";+ await settle();+ assert.equal(JSON.stringify(f.requests[0].body),+ '{"keymap":{"general":{"newShortcut":{"custom":"","default":""}},"editor":{"general":{}}}}');+ f.requests[0].resolve({code: 0});+ await saved;+});+test("config.set queues a namespace, preserves submitted values and returns normalized memory", async () => {const f = fixture();const markdown = {inlineMath: false};diff --git a/app/src/config/util/configApi.ts b/app/src/config/util/configApi.tsindex fb725b4db2..9a0eec6c60 100644--- a/app/src/config/util/configApi.ts+++ b/app/src/config/util/configApi.ts@@ -18,7 +18,8 @@ const get = <T>(path: string): T => {// 同一配置段按提交顺序保存,成功后通过统一刷新流程应用内核的规范化结果。const set = (path: string, value: unknown, onApplied?: (data: unknown, response?: IWebSocketData) => void): Promise<void> => {- value = structuredClone(value);+ // Configuration is JSON data; take the request snapshot without newer WebView APIs.+ value = value === undefined ? undefined : JSON.parse(JSON.stringify(value));const separator = path.indexOf(".");const namespace = separator === -1 ? path : path.slice(0, separator);const relativePath = separator === -1 ? "" : path.slice(separator + 1);