Skip to content

Commit daa862d

Browse files
PR Batch Testerclaude
andcommitted
fix(mobile): a file shared into a new task shows in the composer before you send
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 1451e7c commit daa862d

2 files changed

Lines changed: 37 additions & 3 deletions

File tree

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

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,10 @@ vi.mock("../features/sharing/incoming-share-storage", () => ({
148148
}));
149149

150150
import type { DraftComposerAttachment } from "../lib/composerImages";
151-
import { formatComposerContextReference } from "@t3tools/shared/composerContextReferences";
151+
import {
152+
collectComposerContextReferences,
153+
formatComposerContextReference,
154+
} from "@t3tools/shared/composerContextReferences";
152155
import { appAtomRegistry } from "./atom-registry";
153156
import { threadOutboxManager } from "./thread-outbox";
154157
import {
@@ -2304,6 +2307,35 @@ describe("mobile composer drafts", () => {
23042307
expect(mergeComposerDraftContentState(edited, draftKey, content)).toBe(edited);
23052308
});
23062309

2310+
it("shows a shared non-image file as a composer chip", () => {
2311+
const draftKey = "new-task:environment-1:project-1";
2312+
const sharedFile = {
2313+
id: "share-1:file:0",
2314+
type: "file" as const,
2315+
name: "backup.json",
2316+
mimeType: "application/json",
2317+
sizeBytes: 41,
2318+
fileUri: "file:///documents/backup.json",
2319+
};
2320+
2321+
const merged = mergeComposerDraftContentState({}, draftKey, {
2322+
text: "",
2323+
attachments: [sharedFile],
2324+
sourceShareId: "share-1",
2325+
})[draftKey]!;
2326+
2327+
expect(merged.attachments).toEqual([sharedFile]);
2328+
const references = collectComposerContextReferences(merged.text);
2329+
expect(references).toHaveLength(1);
2330+
expect(merged.context?.records).toEqual([
2331+
expect.objectContaining({
2332+
kind: "file",
2333+
contextId: references[0]!.contextId,
2334+
attachmentId: sharedFile.id,
2335+
}),
2336+
]);
2337+
});
2338+
23072339
it("preserves existing images when shared content exceeds the draft attachment limit", () => {
23082340
const draftKey = "new-task:environment-1:project-1";
23092341
const image = (id: string) => ({

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1578,13 +1578,15 @@ export function mergeComposerDraftContentState(
15781578
}
15791579
return {
15801580
...current,
1581-
[draftKey]: {
1581+
// The composer shows non-image files only as inline chips, so a shared file
1582+
// merged without one would be attached but invisible until sent.
1583+
[draftKey]: restoreMissingComposerFileReferences({
15821584
...existing,
15831585
text,
15841586
attachments,
15851587
context,
15861588
...(importedShareIds ? { importedShareIds } : {}),
1587-
},
1589+
}),
15881590
};
15891591
}
15901592

0 commit comments

Comments
 (0)