Skip to content

Commit b4fc8b7

Browse files
authored
Merge pull request #132 from Automattic/fix/figma-handoff-payload-size
Bound Figma Studio handoff payload
2 parents eac6411 + 36a52ee commit b4fc8b7

4 files changed

Lines changed: 5 additions & 8 deletions

File tree

docs/figma-studio-runner.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,17 +55,17 @@ The payload preserves the source needed for a Studio-side transform:
5555
- `scenegraph` includes the normalized current page and selected nodes rather than only generated HTML.
5656
- `assets` carries the normalized exported assets.
5757
- `transform` requests the `static-site-importer/figma` route with a WordPress target, preserved source scenegraph, asset import, selection scope, page ID, and selected node IDs.
58-
- `debug` carries a per-request handoff ID, generated artifact context, diagnostics, and metadata.
58+
- `debug` carries a per-request handoff ID, a bounded summary, diagnostics, and metadata. The generated website artifact remains local to avoid duplicating binary assets in the handoff request.
5959

60-
The debug summary is deterministic from the selected source and generated artifact. It reports the selection scope and page, selected-node count, recursive node count, asset count, and diagnostic, warning, and error counts. When no nodes are selected, node counting falls back to the current page. `generate-artifact.test.mjs` fixes this shape with a selected-node fixture and verifies the route, preservation options, handoff ID, generated artifact, and summary counts.
60+
The debug summary is deterministic from the selected source and generated artifact. It reports the selection scope and page, selected-node count, recursive node count, asset count, and diagnostic, warning, and error counts. When no nodes are selected, node counting falls back to the current page. `generate-artifact.test.mjs` fixes this shape with a selected-node fixture and verifies the route, preservation options, handoff ID, bounded debug payload, and summary counts.
6161

6262
## Handoff And Diagnostics
6363

6464
The UI posts to `http://127.0.0.1:48732/figma-to-wordpress/import` with `Content-Type: application/json`. The Studio button remains disabled until normalized selection data is available and while a request is active.
6565

6666
Each request receives a `figma-...` handoff ID. On success, Studio may return `requestId`, `siteName`, `siteUrl`, and `importSummary`; the UI displays the accepted site and logs those values with the handoff ID, payload schema, selection identity, source summary, and generated artifact file/entrypoint summary.
6767

68-
A non-2xx response or a response without `success: true` is a failed handoff. The visible error uses Studio's response message when available, appends its request ID for correlation, and otherwise includes the HTTP status. Network and response failures are logged with the same handoff ID and source summary, so Studio and Figma logs can be correlated without treating the debug artifact as the primary import contract.
68+
A non-2xx response or a response without `success: true` is a failed handoff. The visible error uses Studio's response message when available, appends its request ID for correlation, and otherwise includes the HTTP status. Network and response failures are logged with the same handoff ID and source summary, while the generated artifact remains available in local plugin diagnostics.
6969

7070
Not implemented yet:
7171

plugins/figma-to-wordpress-studio/README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,13 @@ The `Open in WordPress Studio` request body is source-first:
9494
}
9595
},
9696
"debug": {
97-
"generatedArtifact": {},
9897
"diagnostics": []
9998
}
10099
},
101100
"siteName": "Marketing site"
102101
}
103102
```
104103

105-
`debug.generatedArtifact` is diagnostic context only. Studio should route from `source`, `scenegraph`, and `transform`, not from a pre-rendered website artifact bundle.
104+
Studio routes from `source`, `scenegraph`, and `transform`. The generated website artifact remains available in the plugin's local diagnostics but is not duplicated in the handoff request.
106105

107106
See [`../../docs/figma-studio-runner.md`](../../docs/figma-studio-runner.md) for the integration notes.

plugins/figma-to-wordpress-studio/src/payload.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ export interface FigmaSourcePayload {
5757
debug: {
5858
handoffId?: string;
5959
summary: FigmaSourceDebugSummary;
60-
generatedArtifact?: GeneratedArtifact["studioImportPayload"];
6160
diagnostics: GeneratedArtifact["diagnostics"];
6261
metadata?: GeneratedArtifact["metadata"];
6362
};
@@ -95,7 +94,6 @@ export function toFigmaSourcePayload(
9594
debug: {
9695
handoffId,
9796
summary: sourceDebugSummary(selection, artifact),
98-
generatedArtifact: artifact?.studioImportPayload,
9997
diagnostics: artifact?.diagnostics || [],
10098
metadata: artifact?.metadata,
10199
},

plugins/figma-to-wordpress-studio/tests/generate-artifact.test.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ test("generates a source-first Figma handoff payload with debug summary", async
270270
assert.equal(source.transform.route, "static-site-importer/figma");
271271
assert.equal(source.transform.options.preserveSourceScenegraph, true);
272272
assert.equal(source.debug.handoffId, "handoff-123");
273-
assert.equal(source.debug.generatedArtifact.schema, "blocks-engine/php-transformer/site-artifact/v1");
273+
assert.equal("generatedArtifact" in source.debug, false);
274274
assert.equal(source.debug.summary.scope, "selected-nodes");
275275
assert.equal(source.debug.summary.selectedNodeCount, 1);
276276
assert.equal(source.debug.summary.nodeCount, 2);

0 commit comments

Comments
 (0)