接口修改
This commit is contained in:
1 parent
f791210e70
commit
6ab6695be7
6 files changed
+373
-128
No files matched your search
@@ -257,10 +257,17 @@ export function useStep1Intent(options: UseStep1IntentOptions): UseStep1IntentRe
|
||||
triggerToast("⚠️ 任务理解智能体尚未就绪,请稍候");
|
||||
return;
|
||||
}
|
||||
if (isIntentSending) {
|
||||
// 重入保护用 ref 而不是 state:isIntentSending 是 React state,
|
||||
// 同一 event-loop tick 内闭包还看到旧值。极速双击 / 输入法回车连击
|
||||
// 会两次都通过 state 检查,结果发两次答案、跑两路 stream,
|
||||
// 回来两张几乎一样的澄清卡——这正是用户报告的"同样选项又出现一次"。
|
||||
// intentAborterRef 在 stream 完成 / abort 后会被清空,正好用来标记"在途"。
|
||||
if (intentAborterRef.current) {
|
||||
triggerToast("⏳ 智能体正在回复,请稍候");
|
||||
return;
|
||||
}
|
||||
const aborter = new AbortController();
|
||||
intentAborterRef.current = aborter;
|
||||
|
||||
setPendingIntentClarificationMsgId(null);
|
||||
|
||||
@@ -300,8 +307,6 @@ export function useStep1Intent(options: UseStep1IntentOptions): UseStep1IntentRe
|
||||
]);
|
||||
|
||||
setIsIntentSending(true);
|
||||
const aborter = new AbortController();
|
||||
intentAborterRef.current = aborter;
|
||||
try {
|
||||
const res = await streamIntent({
|
||||
threadId: intentThreadId,
|
||||
@@ -440,7 +445,7 @@ export function useStep1Intent(options: UseStep1IntentOptions): UseStep1IntentRe
|
||||
setIsIntentSending(false);
|
||||
}
|
||||
},
|
||||
[intentThreadId, isIntentSending, triggerToast],
|
||||
[intentThreadId, triggerToast],
|
||||
);
|
||||
|
||||
const submitIntentClarification = useCallback(
|
||||
|
||||
Reference in new issue
Block a user