Skip to content

Commit b94b589

Browse files
tinchox5claude
andcommitted
fix(plugin: prompt-export): flow metadata to the toPrompt() export
afterClone received one ctx object and stashed metadata on it, but snapdom's export pipeline creates a fresh ctx object for export hooks (spread from the shared options context). The metadata never reached the prompt() call, so toPrompt() always returned { elements: [], prompt: '' } regardless of what was on the page. Write the metadata onto ctx.options (the shared reference) in addition to ctx itself, so the export ctx — which is spread from options — sees it. Keeps the ctx.__promptMetadata assignment for standalone tests that pass a minimal context. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 311c9e4 commit b94b589

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

packages/plugins/prompt-export.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,12 @@ export function promptExport(options = {}) {
4343

4444
afterClone(ctx) {
4545
const meta = extractMetadata(ctx.element, interactiveSelector, semanticSelector);
46+
// The ctx passed to afterClone is NOT the same object passed to the
47+
// prompt() export later — snapdom spreads from ctx.options there. Stash
48+
// on both so (a) standalone tests that pass a minimal ctx still see it
49+
// and (b) the prompt() call can read it through the shared options ref.
4650
ctx.__promptMetadata = meta;
51+
if (ctx.options) ctx.options.__promptMetadata = meta;
4752

4853
if (annotate) {
4954
addAnnotations(ctx.clone, meta.elements, labelStyle);

0 commit comments

Comments
 (0)