Skip to content

fix(agent): decouple MCP startup and improve console UI#985

Open
lumia1998 wants to merge 1 commit into
ChatLunaLab:v1-devfrom
lumia1998:fix/mcp-startup-and-console-ui
Open

fix(agent): decouple MCP startup and improve console UI#985
lumia1998 wants to merge 1 commit into
ChatLunaLab:v1-devfrom
lumia1998:fix/mcp-startup-and-console-ui

Conversation

@lumia1998

Copy link
Copy Markdown
  1. MCP 启动与 WebUI 解耦:各 MCP Server 改为独立后台连接,慢服务器不再阻塞 Agent 和控制台启动;连接与工具发现使用独立启动超时,并增加连接代次校验、重连清理与 WebSocket 断线期间的刷新排队,避免用户进入 WebUI 或切换页面时等待全部 MCP 完成以及出现刷新失败提示。

  2. MCP 工具界面优化:将 Server 作为一级选择入口,使用紧凑且带连接状态、传输类型、工具数量和选中态的服务器卡片,不再展示 stdio 命令;Tool 区域只显示当前 Server 的工具,点击工具卡片直接进入包含工具名称与描述的设置界面,从而降低工具数量较多时的视觉压力。

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

Changes

MCP 与控制台体验

Layer / File(s) Summary
启动超时配置与表单同步
packages/extension-agent/src/types/mcp.ts, packages/extension-agent/client/components/mcp/mcp-servers-view.vue
新增 startupTimeout 配置,并同步到服务器表单、JSON 预览、配置生成与回填流程。
MCP 连接代际与后台重连
packages/extension-agent/src/service/mcp.ts
连接、工具注册、失败处理和重连改用 generation 校验及后台任务执行。
服务器选择与卡片式管理界面
packages/extension-agent/client/components/mcp/mcp-servers-view.vue
重构服务器与工具面板,新增服务器选择、状态标签、操作菜单、工具过滤和响应式样式。
基于连接状态的控制台刷新
packages/extension-agent/client/components/layout/agent-shell.vue
socket 未就绪时缓存刷新请求,并在连接恢复后串行触发刷新。

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant 控制台
  participant agent-shell.vue
  participant socket
  participant ChatLunaAgentMcpService
  控制台->>agent-shell.vue: 请求刷新控制台数据
  agent-shell.vue->>socket: 检查 readyState
  socket-->>agent-shell.vue: 返回连接状态
  agent-shell.vue->>ChatLunaAgentMcpService: 发送 refreshConsoleData
  ChatLunaAgentMcpService-->>agent-shell.vue: 返回刷新任务
  agent-shell.vue-->>控制台: 等待任务完成并更新状态
Loading

Possibly related PRs

Suggested reviewers: dingyi222666

Poem

小兔挥耳连 MCP,
代际守住旧回声。
卡片排开工具亮,
socket 好了再刷新。
超时写入配置里,
胡萝卜庆功蹦三蹦。

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed 标题准确概括了 MCP 启动解耦和控制台 UI 优化这两项主要变更。
Description check ✅ Passed 描述与变更内容高度一致,分别覆盖了 MCP 启动解耦和工具界面优化。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
packages/extension-agent/client/components/layout/agent-shell.vue (1)

127-127: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

内联这一行连接状态判断。

isConsoleConnected 只有一行且仅在本地调用两次,直接使用 socket.value?.readyState === 1 可减少不必要抽象。

建议修改
-const isConsoleConnected = () => socket.value?.readyState === 1
-
 const refreshData = async () => {
-    if (!isConsoleConnected()) {
+    if (socket.value?.readyState !== 1) {
@@
-            if (!isConsoleConnected()) {
+            if (socket.value?.readyState !== 1) {

As per coding guidelines: Do NOT create extra functions for short logic; if a function body would be 1-5 lines, inline it at the call site instead.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/extension-agent/client/components/layout/agent-shell.vue` at line
127, Remove the single-line isConsoleConnected helper and inline
socket.value?.readyState === 1 directly at both of its local call sites in the
agent shell component, preserving the existing connection-state behavior.

Source: Coding guidelines

packages/extension-agent/src/service/mcp.ts (1)

265-266: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

task 从未被重新赋值,应使用 const

声明与赋值可合并为 const task = (async () => { ... })(),去掉多余的 let 声明行。

As per coding guidelines: "Prefer const over let; use ternaries or early returns instead of reassignment"。同时 CodeFactor 也提示了 prefer-const

♻️ 建议改动
-        let task: Promise<boolean>
-        task = (async () => {
+        const task = (async () => {
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/extension-agent/src/service/mcp.ts` around lines 265 - 266, 将包含异步
IIFE 的 task 声明与赋值合并为单个 const 声明,直接初始化为该 Promise;删除现有多余的 let task
声明,保持其余任务执行逻辑不变。

Sources: Coding guidelines, Linters/SAST tools

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@packages/extension-agent/client/components/layout/agent-shell.vue`:
- Line 127: Remove the single-line isConsoleConnected helper and inline
socket.value?.readyState === 1 directly at both of its local call sites in the
agent shell component, preserving the existing connection-state behavior.

In `@packages/extension-agent/src/service/mcp.ts`:
- Around line 265-266: 将包含异步 IIFE 的 task 声明与赋值合并为单个 const 声明,直接初始化为该
Promise;删除现有多余的 let task 声明,保持其余任务执行逻辑不变。

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 53b1b30c-b34a-4b13-a7b2-2ce54b3a1f8a

📥 Commits

Reviewing files that changed from the base of the PR and between 2b4ce4c and 9b56d6f.

📒 Files selected for processing (4)
  • packages/extension-agent/client/components/layout/agent-shell.vue
  • packages/extension-agent/client/components/mcp/mcp-servers-view.vue
  • packages/extension-agent/src/service/mcp.ts
  • packages/extension-agent/src/types/mcp.ts

@dingyi222666

Copy link
Copy Markdown
Member

明天我看看

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.

2 participants