fix(bridge): RUNNING 세션 우선 선택 + IDLE 채널 자동 생성 제거
- extension: bestSession 선택에 2단계 비교 (RUNNING > IDLE, then modTime) - extension: [SESSION-FILTER] 진단 로그 + [projectName] 로그 접두사 - bot: pending_approval_scanner의 IDLE 프로젝트 자동 채널 생성 제거 - known-issues: 2개 항목 추가 (IDLE 고착, 채널 증식)
This commit is contained in:
@@ -1459,6 +1459,21 @@ 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) as [string, any][]) {
|
||||
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) as [string, any][]) {
|
||||
// PRIMARY FILTER: Check workspace URI from trajectoryMetadata
|
||||
const trajMeta = data.trajectoryMetadata;
|
||||
@@ -1489,14 +1504,24 @@ 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) return;
|
||||
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');
|
||||
|
||||
Reference in New Issue
Block a user