fix(extension): acknowledgeCodeActionStep RPC discovery + v0.3.14 3-tier strategy
This commit is contained in:
@@ -2597,8 +2597,10 @@ async function processResponseFile(filePath: string) {
|
||||
const targetSession = sessionId || activeSessionId;
|
||||
let modifiedFiles: string[] = []; // shared between Strategy 1 and 2
|
||||
|
||||
// ── Strategy 1: AcknowledgeCascadeCodeEdit RPC ──
|
||||
// Accept/reject all pending code edits via protocol (no UI interaction needed)
|
||||
// ── Strategy 1: acknowledgeCodeActionStep RPC (correct AG LS method) ──
|
||||
// Discovered via AG source reverse-engineering: the internal LS method is
|
||||
// `acknowledgeCodeActionStep` (proto ID 167), NOT `AcknowledgeCascadeCodeEdit`.
|
||||
// Accept all button → fireEvent({type:"accept-all-in-file"}) → submitCodeAcknowledgement → acknowledgeCodeActionStep
|
||||
if (sdk) {
|
||||
try {
|
||||
// Get tracked step indices from in-memory cache FIRST (pending file may be deleted by Collector)
|
||||
@@ -2627,62 +2629,48 @@ async function processResponseFile(filePath: string) {
|
||||
trackedSteps.push(pendingStepIndex);
|
||||
}
|
||||
|
||||
logToFile(`[DIFF-REVIEW-RPC] AcknowledgeCascadeCodeEdit(session=${targetSession.substring(0, 8)}, accept=${isAccept}, steps=[${trackedSteps.join(',')}])`);
|
||||
logToFile(`[DIFF-REVIEW-RPC] acknowledgeCodeActionStep(session=${targetSession.substring(0, 8)}, accept=${isAccept}, steps=[${trackedSteps.join(',')}])`);
|
||||
|
||||
// ── EXPERIMENT: Try multiple parameter formats to find what AG expects ──
|
||||
// Format A: with stepIndices (current approach)
|
||||
// Strategy 1a: VS Code command (most reliable — same path as UI button)
|
||||
try {
|
||||
const ackA = await sdk.ls.rawRPC('AcknowledgeCascadeCodeEdit', {
|
||||
cascadeId: targetSession,
|
||||
accept: isAccept,
|
||||
...(trackedSteps.length > 0 ? { stepIndices: trackedSteps } : {}),
|
||||
});
|
||||
logToFile(`[DIFF-REVIEW-RPC] Format A (stepIndices=[${trackedSteps.join(',')}]): ${JSON.stringify(ackA).substring(0, 300)}`);
|
||||
} catch (eA: any) {
|
||||
logToFile(`[DIFF-REVIEW-RPC] Format A ERROR: ${eA.message.substring(0, 200)}`);
|
||||
}
|
||||
|
||||
// Format B: WITHOUT stepIndices (accept all pending)
|
||||
try {
|
||||
const ackB = await sdk.ls.rawRPC('AcknowledgeCascadeCodeEdit', {
|
||||
cascadeId: targetSession,
|
||||
accept: isAccept,
|
||||
});
|
||||
logToFile(`[DIFF-REVIEW-RPC] Format B (no stepIndices): ${JSON.stringify(ackB).substring(0, 300)}`);
|
||||
} catch (eB: any) {
|
||||
logToFile(`[DIFF-REVIEW-RPC] Format B ERROR: ${eB.message.substring(0, 200)}`);
|
||||
}
|
||||
|
||||
// Format C: with 'steps' key instead of 'stepIndices'
|
||||
try {
|
||||
const ackC = await sdk.ls.rawRPC('AcknowledgeCascadeCodeEdit', {
|
||||
cascadeId: targetSession,
|
||||
accept: isAccept,
|
||||
steps: trackedSteps,
|
||||
});
|
||||
logToFile(`[DIFF-REVIEW-RPC] Format C (steps=[${trackedSteps.join(',')}]): ${JSON.stringify(ackC).substring(0, 300)}`);
|
||||
} catch (eC: any) {
|
||||
logToFile(`[DIFF-REVIEW-RPC] Format C ERROR: ${eC.message.substring(0, 200)}`);
|
||||
await vscode.commands.executeCommand('antigravity.prioritized.submitCodeAcknowledgement');
|
||||
logToFile(`[DIFF-REVIEW-RPC] ✅ submitCodeAcknowledgement command OK`);
|
||||
diffReviewDone = true;
|
||||
} catch (cmdErr: any) {
|
||||
logToFile(`[DIFF-REVIEW-RPC] submitCodeAcknowledgement command error: ${cmdErr.message?.substring(0, 200)}`);
|
||||
}
|
||||
|
||||
// Format D: with trajectoryId added
|
||||
try {
|
||||
const trajId = activeTrajectoryId || '';
|
||||
const ackD = await sdk.ls.rawRPC('AcknowledgeCascadeCodeEdit', {
|
||||
cascadeId: targetSession,
|
||||
trajectoryId: trajId,
|
||||
accept: isAccept,
|
||||
stepIndices: trackedSteps,
|
||||
});
|
||||
logToFile(`[DIFF-REVIEW-RPC] Format D (with trajectoryId): ${JSON.stringify(ackD).substring(0, 300)}`);
|
||||
} catch (eD: any) {
|
||||
logToFile(`[DIFF-REVIEW-RPC] Format D ERROR: ${eD.message.substring(0, 200)}`);
|
||||
// Strategy 1b: Direct LS RPC with correct method name
|
||||
if (!diffReviewDone) {
|
||||
try {
|
||||
const ackResult = await sdk.ls.rawRPC('acknowledgeCodeActionStep', {
|
||||
cascadeId: targetSession,
|
||||
accept: isAccept,
|
||||
...(trackedSteps.length > 0 ? { stepIndices: trackedSteps } : {}),
|
||||
});
|
||||
logToFile(`[DIFF-REVIEW-RPC] ✅ acknowledgeCodeActionStep: ${JSON.stringify(ackResult).substring(0, 300)}`);
|
||||
diffReviewDone = true;
|
||||
} catch (rpcErr1: any) {
|
||||
logToFile(`[DIFF-REVIEW-RPC] acknowledgeCodeActionStep error: ${rpcErr1.message?.substring(0, 200)}`);
|
||||
}
|
||||
}
|
||||
|
||||
logToFile(`[DIFF-REVIEW-RPC] ✅ All experiments completed`);
|
||||
diffReviewDone = true;
|
||||
} catch (rpcErr: any) {
|
||||
logToFile(`[DIFF-REVIEW-RPC] ❌ ${rpcErr.message.substring(0, 200)}`);
|
||||
// Strategy 1c: Legacy method name (fallback)
|
||||
if (!diffReviewDone) {
|
||||
try {
|
||||
const ackLegacy = await sdk.ls.rawRPC('AcknowledgeCascadeCodeEdit', {
|
||||
cascadeId: targetSession,
|
||||
accept: isAccept,
|
||||
...(trackedSteps.length > 0 ? { stepIndices: trackedSteps } : {}),
|
||||
});
|
||||
logToFile(`[DIFF-REVIEW-RPC] ✅ AcknowledgeCascadeCodeEdit (legacy): ${JSON.stringify(ackLegacy).substring(0, 300)}`);
|
||||
diffReviewDone = true;
|
||||
} catch (rpcErr2: any) {
|
||||
logToFile(`[DIFF-REVIEW-RPC] AcknowledgeCascadeCodeEdit (legacy) error: ${rpcErr2.message?.substring(0, 200)}`);
|
||||
}
|
||||
}
|
||||
} catch (outerErr: any) {
|
||||
logToFile(`[DIFF-REVIEW-RPC] ❌ outer error: ${outerErr.message?.substring(0, 200)}`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3050,16 +3038,26 @@ async function tryApprovalStrategies(approved: boolean, sessionId: string, stepT
|
||||
let interactionPayload: Record<string, any> = {};
|
||||
|
||||
if (typeLower.includes('code_edit') || typeLower.includes('write_to_file') || typeLower.includes('propose_code') || typeLower.includes('write_cascade_edit')) {
|
||||
// CODE EDIT: Uses separate AcknowledgeCascadeCodeEdit RPC
|
||||
// CODE EDIT: Uses acknowledgeCodeActionStep RPC (correct AG LS method)
|
||||
// Try VS Code command first (same path as UI Accept all button)
|
||||
try {
|
||||
logToFile(`[APPROVAL-CODE-EDIT] AcknowledgeCascadeCodeEdit(cascadeId=${sessionId.substring(0,8)}, accept=${approved}, stepIndices=[${effectiveStepIndex}])`);
|
||||
const ackResult = await sdk.ls.rawRPC('AcknowledgeCascadeCodeEdit', {
|
||||
logToFile(`[APPROVAL-CODE-EDIT] trying submitCodeAcknowledgement command`);
|
||||
await vscode.commands.executeCommand('antigravity.prioritized.submitCodeAcknowledgement');
|
||||
logToFile(`[APPROVAL-CODE-EDIT] ✅ submitCodeAcknowledgement OK`);
|
||||
return `CMD:submitCodeAcknowledgement(accept=${approved})`;
|
||||
} catch {
|
||||
logToFile(`[APPROVAL-CODE-EDIT] submitCodeAcknowledgement not available, trying RPC`);
|
||||
}
|
||||
// Direct LS RPC with correct method name
|
||||
try {
|
||||
logToFile(`[APPROVAL-CODE-EDIT] acknowledgeCodeActionStep(cascadeId=${sessionId.substring(0,8)}, accept=${approved}, stepIndices=[${effectiveStepIndex}])`);
|
||||
const ackResult = await sdk.ls.rawRPC('acknowledgeCodeActionStep', {
|
||||
cascadeId: sessionId,
|
||||
accept: approved,
|
||||
stepIndices: [effectiveStepIndex],
|
||||
});
|
||||
logToFile(`[APPROVAL-CODE-EDIT] ✅ SUCCESS: ${JSON.stringify(ackResult).substring(0, 200)}`);
|
||||
return `RPC:AcknowledgeCascadeCodeEdit(accept=${approved})`;
|
||||
return `RPC:acknowledgeCodeActionStep(accept=${approved})`;
|
||||
} catch (e: any) {
|
||||
logToFile(`[APPROVAL-CODE-EDIT] ❌ ${e.message.substring(0, 200)}`);
|
||||
// Fallback: try HandleCascadeUserInteraction with runCommand
|
||||
|
||||
Reference in New Issue
Block a user