AI-native design editor. Open-source Figma alternative.
Fix eval response unwrapping and export_jsx page selection
Danila Poyarkov2b525b816b73
diff --git a/packages/cli/src/commands/eval.ts b/packages/cli/src/commands/eval.tsindex 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<unknown>('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)}}returndiff --git a/src/automation/server.ts b/src/automation/server.tsindex 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 } | undefinedconst 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)