Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(desktop): 修复 review 反馈——终端错误跳过预测与 sticky remote predicate

Shinku92873fe8172d
diff --git a/apps/desktop/src/renderer/components/new-chat/ChatInput.tsx b/apps/desktop/src/renderer/components/new-chat/ChatInput.tsx
index 015677093a..96fa873aea 100644
--- a/apps/desktop/src/renderer/components/new-chat/ChatInput.tsx
+++ b/apps/desktop/src/renderer/components/new-chat/ChatInput.tsx
@@ -1171,6 +1171,9 @@ export function ChatInput({
// 后台 wake 型任务(local_agent / local_workflow)仍在运行时,主 turn 报告
// 用户点击 Stop 或 turn 以错误/中止结束时,不应触发预测。
if (wasTurnStoppedByUserRef.current) return;
+ // turn 以终端错误结束时,不应触发预测:错误上下文可能包含不完整/损坏的对话,
+ // 避免在错误状态下发起付费 provider 调用。
+ if (makerChatStore.getSnapshot(sessionId)?.error) return;
// stopped 但会话仍在工作 —— 跳过预测,避免用不完整上下文发起付费调用。
// hasBackgroundAgentWork 已在 _isSessionBusy 里统一折算,这里单独补门禁。
if (makerChatStore.hasBackgroundAgentWork(sessionId)) return;
diff --git a/apps/desktop/src/renderer/hooks/useCCAgentChat.ts b/apps/desktop/src/renderer/hooks/useCCAgentChat.ts
index f3584d8923..2eec040ee7 100644
--- a/apps/desktop/src/renderer/hooks/useCCAgentChat.ts
+++ b/apps/desktop/src/renderer/hooks/useCCAgentChat.ts
@@ -55,7 +55,7 @@ import type { AttachedFile, MentionedResource } from '@/lib/fileTypes';
import type { PastedTextRange, SlashCommandRange } from '@/lib/imageRef';
import type { AgentInputReference } from '@cindy/maker-shared/agent-input-projection';
import { createLogger } from '@/lib/logger';
-import { isRemoteSession } from '@/lib/makerTransport';
+import { isRemoteSessionSticky } from '@/lib/makerTransport';
import type { UsageLimitRecoveryHint } from '@/lib/usageLimitRecovery';
const log = createLogger('UseCCAgentChat');
@@ -752,7 +752,7 @@ export function useCCAgentChat(
// 远程会话豁免 pendingTaskWake:device-link 与 SSH 镜像事件有设计内的丢失
// 窗口(断连/重连),taskUpdates 不在 reconcile 对账覆盖内,终态 drop 后无自愈
// 路径。与 makerChatStore.hasBackgroundAgentWork 的远程豁免同口径。
- (lightState.pendingTaskWake && sessionId && !isRemoteSession(sessionId) && !makerChatStore.getSnapshot(sessionId)?.remoteHostId) ||
+ (lightState.pendingTaskWake && sessionId && !isRemoteSessionSticky(sessionId) && !makerChatStore.getSnapshot(sessionId)?.remoteHostId) ||
(pendingQueueLength > 0 && !lightState.queuePaused);
const setQueueExpanded = useCallback(