The best way to control Claude Code, Codex and more from any computer or phone

main
ts 21 lines 778 Bytes
Raw
1 import type { EnvironmentId } from "@t3tools/contracts";
2
3 // Keep the latest copy's files alive after source removal, including preview URL revocation.
4 // Replacing the copy releases the previous files instead of accumulating draft attachments.
5 let latestCopy: { environmentId: EnvironmentId; files: ReadonlyMap<string, File> } | null = null;
6
7 export function rememberCopiedComposerAttachments(
8 environmentId: EnvironmentId,
9 files: ReadonlyMap<string, File>,
10 ): void {
11 latestCopy = files.size > 0 ? { environmentId, files } : null;
12 }
13
14 export function copiedComposerAttachmentFile(
15 environmentId: EnvironmentId,
16 attachmentId: string,
17 ): File | undefined {
18 return latestCopy?.environmentId === environmentId
19 ? latestCopy.files.get(attachmentId)
20 : undefined;
21 }