diff --git a/extension/package-lock.json b/extension/package-lock.json index 0b126fd..2af6c18 100644 --- a/extension/package-lock.json +++ b/extension/package-lock.json @@ -1,12 +1,12 @@ { "name": "gravity-bridge", - "version": "0.5.57", + "version": "0.5.58", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "gravity-bridge", - "version": "0.5.57", + "version": "0.5.58", "dependencies": { "cheerio": "^1.2.0", "ws": "^8.19.0" diff --git a/extension/package.json b/extension/package.json index 3f8914b..42fbd55 100644 --- a/extension/package.json +++ b/extension/package.json @@ -2,7 +2,7 @@ "name": "gravity-bridge", "displayName": "Gravity Bridge", "description": "Discord-based unified approval system for Antigravity AI interactions.", - "version": "0.5.57", + "version": "0.5.58", "publisher": "variet", "engines": { "vscode": "^1.100.0" diff --git a/extension/src/http-bridge.ts b/extension/src/http-bridge.ts index ec18cfe..036adb8 100644 --- a/extension/src/http-bridge.ts +++ b/extension/src/http-bridge.ts @@ -361,11 +361,22 @@ function _handlePending(req: any, res: any, ctx: HttpBridgeContext) { buttons: data.buttons, step_index: ctx.lastPendingStepIndex >= 0 ? ctx.lastPendingStepIndex : undefined, }; - // v17: "Always run" auto-approve — click button immediately without Discord roundtrip - // rawCmd is the original button text before enrichment. "Always run" means the user - // already trusts this command pattern, so we auto-approve at the bridge level. + // v17+: "Always run" auto-approve — click button immediately without Discord roundtrip + // Check rawCmd first, then fall back to scanning the buttons array + // (Observer may detect "Run" first while "Always run" is a sibling button) + let alwaysRunIndex = -1; if (/^Always\s+run$/i.test(rawCmd)) { - ctx.logToFile(`[HTTP] AUTO-APPROVE "Always run": enriched="${enrichedCmd.substring(0, 80)}"`); + alwaysRunIndex = 0; + } else if (Array.isArray(data.buttons)) { + for (let bi = 0; bi < data.buttons.length; bi++) { + if (/^Always\s+run$/i.test((data.buttons[bi].text || '').trim())) { + alwaysRunIndex = bi; + break; + } + } + } + if (alwaysRunIndex >= 0) { + ctx.logToFile(`[HTTP] AUTO-APPROVE "Always run" (btnIdx=${alwaysRunIndex}): enriched="${enrichedCmd.substring(0, 80)}"`); // Write response file so observer's pollResponseGroup picks it up and clicks the button const responseDir = path.join(ctx.bridgePath, 'response'); if (!fs.existsSync(responseDir)) { @@ -374,7 +385,7 @@ function _handlePending(req: any, res: any, ctx: HttpBridgeContext) { const respPayload = { request_id: rid, approved: true, - button_index: 0, // "Always run" is always the first button + button_index: alwaysRunIndex, step_type: data.step_type || 'command', project_name: ctx.projectName, };