fix(extension): resolve AI response dropping for sub-5s executions by relaxing IDLE capture condition #task-607

This commit is contained in:
Variet Worker
2026-04-10 16:05:30 +09:00
parent 6bbc9ddd00
commit 2ece05fc6f
4 changed files with 27 additions and 42 deletions

View File

@@ -859,8 +859,8 @@ function setupMonitor() {
}
}
if (wasRunning && !isRunning && currentCount > lastResponseCaptureStep) {
ctx.logToFile(`[RESPONSE-CAPTURE] RUNNING→IDLE, steps=${currentCount}, capturing response...`);
if (!isRunning && currentCount > lastResponseCaptureStep) {
ctx.logToFile(`[RESPONSE-CAPTURE] IDLE check, steps=${currentCount} > last=${lastResponseCaptureStep}, capturing response...`);
lastResponseCaptureStep = currentCount;
try {
const offset = Math.max(0, currentCount - 5);
@@ -875,41 +875,7 @@ function setupMonitor() {
const s = steps[ri];
const sType = s?.type || '';
if (sType.includes('PLANNER_RESPONSE') && !sType.includes('EPHEMERAL')) {
let textContent = '';
// Extract from plannerResponse field
const pr = s?.plannerResponse;
if (pr) {
// Priority: modifiedResponse (confirmed field from AG)
if (pr.modifiedResponse) textContent = pr.modifiedResponse;
else if (pr.rawText) textContent = pr.rawText;
else if (pr.text) textContent = pr.text;
else if (pr.message) textContent = typeof pr.message === 'string' ? pr.message : '';
else if (pr.content?.parts) {
for (const p of pr.content.parts) {
if (p?.text) textContent += p.text;
}
}
// Log first time to capture actual field names
if (!textContent) {
ctx.logToFile(`[RESPONSE-CAPTURE] plannerResponse keys: [${Object.keys(pr).join(',')}] values(100): ${JSON.stringify(pr).substring(0, 200)}`);
}
}
// Extract from ephemeralMessage field
const em = s?.ephemeralMessage;
if (!textContent && em) {
if (typeof em === 'string') textContent = em;
else if (em.message) textContent = em.message;
else if (em.content) textContent = typeof em.content === 'string' ? em.content : JSON.stringify(em.content);
}
// Fallback: metadata, content, rawOutput
if (!textContent) {
const parts = s?.content?.parts || s?.parts || [];
for (const p of parts) {
if (p?.text) textContent += p.text;
}
}
if (!textContent && s?.metadata?.text) textContent = s.metadata.text;
if (!textContent && s?.rawOutput) textContent = typeof s.rawOutput === 'string' ? s.rawOutput : JSON.stringify(s.rawOutput);
const textContent = extractPlannerText(s) || '';
if (textContent.length > 10) {
ctx.logToFile(`[RESPONSE-CAPTURE] found ${sType} (${textContent.length} chars) at step ${offset + ri}`);
const truncated = textContent.length > 3500
@@ -918,7 +884,7 @@ function setupMonitor() {
ctx.writeChatSnapshot(`💬 **AI 응답**\n\n${truncated}`);
break;
} else {
ctx.logToFile(`[RESPONSE-CAPTURE] ${sType} too short (${textContent.length}), keys=[${Object.keys(s).join(',')}]`);
ctx.logToFile(`[RESPONSE-CAPTURE] ${sType} too short (${textContent.length})`);
}
}
}
@@ -930,8 +896,8 @@ function setupMonitor() {
ctx.writeChatSnapshot(`✅ **Step ${currentCount} 작업 종료**`);
}
// ── Diff review detection: if session just went IDLE and files were modified ──
if (wasRunning && !isRunning && pendingModifiedFiles.length > 0) {
// ── Diff review detection: if session went IDLE and files were modified ──
if (!isRunning && pendingModifiedFiles.length > 0) {
// Phase 3 FIX: Filter out brain/ artifact files (task.md, implementation_plan.md etc.)
// These are AG internal artifacts, NOT code changes needing user review.
const brainPathSegment = '.gemini/antigravity/brain/';