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