@devries-cameron20 / t3code Mirror · read-only
Fork 0

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

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 04:45 UTC

main
ts 19 lines 857 Bytes
Raw
1 import type { ThreadReferenceCopyTarget } from "@t3tools/client-runtime/thread-reference";
2 import * as Haptics from "expo-haptics";
3
4 import { writeComposerContextClipboard } from "./composerContextClipboard";
5 import { tryCopyTextWithHaptic } from "./copyTextWithHaptic";
6
7 /** Resolves false, after logging why, when the clipboard write fails. */
8 export async function copyThreadReference(target: ThreadReferenceCopyTarget): Promise<boolean> {
9 if (!target.fragment)
10 return tryCopyTextWithHaptic(target.value, { target: target.clipboardTarget });
11 try {
12 await writeComposerContextClipboard(target.value, target.fragment);
13 } catch (error) {
14 console.error(`Failed to copy ${target.clipboardTarget} to the clipboard.`, error);
15 return false;
16 }
17 void Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Light).catch(() => {});
18 return true;
19 }