Skip to content

feat(settings): add Playwright MCP config and improve CDP layout#1979

Merged
kaizhou-lab merged 2 commits intomainfrom
zk/feat/playwright-mcp-config
Mar 31, 2026
Merged

feat(settings): add Playwright MCP config and improve CDP layout#1979
kaizhou-lab merged 2 commits intomainfrom
zk/feat/playwright-mcp-config

Conversation

@kaizhou-lab
Copy link
Copy Markdown
Collaborator

Summary

  • Add Playwright MCP configuration (@playwright/mcp@latest --cdp-endpoint) alongside existing chrome-devtools config in CDP settings
  • Improve CDP settings layout: separate DevTools toggle into its own card, use collapsible panels for MCP configs, hide port/config when CDP is disabled
  • Fix copy icon rendering (replace missing i-carbon:copy with @icon-park/react Copy component), align current port row with other settings

Test plan

  • bunx tsc --noEmit passes
  • bun run lint passes (0 errors)
  • bun run i18n:types && node scripts/check-i18n.js passes
  • SystemModalContent.dom.test.tsx — 14 tests pass including new tests for:
    • Playwright MCP config displayed alongside chrome-devtools
    • Port and MCP config hidden when CDP is disabled
  • Manual: toggle CDP switch off → port and MCP configs disappear
  • Manual: click collapse arrow → JSON config expands/collapses
  • Manual: click copy button → config copied without triggering collapse

…yout

- Add Playwright MCP configuration with --cdp-endpoint in CDP settings
- Separate DevTools toggle and CDP section into independent cards
- Use collapsible panels for MCP configs (chrome-devtools + playwright)
- Hide port and MCP config when CDP remote debugging is disabled
- Fix copy icon using @icon-park/react Copy component
- Align current port section with other settings rows
- Add i18n keys for Playwright MCP config across all 6 locales
- Update SystemModalContent tests for new layout and Playwright config
@piorpua piorpua added the bot:reviewing Review in progress (mutex) label Mar 31, 2026
@piorpua
Copy link
Copy Markdown
Contributor

piorpua commented Mar 31, 2026

