fix: focus dirty files before executing agentAcceptAllInFile command

This commit is contained in:
2026-03-10 15:34:37 +09:00
parent 0470c03ab3
commit 4dcb78c1ce
4 changed files with 44 additions and 7 deletions

View File

@@ -2148,10 +2148,29 @@ async function processResponseFile(filePath) {
const cmd = isAccept
? 'antigravity.prioritized.agentAcceptAllInFile'
: 'antigravity.prioritized.agentRejectAllInFile';
logToFile(`[RESPONSE] diff_review → executing VS Code command: ${cmd} (btnIdx=${btnIdx})`);
logToFile(`[RESPONSE] diff_review → ${cmd} (btnIdx=${btnIdx})`);
try {
await vscode.commands.executeCommand(cmd);
logToFile(`[RESPONSE] diff_review command executed OK`);
// Find dirty documents and focus each before executing
const dirtyDocs = vscode.workspace.textDocuments.filter(d => d.isDirty);
logToFile(`[RESPONSE] diff_review: ${dirtyDocs.length} dirty docs found`);
if (dirtyDocs.length > 0) {
for (const doc of dirtyDocs) {
try {
await vscode.window.showTextDocument(doc, { preview: false });
await new Promise(r => setTimeout(r, 200)); // brief wait for focus
await vscode.commands.executeCommand(cmd);
logToFile(`[RESPONSE] diff_review: ${cmd} on ${doc.fileName.split(/[\\/]/).pop()} OK`);
}
catch (perFileErr) {
logToFile(`[RESPONSE] diff_review per-file error: ${perFileErr.message?.substring(0, 80)}`);
}
}
}
else {
// No dirty docs — try command anyway
await vscode.commands.executeCommand(cmd);
logToFile(`[RESPONSE] diff_review: no dirty docs, command executed anyway`);
}
}
catch (cmdErr) {
logToFile(`[RESPONSE] diff_review command error: ${cmdErr.message}`);

File diff suppressed because one or more lines are too long

View File

@@ -2104,10 +2104,27 @@ async function processResponseFile(filePath: string) {
const cmd = isAccept
? 'antigravity.prioritized.agentAcceptAllInFile'
: 'antigravity.prioritized.agentRejectAllInFile';
logToFile(`[RESPONSE] diff_review → executing VS Code command: ${cmd} (btnIdx=${btnIdx})`);
logToFile(`[RESPONSE] diff_review → ${cmd} (btnIdx=${btnIdx})`);
try {
await vscode.commands.executeCommand(cmd);
logToFile(`[RESPONSE] diff_review command executed OK`);
// Find dirty documents and focus each before executing
const dirtyDocs = vscode.workspace.textDocuments.filter(d => d.isDirty);
logToFile(`[RESPONSE] diff_review: ${dirtyDocs.length} dirty docs found`);
if (dirtyDocs.length > 0) {
for (const doc of dirtyDocs) {
try {
await vscode.window.showTextDocument(doc, { preview: false });
await new Promise(r => setTimeout(r, 200)); // brief wait for focus
await vscode.commands.executeCommand(cmd);
logToFile(`[RESPONSE] diff_review: ${cmd} on ${doc.fileName.split(/[\\/]/).pop()} OK`);
} catch (perFileErr: any) {
logToFile(`[RESPONSE] diff_review per-file error: ${perFileErr.message?.substring(0, 80)}`);
}
}
} else {
// No dirty docs — try command anyway
await vscode.commands.executeCommand(cmd);
logToFile(`[RESPONSE] diff_review: no dirty docs, command executed anyway`);
}
} catch (cmdErr: any) {
logToFile(`[RESPONSE] diff_review command error: ${cmdErr.message}`);
}