From c9b5ce7db32fb30b94974666c3c3bf349242caae Mon Sep 17 00:00:00 2001 From: Yamila Moreno Date: Tue, 17 Nov 2026 19:00:05 +0100 Subject: [PATCH 01/11] :wrench: Manage renovate PRs (#13131) Signed-off-by: Yamila Moreno --- renovate.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/renovate.json b/renovate.json index 1d7acb30de..6f1e06fb35 100644 --- a/renovate.json +++ b/renovate.json @@ -1,7 +1,8 @@ { "$schema": "https://docs.renovatebot.com/renovate-schema.json", "extends": ["github>penpot/renovate-config"], - "labels": ["dependencies", "team infra", "no issue required"], + "labels": ["dependencies", "team infra", "renovate"], + "prBodyNotes": ["Related to #12126"], "semanticCommits": "disabled", "commitMessagePrefix": ":arrow_up:", "commitMessageAction": "Update", From c56acc7ff3d8c73fee67795a1f6005a75dd6679c Mon Sep 17 00:00:00 2001 From: Yamila Moreno Date: Wed, 18 Nov 2026 09:07:22 +0100 Subject: [PATCH 02/11] :wrench: Require milestone to issues linked to a PR (#13133) Signed-off-by: Yamila Moreno --- .../require-milestone-linked-issues.yml | 75 +++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 .github/workflows/require-milestone-linked-issues.yml diff --git a/.github/workflows/require-milestone-linked-issues.yml b/.github/workflows/require-milestone-linked-issues.yml new file mode 100644 index 0000000000..f1886033cb --- /dev/null +++ b/.github/workflows/require-milestone-linked-issues.yml @@ -0,0 +1,75 @@ +name: Require Milestone on Linked Issues + +on: + pull_request: + types: + - opened + - reopened + - synchronize + - edited + - ready_for_review + - converted_to_draft + workflow_dispatch: + +permissions: + contents: read + pull-requests: read + issues: read + +jobs: + check-linked-issues: + name: Require Milestones on Linked Issues + runs-on: ubuntu-latest + + steps: + - name: Check linked issues + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + PR_NUMBER: ${{ github.event.pull_request.number }} + IS_DRAFT: ${{ github.event.pull_request.draft }} + REPOSITORY: ${{ github.repository }} + run: | + if [ "$IS_DRAFT" = "true" ]; then + echo "Draft PR: milestone check skipped." + exit 0 + fi + + OWNER="${REPOSITORY%%/*}" + REPO="${REPOSITORY#*/}" + + ISSUES=$(gh api graphql \ + -F owner="$OWNER" \ + -F repo="$REPO" \ + -F number="$PR_NUMBER" \ + -f query=' + query($owner: String!, $repo: String!, $number: Int!) { + repository(owner: $owner, name: $repo) { + pullRequest(number: $number) { + closingIssuesReferences(first: 100) { + nodes { + number + title + url + milestone { + title + } + } + } + } + } + } + ') + + MISSING=$(echo "$ISSUES" | jq -r ' + .data.repository.pullRequest.closingIssuesReferences.nodes[] + | select(.milestone == null) + | "- #\(.number): \(.title) (\(.url))" + ') + + if [ -n "$MISSING" ]; then + echo "::error::The following linked issues have no milestone:" + echo "$MISSING" + exit 1 + fi + + echo "All linked issues have a milestone." From 690b32b16344006e1a40798a88449ae3ce11ad16 Mon Sep 17 00:00:00 2001 From: Yamila Moreno Date: Wed, 18 Nov 2026 10:00:39 +0100 Subject: [PATCH 03/11] :wrench: Improve issue templates (#13126) Signed-off-by: Yamila Moreno --- .../{bug-report.yml => bug.yml} | 16 ++++---- .github/ISSUE_TEMPLATE/config.yml | 2 +- .github/ISSUE_TEMPLATE/enhancement.yml | 38 +++++++++++++++++++ .github/ISSUE_TEMPLATE/epic.yml | 26 +++++++++++++ .../{feature-request.yml => feature.yml} | 16 ++++---- .github/ISSUE_TEMPLATE/task.yml | 26 +++++++++++++ 6 files changed, 107 insertions(+), 17 deletions(-) rename .github/ISSUE_TEMPLATE/{bug-report.yml => bug.yml} (90%) create mode 100644 .github/ISSUE_TEMPLATE/enhancement.yml create mode 100644 .github/ISSUE_TEMPLATE/epic.yml rename .github/ISSUE_TEMPLATE/{feature-request.yml => feature.yml} (80%) create mode 100644 .github/ISSUE_TEMPLATE/task.yml diff --git a/.github/ISSUE_TEMPLATE/bug-report.yml b/.github/ISSUE_TEMPLATE/bug.yml similarity index 90% rename from .github/ISSUE_TEMPLATE/bug-report.yml rename to .github/ISSUE_TEMPLATE/bug.yml index 9031969b8e..af5e0e3418 100644 --- a/.github/ISSUE_TEMPLATE/bug-report.yml +++ b/.github/ISSUE_TEMPLATE/bug.yml @@ -1,7 +1,7 @@ -description: Create a report to help us improve -name: Bug report -type: Bug +description: An unexpected problem or behavior labels: ["needs triage"] +name: Bug +type: Bug body: - type: markdown @@ -15,7 +15,7 @@ body: - type: textarea attributes: label: Steps To Reproduce - description: Steps to reproduce the behavior. + description: Steps to reproduce the behavior placeholder: | Steps to reproduce the behavior: 1. Go to '...' @@ -26,22 +26,22 @@ body: - type: textarea id: expected attributes: - description: A clear and concise description of what you expected to happen. label: Expected behavior + description: A clear and concise description of what you expected to happen validations: required: true - type: textarea id: actual attributes: - description: A clear and concise description of what happens instead; what the bug is. label: Actual behavior + description: A clear and concise description of what happens instead; what the bug is validations: required: true - type: textarea id: screenshots attributes: - description: If applicable, add screenshots to help explain your problem. label: Screenshots or video + description: If applicable, add screenshots to help explain your problem - type: textarea id: desktop attributes: @@ -87,4 +87,4 @@ body: id: additional-context attributes: label: Additional context - description: Any other context about the problem. + description: Add any other context or screenshots about the bug here diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index 0086358db1..3ba13e0cec 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -1 +1 @@ -blank_issues_enabled: true +blank_issues_enabled: false diff --git a/.github/ISSUE_TEMPLATE/enhancement.yml b/.github/ISSUE_TEMPLATE/enhancement.yml new file mode 100644 index 0000000000..ee4b3249e0 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/enhancement.yml @@ -0,0 +1,38 @@ +description: Improvement to existing behavior +labels: ["needs triage"] +name: "Enhancement" +type: Enhancement + +body: + - type: markdown + attributes: + value: | + ## Before you start + + Please search our [existing issues](https://github.com/penpot/penpot/issues) and open [pull requests](https://github.com/penpot/penpot/pulls) to lessen the change of filing duplicate issues or feature requests. Thank you. + + --- + - type: textarea + id: problem + attributes: + label: Is your feature request related to a problem? Please describe + description: A clear and concise description of what the problem is. Ex. I'm always frustrated when (...) + validations: + required: true + - type: textarea + id: solution + attributes: + label: Describe the solution you'd like + description: A clear and concise description of what you want to happen + validations: + required: true + - type: textarea + id: alternatives + attributes: + label: Describe alternatives you've considered + description: A clear and concise description of any alternative solutions or features you've considered + - type: textarea + id: additional-context + attributes: + label: Additional context + description: Add any other context or screenshots about the enhancement here diff --git a/.github/ISSUE_TEMPLATE/epic.yml b/.github/ISSUE_TEMPLATE/epic.yml new file mode 100644 index 0000000000..37dd3cff17 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/epic.yml @@ -0,0 +1,26 @@ +description: An epic is a large user story that cannot be delivered as defined within a single iteration +labels: ["needs triage"] +name: "EPIC" +type: EPIC + +body: + - type: markdown + attributes: + value: | + ## Before you start + + Please search our [existing issues](https://github.com/penpot/penpot/issues) and open [pull requests](https://github.com/penpot/penpot/pulls) to lessen the change of filing duplicate issues or feature requests. Thank you. + + --- + - type: textarea + id: description + attributes: + label: Epic description + description: Tell us which epic feature do you want to discuss + validations: + required: true + - type: textarea + id: additional-context + attributes: + label: Additional context + description: Add any other context or screenshots about the feature request here diff --git a/.github/ISSUE_TEMPLATE/feature-request.yml b/.github/ISSUE_TEMPLATE/feature.yml similarity index 80% rename from .github/ISSUE_TEMPLATE/feature-request.yml rename to .github/ISSUE_TEMPLATE/feature.yml index 17f451ae3f..2ba0eb4dbd 100644 --- a/.github/ISSUE_TEMPLATE/feature-request.yml +++ b/.github/ISSUE_TEMPLATE/feature.yml @@ -1,7 +1,7 @@ -description: Suggest an idea for this project. +description: Suggest an idea for this project labels: ["needs triage"] name: "Feature request" -type: Enhancement +type: Feature body: - type: markdown @@ -15,24 +15,24 @@ body: - type: textarea id: problem attributes: + label: Is your feature request related to a problem? Please describe description: A clear and concise description of what the problem is. Ex. I'm always frustrated when (...) - label: Is your feature request related to a problem? Please describe. validations: required: true - type: textarea id: solution attributes: - description: A clear and concise description of what you want to happen. - label: Describe the solution you'd like. + label: Describe the solution you'd like + description: A clear and concise description of what you want to happen validations: required: true - type: textarea id: alternatives attributes: - label: Describe alternatives you've considered. - description: A clear and concise description of any alternative solutions or features you've considered. + label: Describe alternatives you've considered + description: A clear and concise description of any alternative solutions or features you've considered - type: textarea id: additional-context attributes: label: Additional context - description: Add any other context or screenshots about the feature request here. + description: Add any other context or screenshots about the feature request here diff --git a/.github/ISSUE_TEMPLATE/task.yml b/.github/ISSUE_TEMPLATE/task.yml new file mode 100644 index 0000000000..c82e98a04a --- /dev/null +++ b/.github/ISSUE_TEMPLATE/task.yml @@ -0,0 +1,26 @@ +description: A specific piece of work +labels: [] +name: "Task" +type: Task + +body: + - type: markdown + attributes: + value: | + ## Before you start + + Please search our [existing issues](https://github.com/penpot/penpot/issues) and open [pull requests](https://github.com/penpot/penpot/pulls) to lessen the change of filing duplicate issues or feature requests. Thank you. + + --- + - type: textarea + id: task + attributes: + description: A clear and concise description of the task + label: Please describe + validations: + required: true + - type: textarea + id: additional-context + attributes: + label: Additional context + description: Add any other context or screenshots about the task here From 8acb5a84392a90ff8b0ea3d4a57c948faf2d4ca9 Mon Sep 17 00:00:00 2001 From: Yamila Moreno Date: Wed, 18 Nov 2026 11:54:01 +0100 Subject: [PATCH 04/11] :wrench: Require milestone in PRs (#13129) Signed-off-by: Yamila Moreno --- .../require-milestone-linked-issues.yml | 1 + .github/workflows/require-milestone.yml | 45 +++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 .github/workflows/require-milestone.yml diff --git a/.github/workflows/require-milestone-linked-issues.yml b/.github/workflows/require-milestone-linked-issues.yml index f1886033cb..d00dade45e 100644 --- a/.github/workflows/require-milestone-linked-issues.yml +++ b/.github/workflows/require-milestone-linked-issues.yml @@ -37,6 +37,7 @@ jobs: OWNER="${REPOSITORY%%/*}" REPO="${REPOSITORY#*/}" + # shellcheck disable=SC2016 # GraphQL variables, not shell expansion. ISSUES=$(gh api graphql \ -F owner="$OWNER" \ -F repo="$REPO" \ diff --git a/.github/workflows/require-milestone.yml b/.github/workflows/require-milestone.yml new file mode 100644 index 0000000000..641e1a98fa --- /dev/null +++ b/.github/workflows/require-milestone.yml @@ -0,0 +1,45 @@ +name: Require Milestone + +on: + pull_request: + types: + - opened + - reopened + - synchronize + - edited + - milestoned + - demilestoned + - ready_for_review + - converted_to_draft + +permissions: + contents: read + pull-requests: read + +jobs: + check-milestone: + name: Require Milestone + runs-on: ubuntu-latest + + steps: + - name: Check milestone + env: + GH_TOKEN: ${{ github.token }} + PR_NUMBER: ${{ github.event.pull_request.number }} + run: | + pr_api="repos/${GITHUB_REPOSITORY}/pulls/${PR_NUMBER}" + + is_draft=$(gh api "$pr_api" --jq '.draft') + milestone=$(gh api "$pr_api" --jq '.milestone.title // ""') + + if [ "$is_draft" = "true" ]; then + echo "Draft PR: milestone check skipped." + exit 0 + fi + + if [ -z "$milestone" ]; then + echo "::error::This pull request must have a milestone." + exit 1 + fi + + echo "Milestone assigned: $milestone" From c1ad2194dc58ea5202b085317f9f955d2a02071f Mon Sep 17 00:00:00 2001 From: Yamila Moreno Date: Wed, 18 Nov 2026 14:59:46 +0100 Subject: [PATCH 05/11] :wrench: Add PRs to status tech-review (#13152) Signed-off-by: Yamila Moreno --- .github/workflows/auto-label.yml | 64 +++++++++++++++++++++++++++++++- 1 file changed, 63 insertions(+), 1 deletion(-) diff --git a/.github/workflows/auto-label.yml b/.github/workflows/auto-label.yml index 65dcc51875..ff4f55f096 100644 --- a/.github/workflows/auto-label.yml +++ b/.github/workflows/auto-label.yml @@ -43,6 +43,9 @@ jobs: // === 1. CONFIGURATION === const PROJECT_NUMBER = 8; // <--- Replace with your project board number const IS_ORG = true; // <--- Set to false if this is a personal project, true if an organization + const STATUS_FIELD_ID = 'PVTSSF_lADOAcyBPM4BV2pqzhRPY48'; + const STATUS_BACKLOG = 'f75ad846'; + const STATUS_TECH_REVIEW = 'b0f45db9'; const OWNER = context.repo.owner; const REPO = context.repo.repo; @@ -88,6 +91,65 @@ jobs: } `; - await github.graphql(addToProjectMutation, { projectId, contentId }); + let itemId; + try { + const addRes = await github.graphql(addToProjectMutation, { projectId, contentId }); + itemId = addRes.addProjectV2ItemById.item.id; + } catch (error) { + const messages = [ + error && error.message, + ...(Array.isArray(error && error.errors) + ? error.errors.map(e => e && e.message) + : []) + ].filter(Boolean).join('\n'); + if (!messages.includes('Content already exists in this project')) { + throw error; + } + console.log('Item already in project, fetching existing item...'); + const existing = await github.graphql( + `query($contentId: ID!) { + node(id: $contentId) { + ... on Issue { + projectItems(first: 50) { + nodes { id project { id } } + } + } + ... on PullRequest { + projectItems(first: 50) { + nodes { id project { id } } + } + } + } + }`, + { contentId } + ); + const nodes = (existing.node && existing.node.projectItems && existing.node.projectItems.nodes) || []; + const match = nodes.find(n => n.project.id === projectId); + if (!match) { + throw new Error(`Item already in a project, but not found in project ${projectId}`); + } + itemId = match.id; + } + + // === 4. SET PROJECT STATUS === + const statusOptionId = isPR ? STATUS_TECH_REVIEW : STATUS_BACKLOG; + const statusName = isPR ? 'Tech Review' : 'Backlog'; + console.log(`Setting status to "${statusName}" for ${isPR ? 'PR' : 'Issue'} #${issueNumber}...`); + await github.graphql( + `mutation($projectId: ID!, $itemId: ID!, $fieldId: ID!, $optionId: String!) { + updateProjectV2ItemFieldValue(input: { + projectId: $projectId, + itemId: $itemId, + fieldId: $fieldId, + value: { singleSelectOptionId: $optionId } + }) { + projectV2Item { + id + } + } + }`, + { projectId, itemId, fieldId: STATUS_FIELD_ID, optionId: statusOptionId } + ); + console.log("Automation successfully completed!"); From bb87fe07de80269181c09620d6621837efc5b0e9 Mon Sep 17 00:00:00 2001 From: Eva Marco Date: Thu, 19 Nov 2026 09:22:09 +0100 Subject: [PATCH 06/11] :wrench: Test unique layer names in the file builder (#13086) * :wrench: Test unique layer names in the file builder The builder read used names from :unames while track-used-name wrote them to ::unames, so two boards without a name both ended up as "Board". #12794 fixed the key. These tests cover it: two unnamed boards get "Board" and "Board-1", and two names that clean to the same path get "-1" on the second one. Both fail with the old key. AI-assisted-by: claude-opus-5-5 * :wrench: Test that component root names count as used names #12794 also made add-component register the renamed main instance name. A shape added later with the same name must get "-1". The test fails without that track-used-name call. AI-assisted-by: claude-opus-5-5 * :wrench: Test per-page unique names and anonymous components The builder tracks used names per page, so the same name on two pages stays unchanged. A component without a name is called "anonymous". Each test fails without the code it covers. AI-assisted-by: claude-opus-5-5 --- .../test/common_tests/files_builder_test.cljc | 82 +++++++++++++++++++ 1 file changed, 82 insertions(+) diff --git a/common/test/common_tests/files_builder_test.cljc b/common/test/common_tests/files_builder_test.cljc index 9658f51b28..f0c633be30 100644 --- a/common/test/common_tests/files_builder_test.cljc +++ b/common/test/common_tests/files_builder_test.cljc @@ -123,6 +123,88 @@ shape (fb/get-shape state shape-id)] (t/is (= "Group / Subgroup / Name" (:name shape))))) +(t/deftest add-shape-uniquifies-default-names + (let [file-id (uuid/next) + page-id (uuid/next) + board-a (uuid/next) + board-b (uuid/next) + state (-> (fb/create-state) + (fb/add-file {:id file-id :name "Test file"}) + (fb/add-page {:id page-id :name "Page 1"}) + (fb/add-board {:id board-a :x 0 :y 0 :width 10 :height 10}) + (fb/add-board {:id board-b :x 20 :y 0 :width 10 :height 10}))] + (t/is (= "Board" (:name (fb/get-shape state board-a)))) + (t/is (= "Board-1" (:name (fb/get-shape state board-b)))))) + +(t/deftest add-shape-uniquifies-names-that-clean-to-the-same-path + (let [file-id (uuid/next) + page-id (uuid/next) + shape-a (uuid/next) + shape-b (uuid/next) + state (-> (fb/create-state) + (fb/add-file {:id file-id :name "Test file"}) + (fb/add-page {:id page-id :name "Page 1"}) + (fb/add-shape {:id shape-a :type :frame :name "Group/Name" + :x 0 :y 0 :width 10 :height 10}) + (fb/add-shape {:id shape-b :type :frame :name "Group / Name" + :x 20 :y 0 :width 10 :height 10}))] + (t/is (= "Group / Name" (:name (fb/get-shape state shape-a)))) + (t/is (= "Group / Name-1" (:name (fb/get-shape state shape-b)))))) + +(t/deftest add-shape-uniquifies-names-used-by-component-roots + (let [file-id (uuid/next) + page-id (uuid/next) + frame-id (uuid/next) + component-id (uuid/next) + shape-id (uuid/next) + state (-> (fb/create-state) + (fb/add-file {:id file-id :name "Test file"}) + (fb/add-page {:id page-id :name "Page 1"}) + (fb/add-board {:id frame-id :name "Draft" + :x 0 :y 0 :width 10 :height 10}) + (fb/add-component {:component-id component-id + :name "Button" + :path "Forms"}) + (fb/close-board) + (fb/add-shape {:id shape-id :type :frame :name "Forms/Button" + :x 20 :y 0 :width 10 :height 10}))] + (t/is (= "Forms / Button" (:name (fb/get-shape state frame-id)))) + (t/is (= "Forms / Button-1" (:name (fb/get-shape state shape-id)))))) + +(t/deftest add-shape-keeps-unique-names-per-page + (let [file-id (uuid/next) + page-a (uuid/next) + page-b (uuid/next) + board-a (uuid/next) + board-b (uuid/next) + state (-> (fb/create-state) + (fb/add-file {:id file-id :name "Test file"}) + (fb/add-page {:id page-a :name "Page 1"}) + (fb/add-board {:id board-a :x 0 :y 0 :width 10 :height 10}) + (fb/add-page {:id page-b :name "Page 2"}) + (fb/add-board {:id board-b :x 0 :y 0 :width 10 :height 10})) + name-of (fn [page-id shape-id] + (get-in state [::fb/files file-id :data :pages-index + page-id :objects shape-id :name]))] + (t/is (= "Board" (name-of page-a board-a))) + (t/is (= "Board" (name-of page-b board-b))))) + +(t/deftest add-component-without-name-is-anonymous + (let [file-id (uuid/next) + page-id (uuid/next) + frame-id (uuid/next) + component-id (uuid/next) + state (-> (fb/create-state) + (fb/add-file {:id file-id :name "Test file"}) + (fb/add-page {:id page-id :name "Page 1"}) + (fb/add-board {:id frame-id :name "Draft" + :x 0 :y 0 :width 10 :height 10}) + (fb/add-component {:component-id component-id})) + component (get-in state [::fb/files file-id :data + :components component-id])] + (t/is (= "anonymous" (:name component))) + (t/is (= "anonymous" (:name (fb/get-shape state frame-id)))))) + (t/deftest add-component-renames-frame-to-match-component (t/testing "the main instance frame name is aligned with the component's path+name" (let [file-id (uuid/next) From 2695434362d870249e3d26ea8022b8b1c52367ba Mon Sep 17 00:00:00 2001 From: Yamila Moreno Date: Thu, 19 Nov 2026 09:28:57 +0100 Subject: [PATCH 07/11] :wrench: Prevent PRs without issue from merging Signed-off-by: Yamila Moreno --- .github/workflows/require-linked-issue.yml | 90 ++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 .github/workflows/require-linked-issue.yml diff --git a/.github/workflows/require-linked-issue.yml b/.github/workflows/require-linked-issue.yml new file mode 100644 index 0000000000..6379ac4e91 --- /dev/null +++ b/.github/workflows/require-linked-issue.yml @@ -0,0 +1,90 @@ +name: Require Linked Issue + +# A pull request must have at least one closing-issue reference, unless it +# carries the `no issue required` label. +on: + pull_request: + types: + - opened + - reopened + - synchronize + - edited + - labeled + - unlabeled + - ready_for_review + - converted_to_draft + +permissions: + contents: read + pull-requests: read + issues: read + +jobs: + check-linked-issue: + name: Require Linked Issue + if: ${{ !github.event.pull_request.draft }} + runs-on: ubuntu-latest + steps: + - name: Check linked issue + env: + GH_TOKEN: ${{ github.token }} + PR_NUMBER: ${{ github.event.pull_request.number }} + OWNER: ${{ github.repository_owner }} + REPO: ${{ github.event.repository.name }} + run: | + set -euo pipefail + + # shellcheck disable=SC2016 # GraphQL variables, not shell expansion. + result=$(gh api graphql \ + -F owner="$OWNER" \ + -F repo="$REPO" \ + -F number="$PR_NUMBER" \ + -f query=' + query($owner: String!, $repo: String!, $number: Int!) { + repository(owner: $owner, name: $repo) { + pullRequest(number: $number) { + isDraft + labels(first: 100) { + nodes { + name + } + } + closingIssuesReferences(first: 100) { + nodes { + number + title + url + } + } + } + } + } + ') + + pull_request=$(echo "$result" | jq '.data.repository.pullRequest') + + if [ "$(echo "$pull_request" | jq -r '.isDraft')" = "true" ]; then + echo "Draft PR: linked issue check skipped." + exit 0 + fi + + has_exemption=$(echo "$pull_request" | jq -r ' + .labels.nodes | map(.name) | index("no issue required") != null + ') + if [ "$has_exemption" = "true" ]; then + echo 'Label "no issue required" found: linked issue check skipped.' + exit 0 + fi + + issues=$(echo "$pull_request" | jq -r ' + .closingIssuesReferences.nodes[] + | "- #\(.number): \(.title) (\(.url))" + ') + + if [ -z "$issues" ]; then + echo '::error::This pull request must have a linked issue, or the "no issue required" label.' + exit 1 + fi + + echo "Linked issue(s):" + echo "$issues" From be7be634d915e04f71913d5a64dd4c38f0584d5e Mon Sep 17 00:00:00 2001 From: Yamila Moreno Date: Thu, 19 Nov 2026 10:21:13 +0100 Subject: [PATCH 08/11] :wrench: Add exemption to linked issues workflow Signed-off-by: Yamila Moreno --- .github/workflows/require-linked-issue.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/require-linked-issue.yml b/.github/workflows/require-linked-issue.yml index 6379ac4e91..ffb32bffca 100644 --- a/.github/workflows/require-linked-issue.yml +++ b/.github/workflows/require-linked-issue.yml @@ -1,7 +1,7 @@ name: Require Linked Issue # A pull request must have at least one closing-issue reference, unless it -# carries the `no issue required` label. +# carries the `no issue required` or `pr pt` label. on: pull_request: types: @@ -69,10 +69,10 @@ jobs: fi has_exemption=$(echo "$pull_request" | jq -r ' - .labels.nodes | map(.name) | index("no issue required") != null + any(.labels.nodes[]; .name == "no issue required" or .name == "pr pt") ') if [ "$has_exemption" = "true" ]; then - echo 'Label "no issue required" found: linked issue check skipped.' + echo 'Exempt label found: linked issue check skipped.' exit 0 fi @@ -82,7 +82,7 @@ jobs: ') if [ -z "$issues" ]; then - echo '::error::This pull request must have a linked issue, or the "no issue required" label.' + echo '::error::This pull request must have a linked issue, or an exempt label ("no issue required").' exit 1 fi From b6db09e2fb9cec6f6d4817c93b1b025b4b5b0497 Mon Sep 17 00:00:00 2001 From: Alonso Torres Date: Thu, 19 Nov 2026 10:27:04 +0100 Subject: [PATCH 09/11] :sparkles: Expose the instance URL and query params to plugins (#13018) Plugins and the MCP could not learn which Penpot instance they run on, so agents guessed the domain when they wrote links to files. Add penpot.location with the instance base URL (baseUrl), the URL of the current screen (href) and its query params (params). It works in the dashboard and the workspace and requires content:read. Params that carry secrets (share-id, the MCP authorize params, and any key ending in token, secret or password) are left out, and href is rebuilt from the remaining params so it never carries one. The MCP instructions tell agents to use href instead of building links. The plugin API test suite checks location against the open file, and its API surface is regenerated from the current types. Closes #13013 AI-assisted-by: claude-opus-5-5 --- frontend/src/app/plugins/api.cljs | 4 + frontend/src/app/plugins/location.cljs | 45 ++++++++++++ .../frontend_tests/plugins/location_test.cljs | 73 +++++++++++++++++++ frontend/test/frontend_tests/runner.cljs | 2 + .../server/data/initial_instructions.md | 3 + plugins/CHANGELOG.md | 1 + .../src/generated/api-surface.json | 34 +++++++++ .../src/tests/platform.test.ts | 48 ++++++++++++ plugins/libs/plugin-types/index.d.ts | 40 ++++++++++ .../libs/plugins-runtime/src/lib/api/index.ts | 6 ++ .../src/lib/api/plugin-api.spec.ts | 34 +++++++++ 11 files changed, 290 insertions(+) create mode 100644 frontend/src/app/plugins/location.cljs create mode 100644 frontend/test/frontend_tests/plugins/location_test.cljs diff --git a/frontend/src/app/plugins/api.cljs b/frontend/src/app/plugins/api.cljs index 3043ff510b..4220978faa 100644 --- a/frontend/src/app/plugins/api.cljs +++ b/frontend/src/app/plugins/api.cljs @@ -43,6 +43,7 @@ [app.plugins.history :as history] [app.plugins.library :as library] [app.plugins.local-storage :as local-storage] + [app.plugins.location :as location] [app.plugins.management :as management] [app.plugins.page :as page] [app.plugins.parser :as parser] @@ -114,6 +115,9 @@ {:this true :get #(.getTheme ^js %)} + :location + {:get (fn [] (clj->js (location/location @st/state)))} + :localStorage {:this true :get diff --git a/frontend/src/app/plugins/location.cljs b/frontend/src/app/plugins/location.cljs new file mode 100644 index 0000000000..59434fb636 --- /dev/null +++ b/frontend/src/app/plugins/location.cljs @@ -0,0 +1,45 @@ +;; This Source Code Form is subject to the terms of the Mozilla Public +;; License, v. 2.0. If a copy of the MPL was not distributed with this +;; file, You can obtain one at http://mozilla.org/MPL/2.0/. +;; +;; Copyright (c) KALEIDOS SUBSIDIARY SL + +(ns app.plugins.location + "The app URL as plugins see it: the instance base URL and the current + route's query params, without the params that carry secrets." + (:require + [app.common.data.macros :as dm] + [app.common.uri :as u] + [app.config :as cf] + [app.main.router :as rt])) + +(def ^:private secret-params + "Query params that grant access or carry auth state." + #{:share-id :request :code :state}) + +(defn- secret-param? + [k] + (or (contains? secret-params k) + (some? (re-find #"(?i)(token|secret|password)$" (name k))))) + +(defn- public-params + "Return the current route's query params without secrets. A key + repeated in the URL keeps its last value, as the app reads it." + [state] + (let [params (rt/get-params state)] + (into {} + (comp (remove (comp secret-param? key)) + (map (fn [[k _]] [k (rt/get-query-param params k)]))) + params))) + +(defn location + "Return `{:baseUrl :href :params}` for the current route in `state`. + `href` is rebuilt from the public params, so it never carries a secret." + [state] + (let [base-url (dm/str cf/public-uri) + params (public-params state)] + {:baseUrl base-url + :href (if (empty? params) + base-url + (dm/str base-url "?" (u/map->query-string params))) + :params (update-keys params name)})) diff --git a/frontend/test/frontend_tests/plugins/location_test.cljs b/frontend/test/frontend_tests/plugins/location_test.cljs new file mode 100644 index 0000000000..7ac6601b4c --- /dev/null +++ b/frontend/test/frontend_tests/plugins/location_test.cljs @@ -0,0 +1,73 @@ +;; This Source Code Form is subject to the terms of the Mozilla Public +;; License, v. 2.0. If a copy of the MPL was not distributed with this +;; file, You can obtain one at http://mozilla.org/MPL/2.0/. +;; +;; Copyright (c) KALEIDOS SUBSIDIARY SL + +(ns frontend-tests.plugins.location-test + (:require + [app.common.data.macros :as dm] + [app.common.uri :as u] + [app.config :as cf] + [app.plugins.location :as location] + [cljs.test :as t :include-macros true])) + +(defn- state-with-query + [query-params] + {:route {:data {:name (keyword (:screen query-params))} + :params {:path {} :query query-params} + :query-params query-params}}) + +(defn- href-params + [href] + (-> (u/uri href) :query u/query-string->map)) + +(t/deftest base-url-is-the-public-uri + (let [result (location/location (state-with-query {:screen "dashboard-recent"}))] + (t/is (= (dm/str cf/public-uri) (:baseUrl result))))) + +(t/deftest workspace-params-are-exposed + (let [query {:screen "workspace" + :team-id "t1" + :file-id "f1" + :page-id "p1" + :layout "layers"} + result (location/location (state-with-query query))] + (t/is (= {"screen" "workspace" + "team-id" "t1" + "file-id" "f1" + "page-id" "p1" + "layout" "layers"} + (:params result))) + (t/is (= query (href-params (:href result)))) + (t/is (= (dm/str cf/public-uri) (subs (:href result) 0 (count (dm/str cf/public-uri))))))) + +(t/deftest custom-params-are-exposed + (let [result (location/location (state-with-query {:screen "workspace" :my-plugin "on"}))] + (t/is (= "on" (get-in result [:params "my-plugin"]))))) + +(t/deftest secret-params-are-left-out + (let [query {:screen "workspace" + :file-id "f1" + :token "s1" + :invitation-token "s2" + :share-id "s3" + :request "s4" + :code "s5" + :state "s6" + :client-secret "s7" + :password "s8"} + result (location/location (state-with-query query))] + (t/is (= {"screen" "workspace" "file-id" "f1"} (:params result))) + (t/is (= {:screen "workspace" :file-id "f1"} (href-params (:href result)))) + (t/is (not (re-find #"s\d" (:href result)))))) + +(t/deftest repeated-params-keep-the-last-value + (let [result (location/location (state-with-query {:screen "workspace" :page-id ["p1" "p2"]}))] + (t/is (= "p2" (get-in result [:params "page-id"]))) + (t/is (= "p2" (:page-id (href-params (:href result))))))) + +(t/deftest no-route-returns-the-base-url + (let [result (location/location {})] + (t/is (= {} (:params result))) + (t/is (= (:baseUrl result) (:href result))))) diff --git a/frontend/test/frontend_tests/runner.cljs b/frontend/test/frontend_tests/runner.cljs index 9301549572..6c092342c3 100644 --- a/frontend/test/frontend_tests/runner.cljs +++ b/frontend/test/frontend_tests/runner.cljs @@ -97,6 +97,7 @@ [frontend-tests.plugins.interactions-test] [frontend-tests.plugins.library-test] [frontend-tests.plugins.local-storage-test] + [frontend-tests.plugins.location-test] [frontend-tests.plugins.management-test] [frontend-tests.plugins.page-active-validation-test] [frontend-tests.plugins.page-test] @@ -307,6 +308,7 @@ 'frontend-tests.plugins.interactions-test 'frontend-tests.plugins.library-test 'frontend-tests.plugins.local-storage-test + 'frontend-tests.plugins.location-test 'frontend-tests.plugins.page-active-validation-test 'frontend-tests.plugins.page-test 'frontend-tests.plugins.parser-test diff --git a/mcp/packages/server/data/initial_instructions.md b/mcp/packages/server/data/initial_instructions.md index dc49df83e7..1def2cf07c 100644 --- a/mcp/packages/server/data/initial_instructions.md +++ b/mcp/packages/server/data/initial_instructions.md @@ -206,6 +206,9 @@ A key object for navigating the currently active Penpot file is the `penpot` obj * `penpot.root` provides the root shape of the currently active page. * Generation of CSS content for elements via `penpot.generateStyle` * Generation of HTML/SVG content for elements via `penpot.generateMarkup` + * `penpot.location` gives the Penpot instance URL (`baseUrl`), the link to what the user is viewing (`href`, e.g. the open file and page) + and the query params of that link (`params`, e.g. `params["file-id"]`). Use `href` when you need a link to the open file; + never guess the instance domain or build the link by hand. Members of `penpot` (e.g. `penpot.currentFile` and `penpot.root`) will be null no Penpot file is currently opened. You can use `penpotMgmt` to navigate to a file if needed (see below). diff --git a/plugins/CHANGELOG.md b/plugins/CHANGELOG.md index db2c6f861a..3e51bb5ff8 100644 --- a/plugins/CHANGELOG.md +++ b/plugins/CHANGELOG.md @@ -5,6 +5,7 @@ - **plugin-types, plugins-runtime:** Added `penpot.waitForSave(timeout?)` to wait until pending file changes are saved (or there is nothing to save). Rejects on save failure, rollback during the wait, timeout (default 60000 ms), or an invalid timeout. The Error `code` property is `save-timeout`, `rolled-back`, `save-retrying` (an earlier failed save Penpot keeps retrying) or the save failure code. - **plugin-types, plugins-runtime:** `penpotMgmt` returns `Team`, `Project` and `ProjectFile` objects. Assigning `name` renames teams, projects and files, `project.pinned` pins a project and `file.shared` shares a file as a team library; `createProject`, `createFile`, `moveTo`, `duplicate`, `remove` and `restore` live on the objects. Added `penpotMgmt.listTeams`, `penpotMgmt.createTeam`, `penpotMgmt.getFile`, `listDeletedProjects` and `listDeletedFiles`, and the `manage:projects`, `manage:teams` and `manage:delete` permissions. Restoration uses the dashboard's Trash operation; projects need recoverable files and empty projects cannot be restored; the API exposes no permanent deletion method. Team deletion is not exposed. - **plugins-runtime, plugin-types**: Added global plugins (`scope: "global"`) that remain active across dashboard and workspace navigation until closed or logged out, with `penpotMgmt` for project and file discovery, file navigation and workspace events. Global scope adds the `allow:global` permission, which users must accept when installing the plugin. +- **plugin-types, plugins-runtime:** Added `penpot.location` with the instance base URL (`baseUrl`), the URL of the current screen (`href`) and its query params (`params`), in the dashboard and the workspace. Params that carry secrets are left out. Requires `content:read`. Closes #13013. - **plugin-types:** Added the `contentrollback` event and the `ContentRollback` type. The event fires after the backend rejected some changes and the workspace undid them, with the ids of the files, pages and shapes affected. It fires once the undone data is in the workspace, also when the workspace has to reload the file to undo the changes. ### 🩹 Fixes diff --git a/plugins/apps/plugin-api-test-suite/src/generated/api-surface.json b/plugins/apps/plugin-api-test-suite/src/generated/api-surface.json index d8886bec66..18e9d0b9c5 100644 --- a/plugins/apps/plugin-api-test-suite/src/generated/api-surface.json +++ b/plugins/apps/plugin-api-test-suite/src/generated/api-surface.json @@ -104,6 +104,7 @@ "history", "library", "localStorage", + "location", "openPage", "openViewer", "replaceColor", @@ -376,6 +377,7 @@ "Path": ["commands", "d", "fills", "type"], "PathCommand": ["command", "params"], "Penpot": ["closePlugin", "off", "on", "ui", "utils"], + "PenpotLocation": ["baseUrl", "href", "params"], "PenpotMgmt": [ "createTeam", "getFile", @@ -2253,6 +2255,12 @@ "type": "Theme", "array": false }, + "location": { + "decl": "Context", + "kind": "get", + "type": "PenpotLocation", + "array": false + }, "localStorage": { "decl": "Context", "kind": "get", @@ -6711,6 +6719,12 @@ "type": "Theme", "array": false }, + "location": { + "decl": "Context", + "kind": "get", + "type": "PenpotLocation", + "array": false + }, "localStorage": { "decl": "Context", "kind": "get", @@ -6892,6 +6906,26 @@ "array": false } }, + "PenpotLocation": { + "baseUrl": { + "decl": "PenpotLocation", + "kind": "get", + "type": null, + "array": false + }, + "href": { + "decl": "PenpotLocation", + "kind": "get", + "type": null, + "array": false + }, + "params": { + "decl": "PenpotLocation", + "kind": "get", + "type": null, + "array": false + } + }, "PenpotMgmt": { "workspace": { "decl": "PenpotMgmt", diff --git a/plugins/apps/plugin-api-test-suite/src/tests/platform.test.ts b/plugins/apps/plugin-api-test-suite/src/tests/platform.test.ts index f77e063304..b96a33d518 100644 --- a/plugins/apps/plugin-api-test-suite/src/tests/platform.test.ts +++ b/plugins/apps/plugin-api-test-suite/src/tests/platform.test.ts @@ -45,6 +45,54 @@ describe('Platform', () => { }); }); + describe('Location', () => { + // Parses a query string by hand: the plugin sandbox may not expose `URL`. + function queryParams(href: string): Record { + const query = href.split('?')[1] ?? ''; + const params: Record = {}; + for (const pair of query.split('&').filter(Boolean)) { + const [key, value = ''] = pair.split('='); + params[decodeURIComponent(key)] = decodeURIComponent( + value.replace(/\+/g, ' '), + ); + } + return params; + } + + test('baseUrl is an absolute instance URL ending in a slash', (ctx) => { + const { baseUrl } = ctx.penpot.location; + expect(/^https?:\/\/[^/?#]+(\/[^?#]*)?$/.test(baseUrl)).toBe(true); + expect(baseUrl.endsWith('/')).toBe(true); + }); + + test('href links to the open file and page', (ctx) => { + const { baseUrl, href } = ctx.penpot.location; + const file = ctx.penpot.currentFile; + const page = ctx.penpot.currentPage; + expect(file).not.toBeNull(); + expect(page).not.toBeNull(); + expect(href.startsWith(baseUrl + '?')).toBe(true); + + const params = queryParams(href); + expect(params['screen']).toBe('workspace'); + expect(params['file-id']).toBe(file!.id); + expect(params['page-id']).toBe(page!.id); + expect(params['team-id']).toBe(ctx.penpotMgmt.workspace.teamId); + }); + + test('params match the query of href', (ctx) => { + const { href, params } = ctx.penpot.location; + expect(params).toEqual(queryParams(href)); + }); + + test('each read returns a new snapshot', (ctx) => { + const first = ctx.penpot.location; + const second = ctx.penpot.location; + expect(first === second).toBe(false); + expect(first).toEqual(second); + }); + }); + describe('History', () => { test('undo block begin and finish wrap operations', (ctx) => { const block = ctx.penpot.history.undoBlockBegin(); diff --git a/plugins/libs/plugin-types/index.d.ts b/plugins/libs/plugin-types/index.d.ts index fade26e1f2..3ae76ca542 100644 --- a/plugins/libs/plugin-types/index.d.ts +++ b/plugins/libs/plugin-types/index.d.ts @@ -1165,6 +1165,19 @@ export interface Context { */ readonly theme: Theme; + /** + * The Penpot instance URL and the current address in the app, in the + * dashboard as well as in the workspace. Requires `content:read` permission. + * + * @example + * ```js + * const { baseUrl, href, params } = penpot.location; + * console.log(baseUrl); // "https://design.penpot.app/" + * console.log(params['file-id']); + * ``` + */ + readonly location: PenpotLocation; + /** * Access to the localStorage proxy */ @@ -3404,6 +3417,33 @@ export interface LibraryTypography extends LibraryElement { setFont(font: Font, variant?: FontVariant): void; } +/** + * The Penpot instance URL and the current address in the app. + * Each read of `penpot.location` returns a new snapshot. + * + * Query params that carry secrets (`share-id`, any param ending in + * `token`, `secret` or `password`, and the OAuth params `request`, + * `code` and `state`) are left out of `params` and `href`. + */ +export interface PenpotLocation { + /** + * The public URL of the Penpot instance, ending in `/`, + * e.g. `"https://design.penpot.app/"`. + */ + readonly baseUrl: string; + /** + * The URL of the current screen, e.g. the open file and page: + * `"https://design.penpot.app/?screen=workspace&team-id=…&file-id=…&page-id=…"`. + * Use it to link to what the user is looking at. + */ + readonly href: string; + /** + * The query params of the current URL, e.g. `screen`, `team-id`, + * `file-id` and `page-id`. A param repeated in the URL keeps its last value. + */ + readonly params: Record; +} + /** * Proxy for the local storage. Only elements owned by the plugin * can be stored and accessed. diff --git a/plugins/libs/plugins-runtime/src/lib/api/index.ts b/plugins/libs/plugins-runtime/src/lib/api/index.ts index 5fa70a68c7..e99678670b 100644 --- a/plugins/libs/plugins-runtime/src/lib/api/index.ts +++ b/plugins/libs/plugins-runtime/src/lib/api/index.ts @@ -19,6 +19,7 @@ import type { Page, Path, Penpot, + PenpotLocation, PenpotMgmt, Rectangle, Shape, @@ -268,6 +269,11 @@ export function createApi( return plugin.context.theme; }, + get location(): PenpotLocation { + checkPermission('content:read', false); + return plugin.context.location; + }, + get localStorage(): LocalStorage { checkPermission('allow:localstorage'); return plugin.context.localStorage; diff --git a/plugins/libs/plugins-runtime/src/lib/api/plugin-api.spec.ts b/plugins/libs/plugins-runtime/src/lib/api/plugin-api.spec.ts index d177d02f9c..835ce567b7 100644 --- a/plugins/libs/plugins-runtime/src/lib/api/plugin-api.spec.ts +++ b/plugins/libs/plugins-runtime/src/lib/api/plugin-api.spec.ts @@ -276,4 +276,38 @@ describe('Plugin api', () => { expect(currentSelection).toEqual(selection); }); }); + + describe('location', () => { + const location = { + baseUrl: 'https://design.penpot.app/', + href: 'https://design.penpot.app/?screen=dashboard-recent&team-id=t', + params: { screen: 'dashboard-recent', 'team-id': 't' }, + }; + + it('returns the location while no workspace is ready', () => { + const { penpot } = createApi({ + ...pluginManager, + manifest: { ...pluginManager.manifest, scope: 'global' }, + context: { + ...pluginManager.context, + location, + management: { workspace: { status: 'none' } }, + }, + } as any); + + expect(penpot.location).toEqual(location); + }); + + it('requires content:read', () => { + const { penpot } = createApi({ + ...pluginManager, + manifest: { ...pluginManager.manifest, permissions: [] }, + context: { ...pluginManager.context, location }, + } as any); + + expect(() => penpot.location).toThrow( + 'Permission content:read is not granted', + ); + }); + }); }); From 981fa0696137d40794665a45e7a8c9b362081083 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elena=20Torr=C3=B3?= Date: Thu, 19 Nov 2026 11:02:15 +0100 Subject: [PATCH 10/11] :bug: Keep fill copies laid out after a component sync in the WebGL render (#13154) * :bug: Keep fill copies laid out after a component sync in the WebGL render Lay out other pages in CLJS and reflow nested layouts that keep their size. Closes #13015 AI-assisted-by: claude-opus-5-5 * :zap: Skip the nested layout pass during WebGL drag previews Gap, padding and margin drags keep the cost they had before the fix. Relates to #13015 AI-assisted-by: claude-opus-5-5 --- .../app/main/data/workspace/shape_layout.cljs | 3 +- .../workspace_layout_other_page_test.cljs | 57 +++++++++ frontend/test/frontend_tests/runner.cljs | 2 + render-wasm/src/shapes/modifiers.rs | 112 ++++++++++++++++++ 4 files changed, 173 insertions(+), 1 deletion(-) create mode 100644 frontend/test/frontend_tests/data/workspace_layout_other_page_test.cljs diff --git a/frontend/src/app/main/data/workspace/shape_layout.cljs b/frontend/src/app/main/data/workspace/shape_layout.cljs index 0a5c7b4cfe..6f6cfba59d 100644 --- a/frontend/src/app/main/data/workspace/shape_layout.cljs +++ b/frontend/src/app/main/data/workspace/shape_layout.cljs @@ -112,7 +112,8 @@ update-positions-stream (if (d/not-empty? ids) (let [modif-tree (dwm/create-modif-tree ids (ctm/reflow-modifiers))] - (if (features/active-feature? state "render-wasm/v1") + (if (and (features/active-feature? state "render-wasm/v1") + (= page-id (:current-page-id state))) (rx/of (dwm/apply-wasm-modifiers modif-tree :stack-undo? true :undo-group undo-group diff --git a/frontend/test/frontend_tests/data/workspace_layout_other_page_test.cljs b/frontend/test/frontend_tests/data/workspace_layout_other_page_test.cljs new file mode 100644 index 0000000000..ac0cc0db6f --- /dev/null +++ b/frontend/test/frontend_tests/data/workspace_layout_other_page_test.cljs @@ -0,0 +1,57 @@ +;; This Source Code Form is subject to the terms of the Mozilla Public +;; License, v. 2.0. If a copy of the MPL was not distributed with this +;; file, You can obtain one at http://mozilla.org/MPL/2.0/. +;; +;; Copyright (c) KALEIDOS SUBSIDIARY SL + +(ns frontend-tests.data.workspace-layout-other-page-test + "Regression test for #13015: with render-wasm/v1 active, a `:layout/update` + for a page other than the current one must still lay out its shapes." + (:require + [app.common.test-helpers.compositions :as ctho] + [app.common.test-helpers.files :as cthf] + [app.common.test-helpers.ids-map :as cthi] + [app.common.test-helpers.shapes :as cths] + [app.main.data.workspace.shape-layout :as dwsl] + [cljs.test :as t :include-macros true] + [frontend-tests.helpers.state :as ths] + [frontend-tests.helpers.wasm :as thw])) + +(t/use-fixtures :each + {:before thw/setup-wasm-mocks! + :after thw/teardown-wasm-mocks!}) + +(defn- setup-file + [] + (-> (cthf/sample-file :file1 :page-label :page-a) + (cthf/add-sample-page :page-b) + (ctho/add-frame :board + :x 0 :y 0 :width 500 :height 300 + :layout :flex + :layout-flex-dir :column + :layout-align-items :start + :layout-padding-type :multiple + :layout-padding {:p1 50 :p2 50 :p3 50 :p4 50}) + (cths/add-sample-shape :child + :type :rect + :parent-label :board + :x 50 :y 50 :width 100 :height 20 + :layout-item-h-sizing :fill) + (cthf/switch-to-page :page-a))) + +(t/deftest layout-update-on-another-page-resizes-fill-children + (t/async + done + (let [file (setup-file) + store (ths/setup-store file) + event (#'dwsl/update-layout-positions {:page-id (cthi/id :page-b) + :ids [(cthi/id :board)]})] + (ths/run-store + store done [event] + (fn [new-state] + (let [file' (ths/get-file-from-state new-state) + child (cths/get-shape file' :child :page-label :page-b)] + (t/is (= 400 (:width child)) + "the fill child takes the board width minus its padding") + (t/is (zero? (thw/call-count :propagate-modifiers)) + "WASM only holds the current page, so it must not lay out another one"))))))) diff --git a/frontend/test/frontend_tests/runner.cljs b/frontend/test/frontend_tests/runner.cljs index 6c092342c3..3ab76c823c 100644 --- a/frontend/test/frontend_tests/runner.cljs +++ b/frontend/test/frontend_tests/runner.cljs @@ -41,6 +41,7 @@ [frontend-tests.data.workspace-context-menu-test] [frontend-tests.data.workspace-focus-test] [frontend-tests.data.workspace-interactions-test] + [frontend-tests.data.workspace-layout-other-page-test] [frontend-tests.data.workspace-libraries-load-test] [frontend-tests.data.workspace-libraries-sync-test] [frontend-tests.data.workspace-mcp-test] @@ -251,6 +252,7 @@ 'frontend-tests.data.workspace-context-menu-test 'frontend-tests.data.workspace-focus-test 'frontend-tests.data.workspace-interactions-test + 'frontend-tests.data.workspace-layout-other-page-test 'frontend-tests.data.workspace-libraries-load-test 'frontend-tests.data.workspace-libraries-sync-test 'frontend-tests.data.workspace-mcp-test diff --git a/render-wasm/src/shapes/modifiers.rs b/render-wasm/src/shapes/modifiers.rs index 1898ed7276..b79d811459 100644 --- a/render-wasm/src/shapes/modifiers.rs +++ b/render-wasm/src/shapes/modifiers.rs @@ -17,6 +17,7 @@ use crate::shapes::{ }; use crate::state::{ShapesPoolRef, State}; use crate::uuid::Uuid; +use crate::{get_render_state, has_render_state}; #[allow(clippy::too_many_arguments)] fn propagate_children( @@ -438,6 +439,22 @@ fn propagate_reflow( } } +fn propagate_nested_reflows( + ids: &[Uuid], + shapes: ShapesPoolRef, + reflown: &HashSet, + entries: &mut VecDeque, +) { + for shape in ids.iter().filter_map(|id| shapes.get(id)) { + for child_id in shape.all_children_iter(shapes, false, false) { + if !reflown.contains(&child_id) && shapes.get(&child_id).is_some_and(Shape::has_layout) + { + entries.push_back(Modifier::reflow(child_id, false)); + } + } + } +} + fn reflow_shape( id: &Uuid, state: &State, @@ -504,6 +521,16 @@ pub fn propagate_modifiers( // are transformed in the same pass. let mut pending_reflows = HashSet::::new(); + let requested_reflows: Vec = entries + .iter() + .filter_map(|modifier| match modifier { + Modifier::Reflow(id, _) => Some(*id), + Modifier::Transform(..) => None, + }) + .collect(); + let interactive = has_render_state() && get_render_state().options.is_interactive_transform(); + let mut nested_layouts_queued = interactive || requested_reflows.is_empty(); + // We first propagate the transforms to the children and then after // recalculate the layouts. The layout can create further transforms that // we need to re-propagate. @@ -564,6 +591,14 @@ pub fn propagate_modifiers( } reflow_shape(id, state, &mut reflown, &mut entries, &mut bounds_temp)?; } + + // A requested reflow also lays out the layouts below it that kept + // their size, so were skipped: a component sync can leave their + // children where the layout would not put them. + if entries.is_empty() && !nested_layouts_queued { + nested_layouts_queued = true; + propagate_nested_reflows(&requested_reflows, shapes, &reflown, &mut entries); + } } Ok(modifiers @@ -927,4 +962,81 @@ mod tests { assert_eq!(bounds.width(), 4.0); assert_eq!(bounds.height(), 4.0); } + + fn add_flex_row(shape: &mut Shape) { + shape.set_shape_type(Type::Frame(Frame::default())); + shape.set_flex_layout_data( + FlexDirection::Row, + 0.0, + 0.0, + AlignItems::Start, + AlignContent::Start, + JustifyItems::Start, + JustifyContent::Start, + WrapType::NoWrap, + 0.0, + 0.0, + 0.0, + 0.0, + ); + } + + fn add_fixed_layout_child(shape: &mut Shape, parent_id: Uuid) { + shape.set_parent(parent_id); + shape.set_flex_layout_child_data( + 0.0, + 0.0, + 0.0, + 0.0, + Sizing::Fix, + Sizing::Fix, + None, + None, + None, + None, + None, + false, + None, + ); + } + + #[test] + fn test_reflow_lays_out_nested_layout_that_keeps_its_size() { + let outer_id = Uuid::new_v4(); + let inner_id = Uuid::new_v4(); + let child_id = Uuid::new_v4(); + + let mut state = State::new(); + state.shapes.initialize(10); + { + let child = state.shapes.add_shape(child_id); + child.set_selrect(100.0, 0.0, 116.0, 16.0); + add_fixed_layout_child(child, inner_id); + + let inner = state.shapes.add_shape(inner_id); + add_flex_row(inner); + add_fixed_layout_child(inner, outer_id); + inner.add_child(child_id); + inner.set_selrect(0.0, 0.0, 300.0, 16.0); + + let outer = state.shapes.add_shape(outer_id); + add_flex_row(outer); + outer.add_child(inner_id); + outer.set_selrect(0.0, 0.0, 300.0, 16.0); + } + + let entry = TransformEntry::from_input(outer_id, Matrix::new_identity()); + let result = propagate_modifiers(&state, &[entry], PixelPrecision::Disabled).unwrap(); + + let transform = result + .iter() + .find(|entry| entry.id == child_id) + .map(|entry| entry.transform) + .expect("the child of the nested layout is laid out"); + + let child = state.shapes.get(&child_id).unwrap(); + let bounds = child.bounds().transform(&transform); + + assert!(is_close_to(bounds.min_x(), 0.0)); + } } From 951ebbba6ac70316c2fb41af7359a67301ef0fdb Mon Sep 17 00:00:00 2001 From: Alonso Torres Date: Thu, 19 Nov 2026 11:21:54 +0100 Subject: [PATCH 11/11] :bug: Fix problem with Penpot plugins being blocked (#13147) --- frontend/src/app/main/data/plugins.cljs | 2 +- frontend/src/app/plugins/register.cljs | 27 ++++++++---- .../frontend_tests/plugins/register_test.cljs | 44 ++++++++++++++++++- frontend/translations/en.po | 2 +- frontend/translations/es.po | 2 +- 5 files changed, 64 insertions(+), 13 deletions(-) diff --git a/frontend/src/app/main/data/plugins.cljs b/frontend/src/app/main/data/plugins.cljs index 4d3f8b5ef5..7e489d1351 100644 --- a/frontend/src/app/main/data/plugins.cljs +++ b/frontend/src/app/main/data/plugins.cljs @@ -63,7 +63,7 @@ [plugin] (when (and (preg/global-requested? plugin) (not (preg/global-allowed? plugin))) - (log/warn :hint "Global plugins can only be loaded from localhost" + (log/warn :hint "Global plugins are not allowed from this host" :plugin-id (:plugin-id plugin) :host (:host plugin)) (st/emit! (ntf/warn (tr "workspace.plugins.error.global-not-allowed"))) diff --git a/frontend/src/app/plugins/register.cljs b/frontend/src/app/plugins/register.cljs index 5c7c4b4fe6..d1ab6ea5ac 100644 --- a/frontend/src/app/plugins/register.cljs +++ b/frontend/src/app/plugins/register.cljs @@ -34,14 +34,25 @@ (def global-permissions #{"allow:global" "manage:projects" "manage:teams" "manage:delete"}) -(def ^:private local-hosts +;; Loopback hosts that may serve global plugins over any scheme +(def ^:private trusted-hosts #{"localhost" "127.0.0.1" "[::1]" "::1"}) -(defn- local-url? - "True when the url host is a loopback name, ignoring case and a - trailing dot." +;; Domains whose https subdomains may serve global plugins +(def ^:private trusted-domains + #{"penpot.dev" "penpot.app"}) + +(defn- trusted-url? + "True when the url host is one of `trusted-hosts`, or the url uses + https and its host is a subdomain of one of `trusted-domains`. Hosts + are compared ignoring case and a trailing dot." [url] - (contains? local-hosts (some-> url u/uri :host str/lower (str/rtrim ".")))) + (let [uri (some-> url u/uri) + host (some-> uri :host str/lower (str/rtrim "."))] + (or (contains? trusted-hosts host) + (and (= "https" (some-> uri :scheme str/lower)) + (some? host) + (boolean (some #(str/ends-with? host (str "." %)) trusted-domains)))))) (defn global-requested? "True when the plugin asks for global scope or a management permission." @@ -52,10 +63,10 @@ (defn global-allowed? "True when the plugin may run with global scope and use the management API. The feature is still in progress, so only the bundled MCP plugin - and plugins served from localhost get it." + and plugins served from a trusted url get it." [{:keys [plugin-id host]}] (or (= plugin-id mcp-plugin-id) - (local-url? host))) + (trusted-url? host))) ;; Promise that resolves when plugins runtime is initialized. ;; Lives here to avoid circular dependency: workspace.mcp -> app.plugins -> app.plugins.api -> workspace @@ -155,7 +166,7 @@ (and (global-requested? manifest) (not (global-allowed? manifest))) - (throw (ex-info "Global plugins can only be loaded from localhost" + (throw (ex-info "Global plugins are not allowed from this host" {:type ::global-not-allowed :host origin})) diff --git a/frontend/test/frontend_tests/plugins/register_test.cljs b/frontend/test/frontend_tests/plugins/register_test.cljs index afa0cfe304..b59b3141cc 100644 --- a/frontend/test/frontend_tests/plugins/register_test.cljs +++ b/frontend/test/frontend_tests/plugins/register_test.cljs @@ -363,11 +363,45 @@ (t/is (preg/global-allowed? {:plugin-id preg/mcp-plugin-id :host "https://design.penpot.app/plugins/mcp/"})) (doseq [host ["http://localhost:4400/" "http://127.0.0.1:4400/" "http://[::1]:4400/" - "http://LOCALHOST:4400/" "http://LocalHost/" "http://localhost.:4400/"]] + "http://LOCALHOST:4400/" "http://LocalHost/" "http://localhost.:4400/" + "https://localhost:4400/" "https://127.0.0.1/"]] (t/is (preg/global-allowed? {:plugin-id "local" :host host}) host)) (t/is (not (preg/global-allowed? {:plugin-id "remote" :host "https://plugins.example.com/"}))) (t/is (not (preg/global-allowed? {:plugin-id "remote" :host "https://localhost.example.com/"})))) +(t/deftest global-plugins-are-allowed-for-penpot-domains + (doseq [host ["https://api-test-suite.plugins.penpot.dev/" + "https://design.penpot.dev/plugins/x/" + "https://plugins.penpot.app/" + "https://Plugins.PENPOT.app./"]] + (t/is (preg/global-allowed? {:plugin-id "penpot" :host host}) host)) + (doseq [host ["http://api-test-suite.plugins.penpot.dev/" + "https://penpot.dev/" + "https://penpot.app/" + "https://evilpenpot.app/" + "https://penpot.app.example.com/" + "https://plugins.penpot.dev.example.com/"]] + (t/is (not (preg/global-allowed? {:plugin-id "remote" :host host})) host))) + +(t/deftest parse-manifest-keeps-localhost-management-permissions + (let [manifest (preg/parse-manifest + "http://localhost:4400/manifest.json" + #js {:name "Local management plugin" + :code "plugin.js" + :permissions #js ["content:read" "manage:projects" "manage:teams" "manage:delete"]})] + (t/is (= #{"content:read" "manage:projects" "manage:teams" "manage:delete"} + (:permissions manifest))))) + +(t/deftest parse-manifest-keeps-penpot-domain-global-scope + (let [manifest (preg/parse-manifest + "https://api-test-suite.plugins.penpot.dev/manifest.json" + #js {:name "Penpot global plugin" + :code "plugin.js" + :scope "global" + :permissions #js ["content:read" "manage:projects"]})] + (t/is (= "global" (:scope manifest))) + (t/is (contains? (:permissions manifest) "manage:projects")))) + (t/deftest parse-manifest-rejects-remote-global-scope (t/is (= ::preg/global-not-allowed (global-not-allowed-error @@ -413,5 +447,11 @@ (t/is (preg/has-permission? "reg-global-remote" "content:read")) (t/is (not (preg/has-permission? "reg-global-remote" "allow:global"))) (t/is (not (preg/has-permission? "reg-global-remote" "manage:projects"))) + (preg/install-plugin! {:plugin-id "reg-global-penpot" + :host "https://api-test-suite.plugins.penpot.dev/" + :scope "global" + :permissions permissions}) (t/is (preg/has-permission? "reg-global-local" "allow:global")) - (t/is (preg/has-permission? "reg-global-local" "manage:projects")))))) + (t/is (preg/has-permission? "reg-global-local" "manage:projects")) + (t/is (preg/has-permission? "reg-global-penpot" "allow:global")) + (t/is (preg/has-permission? "reg-global-penpot" "manage:projects")))))) diff --git a/frontend/translations/en.po b/frontend/translations/en.po index b90c25212a..d50bda0f83 100644 --- a/frontend/translations/en.po +++ b/frontend/translations/en.po @@ -8552,7 +8552,7 @@ msgstr "No plugins installed yet" #: src/app/main/data/plugins.cljs, src/app/main/ui/dashboard.cljs, src/app/main/ui/workspace/plugins.cljs msgid "workspace.plugins.error.global-not-allowed" -msgstr "Plugins that work outside a file can only be installed from localhost for now." +msgstr "Plugins that work outside a file can only be installed from trusted sources for now." #: src/app/main/ui/workspace/plugins.cljs:237 msgid "workspace.plugins.error.manifest" diff --git a/frontend/translations/es.po b/frontend/translations/es.po index c6c13b91af..b611f2c42c 100644 --- a/frontend/translations/es.po +++ b/frontend/translations/es.po @@ -8629,7 +8629,7 @@ msgstr "No se encuentran extensiones" #: src/app/main/data/plugins.cljs, src/app/main/ui/dashboard.cljs, src/app/main/ui/workspace/plugins.cljs msgid "workspace.plugins.error.global-not-allowed" -msgstr "Por ahora, las extensiones que funcionan fuera de un archivo solo se pueden instalar desde localhost." +msgstr "Por ahora, las extensiones que funcionan fuera de un archivo solo se pueden instalar desde fuentes de confianza." #: src/app/main/ui/workspace/plugins.cljs:237 msgid "workspace.plugins.error.manifest"