Code Review:feat(settings): add Playwright MCP config and improve CDP layout (#1979)

变更概述

本 PR 实际包含多个独立特性和修复,远超标题所述范围:(1) CDP 设置页新增 Playwright MCP 配置和折叠面板布局;(2) 新增 inline thinking 消息类型,将 thought 事件转换为可展开的思考过程显示;(3) CodeBlock 组件重构为默认折叠(3 行预览)模式;(4) Markdown 组件 memoize 优化;(5) 多处 bug 修复(序列化防护、Codex 启动信号退出、会话创建并发守卫、Linux headless 强制启用等)。涉及 process、renderer、common 三个进程层共 57 个文件。


方案评估

结论⚠️ 方案有缺陷

PR 涵盖了多个不相关的特性和修复,ideally 应拆分为独立 PR 以降低 review 难度和回滚风险。但各项改动的实现方案总体合理:thinking 消息系统正确使用了 msg_id 合并和 DB 持久化;CodeBlock 折叠状态使用模块级 Map 持久化避免流式更新重建丢失状态;序列化防护提前捕获 JSON.stringify 异常。有一处残留的 JSDoc 注释需清理,CodeBlock 的指纹碰撞可能导致不同代码块共享展开状态。


问题清单

🟡 MEDIUM — AcpAgentManager 残留的旧方法 JSDoc 注释

文件src/process/task/AcpAgentManager.ts,第 811–817 行

问题代码

  /**
   * Filter think tags from message content during streaming
   * This ensures users don't see internal reasoning tags in real-time
   *
   * @param message - The streaming message to filter
   * @returns Message with think tags removed from content
   */
  /**
   * Emit a thinking message to the UI stream.
   * Creates a new thinking msg_id on first call per turn, reuses it for subsequent calls.
   */
  private emitThinkingMessage(...)

问题说明filterThinkTagsFromMessage 方法已被移除,但其 JSDoc 注释遗留在新方法 emitThinkingMessage 上方,两个 JSDoc 块叠在一起,产生误导。

修复建议

  /**
   * Emit a thinking message to the UI stream.
   * Creates a new thinking msg_id on first call per turn, reuses it for subsequent calls.
   */
  private emitThinkingMessage(...)

🟡 MEDIUM — CodeBlock 指纹碰撞导致不同代码块共享展开/折叠状态

文件src/renderer/components/Markdown/CodeBlock.tsx,第 28–36 行

问题代码

function getBlockFingerprint(language: string, firstLine: string): string {
  const key = `${language}:${firstLine}`;
  ...
  return key;
}

问题说明:指纹仅由 language + 第一行 组成。当同一对话中存在多个相同语言、相同首行的代码块(如多个 ts:import React from 'react')时,它们会共享展开/折叠状态。用户展开一个代码块可能导致其他具有相同指纹的代码块也被标记为展开。

修复建议:在指纹中加入更多区分信息,例如代码块的前几行内容或行数:

function getBlockFingerprint(language: string, lines: string[]): string {
  const preview = lines.slice(0, PREVIEW_LINES).join('\n');
  const key = `${language}:${lines.length}:${preview}`;
  ...
  return key;
}

🔵 LOW — increaseViewportBy 从 200 增加到 800 可能增加大量消息的内存压力

文件src/renderer/pages/conversation/Messages/MessageList.tsx,第 358 行

问题代码

increaseViewportBy={800}

问题说明:Virtuoso 的 increaseViewportBy 从 200 增至 800,意味着视口外将多渲染约 600px 的消息项。对于包含大量代码块或思考消息的长对话,这会增加 DOM 节点数和内存占用。这个改动可能是为了解决滚动平滑度问题,但 trade-off 值得关注。


🔵 LOW — PR 包含多个不相关特性,建议未来拆分

本 PR 包含至少 5 个独立的改动主题(CDP 设置、thinking 消息、CodeBlock 折叠、Markdown 优化、多处 bug 修复)。虽然各项改动质量良好,但混合在一起增加了 review 难度和回滚风险。建议后续保持单一职责的 PR 粒度。


汇总

# 严重级别 文件 问题
1 🟡 MEDIUM AcpAgentManager.ts:811 残留的旧方法 JSDoc 注释
2 🟡 MEDIUM CodeBlock.tsx:28 指纹碰撞导致代码块共享展开状态
3 🔵 LOW MessageList.tsx:358 increaseViewportBy 增大的内存影响
4 🔵 LOW PR 包含多个不相关特性

结论

⚠️ 有条件批准 — 存在两个 MEDIUM 级别问题(残留 JSDoc、CodeBlock 指纹碰撞),处理后可合并。其余改动实现合理,测试覆盖充分,i18n 完整。


本报告由本地 pr-review skill 生成,包含完整项目上下文,无截断限制。

CONCLUSION: CONDITIONAL
IS_CRITICAL_PATH: false
PR_NUMBER: 1979

@piorpua piorpua added bot:ready-to-fix CONDITIONAL review done, waiting for bot fix bot:fixing Fix in progress (mutex) and removed bot:reviewing Review in progress (mutex) bot:ready-to-fix CONDITIONAL review done, waiting for bot fix labels Mar 31, 2026
- Remove stale JSDoc comment for deleted filterThinkTagsFromMessage method
- Improve CodeBlock fingerprint to include line count and preview content,
  preventing different code blocks with same language and first line from
  sharing expanded/collapsed state

Review follow-up for #1979
@piorpua
Copy link
Copy Markdown
Contributor

piorpua commented Mar 31, 2026

PR Fix 验证报告

原始 PR: #1979
修复方式: 直接推送到 zk/feat/playwright-mcp-config

# 严重级别 文件 问题 修复方式 状态
1 🟡 MEDIUM AcpAgentManager.ts:811 残留的旧方法 JSDoc 注释 删除已移除方法 filterThinkTagsFromMessage 的遗留 JSDoc 块 ✅ 已修复
2 🟡 MEDIUM CodeBlock.tsx:28 指纹碰撞导致代码块共享展开状态 指纹改为包含行数和前 3 行预览内容 (language:lineCount:preview) ✅ 已修复

总结: ✅ 已修复 2 个 | ❌ 未能修复 0 个

🔵 LOW 级别问题已跳过(不阻塞合并,修复优先级低)。

@piorpua piorpua added bot:ready-to-merge Bot done, code is clean — human just needs to confirm and merge and removed bot:fixing Fix in progress (mutex) labels Mar 31, 2026
@kaizhou-lab kaizhou-lab merged commit 40c63ef into main Mar 31, 2026
17 checks passed
@kaizhou-lab kaizhou-lab deleted the zk/feat/playwright-mcp-config branch March 31, 2026 07:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot:ready-to-merge Bot done, code is clean — human just needs to confirm and merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants