fix(bridge): Always run auto-approve now checks buttons array, not just rawCmd (v0.5.58) #task-634
This commit is contained in:
4
extension/package-lock.json
generated
4
extension/package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "gravity-bridge",
|
"name": "gravity-bridge",
|
||||||
"version": "0.5.57",
|
"version": "0.5.58",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "gravity-bridge",
|
"name": "gravity-bridge",
|
||||||
"version": "0.5.57",
|
"version": "0.5.58",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"cheerio": "^1.2.0",
|
"cheerio": "^1.2.0",
|
||||||
"ws": "^8.19.0"
|
"ws": "^8.19.0"
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
"name": "gravity-bridge",
|
"name": "gravity-bridge",
|
||||||
"displayName": "Gravity Bridge",
|
"displayName": "Gravity Bridge",
|
||||||
"description": "Discord-based unified approval system for Antigravity AI interactions.",
|
"description": "Discord-based unified approval system for Antigravity AI interactions.",
|
||||||
"version": "0.5.57",
|
"version": "0.5.58",
|
||||||
"publisher": "variet",
|
"publisher": "variet",
|
||||||
"engines": {
|
"engines": {
|
||||||
"vscode": "^1.100.0"
|
"vscode": "^1.100.0"
|
||||||
|
|||||||
@@ -361,11 +361,22 @@ function _handlePending(req: any, res: any, ctx: HttpBridgeContext) {
|
|||||||
buttons: data.buttons,
|
buttons: data.buttons,
|
||||||
step_index: ctx.lastPendingStepIndex >= 0 ? ctx.lastPendingStepIndex : undefined,
|
step_index: ctx.lastPendingStepIndex >= 0 ? ctx.lastPendingStepIndex : undefined,
|
||||||
};
|
};
|
||||||
// v17: "Always run" auto-approve — click button immediately without Discord roundtrip
|
// v17+: "Always run" auto-approve — click button immediately without Discord roundtrip
|
||||||
// rawCmd is the original button text before enrichment. "Always run" means the user
|
// Check rawCmd first, then fall back to scanning the buttons array
|
||||||
// already trusts this command pattern, so we auto-approve at the bridge level.
|
// (Observer may detect "Run" first while "Always run" is a sibling button)
|
||||||
|
let alwaysRunIndex = -1;
|
||||||
if (/^Always\s+run$/i.test(rawCmd)) {
|
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
|
// Write response file so observer's pollResponseGroup picks it up and clicks the button
|
||||||
const responseDir = path.join(ctx.bridgePath, 'response');
|
const responseDir = path.join(ctx.bridgePath, 'response');
|
||||||
if (!fs.existsSync(responseDir)) {
|
if (!fs.existsSync(responseDir)) {
|
||||||
@@ -374,7 +385,7 @@ function _handlePending(req: any, res: any, ctx: HttpBridgeContext) {
|
|||||||
const respPayload = {
|
const respPayload = {
|
||||||
request_id: rid,
|
request_id: rid,
|
||||||
approved: true,
|
approved: true,
|
||||||
button_index: 0, // "Always run" is always the first button
|
button_index: alwaysRunIndex,
|
||||||
step_type: data.step_type || 'command',
|
step_type: data.step_type || 'command',
|
||||||
project_name: ctx.projectName,
|
project_name: ctx.projectName,
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user