From 2b525b816b7304b3c7eb0110559ef1fed24d7817 Mon Sep 17 00:00:00 2001 From: Danila Poyarkov Date: Sat, 7 Mar 2026 20:51:53 +0300 Subject: [PATCH] Fix eval response unwrapping and export_jsx page selection MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - eval CLI was typing rpc result as {ok, result} but the bridge already unwraps to the inner value — use rpc directly - export_jsx defaults to current page children, not first page - Fix import ordering in server.ts (doc comment above imports) --- packages/cli/src/commands/eval.ts | 8 ++++---- src/automation/server.ts | 5 +++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/packages/cli/src/commands/eval.ts b/packages/cli/src/commands/eval.ts index bc9197424..2871f460c 100644 --- a/packages/cli/src/commands/eval.ts +++ b/packages/cli/src/commands/eval.ts @@ -41,12 +41,12 @@ export default defineCommand({ } if (isAppMode(args.file)) { - const response = await rpc<{ ok: boolean; result?: unknown; error?: string }>('eval', { code }) - if (!args.quiet && response.result !== undefined) { + const result = await rpc('eval', { code }) + if (!args.quiet && result !== undefined && result !== null) { if (args.json || !process.stdout.isTTY) { - console.log(JSON.stringify(response.result, null, 2)) + console.log(JSON.stringify(result, null, 2)) } else { - console.log(response.result) + console.log(result) } } return diff --git a/src/automation/server.ts b/src/automation/server.ts index 46bbee9bb..f9c0772c3 100644 --- a/src/automation/server.ts +++ b/src/automation/server.ts @@ -1,4 +1,3 @@ -import { makeFigmaFromStore } from '@/automation/figma-factory' /** * Browser-side automation handler. * @@ -15,6 +14,7 @@ import { sceneNodeToJSX } from '@open-pencil/core' +import { makeFigmaFromStore } from '@/automation/figma-factory' import type { EditorStore } from '@/stores/editor' import type { ExportFormat } from '@open-pencil/core' @@ -107,7 +107,8 @@ export function connectAutomation(getStore: () => EditorStore) { if (command === 'export_jsx') { const jsxArgs = args as { nodeIds?: string[]; style?: string } | undefined const style = (jsxArgs?.style ?? 'openpencil') as 'openpencil' | 'tailwind' - const nodeIds = jsxArgs?.nodeIds ?? store.graph.getPages()[0]?.childIds ?? [] + const currentPage = store.graph.getNode(store.state.currentPageId) + const nodeIds = jsxArgs?.nodeIds ?? currentPage?.childIds ?? [] const jsx = nodeIds.length === 1 ? sceneNodeToJSX(nodeIds[0], store.graph, style)