Skip to content

fix(robot): add the API tab of the MCP and adjust the display control of the robot. #3485

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 6, 2025

Conversation

shenjunjian
Copy link
Collaborator

@shenjunjian shenjunjian commented Jun 6, 2025

PR

fix(robot): 添加MCP 的api 页签,调整robot的显示控制

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)

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:

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

    • Introduced a new MCP documentation tab that displays parameter information for components when available.
    • Added an AI assistant button to the demo style settings popover, visible when the floating robot feature is enabled.
  • Refactor

    • Enhanced the grid component demo to include a city selection dropdown and integrated MCP server/client setup.
    • Updated component documentation views to conditionally show the MCP tab and AI assistant based on route and app state.
  • Bug Fixes

    • Adjusted the rendering conditions for the AI assistant to ensure it only appears when appropriate.
  • Chores

    • Removed AI agent grid demos and related documentation.
    • Updated dependencies to include @vue/shared.
    • Removed the AI agent grid menu entry.
  • Documentation

    • Deleted markdown documentation files related to the AI agent grid.
  • Style

    • Disabled the AI assistant toggle button in the UI.

Copy link

coderabbitai bot commented Jun 6, 2025

Walkthrough

This update removes the AI Agent grid demo, its documentation, and related menu entries. The base grid demo is refactored to integrate a city filter, MCP server/client setup, and removes boolean editing. The UI adapts to show MCP documentation and floating robot controls only for relevant routes, with new components and state properties added to manage these features.

Changes

Files / Groups Change Summary
.../grid/ai-agent/basic-usage.vue
.../grid/ai-agent/basic-usage-composition-api.vue
Deleted AI Agent grid demo components and their composition API variant.
.../grid/webdoc/grid-ai-agent.en.md
.../grid/webdoc/grid-ai-agent.cn.md
Deleted AI Agent grid documentation in English and Chinese.
.../grid/base/basic-usage.vue
.../grid/base/basic-usage-composition-api.vue
Refactored: replaced boolean checkbox editing with city filter dropdown, MCP integration, and updated data model.
.../grid/base/basic-usage.spec.js Commented out a test assertion for a removed row; no logic changes.
.../menus.js Removed 'AI智能体' (AI Agent) menu entry from grid/table menus.
.../package.json Added dependency: "@vue/shared": "^3.4.31".
.../src/router.js Added logic to set appData.hasFloatRobot based on route; imports appData.
.../src/tools/appData.js Added hasFloatRobot boolean property to appData state.
.../src/views/components-doc/common.vue Shows MCP tab and robot chat only if hasFloatRobot is true; imports McpDocs.
.../src/views/components-doc/components/float-settings.vue Adds conditional AI button if hasFloatRobot is true; imports appData and IconAi.
.../src/views/components-doc/components/mcp-docs.vue New component: displays MCP parameter schema in a grid for a given component.
.../src/views/components-doc/tiny-robot-chat.vue Disabled the toggle button for showing the AI assistant by commenting out related code and styles.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant VueApp
    participant Router
    participant appData
    participant MCPServer
    participant MCPClient
    participant SSEProxy

    User->>VueApp: Navigates to grid component
    VueApp->>Router: Route change
    Router->>appData: Set hasFloatRobot (true if grid route)
    alt hasFloatRobot is true
        VueApp->>MCPServer: Initialize server
        VueApp->>MCPClient: Initialize client
        VueApp->>SSEProxy: Connect via SSE, get sessionID
        SSEProxy-->>VueApp: Return sessionID
        VueApp->>MCPServer: Connect server with transport
        VueApp->>UI: Show city filter, MCP tab, robot chat
    else hasFloatRobot is false
        VueApp->>UI: Hide MCP tab and robot chat
    end
Loading

Poem

In the garden of code, the AI grid hops away,
While new city filters bloom in bright array.
The robot floats only where it should appear,
And MCP docs now bring their wisdom near.
With menus trimmed and toggles at rest,
This update leaves our warren neat and blessed!
🐰✨

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

examples/sites/src/views/components-doc/tiny-robot-chat.vue

Oops! Something went wrong! :(

ESLint: 8.57.1

ESLint couldn't find the plugin "eslint-plugin-vue".

(The package "eslint-plugin-vue" was not found when loaded as a Node module from the directory "".)

It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:

npm install eslint-plugin-vue@latest --save-dev

The plugin "eslint-plugin-vue" was referenced from the config file in ".eslintrc.js » @antfu/eslint-config » @antfu/eslint-config-vue".

If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e3c0049 and 1cbece1.

📒 Files selected for processing (1)
  • examples/sites/src/views/components-doc/tiny-robot-chat.vue (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • examples/sites/src/views/components-doc/tiny-robot-chat.vue
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: PR E2E Test (pnpm test:e2e3)

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.
    • Explain this complex logic.
    • 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. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • 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 src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

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

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

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

Documentation and Community

  • 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.

@github-actions github-actions bot added the bug Something isn't working label Jun 6, 2025
border-top-right-radius: 0;
border-bottom-right-radius: 0;
// .tr-toggle {
// position: absolute;
Copy link
Member

Choose a reason for hiding this comment

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

注释的代码要去掉,后面可以用历史记录找到

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

已删除

Copy link

@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: 7

🔭 Outside diff range comments (1)
examples/sites/demos/pc/app/grid/base/basic-usage-composition-api.vue (1)

1-101: ⚠️ Potential issue

Critical: This file is identical to basic-usage.vue

This file is named basic-usage-composition-api.vue but:

  1. It uses Options API instead of Composition API
  2. It's completely identical to basic-usage.vue

This appears to be a copy-paste error during refactoring.

Either:

  1. Refactor this file to actually use Composition API with <script setup> or setup() function
  2. Remove this file if only one implementation is needed

Example Composition API structure:

<script setup>
import { ref, onMounted } from 'vue'
// ... imports

const server = new McpServer({ name: 'base-config', version: '1.0.0' }, {})
const sessionID = ref('')
const queryCity = ref('')
// ... other refs

onMounted(async () => {
  // ... initialization logic
})
</script>
🧹 Nitpick comments (7)
examples/sites/src/views/components-doc/tiny-robot-chat.vue (1)

42-48: Consider removing commented code instead of leaving it in place.

While the functionality is correct, leaving large blocks of commented code can lead to maintenance overhead and confusion. If this toggle button is no longer needed, consider removing it entirely rather than commenting it out.

If you plan to restore this functionality later, consider using a feature flag or documenting the intention:

-  <!-- <div class="tr-toggle" v-if="!appData.showTinyRobot" title="AI智能助手" @click="appData.showTinyRobot = true">
+  <!-- TODO: Restore toggle button functionality if needed
+  <div class="tr-toggle" v-if="!appData.showTinyRobot" title="AI智能助手" @click="appData.showTinyRobot = true">

Also applies to: 134-157

examples/sites/src/router.js (1)

61-62: Consider making the route check more flexible.

The logic correctly updates the hasFloatRobot flag based on the route, but the hard-coded string 'components/grid' could be brittle if route structures change.

Consider extracting the route pattern to a constant:

+const ROBOT_ENABLED_ROUTES = ['components/grid']

// tiny-robot 通过路由,确定浮动区,是否显示AI按钮
-appData.hasFloatRobot = to.path.endsWith('components/grid')
+appData.hasFloatRobot = ROBOT_ENABLED_ROUTES.some(route => to.path.endsWith(route))
examples/sites/src/views/components-doc/components/mcp-docs.vue (3)

42-42: Remove empty onMounted hook.

The empty onMounted(() => {}) hook serves no purpose and should be removed to keep the code clean.

-onMounted(() => {})

20-22: Add prop validation for better type safety.

Consider adding validation to ensure the name prop is provided since the component depends on it.

const props = defineProps({
-  name: String
+  name: {
+    type: String,
+    required: true
+  }
})

24-24: Add error handling for MCP configuration loading.

Consider wrapping the getTinyVueMcpConfig call in a try-catch block to handle potential errors gracefully.

+let mcpTools
+try {
-const mcpTools = getTinyVueMcpConfig({ t: null })
+  mcpTools = getTinyVueMcpConfig({ t: null })
+} catch (error) {
+  console.warn('Failed to load MCP configuration:', error)
+  mcpTools = { components: {} }
+}
examples/sites/src/views/components-doc/components/float-settings.vue (1)

62-77: Consider the button layout and spacing consistency.

The new button structure creates a wrapper div that contains both the AI button and the style settings button. Ensure this doesn't affect the intended layout or spacing.

You might want to add specific styling for the button container to maintain consistent spacing:

  <template #reference>
    <div>
+     <div class="settings-buttons-container">
        <div
          v-if="appData.hasFloatRobot"
          class="settings-btn style-settings-btn"
          @click="appData.showTinyRobot = true"
        >
          <IconAi class="settings-icon style-settings-icon"></IconAi>
        </div>
        <div
          class="settings-btn style-settings-btn"
          @click="demoStyleVisible = !demoStyleVisible"
          @blur="demoStyleVisible = false"
        >
          <style-settings-icon class="settings-icon style-settings-icon"></style-settings-icon>
        </div>
+     </div>
    </div>
  </template>

And add corresponding CSS:

.settings-buttons-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
examples/sites/demos/pc/app/grid/base/basic-usage.vue (1)

82-82: Replace numbered comments with descriptive ones.

The comments // 1、, // 2、, // 3、 are not descriptive and don't help understand the code flow.

-    // 1、
+    // Create transport pair for client-server communication
     const [transport, clientTransport] = createTransportPair()

-    // 2、
+    // Initialize client and establish SSE proxy connection
     const client = new Client({ name: 'ai-agent', version: '1.0.0' }, {})

-    // 3、
+    // Connect MCP server to transport
     await this.server.connect(transport)

Also applies to: 85-85, 96-96

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7045fa1 and e3c0049.

📒 Files selected for processing (15)
  • examples/sites/demos/pc/app/grid/ai-agent/basic-usage-composition-api.vue (0 hunks)
  • examples/sites/demos/pc/app/grid/ai-agent/basic-usage.vue (0 hunks)
  • examples/sites/demos/pc/app/grid/base/basic-usage-composition-api.vue (1 hunks)
  • examples/sites/demos/pc/app/grid/base/basic-usage.spec.js (1 hunks)
  • examples/sites/demos/pc/app/grid/base/basic-usage.vue (1 hunks)
  • examples/sites/demos/pc/app/grid/webdoc/grid-ai-agent.cn.md (0 hunks)
  • examples/sites/demos/pc/app/grid/webdoc/grid-ai-agent.en.md (0 hunks)
  • examples/sites/demos/pc/menus.js (0 hunks)
  • examples/sites/package.json (1 hunks)
  • examples/sites/src/router.js (2 hunks)
  • examples/sites/src/tools/appData.js (1 hunks)
  • examples/sites/src/views/components-doc/common.vue (5 hunks)
  • examples/sites/src/views/components-doc/components/float-settings.vue (4 hunks)
  • examples/sites/src/views/components-doc/components/mcp-docs.vue (1 hunks)
  • examples/sites/src/views/components-doc/tiny-robot-chat.vue (2 hunks)
💤 Files with no reviewable changes (5)
  • examples/sites/demos/pc/app/grid/webdoc/grid-ai-agent.en.md
  • examples/sites/demos/pc/menus.js
  • examples/sites/demos/pc/app/grid/webdoc/grid-ai-agent.cn.md
  • examples/sites/demos/pc/app/grid/ai-agent/basic-usage.vue
  • examples/sites/demos/pc/app/grid/ai-agent/basic-usage-composition-api.vue
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: PR E2E Test (pnpm test:e2e3)
🔇 Additional comments (6)
examples/sites/src/tools/appData.js (1)

13-13: LGTM! Property addition follows existing patterns.

The new hasFloatRobot boolean property is correctly added to the reactive appData object and follows the same pattern as existing properties.

examples/sites/src/router.js (1)

4-4: LGTM! Import is correctly added.

The appData import is properly added and will be used in the router logic.

examples/sites/src/views/components-doc/common.vue (3)

91-91: Good logical improvement for robot chat visibility.

The updated condition ensures the robot chat only appears when both conditions are met, which aligns well with the broader feature integration.


178-181: Good practice: Defer footer rendering to nextTick.

Moving the footer rendering inside nextTick ensures the DOM is fully ready before rendering, which is a best practice.


65-67:

✅ Verification successful

Verify the McpDocs component exists and add prop validation.

The new MCP tab conditionally renders the McpDocs component, but there's no guarantee this component exists or handles the name prop correctly.


🏁 Script executed:

#!/bin/bash
# Description: Verify that McpDocs component exists and check its prop definitions
# Expected: Component file exists and accepts 'name' prop

# Check if McpDocs component file exists
fd -t f "mcp-docs.vue" examples/sites/src/views/components-doc/components/

# Look for prop definitions in the component
if [ -f "examples/sites/src/views/components-doc/components/mcp-docs.vue" ]; then
  echo "=== McpDocs component prop definitions ==="
  rg -A 10 -B 2 "props|defineProps" examples/sites/src/views/components-doc/components/mcp-docs.vue
fi

Length of output: 941


McpDocs component exists and correctly defines name prop

The examples/sites/src/views/components-doc/components/mcp-docs.vue file uses:

  • defineProps({ name: String })

which matches the usage in the new MCP tab. No further prop validation or changes are needed.

examples/sites/package.json (1)

59-59: Dependency addition looks good.

The addition of @vue/shared aligns with the existing Vue version and supports the MCP integration features.

Comment on lines +27 to +40
const mcpInfo = computed(() => {
const schema = mcpTools.components[capName.value]?.paramsSchema
if (schema) {
return Object.keys(schema).map((name) => {
const item = schema[name]
return {
name,
param: item._def?.innerType?._def?.typeName || '',
desc: item._def?.description || ''
}
})
}
return null
})
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Improve error handling and null safety.

The current implementation has several potential issues:

  1. Deep property access without null checking could cause runtime errors
  2. No error handling if getTinyVueMcpConfig fails
  3. The logic assumes a specific schema structure
const mcpInfo = computed(() => {
+  if (!capName.value || !mcpTools?.components) {
+    return []
+  }
+  
  const schema = mcpTools.components[capName.value]?.paramsSchema
  if (schema) {
    return Object.keys(schema).map((name) => {
      const item = schema[name]
      return {
        name,
-        param: item._def?.innerType?._def?.typeName || '',
-        desc: item._def?.description || ''
+        param: item?._def?.innerType?._def?.typeName || item?._def?.typeName || 'unknown',
+        desc: item?._def?.description || 'No description available'
      }
    })
  }
-  return null
+  return []
})
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const mcpInfo = computed(() => {
const schema = mcpTools.components[capName.value]?.paramsSchema
if (schema) {
return Object.keys(schema).map((name) => {
const item = schema[name]
return {
name,
param: item._def?.innerType?._def?.typeName || '',
desc: item._def?.description || ''
}
})
}
return null
})
const mcpInfo = computed(() => {
// Early guard for missing capName or components
if (!capName.value || !mcpTools?.components) {
return []
}
const schema = mcpTools.components[capName.value]?.paramsSchema
if (schema) {
return Object.keys(schema).map((name) => {
const item = schema[name]
return {
name,
param: item?._def?.innerType?._def?.typeName
|| item?._def?.typeName
|| 'unknown',
desc: item?._def?.description
|| 'No description available'
}
})
}
return []
})
🤖 Prompt for AI Agents
In examples/sites/src/views/components-doc/components/mcp-docs.vue around lines
27 to 40, improve null safety by adding checks before accessing deep nested
properties like _def and innerType to avoid runtime errors. Wrap the logic in a
try-catch block to handle potential errors from getTinyVueMcpConfig or other
calls gracefully. Also, add validation to confirm the schema structure matches
expectations before processing it, returning null or a safe default if not.

Comment on lines +64 to +69
v-if="appData.hasFloatRobot"
class="settings-btn style-settings-btn"
@click="appData.showTinyRobot = true"
>
<IconAi class="settings-icon style-settings-icon"></IconAi>
</div>
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Avoid direct state mutation in template and add accessibility attributes.

The button directly mutates appData.showTinyRobot in the template, which is not a best practice. Also, the button lacks accessibility attributes.

  <div
    v-if="appData.hasFloatRobot"
    class="settings-btn style-settings-btn"
-   @click="appData.showTinyRobot = true"
+   @click="showRobot"
+   :title="i18nByKey('showAIAssistant')"
+   aria-label="Show AI Assistant"
  >
    <IconAi class="settings-icon style-settings-icon"></IconAi>
  </div>

Add the method to the setup function:

const funcs = {
  showRobot() {
    appData.showTinyRobot = true
  },
  // ... existing methods
}
🤖 Prompt for AI Agents
In examples/sites/src/views/components-doc/components/float-settings.vue around
lines 64 to 69, avoid directly mutating the reactive state appData.showTinyRobot
in the template. Instead, create a method named showRobot inside the setup
function that sets appData.showTinyRobot to true, and call this method on the
button's click event. Additionally, add appropriate accessibility attributes
such as aria-label or role to the button element to improve accessibility.

import { router } from '@/router'
import useStyleSettings from '@/tools/useStyleSettings'
import { IconAi } from '@opentiny/tiny-robot-svgs'
Copy link

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Verify the IconAi import path and component availability.

Ensure the IconAi component is available from the specified package.


🏁 Script executed:

#!/bin/bash
# Description: Verify IconAi component exists in the specified package
# Expected: IconAi should be available from @opentiny/tiny-robot-svgs

# Check if the package is installed and contains IconAi
if [ -f "package.json" ]; then
  echo "=== Checking if @opentiny/tiny-robot-svgs package is installed ==="
  jq '.dependencies["@opentiny/tiny-robot-svgs"], .devDependencies["@opentiny/tiny-robot-svgs"]' package.json
fi

# Search for IconAi usage in other files to verify the import pattern
echo "=== Other IconAi imports in the codebase ==="
rg -B 2 -A 2 "IconAi.*@opentiny/tiny-robot-svgs"

Length of output: 1651


Fix missing @opentiny/tiny-robot-svgs dependency

The import in
examples/sites/src/views/components-doc/components/float-settings.vue (line 107):

import { IconAi } from '@opentiny/tiny-robot-svgs'

will fail because @opentiny/tiny-robot-svgs is not listed in your package.json. To address this:

  • Add @opentiny/tiny-robot-svgs to your dependencies (e.g. run npm install @opentiny/tiny-robot-svgs --save).
  • Confirm that IconAi is indeed exported by that package (inspect its entry point in node_modules/@opentiny/tiny-robot-svgs).

This will ensure both your examples and any other imports (e.g. in useTinyRobot.ts) resolve correctly.

🤖 Prompt for AI Agents
In examples/sites/src/views/components-doc/components/float-settings.vue at line
107, the import of IconAi from '@opentiny/tiny-robot-svgs' will fail because the
package is not listed in package.json dependencies. Fix this by adding
'@opentiny/tiny-robot-svgs' to your dependencies using npm or yarn (e.g., npm
install @opentiny/tiny-robot-svgs --save). Also verify that IconAi is exported
by this package by checking its entry point in node_modules. This ensures the
import resolves correctly.

@@ -4,5 +4,5 @@ test('标签式表格', async ({ page }) => {
page.on('pageerror', (exception) => expect(exception).toBeNull())
await page.goto('grid#base-basic-usage')

await expect(page.getByRole('row', { name: '1 800 2014-04-30 00:56:00 福州' })).toBeVisible()
// await expect(page.getByRole('row', { name: '1 800 2014-04-30 00:56:00 福州' })).toBeVisible()
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Update or remove the test instead of commenting it out.

Instead of commenting out the assertion, either:

  1. Update it to test the new grid structure with company information
  2. Remove it entirely if this test is no longer applicable

Apply this diff to update the test to match the new data structure:

-  // await expect(page.getByRole('row', { name: '1 800 2014-04-30 00:56:00 福州' })).toBeVisible()
+  await expect(page.getByRole('row', { name: /GFD 有限责任公司.*广州.*800.*2014-04-30/ })).toBeVisible()
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// await expect(page.getByRole('row', { name: '1 800 2014-04-30 00:56:00 福州' })).toBeVisible()
await expect(page.getByRole('row', { name: /GFD .*广.*800.*2014-04-30/ })).toBeVisible()
🤖 Prompt for AI Agents
In examples/sites/demos/pc/app/grid/base/basic-usage.spec.js at line 7, the test
assertion is commented out instead of being updated or removed. Review the
current grid structure and either update the expect statement to match the new
company information format or remove the test if it no longer applies. Replace
the commented line with a valid assertion reflecting the new data or delete it
entirely.

await client.connect(clientTransport)
const { sessionId } = await createSseProxy({
client,
url: 'https://39.108.160.245/sse'
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Move hardcoded URL to configuration.

The hardcoded SSE proxy URL 'https://39.108.160.245/sse' should be externalized for better maintainability and security.

Consider moving this URL to an environment variable or configuration file. This allows different URLs for development, staging, and production environments.

🤖 Prompt for AI Agents
In examples/sites/demos/pc/app/grid/base/basic-usage.vue at line 90, the SSE
proxy URL is hardcoded as 'https://39.108.160.245/sse'. To improve
maintainability and security, move this URL to a configuration source such as an
environment variable or a config file. Replace the hardcoded string with a
reference to this external configuration so that different environments can use
different URLs without code changes.

const [transport, clientTransport] = createTransportPair()

// 2、
const client = new Client({ name: 'ai-agent', version: '1.0.0' }, {})
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Update the client name to match the component context.

The client name 'ai-agent' is misleading since this is a base example, not an AI agent demo.

-    const client = new Client({ name: 'ai-agent', version: '1.0.0' }, {})
+    const client = new Client({ name: 'grid-base-example', version: '1.0.0' }, {})
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const client = new Client({ name: 'ai-agent', version: '1.0.0' }, {})
const client = new Client({ name: 'grid-base-example', version: '1.0.0' }, {})
🤖 Prompt for AI Agents
In examples/sites/demos/pc/app/grid/base/basic-usage.vue at line 86, update the
client name from 'ai-agent' to a name that reflects the base example context,
such as 'basic-usage-client', to accurately represent the component's purpose.

Comment on lines +81 to 98
async mounted() {
// 1、
const [transport, clientTransport] = createTransportPair()

// 2、
const client = new Client({ name: 'ai-agent', version: '1.0.0' }, {})
await client.connect(clientTransport)
const { sessionId } = await createSseProxy({
client,
url: 'https://39.108.160.245/sse'
})

this.sessionID = sessionId
window.$sessionId = this.sessionID

// 3、
await this.server.connect(transport)
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Add error handling for async operations in mounted().

The async operations in mounted() lack error handling. Network failures or connection issues could cause unhandled promise rejections.

Wrap the async operations in a try-catch block:

 async mounted() {
+  try {
     // 1、
     const [transport, clientTransport] = createTransportPair()

     // 2、
     const client = new Client({ name: 'ai-agent', version: '1.0.0' }, {})
     await client.connect(clientTransport)
     const { sessionId } = await createSseProxy({
       client,
       url: 'https://39.108.160.245/sse'
     })

     this.sessionID = sessionId
     window.$sessionId = this.sessionID

     // 3、
     await this.server.connect(transport)
+  } catch (error) {
+    console.error('Failed to initialize MCP connection:', error)
+    // Consider showing user-friendly error message
+  }
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
async mounted() {
// 1、
const [transport, clientTransport] = createTransportPair()
// 2、
const client = new Client({ name: 'ai-agent', version: '1.0.0' }, {})
await client.connect(clientTransport)
const { sessionId } = await createSseProxy({
client,
url: 'https://39.108.160.245/sse'
})
this.sessionID = sessionId
window.$sessionId = this.sessionID
// 3、
await this.server.connect(transport)
}
async mounted() {
try {
// 1、
const [transport, clientTransport] = createTransportPair()
// 2、
const client = new Client({ name: 'ai-agent', version: '1.0.0' }, {})
await client.connect(clientTransport)
const { sessionId } = await createSseProxy({
client,
url: 'https://39.108.160.245/sse'
})
this.sessionID = sessionId
window.$sessionId = this.sessionID
// 3、
await this.server.connect(transport)
} catch (error) {
console.error('Failed to initialize MCP connection:', error)
// Consider showing user-friendly error message
}
}
🤖 Prompt for AI Agents
In examples/sites/demos/pc/app/grid/base/basic-usage.vue around lines 81 to 98,
the async operations in the mounted() lifecycle method lack error handling,
which can lead to unhandled promise rejections on network or connection
failures. Wrap the entire async code inside mounted() in a try-catch block to
catch and handle any errors that occur during the creation of transports, client
connection, SSE proxy creation, and server connection. In the catch block, log
or handle the error appropriately to ensure the app remains stable.

@zzcr zzcr merged commit 35a0210 into dev Jun 6, 2025
9 of 10 checks passed
@zzcr zzcr deleted the shen/update-site-robot-6.6 branch June 6, 2025 09:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants