fix(mcp-server): fix duplicate page exports and auto-save deleting user files

- Preview page: keep an MCP export open until the server has its result.
  A poll answered before that still saw the request and started the same
  export again, so a parallel page export could write the previous
  page's image into its file
- Auto-save only removes its own mcp-*.drawio files, so a DRAWIO_DATA_DIR
  that also holds the user's diagrams keeps them
- screenshot_diagram captures a page that has no id attribute by loading
  just that page, like export_diagram
- An empty <Array as="points"/> no longer hides orphan mxPoints that
  come after it
- POST /api/state refuses a push without xml, which used to wipe the
  stored diagram
- Clear exportOptions when an export ends, reuse hasCells for the empty
  diagram check, and reword two log lines
This commit is contained in:
dayuan.jiang
2026-10-04 07:38:17 +09:00
parent 392c8af84a
commit 899924ba98
8 changed files with 77 additions and 29 deletions
+5
View File
@@ -477,6 +477,11 @@ function handleStateApi(
return
}
if (typeof data.xml !== "string") {
res.writeHead(400, { "Content-Type": "application/json" })
res.end(JSON.stringify({ error: "xml must be a string" }))
return
}
const version = setState(sessionId, data.xml, data.svg, true)
res.writeHead(200, { "Content-Type": "application/json" })
res.end(JSON.stringify({ success: true, version }))