Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(desktop): 修复 predict-prompt review 反馈——IPC 错误协议与会话归属空窗
Shinku4781eaacbab9
diff --git a/apps/desktop/src/main/maker-ipc/title.ts b/apps/desktop/src/main/maker-ipc/title.tsindex 08bbfd55a8..55df8f9f6d 100644--- a/apps/desktop/src/main/maker-ipc/title.ts+++ b/apps/desktop/src/main/maker-ipc/title.ts@@ -367,17 +367,17 @@ const PREDICTION_WORKDIR_MAX = 512;function parsePredictPromptRequest(raw: unknown): PromptPredictionParams {if (!raw || typeof raw !== 'object' || Array.isArray(raw)) {- throw new Error('predict-prompt request required');+ throwIpcError('INVALID_PARAMS', 'predict-prompt request must be a non-null object');}const { sessionId, agentKind, messages, workingDir } = raw as Record<string, unknown>;if (typeof sessionId !== 'string' || !sessionId || sessionId.length > SESSION_ID_MAX) {- throw new Error('invalid sessionId');+ throwIpcError('INVALID_PARAMS', 'invalid or missing sessionId for predict-prompt');}if (!TITLE_AGENT_KINDS.includes(agentKind as AgentKind)) {- throw new Error('invalid agentKind');+ throwIpcError('INVALID_PARAMS', `invalid agentKind for predict-prompt: ${String(agentKind)}`);}if (!Array.isArray(messages)) {- throw new Error('messages must be an array');+ throwIpcError('INVALID_PARAMS', 'messages must be an array for predict-prompt');}const sliced = messages.slice(-PREDICTION_MESSAGES_MAX).map((m: unknown) => {if (typeof m !== 'object' || m === null) {diff --git a/apps/desktop/src/renderer/components/new-chat/ChatInput.tsx b/apps/desktop/src/renderer/components/new-chat/ChatInput.tsxindex d325017403..4a58d103b5 100644--- a/apps/desktop/src/renderer/components/new-chat/ChatInput.tsx+++ b/apps/desktop/src/renderer/components/new-chat/ChatInput.tsx@@ -1108,17 +1108,20 @@ export function ChatInput({if (turnStarting) {turnGenRef.current += 1;}- // sessionId 切换时重置预测相关 ref,防止旧 session 的推荐/ref 残留。+ // sessionId 切换时在 render 阶段同步更新预测相关 ref,关闭 useEffect 延迟空窗:+ // 若旧 session 的预测请求在 render→commit 之间返回,prevSessionIdRef 已指向+ // 新 session,落地校验会拒绝该结果,不会让旧会话推荐词写入新会话输入框。const prevSessionIdRef = useRef(sessionId);+ if (prevSessionIdRef.current !== sessionId) {+ prevSessionIdRef.current = sessionId;+ prevShowStopRef.current = false;+ turnGenRef.current = 0;+ prevShowStopRender.current = false;+ showRecommendationRef.current = false;+ }useEffect(() => {- if (prevSessionIdRef.current !== sessionId) {- prevSessionIdRef.current = sessionId;- prevShowStopRef.current = false;- turnGenRef.current = 0;- prevShowStopRender.current = false;- showRecommendationRef.current = false;- setRecommendedPrompt(null);- }+ // sessionId 变化时清除推荐 UI(ref 已在 render 阶段同步更新)+ setRecommendedPrompt(null);}, [sessionId]);// messages 是可选 prop,缺省按空历史处理(空历史不发预测请求)。const messagesRef = useRef(messages ?? []);