Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(desktop): drain blocked 诊断按 gate 分层日志级别
ficowang31202cbab0d3
diff --git a/apps/desktop/src/main/maker-ipc/__tests__/deferredRestartQueueDrain.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/deferredRestartQueueDrain.test.tsindex 270354d5ac..9df31641d4 100644--- a/apps/desktop/src/main/maker-ipc/__tests__/deferredRestartQueueDrain.test.ts+++ b/apps/desktop/src/main/maker-ipc/__tests__/deferredRestartQueueDrain.test.ts@@ -16,7 +16,8 @@* 3. 竞态排列 b:close cleanup 吞掉已排程的 wake-drain(register 接线的* 「先关后唤」顺序是正确性前提,本用例锁住反例的行为);* 4. 竞态排列 c:迟到/重复 wake 的恰好一次语义;- * 5. drain blocked 结果级诊断落日志(gate 枚举 + 脱敏字段)。+ * 5. drain blocked 结果级诊断落日志(gate 枚举 + 脱敏字段;常规 gate 走+ * debug,仅 queue-restore-failed 保留 info)。*/import { beforeEach, describe, expect, it, vi } from 'vitest';import { AgentInputCoordinator } from '../agent-input-coordinator.js';@@ -238,7 +239,9 @@ function latestSnapshotClientIds(}function drainBlockedLogs(): Array<Record<string, unknown>> {- return mocks.logger.info.mock.calls+ // 常规 gate 的阻塞诊断走 debug(正常排队每次 drain 都进这里,info 会刷爆+ // packaged 日志);只有 queue-restore-failed 保留 info 常驻观测。+ return mocks.logger.debug.mock.calls.filter(([message]) => message === 'drain blocked').map(([, meta]) => meta as Record<string, unknown>);}@@ -251,7 +254,7 @@ describe('deferred Codex restart × input queue drain (#2506)', () => {it('端到端:pending 门挡住的后续消息在重启兑现后恰好派发一次并落库', async () => {const h = createRestartHarness();await h.coordinator.ensureQueueRestored(h.SID);- mocks.logger.info.mockClear();+ mocks.logger.debug.mockClear();// 另一会话忙 → 重启延期挂起;本会话上一轮已完成(running=false)。h.setBusyOtherSession(true);@@ -308,7 +311,7 @@ describe('deferred Codex restart × input queue drain (#2506)', () => {expect(h.sendToAgent).not.toHaveBeenCalled();// 迟到的二次 wake 不越过暂停态,且必须留下 gate 诊断而不是静默无痕。- mocks.logger.info.mockClear();+ mocks.logger.debug.mockClear();h.coordinator.wakeSession(h.SID, 'deferred-codex-restart-applied');await flush();expect(h.sendToAgent).not.toHaveBeenCalled();diff --git a/apps/desktop/src/main/maker-ipc/agent-input-coordinator.ts b/apps/desktop/src/main/maker-ipc/agent-input-coordinator.tsindex e06bc1978c..86e98e1504 100644--- a/apps/desktop/src/main/maker-ipc/agent-input-coordinator.ts+++ b/apps/desktop/src/main/maker-ipc/agent-input-coordinator.ts@@ -3143,9 +3143,15 @@ export class AgentInputCoordinator {// #2506 结果级诊断:排队输入被 gate 挡住时留痕(此前零日志,gate-clear// 到成功 drain 之间的静默滞留无从定位)。只记 id / 布尔 / 枚举,不记正文;// 空队列的例行 drain 不记,避免每次 turn-done 都产生噪音。+ // 级别按 gate 分层(Codex review):turn 运行中排队、恢复暂停、交互锁等+ // 都是**正常态**,每次 drain 尝试都会进这里 —— packaged 默认 info,记+ // info 会让普通排队持续刷日志、淹没真正的异常断点,复现期排障走 DEBUG+ // (工程规范)。只有 queue-restore-failed(快照恢复确已失败,队列滞留到+ // 人工介入,非瞬态)保留 info 常驻观测。const gate = this.explainDrainBlockGate(sessionId, state);if (gate !== null && gate !== 'queue-empty') {- log.info('drain blocked', {+ const logAt = gate === 'queue-restore-failed' ? log.info : log.debug;+ logAt('drain blocked', {sessionId,reason,gate,