docs: devlog 013 + known-issues (Reload Window stale session, RUNNING 우선 선택, IDLE 채널)

This commit is contained in:
2026-03-10 22:21:32 +09:00
parent 6179c4d242
commit 4d780ec5e7
4 changed files with 58 additions and 11 deletions

View File

@@ -55,8 +55,10 @@ const crypto = __importStar(require("crypto"));
// ─── File-based logging (AI can read directly) ───
function logToFile(msg) {
const ts = new Date().toISOString().replace('T', ' ').substring(0, 19);
const line = `${ts} ${msg}`;
console.log(`Gravity Bridge: ${msg}`);
// Include projectName prefix so shared log can distinguish which extension instance logged
const prefix = projectName ? `[${projectName}]` : '';
const line = `${ts} ${prefix} ${msg}`;
console.log(`Gravity Bridge: ${prefix} ${msg}`);
try {
if (!bridgePath)
return;
@@ -1481,6 +1483,19 @@ function setupMonitor() {
let bestModTime = '';
const regDir = path.join(bridgePath, 'register');
const normalizedWorkspace = workspaceUri.replace(/\\/g, '/').toLowerCase();
// ── DEBUG: Log all available sessions on every 12th poll ──
const sessionIds = Object.keys(allTraj.trajectorySummaries);
if (pollCount <= 3 || pollCount % 12 === 0) {
logToFile(`[SESSION-FILTER] total=${sessionIds.length} myWorkspace="${normalizedWorkspace}"`);
for (const [sid, data] of Object.entries(allTraj.trajectorySummaries)) {
const tm = data.trajectoryMetadata;
const wsRaw = tm?.workspaces?.[0]?.workspaceFolderAbsoluteUri || 'NO_META';
const status = String(data.status || '').replace('CASCADE_RUN_STATUS_', '');
const steps = data.stepCount || 0;
const modT = (data.lastModifiedTime || '').substring(11, 19);
logToFile(`[SESSION-FILTER] ${sid.substring(0, 8)} ws=${wsRaw.substring(wsRaw.lastIndexOf('/') + 1)} steps=${steps} ${status} mod=${modT}`);
}
}
for (const [sid, data] of Object.entries(allTraj.trajectorySummaries)) {
// PRIMARY FILTER: Check workspace URI from trajectoryMetadata
const trajMeta = data.trajectoryMetadata;
@@ -1512,14 +1527,23 @@ function setupMonitor() {
}
}
const modTime = data.lastModifiedTime || '';
if (!bestSession || modTime > bestModTime) {
const candidateRunning = String(data.status || '').includes('RUNNING');
const bestIsRunning = bestSession ? String(bestSession.status || '').includes('RUNNING') : false;
// Prefer RUNNING over IDLE, then latest modTime within same status tier
if (!bestSession
|| (candidateRunning && !bestIsRunning)
|| (candidateRunning === bestIsRunning && modTime > bestModTime)) {
bestSession = data;
bestSessionId = sid;
bestModTime = modTime;
}
}
if (!bestSession)
if (!bestSession) {
if (pollCount <= 10 || pollCount % 12 === 0) {
logToFile(`[SESSION-FILTER] NO session matched! total=${sessionIds.length}`);
}
return;
}
const currentCount = bestSession.stepCount || 0;
const currentTitle = (bestSession.summary || 'Untitled').substring(0, 50);
const isRunning = String(bestSession.status || '').includes('RUNNING');
@@ -1739,7 +1763,7 @@ function setupMonitor() {
conversation_id: activeSessionId,
command,
description: `Step #${actualIndex} (${(oStep.type || '').replace('CORTEX_STEP_TYPE_', '')})`,
step_type: ['view_file', 'list_dir', 'find_by_name', 'read_file', 'grep_search'].includes(toolName) ? 'file_permission' : toolName,
step_type: ['view_file', 'list_dir', 'find_by_name', 'read_file', 'grep_search', 'replace_file_content', 'write_to_file', 'multi_replace_file_content'].includes(toolName) ? 'file_permission' : toolName,
step_index: actualIndex,
source: 'step_probe_offset',
});
@@ -1795,7 +1819,7 @@ function setupMonitor() {
conversation_id: activeSessionId,
command,
description,
step_type: ['view_file', 'list_dir', 'find_by_name', 'read_file', 'grep_search'].includes(toolName) ? 'file_permission' : toolName,
step_type: ['view_file', 'list_dir', 'find_by_name', 'read_file', 'grep_search', 'replace_file_content', 'write_to_file', 'multi_replace_file_content'].includes(toolName) ? 'file_permission' : toolName,
step_index: si,
source: 'step_probe',
});
@@ -2101,6 +2125,17 @@ function setupResponseWatcher() {
}
catch { }
}
else {
// Pending file missing (deleted or auto_resolved) — check response data itself
try {
const respData = JSON.parse(fs.readFileSync(fp, 'utf-8'));
if (respData.project_name && respData.project_name !== projectName) {
logToFile(`[RESPONSE] skip (from resp data) ${rid} (project=${respData.project_name}, we=${projectName})`);
return;
}
}
catch { }
}
setTimeout(() => processResponseFile(fp), 300);
}
}
@@ -2213,14 +2248,18 @@ async function processResponseFile(filePath) {
}
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);
// Use sessionId from pending file if available, fallback to activeSessionId
const targetSession = sessionId || activeSessionId;
logToFile(`[RESPONSE] dom_observer → tryApprovalStrategies(${approved}, ${targetSession.substring(0, 8)}, type=${pendingStepType}, step=${pendingStepIndex})`);
const strategyResult = await tryApprovalStrategies(approved, targetSession, pendingStepType, pendingStepIndex);
logToFile(`[RESPONSE] dom strategy result: ${strategyResult}`);
}
else {
// Step probe path: run ALL approval strategies
logToFile(`[RESPONSE] step_probe → tryApprovalStrategies(${approved}, ${activeSessionId.substring(0, 8)}, type=${pendingStepType}, step=${pendingStepIndex})`);
const strategyResult = await tryApprovalStrategies(approved, activeSessionId, pendingStepType, pendingStepIndex);
// Use sessionId from pending file if available, fallback to activeSessionId
const targetSession = sessionId || activeSessionId;
logToFile(`[RESPONSE] step_probe → tryApprovalStrategies(${approved}, ${targetSession.substring(0, 8)}, type=${pendingStepType}, step=${pendingStepIndex})`);
const strategyResult = await tryApprovalStrategies(approved, targetSession, pendingStepType, pendingStepIndex);
logToFile(`[RESPONSE] strategy result: ${strategyResult}`);
}
logToFile(`[RESPONSE] ${approved ? 'approve' : 'reject'} done (${isDomObserver ? 'dom' : 'step_probe'})`);