fix(mcp): capture SVG for AI-generated diagrams

- Sync browser state before saving history in display_diagram
- Save AI result to history (in addition to state before)
- Add SVG capture after browser loads AI diagrams
- Add /api/history-svg endpoint to update last entry's SVG
- Add updateLastHistorySvg() function to history module
This commit is contained in:
dayuan.jiang
2025-12-21 16:58:41 +09:00
parent b9bc2a72c6
commit 864375b8e4
4 changed files with 132 additions and 44 deletions

View File

@@ -49,3 +49,14 @@ export function getHistoryEntry(
export function clearHistory(sessionId: string): void {
historyStore.delete(sessionId)
}
export function updateLastHistorySvg(sessionId: string, svg: string): boolean {
const history = historyStore.get(sessionId)
if (!history || history.length === 0) return false
const last = history[history.length - 1]
if (!last.svg) {
last.svg = svg
return true
}
return false
}