Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(desktop): count cap-time image duplicates as duplicates, not drops (R2-L1)
M4970a551e2ba
diff --git a/desktop-app/ui/src/hooks/domain/__tests__/composerMergeZipProperties.test.tsx b/desktop-app/ui/src/hooks/domain/__tests__/composerMergeZipProperties.test.tsxindex c4c831afd..26a7bfc27 100644--- a/desktop-app/ui/src/hooks/domain/__tests__/composerMergeZipProperties.test.tsx+++ b/desktop-app/ui/src/hooks/domain/__tests__/composerMergeZipProperties.test.tsx@@ -43,6 +43,28 @@ const referenceArbitrary = fc}))describe('composer merge invariants (R1-M6)', () => {+ it('counts a cap-time duplicate as a duplicate, not a drop (R2-L1)', () => {+ // Composer already at the cap; the restore payload is byte-identical to+ // what is held. Nothing is lost — reporting a drop would be a lie.+ const held = Array.from({ length: COMPOSER_MAX_IMAGE_ATTACHMENTS }, (_, index) => ({+ ...({} as ComposerImageAttachment),+ id: `held-${index}`,+ name: `held-${index}.png`,+ mimeType: 'image/png' as const,+ dataBase64: `aGVsZA-${index}`,+ sizeBytes: 4,+ previewDataUrl: `data:image/png;base64,aGVsZA-${index}`,+ }))+ const restore = [held[3]!, held[7]!]+ const outcome = mergeComposerImageAttachments(held, restore)+ expect(outcome.duplicates).toBe(2)+ expect(outcome.dropped).toBe(0)+ expect(outcome.kept).toBe(0)+ expect(outcome.next).toHaveLength(COMPOSER_MAX_IMAGE_ATTACHMENTS)+ // The exact same set survives: restoring dropped nothing new.+ expect(outcome.next).toEqual(held)+ })+it('image merge: cap, count conservation, and existing-set stability', () => {fc.assert(fc.property(diff --git a/desktop-app/ui/src/hooks/domain/useComposerAttachments.ts b/desktop-app/ui/src/hooks/domain/useComposerAttachments.tsindex 535dd9393..7a8f0d76c 100644--- a/desktop-app/ui/src/hooks/domain/useComposerAttachments.ts+++ b/desktop-app/ui/src/hooks/domain/useComposerAttachments.ts@@ -31,7 +31,10 @@ export function mergeComposerImageAttachments(let kept = 0let duplicates = 0for (const attachment of incoming) {- if (accepted.length >= COMPOSER_MAX_IMAGE_ATTACHMENTS) break+ // Dedupe BEFORE capacity (R2-L1): a byte-identical copy of an attachment+ // the composer already holds is not "dropped at the cap" — nothing is+ // lost, it is already there — so it must never consume the drop count (or+ // a slot) even when the composer is full.const duplicate = accepted.some(candidate =>candidate.mimeType === attachment.mimeType &&@@ -42,6 +45,7 @@ export function mergeComposerImageAttachments(duplicates += 1continue}+ if (accepted.length >= COMPOSER_MAX_IMAGE_ATTACHMENTS) breakaccepted.push(attachment.addedOrder != null ? attachment : { ...attachment, addedOrder: nextOrder() })