diff --git a/components/canvas/CanvasChatPanel.tsx b/components/canvas/CanvasChatPanel.tsx index bff96deab..62825f464 100644 --- a/components/canvas/CanvasChatPanel.tsx +++ b/components/canvas/CanvasChatPanel.tsx @@ -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);