fix(bridge): Always run auto-approve now checks buttons array, not just rawCmd (v0.5.58) #task-634

This commit is contained in:
Variet Worker
2026-04-18 06:35:01 +09:00
parent 7a1675fd5d
commit c7f939ce85
3 changed files with 19 additions and 8 deletions

View File

@@ -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"

View File

@@ -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"

View File

@@ -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,
};