fix(claw): prevent sent text returning to composer
This commit is contained in:
parent
8b4fd29fce
commit
288cd7bf79
@ -404,6 +404,7 @@ const CLAWD_TABLE_MAX_BYTES = 10 * 1024 * 1024;
|
||||
const CLAWD_PROCESSING_HINT =
|
||||
"已收到,这个任务稍微繁重一些,处理时间可能会长一点,请耐心等候。";
|
||||
const CLAWD_SUBMITTED_COMPOSER_RECOVERY_TTL_MS = 30 * 60 * 1000;
|
||||
const CLAWD_SUBMITTED_COMPOSER_POST_SEND_GUARD_TTL_MS = 15 * 1000;
|
||||
const CLAWD_SUBMITTED_COMPOSER_RESTORE_GUARD_DELAYS_MS = [
|
||||
0, 80, 180, 360, 700, 1200, 2000, 3500, 6000, 10000,
|
||||
];
|
||||
@ -11681,6 +11682,7 @@ export function CanvasChatPanel({
|
||||
clearSelection();
|
||||
}
|
||||
|
||||
let clawdRequestAccepted = false;
|
||||
try {
|
||||
const formData = new FormData();
|
||||
formData.append("id", rawChatId);
|
||||
@ -11714,6 +11716,7 @@ export function CanvasChatPanel({
|
||||
body: formData,
|
||||
signal: clawdAbortController.signal,
|
||||
});
|
||||
clawdRequestAccepted = response.ok;
|
||||
const responseData = await readClawdResponse(response, (progress) => {
|
||||
const display = String(
|
||||
progress.display || progress.message || ""
|
||||
@ -11801,6 +11804,14 @@ export function CanvasChatPanel({
|
||||
}
|
||||
console.error("[CanvasChat] Claw request failed:", error);
|
||||
pendingClawdSubmissionRef.current = null;
|
||||
if (clawdRequestAccepted) {
|
||||
toast.error("Claw 连接中断,已保留已发送消息;任务可能仍在处理中,请稍后刷新历史查看");
|
||||
void mutateClawdHistory();
|
||||
if (rawChatId) {
|
||||
void mutate(buildHistoryMessagesUrl(rawChatId, { cacheBust: true }));
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (recentClawdSubmissionRef.current === clawdSubmissionSnapshot) {
|
||||
recentClawdSubmissionRef.current = null;
|
||||
writeStoredClawdComposerSubmissionSnapshot(null);
|
||||
@ -11853,12 +11864,22 @@ export function CanvasChatPanel({
|
||||
recentClawdSubmissionRef.current = null;
|
||||
writeStoredClawdComposerSubmissionSnapshot(null);
|
||||
} else {
|
||||
const refreshedSubmissionSnapshot = {
|
||||
...clawdSubmissionSnapshot,
|
||||
expiresAt: Date.now() + CLAWD_SUBMITTED_COMPOSER_RECOVERY_TTL_MS,
|
||||
};
|
||||
recentClawdSubmissionRef.current = refreshedSubmissionSnapshot;
|
||||
writeStoredClawdComposerSubmissionSnapshot(refreshedSubmissionSnapshot);
|
||||
const refreshedSubmissionSnapshot = {
|
||||
...clawdSubmissionSnapshot,
|
||||
expiresAt:
|
||||
Date.now() + CLAWD_SUBMITTED_COMPOSER_POST_SEND_GUARD_TTL_MS,
|
||||
};
|
||||
recentClawdSubmissionRef.current = refreshedSubmissionSnapshot;
|
||||
writeStoredClawdComposerSubmissionSnapshot(refreshedSubmissionSnapshot);
|
||||
scheduleClearRestoredClawdComposerText();
|
||||
if (typeof window !== "undefined") {
|
||||
window.setTimeout(() => {
|
||||
if (recentClawdSubmissionRef.current === refreshedSubmissionSnapshot) {
|
||||
recentClawdSubmissionRef.current = null;
|
||||
writeStoredClawdComposerSubmissionSnapshot(null);
|
||||
}
|
||||
}, CLAWD_SUBMITTED_COMPOSER_POST_SEND_GUARD_TTL_MS);
|
||||
}
|
||||
}
|
||||
}
|
||||
setIsClawdSubmitting(false);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user