fix: skip harm classifier under No-Log, fix flush concurrency race

- classifyHarm() skipped when noLogMode is true (saves OpenRouter credits + up to 4s latency)
- flushTelemetry() no-log early return no longer resets _telemetry.flushing
  (prevents concurrent flushes when an in-flight request is still pending)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
faber
2026-07-13 13:53:27 -04:00
parent 9ff3082dc2
commit e4fc62fb79

View File

@@ -4306,7 +4306,7 @@
}
async function flushTelemetry() {
if (state.noLogMode) { _telemetry.buffer.length = 0; _telemetry.flushing = false; return; }
if (state.noLogMode) { _telemetry.buffer.length = 0; return; }
if (_telemetry.flushing || _telemetry.buffer.length === 0) return;
_telemetry.flushing = true;
@@ -14285,9 +14285,11 @@ Ignoring conversation history will cause you to LOSE the evaluation.`;
visionContext = '[Image attached — vision analysis unavailable without OpenRouter key]';
}
// Fire harm classification in parallel (never blocks UI)
// Fire harm classification in parallel (telemetry-only — skip when No-Log)
_lastHarmResult = null;
const harmPromise = classifyHarm(content).then(r => { _lastHarmResult = r; }).catch(() => {});
if (!state.noLogMode) {
classifyHarm(content).then(r => { _lastHarmResult = r; }).catch(() => {});
}
// Capture structural context for telemetry (no content, no PII)
_lastTelemetryCtx = {