From 7eb9a207f5a696172db91be010be9bfc0c606c86 Mon Sep 17 00:00:00 2001 From: Dominik Jain Date: Wed, 11 Feb 2026 11:00:00 +0100 Subject: [PATCH] :sparkles: Change PenpotUtils.findShapes to search on all pages by default This matches the behaviour of findShape, more closely aligning with the LLM's expectations (given the lack of concrete information in the instructions) --- mcp/packages/plugin/src/PenpotUtils.ts | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/mcp/packages/plugin/src/PenpotUtils.ts b/mcp/packages/plugin/src/PenpotUtils.ts index d4d3f49967..964cf70f4c 100644 --- a/mcp/packages/plugin/src/PenpotUtils.ts +++ b/mcp/packages/plugin/src/PenpotUtils.ts @@ -71,9 +71,9 @@ export class PenpotUtils { * Finds all shapes that matches the given predicate in the given shape tree. * * @param predicate - A function that takes a shape and returns true if it matches the criteria - * @param root - The root shape to start the search from (defaults to penpot.root) + * @param root - The root shape to start the search from (if null, searches all pages) */ - public static findShapes(predicate: (shape: Shape) => boolean, root: Shape | null = penpot.root): Shape[] { + public static findShapes(predicate: (shape: Shape) => boolean, root: Shape | null = null): Shape[] { let result = new Array(); let find = function (shape: Shape | null) { @@ -90,7 +90,16 @@ export class PenpotUtils { } }; - find(root); + if (root === null) { + const pages = penpot.currentFile?.pages; + if (pages) { + for (let page of pages) { + find(page.root); + } + } + } else { + find(root); + } return result; }