From ad1e598efe6ca9e152132c6237fd3953a983e107 Mon Sep 17 00:00:00 2001 From: Dominik Jain Date: Mon, 30 Mar 2026 12:20:57 +0200 Subject: [PATCH] :sparkles: Add wait time in exportImage to account for async updates #8836 This is a temporary workaround for penpot/penpot-mcp#27. It adds a wait time before exports via the export_shape tool to account for asynchronous updates in Penpot, increasing the likelihood of exporting the fully updated state. --- mcp/packages/plugin/src/PenpotUtils.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mcp/packages/plugin/src/PenpotUtils.ts b/mcp/packages/plugin/src/PenpotUtils.ts index ab5be791e1..2c2cc3e4e5 100644 --- a/mcp/packages/plugin/src/PenpotUtils.ts +++ b/mcp/packages/plugin/src/PenpotUtils.ts @@ -420,6 +420,11 @@ export class PenpotUtils { * - For mode="fill", it will be whatever format the fill image is stored in. */ public static async exportImage(shape: Shape, mode: "shape" | "fill", asSVG: boolean): Promise { + // Updates are asynchronous in Penpot, so wait a tick to ensure any pending updates are applied before export. + // The constant wait time is a temporary workardound until a better solution for penpot/penpot-mcp#27 + // is implemented. + await new Promise((resolve) => setTimeout(resolve, 200)); + // Perform export switch (mode) { case "shape": return shape.export({ type: asSVG ? "svg" : "png" });