fix(flowchart): pre-await getUserDataPath to fix persistence; bump v4.9.0 → v4.9.1

Amit Haridas
This commit is contained in:
2026-09-14 22:24:27 +05:30
parent 58aa4da00f
commit 8c708b7abb
6 changed files with 51 additions and 7 deletions
+12 -4
View File
@@ -2436,16 +2436,24 @@ document.addEventListener('DOMContentLoaded', async () => {
.run({ nodes: [div] })
.catch((err) => console.warn('flowchart preview render failed:', err));
};
// Pre-resolve the userData path on first panel render and cache it. The
// flowchart panel's getUserDataPath() must be sync (it is interpolated into
// the persistence path on mount); calling flowchartIO.getUserDataPath()
// directly would coerce the IPC Promise to "[object Promise]" and break
// every write/read against <userData>/flowchart-session.json.
let cachedUserDataPath = null;
sidebarManager.registerPanel('flowchart', {
title: 'Flow Chart',
render: (container) =>
renderFlowChartPanel(container, {
getUserDataPath: flowchartIO.getUserDataPath,
render: async (container) => {
if (!cachedUserDataPath) cachedUserDataPath = await flowchartIO.getUserDataPath();
return renderFlowChartPanel(container, {
getUserDataPath: () => cachedUserDataPath,
readFile: flowchartIO.readFile,
writeFile: flowchartIO.writeFile,
insertAtCursor: (text) => tabManager.insertAtCursor(text),
renderMermaid: renderFlowChartMermaid,
}),
});
},
});
// Wiki-link navigation: open the target note (creating it on demand after