Skip to content

Commit a68615c

Browse files
PR Batch Testerclaude
andcommitted
fix(mobile): only add chips for files the merge brought in
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent daa862d commit a68615c

1 file changed

Lines changed: 15 additions & 9 deletions

File tree

‎apps/mobile/src/state/use-composer-drafts.ts‎

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,10 @@ function attachmentContextRecord(
489489
: { ...common, kind: "file" as const };
490490
}
491491

492-
function restoreMissingComposerFileReferences(draft: ComposerDraft): ComposerDraft {
492+
function restoreMissingComposerFileReferences(
493+
draft: ComposerDraft,
494+
attachments = draft.attachments,
495+
): ComposerDraft {
493496
const records = [...(draft.context?.records ?? [])];
494497
const usedIds = new Set<string>(records.map((record) => record.contextId));
495498
const referenced = new Set(
@@ -499,7 +502,7 @@ function restoreMissingComposerFileReferences(draft: ComposerDraft): ComposerDra
499502
);
500503
let text = draft.text;
501504
let changed = false;
502-
for (const attachment of draft.attachments) {
505+
for (const attachment of attachments) {
503506
if (
504507
attachment.type === "image" ||
505508
imageMimeType(attachment) !== null ||
@@ -1580,13 +1583,16 @@ export function mergeComposerDraftContentState(
15801583
...current,
15811584
// The composer shows non-image files only as inline chips, so a shared file
15821585
// merged without one would be attached but invisible until sent.
1583-
[draftKey]: restoreMissingComposerFileReferences({
1584-
...existing,
1585-
text,
1586-
attachments,
1587-
context,
1588-
...(importedShareIds ? { importedShareIds } : {}),
1589-
}),
1586+
[draftKey]: restoreMissingComposerFileReferences(
1587+
{
1588+
...existing,
1589+
text,
1590+
attachments,
1591+
context,
1592+
...(importedShareIds ? { importedShareIds } : {}),
1593+
},
1594+
attachments.slice(existing.attachments.length),
1595+
),
15901596
};
15911597
}
15921598

0 commit comments

Comments
 (0)