Skip to content

Commit 39e3662

Browse files
committed
feat: 多IDE发送支持(Trae/Cursor/Copilot)+Bug归因自查清单
1 parent 6322540 commit 39e3662

1 file changed

Lines changed: 50 additions & 18 deletions

File tree

extension/src/sidebarProvider.ts

Lines changed: 50 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,13 @@ export class SidebarProvider implements vscode.WebviewViewProvider {
429429
"- 无标签:需要你自行判断是应用问题还是蓝本问题",
430430
"- ⚠️ 归因提示:TestPilot AI基于规则的自动推断,供参考,请结合实际源码判断",
431431
"",
432+
"🔍 修复前请先自行判断每个Bug的真实来源,常见蓝本问题误报为[应用Bug]的情况:",
433+
"1. assert_text 断言了 SnackBar/Toast 等瞬态提示(2-3秒消失,Appium来不及检查)→ 改为 screenshot",
434+
"2. accessibility_id 使用了英文缩写(如 btn_login),而非源码 Semantics(label:'xxx') 的实际中文值 → 查源码更新选择器",
435+
"3. XPath[@hint='xxx'] 在 Flutter EditText 中不稳定 → 改用 Semantics label 的 accessibility_id",
436+
"4. 被测APP没有后端/数据库,操作后无持久化反馈 → 断言改为验证UI状态变化(如表单清空、余额数字变化),而非文字提示",
437+
"如果以上任何一条符合,请直接修改蓝本,不要改APP代码。",
438+
"",
432439
);
433440
// 闭环指令:包含蓝本路径,让编程AI能直接调用MCP工具重测
434441
if (blueprintPath) {
@@ -448,28 +455,53 @@ export class SidebarProvider implements vscode.WebviewViewProvider {
448455
private async _handleCopyBugs(report: Record<string, unknown>, blueprintPath: string = ""): Promise<void> {
449456
const bugText = this._formatBugText(report, blueprintPath);
450457

451-
// 尝试直接发送到 Cascade/Copilot 聊天
452-
try {
453-
// Windsurf Cascade
454-
await vscode.commands.executeCommand("windsurf.newCascade", bugText);
455-
vscode.window.showInformationMessage("Bug报告已发送给AI,等待修复");
456-
return;
457-
} catch {
458-
// 不是 Windsurf,尝试其他方式
459-
}
458+
// 按IDE类型依次尝试发送到聊天面板
459+
// 各IDE的 appHost / 扩展 ID 用于检测当前运行环境
460+
const chatCommands: Array<{ name: string; fn: () => Promise<void> }> = [
461+
{
462+
// Windsurf — Cascade 新建对话
463+
name: "Windsurf",
464+
fn: async () => { await vscode.commands.executeCommand("windsurf.newCascade", bugText); },
465+
},
466+
{
467+
// Trae(字节跳动)— 发送到 AI 对话
468+
name: "Trae",
469+
fn: async () => { await vscode.commands.executeCommand("trae.action.newChat", bugText); },
470+
},
471+
{
472+
// Cursor — 打开 Composer/Chat 并填入内容
473+
name: "Cursor",
474+
fn: async () => { await vscode.commands.executeCommand("aichat.newchataction", bugText); },
475+
},
476+
{
477+
// GitHub Copilot Chat(VS Code 原生)
478+
name: "Copilot",
479+
fn: async () => {
480+
await vscode.commands.executeCommand("workbench.action.chat.open", { query: bugText });
481+
},
482+
},
483+
{
484+
// Copilot Chat 旧版命令(VS Code < 1.90)
485+
name: "Copilot(legacy)",
486+
fn: async () => {
487+
await vscode.commands.executeCommand("github.copilot.chat", bugText);
488+
},
489+
},
490+
];
460491

461-
try {
462-
// GitHub Copilot Chat
463-
await vscode.commands.executeCommand("workbench.action.chat.open", { query: bugText });
464-
vscode.window.showInformationMessage("Bug报告已发送到聊天面板");
465-
return;
466-
} catch {
467-
// 没有 Copilot Chat
492+
for (const { name, fn } of chatCommands) {
493+
try {
494+
await fn();
495+
vscode.window.showInformationMessage(`Bug报告已发送到 ${name} AI,等待修复`);
496+
return;
497+
} catch {
498+
// 当前IDE不支持此命令,继续尝试下一个
499+
}
468500
}
469501

470-
// 兜底:复制到剪贴板
502+
// 所有IDE命令均不可用,兜底复制到剪贴板
471503
await vscode.env.clipboard.writeText(bugText);
472-
vscode.window.showInformationMessage("Bug摘要已复制到剪贴板,粘贴到聊天窗口让AI修复");
504+
vscode.window.showInformationMessage("Bug摘要已复制到剪贴板,请粘贴到AI聊天窗口让AI修复");
473505
}
474506

475507
private async _handleScanBlueprints(): Promise<void> {

0 commit comments

Comments
 (0)