Skip to content

Release/v2.8.x#1597

Merged
chilingling merged 14 commits intodevelopfrom
release/v2.8.x
Aug 27, 2025
Merged

Release/v2.8.x#1597
chilingling merged 14 commits intodevelopfrom
release/v2.8.x

Conversation

@hexqi
Copy link
Collaborator

@hexqi hexqi commented Aug 26, 2025

English | 简体中文

PR

PR Checklist

Please check if your PR fulfills the following requirements:

  • The commit message follows our Commit Message Guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)
  • Built its own designer, fully self-validated

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

Background and solution

What is the current behavior?

Issue Number: N/A

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Summary by CodeRabbit

  • New Features

    • Added TinyGrid component to templates/mock data.
    • Robot assistant: new message rendering, loading indicator, themed Markdown, MCP panel positioning.
    • Canvas overlay gains smarter label/toolbar alignment.
  • Improvements

    • More robust HTTP response handling.
    • Page and node tools now include titles, validations, and clearer error guidance.
    • Editor layout refined (flex-based); Help guide shows after brief delay.
    • Plugin discovery/switching refined; Markdown highlighting and theming enhanced.
  • Chores

    • Version bump to 2.8.0 across packages and template dependencies.
    • Minor dependency updates for robot-related packages.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 26, 2025

Walkthrough

Version bumps to 2.8.0 across packages. HTTP response helpers add a fallback return. Mock bundles add TinyGrid/version metadata. Canvas MCP tools gain titles, richer validation/errors, and a new addNode schema; Canvas overlay alignment logic refactored. Layout plugin filtering/type titles adjusted. Page tools add existence checks and a utility to flatten pages. Robot plugin overhauls chat/MCP flow, types, renderers, and server handling; adds system prompt and loading renderer. Minor style tweaks and dependency spec updates.

Changes

Cohort / File(s) Summary
Version bumps
designer-demo/package.json, mockServer/package.json, packages/*/package.json, packages/plugins/*/package.json, packages/settings/*/package.json, packages/toolbars/*/package.json
Bump versions from 2.7.0 to 2.8.0 (and robot deps to rc). No code changes.
HTTP response fallback
designer-demo/src/composable/http/index.js, packages/engine-cli/template/designer/src/composable/http/index.js
preResponse now returns `res.data?.data
Mock bundle metadata
designer-demo/public/mock/bundle.json, packages/engine-cli/template/designer/public/mock/bundle.json
Add TinyGrid entry/version metadata; insert version: "3.20.0" in TinyGrid object.
Canvas MCP tools: metadata and validation
packages/canvas/DesignCanvas/src/mcp/tools/addNode.ts, .../changeNodeProps.ts, .../delNode.ts, .../getCurrentSelectedNode.ts, .../getPageSchema.ts, .../queryNodeById.ts, .../selectSpecificNode.ts
Add title/annotations, expand input descriptions, add runtime validations and structured error payloads; addNode input schema replaced with concrete object; insert payload shape adjusted.
Canvas overlay alignment
packages/canvas/container/src/components/CanvasAction.vue
Refactor vertical alignment logic for label/option toolbars; compute placements based on available space; disable text selection; update computed styles.
Common style tweak
packages/common/component/MonacoEditor.vue
Make editor content a flex container via CSS.
Design-core dep spec
packages/design-core/package.json
Change @opentiny/tiny-engine-layout workspace range from ~ to *.
Layout plugin/tools
packages/layout/src/composable/useLayout.ts, packages/layout/src/mcp/tools/getAllPlugins.ts, .../switchPlugin.ts
Filter type from 'plugin' to 'plugins'; add titles; switchPlugin validates pluginId and returns structured errors; close uses closePlugin(true).
Help plugin UX
packages/plugins/help/src/HelpIcon.vue
Delay toggling showStep by 1s when guide inactive.
Materials/i18n tools titles
packages/plugins/materials/src/mcp/tools/getComponentDetail.ts, .../getComponentList.ts, packages/plugins/i18n/src/composable/tools/*
Add title fields; no logic changes.
Page tools: validation and utils
packages/plugins/page/src/mcp/tools/*.ts, .../get_all_pages_utils.ts, packages/plugins/page/src/composable/usePage.ts
Add titles, expand input descriptions, pre-validate page existence using new getAllPages utility; return structured errors; refine error stringification in CRUD functions.
Robot plugin: chat/MCP overhaul
packages/plugins/robot/index.ts, .../src/Main.vue, .../src/js/robotSetting.ts, .../src/mcp/{LoadingRenderer.vue,MarkdownRenderer.vue,McpServer.vue,types.ts,useMcp.ts,utils.ts}, .../src/system-prompt.md
Introduce renderContent pipeline, content renderers (markdown/loading), auto-scroll, MCP popup position prop, server/tool metadata/title handling, remove mock servers, new types (title fields, renderContent), meta API usage, serializeError, system prompt; UI/role/config tweaks.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant U as User
  participant RP as Robot Plugin UI
  participant MS as McpServer (picker)
  participant MU as useMcp/utils
  participant LLM as MetaAPI Chat
  participant TE as TinyEngine MCP Tools

  U->>RP: Send message
  RP->>MU: sendMcpRequest(messages)
  MU->>LLM: fetchLLM(formatMessages(history))
  LLM-->>MU: { content or tool_calls }
  alt tool_calls present
    loop For each tool call
      MU->>TE: Invoke tool(args)
      TE-->>MU: { result | errorCode }
      MU->>MU: Update renderContent (loading -> result/error)
    end
    MU->>LLM: fetchLLM(with toolMessages)
    LLM-->>MU: final content
  else plain content
    MU->>MU: Render markdown to renderContent
  end
  MU-->>RP: Update last message (content/renderContent)
  RP-->>U: Display bubbles (markdown/loading)
Loading
sequenceDiagram
  autonumber
  participant Tool as addNode (MCP)
  participant MR as Material Registry
  participant DC as DesignCanvas
  participant CL as Caller

  CL->>Tool: invoke({ newNodeData })
  Tool->>MR: useMaterial().getComponent(materialName)
  alt component not found or no name
    Tool-->>CL: { isError: true, errorCode: COMPONENT_NAME_REQUIRED, next_action: get_component_list }
  else valid
    Tool->>DC: operateNode({ newNodeData })
    DC-->>Tool: { success }
    Tool-->>CL: { isError: false, data: newNodeData }
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Suggested labels

release, chore

Suggested reviewers

  • chilingling
  • rhlin

Poem

Hops on the canvas, I align and I glide,
Tools gain their titles, errors now confide.
Pages checked politely, nodes add with care,
A robot hums softly, rendering flair.
TinyGrid waves hello—versioned and bright,
2.8.0 carrots stacked just right. 🥕✨

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch release/v2.8.x

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 19

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (7)
designer-demo/package.json (1)

26-33: Ensure CI Runs on Node.js ≥18 and Specify in designer-demo/package.json

Vite v5.4.2 declares

"engines": {
  "node": "^18.0.0 || >=20.0.0"
}

Vitest v3.0.9 declares

"engines": {
  "node": "^18.0.0 || ^20.0.0 || >=22.0.0"
}

(Verified via npm registry)

  • The root package.json enforces only Node >=16, and designer-demo/package.json has no engines field.
  • If your CI runs on Node 16, tests or builds will fail.

Action items:

  • Confirm your CI is running Node.js 18 or above.
  • Add an engines block to designer-demo/package.json to enforce this:
  "devDependencies": {
    "@opentiny/tiny-engine-mock": "workspace:^",
    "@opentiny/tiny-engine-vite-config": "workspace:^",
    "@vitejs/plugin-vue": "^5.1.2",
    "cross-env": "^7.0.3",
    "vite": "^5.4.2",
    "vitest": "3.0.9"
  },
+ "engines": {
+   "node": ">=18"
+ }

This ensures consistency between local development and CI environments.

packages/plugins/i18n/src/composable/tools/updateI18n.ts (1)

41-54: Validation does not enforce “at least one translation”; currently always passes.

The safeParse against optional fields will succeed even when both zh_CN and en_US are absent, allowing a no-op update to return success. Enforce presence of at least one non-empty translation.

Apply this diff to make the check effective and reject empty-string updates:

-    // 验证至少有一个翻译字段
-    const translationValidation = z
-      .object({
-        zh_CN: z.string().optional(),
-        en_US: z.string().optional()
-      })
-      .safeParse(args)
-
-    if (!translationValidation.success) {
-      // 直接返回验证错误,已经符合新的结构化格式
-      return createErrorResponse(
-        'Invalid translation fields',
-        'At least one translation (zh_CN or en_US) must be provided'
-      )
-    }
+    // 验证至少有一个翻译字段(非空)
+    const hasTranslation =
+      (typeof zh_CN === 'string' && zh_CN.trim() !== '') ||
+      (typeof en_US === 'string' && en_US.trim() !== '')
+    if (!hasTranslation) {
+      return createErrorResponse(
+        'Missing translation',
+        'At least one non-empty translation (zh_CN or en_US) must be provided'
+      )
+    }
packages/plugins/i18n/src/composable/tools/getI18n.ts (1)

36-42: Ensure getLangs can’t produce undefined before use

I verified that all i18n composable tools consistently use .shape for both inputSchema and outputSchema (e.g. in addI18n.ts, updateI18n.ts, getI18n.ts, delI18n.ts), so there’s no mismatch to address there. However, it is still possible—albeit unlikely—for useTranslate().getLangs() to return undefined or null, which would lead to runtime errors when doing Object.keys(langs) or indexing into langs[key].

Please apply the following mandatory refactor in both getI18n.ts and delI18n.ts (around the callback’s useTranslate call):

  • packages/plugins/i18n/src/composable/tools/getI18n.ts (lines ~36–42)
  • packages/plugins/i18n/src/composable/tools/delI18n.ts (lines ~33–37)
-      const { getLangs } = useTranslate()
-      const langs = getLangs() as Record<string, any>
+      const { getLangs } = useTranslate()
+      // guard against undefined/null
+      const langs = (getLangs?.() as Record<string, unknown>) ?? {}

This small change ensures you always have a safe default object and prevents potential crashes if getLangs ever returns nothing.

packages/engine-cli/template/designer/public/mock/bundle.json (1)

10521-10558: Typo in parameter name: "selction" should be "selection".

This will leak into generated handler signatures and break code completion/mapping.

                   {
-                      "name": "selction",
+                      "name": "selection",
                       "type": "Array",
                       "defaultValue": "",
                       "description": {
                         "zh_CN": "选中的表格数据数组"
                       }
                   }
packages/plugins/page/src/mcp/tools/getPageDetail.ts (1)

1-86: Ensure consistent ID normalization across all page-related tools

A repo-wide scan for page.id === id comparisons uncovered three call sites that currently perform strict equality checks without any normalization:

  • packages/plugins/page/src/mcp/tools/getPageDetail.ts at line 26
  • packages/plugins/page/src/mcp/tools/delPage.ts at line 24
  • packages/plugins/page/src/mcp/tools/changePageBasicInfo.ts at line 36

Strictly comparing raw page.id and incoming id can lead to subtle bugs if one is a number, a string with extra whitespace, or differently typed. To make these comparisons robust, normalize both operands before comparing. For example:

- const page = allPages.find((page) => page.id === id)
+ const page = allPages.find((page) => String(page.id).trim() === String(id).trim())

Recommended next steps:

  • Apply the above normalization diff at each of the three locations.
  • (Optional) Extract a shared helper for readability and consistency:
    /** Compare two IDs by stringifying and trimming */
    function idsEqual(a: unknown, b: unknown): boolean {
      return String(a).trim() === String(b).trim()
    }
    // Usage
    const page = allPages.find((page) => idsEqual(page.id, id))

These changes will safeguard against type or formatting mismatches across all page-management tools.

packages/plugins/page/src/mcp/tools/editSpecificPage.ts (1)

48-64: Handle switchPage errors and return a structured failure

If switchPage throws (network/state issues), the tool currently leaks an exception. Wrap it and return a consistent error payload with guidance.

-    await switchPage(page.id)
-
-    const res = {
-      status: 'success',
-      message: `Page now can be edited.`,
-      data: {}
-    }
-
-    return {
-      content: [
-        {
-          type: 'text',
-          text: JSON.stringify(res)
-        }
-      ]
-    }
+    try {
+      await switchPage(page.id)
+    } catch (error) {
+      return {
+        content: [
+          {
+            isError: true,
+            type: 'text',
+            text: JSON.stringify({
+              errorCode: 'SWITCH_PAGE_FAILED',
+              reason: error instanceof Error ? error.message : 'Unknown error occurred',
+              userMessage: 'Failed to open the page for editing.',
+              next_action: [
+                {
+                  type: 'tool_call',
+                  name: 'get_page_list',
+                  args: {},
+                  when: 'you want to reselect a valid page to edit'
+                }
+              ]
+            })
+          }
+        ]
+      }
+    }
+
+    const res = {
+      status: 'success',
+      message: `Page now can be edited.`,
+      data: {}
+    }
+
+    return {
+      content: [
+        {
+          type: 'text',
+          text: JSON.stringify(res)
+        }
+      ]
+    }
packages/canvas/DesignCanvas/src/mcp/tools/changeNodeProps.ts (1)

71-78: Wrap operateNode in try/catch to return structured errors

operateNode can throw on invalid state or schema issues. Return a stable MCP error payload instead of bubbling.

-    useCanvas().operateNode({
-      type: 'changeProps',
-      id,
-      value: { props },
-      option: {
-        overwrite
-      }
-    })
+    try {
+      useCanvas().operateNode({
+        type: 'changeProps',
+        id,
+        value: { props },
+        option: {
+          overwrite
+        }
+      })
+    } catch (error) {
+      return {
+        content: [
+          {
+            isError: true,
+            type: 'text',
+            text: JSON.stringify({
+              errorCode: 'CHANGE_PROPS_FAILED',
+              reason: error instanceof Error ? error.message : 'Unknown error occurred',
+              userMessage: `Failed to change props for node: ${id}.`
+            })
+          }
+        ]
+      }
+    }
♻️ Duplicate comments (3)
packages/plugins/tutorial/package.json (1)

32-37: Engines constraint suggestion applies here as well

Same rationale as the help plugin: Vite 5.x implies Node 18+. Consider adding the engines field; if you add it repo-wide, feel free to skip per-package duplication.

packages/plugins/materials/package.json (1)

35-40: Add engines.node ≥18 for Vite 5

Same recommendation as other packages in this release.

packages/settings/props/package.json (1)

34-39: Add engines.node ≥18 for consistency with Vite 5

Recommend adding the engines constraint; track centrally if you prefer.

@chilingling chilingling merged commit 7cce9b6 into develop Aug 27, 2025
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants