fix: add snapshot diagnostics + lower content filter for Discord messages
This commit is contained in:
@@ -132,6 +132,8 @@ function writeChatSnapshot(text) {
|
|||||||
const filePath = path.join(snapshotDir, `${id}.json`);
|
const filePath = path.join(snapshotDir, `${id}.json`);
|
||||||
fs.writeFileSync(filePath, JSON.stringify(data, null, 2), 'utf-8');
|
fs.writeFileSync(filePath, JSON.stringify(data, null, 2), 'utf-8');
|
||||||
console.log(`Gravity Bridge: chat snapshot written (${text.length} chars) → ${id}.json`);
|
console.log(`Gravity Bridge: chat snapshot written (${text.length} chars) → ${id}.json`);
|
||||||
|
logToFile(`[SNAPSHOT] written ${id}.json (${text.length} chars)`);
|
||||||
|
logToFile(`[SNAPSHOT] content: ${text.substring(0, 200)}`);
|
||||||
// Lazily register session → project mapping (correct because projectName is per-window)
|
// Lazily register session → project mapping (correct because projectName is per-window)
|
||||||
if (activeSessionId) {
|
if (activeSessionId) {
|
||||||
writeRegistration(activeSessionId);
|
writeRegistration(activeSessionId);
|
||||||
@@ -1740,37 +1742,46 @@ function setupMonitor() {
|
|||||||
}
|
}
|
||||||
// ── Process latestNotifyUserStep ──
|
// ── Process latestNotifyUserStep ──
|
||||||
const notifyStep = bestSession.latestNotifyUserStep;
|
const notifyStep = bestSession.latestNotifyUserStep;
|
||||||
if (notifyStep && notifyStep.stepIndex > lastNotifyStepIndex) {
|
if (notifyStep) {
|
||||||
lastNotifyStepIndex = notifyStep.stepIndex;
|
if (notifyStep.stepIndex > lastNotifyStepIndex) {
|
||||||
const content = notifyStep.step?.notifyUser?.notificationContent || '';
|
lastNotifyStepIndex = notifyStep.stepIndex;
|
||||||
// Filter: only relay meaningful notifications (skip trivial ones)
|
const content = notifyStep.step?.notifyUser?.notificationContent || '';
|
||||||
if (content.length > 50) {
|
logToFile(`[NOTIFY-STEP] NEW step=${notifyStep.stepIndex} content=${content.length} chars`);
|
||||||
writeChatSnapshot(`📣 **알림** (step ${notifyStep.stepIndex})\n\n${content}`);
|
// Filter: relay all non-empty notifications
|
||||||
console.log(`Gravity Bridge: [POLL#${pollCount}] NOTIFY step=${notifyStep.stepIndex} ${content.length} chars`);
|
if (content.length > 10) {
|
||||||
}
|
writeChatSnapshot(`📣 **알림** (step ${notifyStep.stepIndex})\n\n${content}`);
|
||||||
else if (content.length > 0) {
|
}
|
||||||
logToFile(`[POLL] NOTIFY skipped (too short: ${content.length} chars): ${content.substring(0, 80)}`);
|
else if (content.length > 0) {
|
||||||
|
logToFile(`[NOTIFY-STEP] skipped (too short: ${content.length} chars): ${content}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (pollCount <= 5) {
|
||||||
|
logToFile(`[NOTIFY-STEP] null (no notify step in session)`);
|
||||||
|
}
|
||||||
// ── Process latestTaskBoundaryStep ──
|
// ── Process latestTaskBoundaryStep ──
|
||||||
const taskStep = bestSession.latestTaskBoundaryStep;
|
const taskStep = bestSession.latestTaskBoundaryStep;
|
||||||
if (taskStep && taskStep.stepIndex > lastTaskStepIndex) {
|
if (taskStep) {
|
||||||
lastTaskStepIndex = taskStep.stepIndex;
|
if (taskStep.stepIndex > lastTaskStepIndex) {
|
||||||
const tb = taskStep.step?.taskBoundary;
|
lastTaskStepIndex = taskStep.stepIndex;
|
||||||
if (tb?.taskName) {
|
const tb = taskStep.step?.taskBoundary;
|
||||||
const mode = tb.mode ? tb.mode.replace('AGENT_MODE_', '') : '';
|
if (tb?.taskName) {
|
||||||
// Filter: skip status-only updates with same task name (noise)
|
const mode = tb.mode ? tb.mode.replace('AGENT_MODE_', '') : '';
|
||||||
const taskText = `${tb.taskName}|${tb.taskStatus || ''}`;
|
const taskText = `${tb.taskName}|${tb.taskStatus || ''}`;
|
||||||
if (taskText !== lastRelayedTaskText) {
|
logToFile(`[TASK-STEP] NEW step=${taskStep.stepIndex} name="${tb.taskName}" mode=${mode}`);
|
||||||
lastRelayedTaskText = taskText;
|
if (taskText !== lastRelayedTaskText) {
|
||||||
writeChatSnapshot(`📋 **[${mode}] ${tb.taskName}**\n${tb.taskStatus || ''}\n\n${tb.taskSummary || ''}`);
|
lastRelayedTaskText = taskText;
|
||||||
console.log(`Gravity Bridge: [POLL#${pollCount}] TASK step=${taskStep.stepIndex} "${tb.taskName}"`);
|
writeChatSnapshot(`📋 **[${mode}] ${tb.taskName}**\n${tb.taskStatus || ''}\n\n${tb.taskSummary || ''}`);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
logToFile(`[POLL] TASK skipped (duplicate): "${tb.taskName}"`);
|
logToFile(`[TASK-STEP] skipped (duplicate): "${tb.taskName}"`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (pollCount <= 5) {
|
||||||
|
logToFile(`[TASK-STEP] null (no task step in session)`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
if (pollCount <= 5 || pollCount % 20 === 0) {
|
if (pollCount <= 5 || pollCount % 20 === 0) {
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -98,6 +98,8 @@ function writeChatSnapshot(text: string) {
|
|||||||
const filePath = path.join(snapshotDir, `${id}.json`);
|
const filePath = path.join(snapshotDir, `${id}.json`);
|
||||||
fs.writeFileSync(filePath, JSON.stringify(data, null, 2), 'utf-8');
|
fs.writeFileSync(filePath, JSON.stringify(data, null, 2), 'utf-8');
|
||||||
console.log(`Gravity Bridge: chat snapshot written (${text.length} chars) → ${id}.json`);
|
console.log(`Gravity Bridge: chat snapshot written (${text.length} chars) → ${id}.json`);
|
||||||
|
logToFile(`[SNAPSHOT] written ${id}.json (${text.length} chars)`);
|
||||||
|
logToFile(`[SNAPSHOT] content: ${text.substring(0, 200)}`);
|
||||||
// Lazily register session → project mapping (correct because projectName is per-window)
|
// Lazily register session → project mapping (correct because projectName is per-window)
|
||||||
if (activeSessionId) { writeRegistration(activeSessionId); }
|
if (activeSessionId) { writeRegistration(activeSessionId); }
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
@@ -1709,35 +1711,42 @@ function setupMonitor() {
|
|||||||
|
|
||||||
// ── Process latestNotifyUserStep ──
|
// ── Process latestNotifyUserStep ──
|
||||||
const notifyStep = bestSession.latestNotifyUserStep;
|
const notifyStep = bestSession.latestNotifyUserStep;
|
||||||
if (notifyStep && notifyStep.stepIndex > lastNotifyStepIndex) {
|
if (notifyStep) {
|
||||||
lastNotifyStepIndex = notifyStep.stepIndex;
|
if (notifyStep.stepIndex > lastNotifyStepIndex) {
|
||||||
const content = notifyStep.step?.notifyUser?.notificationContent || '';
|
lastNotifyStepIndex = notifyStep.stepIndex;
|
||||||
// Filter: only relay meaningful notifications (skip trivial ones)
|
const content = notifyStep.step?.notifyUser?.notificationContent || '';
|
||||||
if (content.length > 50) {
|
logToFile(`[NOTIFY-STEP] NEW step=${notifyStep.stepIndex} content=${content.length} chars`);
|
||||||
writeChatSnapshot(`📣 **알림** (step ${notifyStep.stepIndex})\n\n${content}`);
|
// Filter: relay all non-empty notifications
|
||||||
console.log(`Gravity Bridge: [POLL#${pollCount}] NOTIFY step=${notifyStep.stepIndex} ${content.length} chars`);
|
if (content.length > 10) {
|
||||||
} else if (content.length > 0) {
|
writeChatSnapshot(`📣 **알림** (step ${notifyStep.stepIndex})\n\n${content}`);
|
||||||
logToFile(`[POLL] NOTIFY skipped (too short: ${content.length} chars): ${content.substring(0, 80)}`);
|
} else if (content.length > 0) {
|
||||||
|
logToFile(`[NOTIFY-STEP] skipped (too short: ${content.length} chars): ${content}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} else if (pollCount <= 5) {
|
||||||
|
logToFile(`[NOTIFY-STEP] null (no notify step in session)`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ── Process latestTaskBoundaryStep ──
|
// ── Process latestTaskBoundaryStep ──
|
||||||
const taskStep = bestSession.latestTaskBoundaryStep;
|
const taskStep = bestSession.latestTaskBoundaryStep;
|
||||||
if (taskStep && taskStep.stepIndex > lastTaskStepIndex) {
|
if (taskStep) {
|
||||||
lastTaskStepIndex = taskStep.stepIndex;
|
if (taskStep.stepIndex > lastTaskStepIndex) {
|
||||||
const tb = taskStep.step?.taskBoundary;
|
lastTaskStepIndex = taskStep.stepIndex;
|
||||||
if (tb?.taskName) {
|
const tb = taskStep.step?.taskBoundary;
|
||||||
const mode = tb.mode ? tb.mode.replace('AGENT_MODE_', '') : '';
|
if (tb?.taskName) {
|
||||||
// Filter: skip status-only updates with same task name (noise)
|
const mode = tb.mode ? tb.mode.replace('AGENT_MODE_', '') : '';
|
||||||
const taskText = `${tb.taskName}|${tb.taskStatus || ''}`;
|
const taskText = `${tb.taskName}|${tb.taskStatus || ''}`;
|
||||||
if (taskText !== lastRelayedTaskText) {
|
logToFile(`[TASK-STEP] NEW step=${taskStep.stepIndex} name="${tb.taskName}" mode=${mode}`);
|
||||||
lastRelayedTaskText = taskText;
|
if (taskText !== lastRelayedTaskText) {
|
||||||
writeChatSnapshot(`📋 **[${mode}] ${tb.taskName}**\n${tb.taskStatus || ''}\n\n${tb.taskSummary || ''}`);
|
lastRelayedTaskText = taskText;
|
||||||
console.log(`Gravity Bridge: [POLL#${pollCount}] TASK step=${taskStep.stepIndex} "${tb.taskName}"`);
|
writeChatSnapshot(`📋 **[${mode}] ${tb.taskName}**\n${tb.taskStatus || ''}\n\n${tb.taskSummary || ''}`);
|
||||||
} else {
|
} else {
|
||||||
logToFile(`[POLL] TASK skipped (duplicate): "${tb.taskName}"`);
|
logToFile(`[TASK-STEP] skipped (duplicate): "${tb.taskName}"`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if (pollCount <= 5) {
|
||||||
|
logToFile(`[TASK-STEP] null (no task step in session)`);
|
||||||
}
|
}
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
if (pollCount <= 5 || pollCount % 20 === 0) {
|
if (pollCount <= 5 || pollCount % 20 === 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user