feat: diff review Discord relay — Accept/Reject all via VS Code commands
This commit is contained in:
@@ -1997,6 +1997,60 @@ function setupMonitor() {
|
||||
logToFile(`[RESPONSE-CAPTURE] error: ${re.message.substring(0, 100)}`);
|
||||
}
|
||||
}
|
||||
// ── Diff review detection: if session just went IDLE and file writes happened ──
|
||||
if (wasRunning && !isRunning && sdk) {
|
||||
try {
|
||||
const drOffset = Math.max(0, currentCount - 10);
|
||||
const drResp = await sdk.ls.rawRPC('GetCascadeTrajectorySteps', {
|
||||
cascadeId: bestSessionId,
|
||||
stepOffset: drOffset,
|
||||
verbosity: 1,
|
||||
});
|
||||
if (drResp?.steps?.length > 0) {
|
||||
const fileWriteSteps = drResp.steps.filter((s) => {
|
||||
const t = s?.type || '';
|
||||
return t.includes('WRITE_TO_FILE') || t.includes('REPLACE_FILE') || t.includes('MULTI_REPLACE');
|
||||
});
|
||||
if (fileWriteSteps.length > 0) {
|
||||
// Extract modified file names
|
||||
const modifiedFiles = [];
|
||||
for (const fw of fileWriteSteps) {
|
||||
try {
|
||||
const args = JSON.parse(fw?.metadata?.toolCall?.argumentsJson || '{}');
|
||||
const f = args.TargetFile || args.target_file || '';
|
||||
if (f) {
|
||||
const basename = f.split(/[\\/]/).pop() || f;
|
||||
if (!modifiedFiles.includes(basename))
|
||||
modifiedFiles.push(basename);
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
const fileList = modifiedFiles.length > 0
|
||||
? modifiedFiles.slice(0, 5).join(', ')
|
||||
: `${fileWriteSteps.length}개 파일`;
|
||||
logToFile(`[DIFF-REVIEW] ${fileWriteSteps.length} file write steps detected, files: ${fileList}`);
|
||||
writeChatSnapshot(`📝 **코드 리뷰 대기**\n\n수정된 파일: ${fileList}\n\nAG에서 Accept all / Reject all로 확인해주세요.`);
|
||||
// Create pending for Discord approval
|
||||
writePendingApproval({
|
||||
conversation_id: activeSessionId,
|
||||
command: `코드 리뷰: ${fileList}`,
|
||||
description: `${fileWriteSteps.length}개 파일이 수정되었습니다`,
|
||||
step_type: 'diff_review',
|
||||
step_index: currentCount,
|
||||
source: 'diff_review_detect',
|
||||
buttons: [
|
||||
{ text: 'Accept all', index: 0 },
|
||||
{ text: 'Reject all', index: 1 },
|
||||
],
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (dre) {
|
||||
logToFile(`[DIFF-REVIEW] error: ${dre.message?.substring(0, 100)}`);
|
||||
}
|
||||
}
|
||||
wasRunning = isRunning;
|
||||
}
|
||||
catch (e) {
|
||||
@@ -2094,7 +2148,23 @@ async function processResponseFile(filePath) {
|
||||
// DOM observer: renderer handles clicking via pollResponse
|
||||
// Step probe/stall: try RPC → VS Code commands → log results
|
||||
const approved = resp.approved;
|
||||
if (isDomObserver) {
|
||||
// ── diff_review: Accept all / Reject all via VS Code commands ──
|
||||
if (pendingStepType === 'diff_review') {
|
||||
const btnIdx = resp.button_index ?? -1;
|
||||
const isAccept = btnIdx === 0 || (btnIdx === -1 && approved);
|
||||
const cmd = isAccept
|
||||
? 'antigravity.prioritized.agentAcceptAllInFile'
|
||||
: 'antigravity.prioritized.agentRejectAllInFile';
|
||||
logToFile(`[RESPONSE] diff_review → executing VS Code command: ${cmd} (btnIdx=${btnIdx})`);
|
||||
try {
|
||||
await vscode.commands.executeCommand(cmd);
|
||||
logToFile(`[RESPONSE] diff_review command executed OK`);
|
||||
}
|
||||
catch (cmdErr) {
|
||||
logToFile(`[RESPONSE] diff_review command error: ${cmdErr.message}`);
|
||||
}
|
||||
}
|
||||
else if (isDomObserver) {
|
||||
// DOM observer path: ALSO try RPC strategies (renderer click is unreliable)
|
||||
logToFile(`[RESPONSE] dom_observer → tryApprovalStrategies(${approved}, ${activeSessionId.substring(0, 8)}, type=${pendingStepType}, step=${pendingStepIndex})`);
|
||||
const strategyResult = await tryApprovalStrategies(approved, activeSessionId, pendingStepType, pendingStepIndex);
|
||||
|
||||
Reference in New Issue
Block a user