fix(claw): clear restored submitted composer text

This commit is contained in:
134 2026-08-01 10:52:27 +08:00
parent 288cd7bf79
commit 9093b0370b

View File

@ -404,7 +404,6 @@ 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,
];
@ -3290,7 +3289,6 @@ export function CanvasChatPanel({
const editableDiv = textareaRef.current as HTMLDivElement | null;
if (!submissionSnapshot || !editableDiv) return;
if (!isClawdSubmissionForCurrentComposer(submissionSnapshot)) return;
if (composerUserEditedAtRef.current > submissionSnapshot.startedAt) return;
const editorText = normalizeClawdComposerText(
getComposerPlainTextFromElement(editableDiv)
@ -11866,20 +11864,11 @@ export function CanvasChatPanel({
} else {
const refreshedSubmissionSnapshot = {
...clawdSubmissionSnapshot,
expiresAt:
Date.now() + CLAWD_SUBMITTED_COMPOSER_POST_SEND_GUARD_TTL_MS,
expiresAt: Date.now() + CLAWD_SUBMITTED_COMPOSER_RECOVERY_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);
@ -16786,8 +16775,14 @@ export function CanvasChatPanel({
);
if (isRestoredSubmittedClawdText) {
scheduleClearRestoredClawdComposerText();
clearComposerEditor();
return;
}
if (!isRestoredSubmittedClawdText) {
const isProgrammaticClawdClearEvent =
activeClawdSubmission !== null &&
isClawdSubmissionForCurrentComposer(activeClawdSubmission) &&
!textContent;
if (!isProgrammaticClawdClearEvent) {
composerUserEditedAtRef.current = Date.now();
}
setInput(textContent);