Skip to content

✨ Add createComponent() helper with penpot.root guard#8694

Open
abhishek-mittal wants to merge 2 commits intopenpot:stagingfrom
abhishek-mittal:feature/mcp-create-component-helper-v2
Open

✨ Add createComponent() helper with penpot.root guard#8694
abhishek-mittal wants to merge 2 commits intopenpot:stagingfrom
abhishek-mittal:feature/mcp-create-component-helper-v2

Conversation

@abhishek-mittal
Copy link

Summary

Adds a PenpotUtils.createComponent() static helper that wraps the undocumented penpot.library.local.createComponent() Plugin API method behind a clear precondition guard.

Problem

penpot.library.local.createComponent() has a non-obvious silent-failure behaviour: if the board being converted is not already a direct child of penpot.root, the call silently produces an empty, unnamed component instead of throwing an error. This makes plugins that create components appear to work while producing broken assets.

Additionally, cross-page component creation is unsupported by the API (main instances always land on the current page), and the "/" group-separator in component names is not documented anywhere in the public-facing MCP instructions.

Changes

  • mcp/packages/plugin/src/PenpotUtils.ts — new createComponent(board, name) static method:

    • Validates that board is a direct child of penpot.root before calling the API; throws a descriptive Error if not, with a remediation hint.
    • Uses @ts-ignore to bridge the gap until createComponent is added to the official TS type definitions.
    • JSDoc documents the board-on-root precondition, the cross-page limitation, and the "/" group-separator behaviour.
  • CHANGES.md — community entry added to the ## 2.15.0 (Unreleased) section.

Related


Signed-off-by: Abhishek Mittal abhishekmittaloffice@gmail.com

Wrap penpot.library.local.createComponent() in a PenpotUtils static
helper that validates the board is already inserted into penpot.root
before the call (silently fails otherwise) and documents the cross-page
reparenting limitation and '/' group-separator behaviour.

Closes penpot#8691

Signed-off-by: Abhishek Mittal <abhishekmittaloffice@gmail.com>
- Fix scroll on library modal [Taiga #13639](https://tree.taiga.io/project/penpot/issue/13639)
- Update copy on penpot update message [Taiga #12924](https://tree.taiga.io/project/penpot/issue/12924)
- Fix id prop on switch component [Taiga #13534](https://tree.taiga.io/project/penpot/issue/13534)
- Fix tooltip shown on tab change [Taiga #13627](https://tree.taiga.io/project/penpot/issue/13627)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this additions to the CHANGES.md should not go on this PR. I suggest rebase it with staging, and ensure only the related to this PR changes are put on changelog.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants