fix(agent): decouple MCP startup and improve console UI#985
Conversation
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
WalkthroughChangesMCP 与控制台体验
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-->>控制台: 等待任务完成并更新状态
Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
🧹 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
constoverlet; 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
📒 Files selected for processing (4)
packages/extension-agent/client/components/layout/agent-shell.vuepackages/extension-agent/client/components/mcp/mcp-servers-view.vuepackages/extension-agent/src/service/mcp.tspackages/extension-agent/src/types/mcp.ts
|
明天我看看 |
MCP 启动与 WebUI 解耦:各 MCP Server 改为独立后台连接,慢服务器不再阻塞 Agent 和控制台启动;连接与工具发现使用独立启动超时,并增加连接代次校验、重连清理与 WebSocket 断线期间的刷新排队,避免用户进入 WebUI 或切换页面时等待全部 MCP 完成以及出现刷新失败提示。
MCP 工具界面优化:将 Server 作为一级选择入口,使用紧凑且带连接状态、传输类型、工具数量和选中态的服务器卡片,不再展示 stdio 命令;Tool 区域只显示当前 Server 的工具,点击工具卡片直接进入包含工具名称与描述的设置界面,从而降低工具数量较多时的视觉压力。