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`);
|
||||
fs.writeFileSync(filePath, JSON.stringify(data, null, 2), 'utf-8');
|
||||
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)
|
||||
if (activeSessionId) {
|
||||
writeRegistration(activeSessionId);
|
||||
@@ -1740,37 +1742,46 @@ function setupMonitor() {
|
||||
}
|
||||
// ── Process latestNotifyUserStep ──
|
||||
const notifyStep = bestSession.latestNotifyUserStep;
|
||||
if (notifyStep && notifyStep.stepIndex > lastNotifyStepIndex) {
|
||||
lastNotifyStepIndex = notifyStep.stepIndex;
|
||||
const content = notifyStep.step?.notifyUser?.notificationContent || '';
|
||||
// Filter: only relay meaningful notifications (skip trivial ones)
|
||||
if (content.length > 50) {
|
||||
writeChatSnapshot(`📣 **알림** (step ${notifyStep.stepIndex})\n\n${content}`);
|
||||
console.log(`Gravity Bridge: [POLL#${pollCount}] NOTIFY step=${notifyStep.stepIndex} ${content.length} chars`);
|
||||
}
|
||||
else if (content.length > 0) {
|
||||
logToFile(`[POLL] NOTIFY skipped (too short: ${content.length} chars): ${content.substring(0, 80)}`);
|
||||
if (notifyStep) {
|
||||
if (notifyStep.stepIndex > lastNotifyStepIndex) {
|
||||
lastNotifyStepIndex = notifyStep.stepIndex;
|
||||
const content = notifyStep.step?.notifyUser?.notificationContent || '';
|
||||
logToFile(`[NOTIFY-STEP] NEW step=${notifyStep.stepIndex} content=${content.length} chars`);
|
||||
// Filter: relay all non-empty notifications
|
||||
if (content.length > 10) {
|
||||
writeChatSnapshot(`📣 **알림** (step ${notifyStep.stepIndex})\n\n${content}`);
|
||||
}
|
||||
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 ──
|
||||
const taskStep = bestSession.latestTaskBoundaryStep;
|
||||
if (taskStep && taskStep.stepIndex > lastTaskStepIndex) {
|
||||
lastTaskStepIndex = taskStep.stepIndex;
|
||||
const tb = taskStep.step?.taskBoundary;
|
||||
if (tb?.taskName) {
|
||||
const mode = tb.mode ? tb.mode.replace('AGENT_MODE_', '') : '';
|
||||
// Filter: skip status-only updates with same task name (noise)
|
||||
const taskText = `${tb.taskName}|${tb.taskStatus || ''}`;
|
||||
if (taskText !== lastRelayedTaskText) {
|
||||
lastRelayedTaskText = taskText;
|
||||
writeChatSnapshot(`📋 **[${mode}] ${tb.taskName}**\n${tb.taskStatus || ''}\n\n${tb.taskSummary || ''}`);
|
||||
console.log(`Gravity Bridge: [POLL#${pollCount}] TASK step=${taskStep.stepIndex} "${tb.taskName}"`);
|
||||
}
|
||||
else {
|
||||
logToFile(`[POLL] TASK skipped (duplicate): "${tb.taskName}"`);
|
||||
if (taskStep) {
|
||||
if (taskStep.stepIndex > lastTaskStepIndex) {
|
||||
lastTaskStepIndex = taskStep.stepIndex;
|
||||
const tb = taskStep.step?.taskBoundary;
|
||||
if (tb?.taskName) {
|
||||
const mode = tb.mode ? tb.mode.replace('AGENT_MODE_', '') : '';
|
||||
const taskText = `${tb.taskName}|${tb.taskStatus || ''}`;
|
||||
logToFile(`[TASK-STEP] NEW step=${taskStep.stepIndex} name="${tb.taskName}" mode=${mode}`);
|
||||
if (taskText !== lastRelayedTaskText) {
|
||||
lastRelayedTaskText = taskText;
|
||||
writeChatSnapshot(`📋 **[${mode}] ${tb.taskName}**\n${tb.taskStatus || ''}\n\n${tb.taskSummary || ''}`);
|
||||
}
|
||||
else {
|
||||
logToFile(`[TASK-STEP] skipped (duplicate): "${tb.taskName}"`);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (pollCount <= 5) {
|
||||
logToFile(`[TASK-STEP] null (no task step in session)`);
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
if (pollCount <= 5 || pollCount % 20 === 0) {
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user