fix(ai-toolbar): honor AI state in shortcuts and clipboard dedup

This commit is contained in:
2026-04-23 04:39:27 -04:00
parent 6f7f727b27
commit 470d76d46c
4 changed files with 95 additions and 15 deletions

View File

@@ -310,6 +310,8 @@ export const AIToolbar = ({
if (
e.key === "Enter" &&
(e.metaKey || e.ctrlKey) &&
!aiLoading &&
canUseAi &&
(aiPrompt.trim() || hasImages)
) {
e.preventDefault();

View File

@@ -8,14 +8,15 @@
/**
* Returns a stable deduplication key for a File.
* Key = `name:size` — cheap, deterministic, and catches re-selections of the
* exact same file (same name *and* same byte count).
* Key = `name:size:lastModified` — cheap, deterministic, and catches
* re-selections of the exact same file while keeping clipboard fallback files
* distinct when they share a generated name and byte size.
*
* Two different files that happen to share a name but have different content
* will have different sizes and therefore different keys.
* Two different files that happen to share a generated fallback name but have
* different timestamps will not collapse to the same key.
*/
export function imageFileKey(file: File): string {
return `${file.name}:${file.size}`;
return `${file.name}:${file.size}:${file.lastModified}`;
}
/**