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

main
ts 25 lines 887 Bytes
Raw
1 import {
2 composerTargetKey,
3 type ComposerThreadTarget,
4 useComposerDraftStore,
5 } from "../../composerDraftStore";
6 import {
7 type ComposerContextReference,
8 ensureInlineContextReferences,
9 } from "../../lib/composerContextReferences";
10
11 export function insertAttachmentReferencesForDraft(input: {
12 target: ComposerThreadTarget;
13 liveAttachmentTargetKey: string;
14 references: ReadonlyArray<ComposerContextReference>;
15 insertReferences: () => boolean;
16 }): boolean {
17 if (composerTargetKey(input.target) !== input.liveAttachmentTargetKey) {
18 // The shared editor now belongs to another draft or question.
19 const store = useComposerDraftStore.getState();
20 const prompt = store.getComposerDraft(input.target)?.prompt ?? "";
21 store.setPrompt(input.target, ensureInlineContextReferences(prompt, input.references));
22 return true;
23 }
24 return input.insertReferences();
25 }