Skip to content

Commit 30867de

Browse files
committed
fix: add onStartupFinished activation event to ensure plugin activates on VS Code startup
- Without this, plugin only activated when sidebar was rendered - This caused autoInjectOnActivate to never run if sidebar wasn't opened - Also added detailed logging to autoInjectOnActivate for debugging
1 parent 052bbed commit 30867de

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

extension/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"repair"
2020
],
2121
"icon": "resources/icon.png",
22-
"activationEvents": [],
22+
"activationEvents": ["onStartupFinished"],
2323
"main": "./out/extension.js",
2424
"contributes": {
2525
"viewsContainers": {

extension/src/rulesInjector.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -379,11 +379,18 @@ export async function autoInjectOnActivate(
379379
outputChannel?: vscode.OutputChannel,
380380
extensionPath = "",
381381
): Promise<void> {
382+
outputChannel?.appendLine(`[TestPilot AI] autoInjectOnActivate 启动, extensionPath=${extensionPath}`);
382383
const folders = vscode.workspace.workspaceFolders;
383-
if (!folders) { return; }
384+
if (!folders) {
385+
outputChannel?.appendLine(`[TestPilot AI] 没有工作区文件夹,跳过`);
386+
return;
387+
}
388+
389+
outputChannel?.appendLine(`[TestPilot AI] 发现 ${folders.length} 个工作区文件夹`);
384390

385391
for (const folder of folders) {
386392
const root = folder.uri.fsPath;
393+
outputChannel?.appendLine(`[TestPilot AI] 检查文件夹: ${folder.name} (${root})`);
387394

388395
// 跳过 TestPilotAI 项目本身(我们自己的项目已有规则)
389396
if (fs.existsSync(path.join(root, "cli.py")) && fs.existsSync(path.join(root, "src", "app.py"))) {
@@ -392,7 +399,9 @@ export async function autoInjectOnActivate(
392399
}
393400

394401
// 检查是否需要注入
395-
if (needsInjection(root)) {
402+
const needs = needsInjection(root);
403+
outputChannel?.appendLine(`[TestPilot AI] ${folder.name} needsInjection=${needs}`);
404+
if (needs) {
396405
outputChannel?.appendLine(`[TestPilot AI] 检测到 ${folder.name} 没有蓝本规则,自动注入中...`);
397406
const result = injectRules(root, outputChannel, false, extensionPath);
398407

0 commit comments

Comments
 (0)