MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / copyCode

Function copyCode

graph-ui/src/browser-ai/ChatMarkdown.tsx:17–27  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

15 const copyTicket = useRef(0);
16 const status = copy.text === codeText ? copy.status : 'idle';
17 const copyCode = async (): Promise<void> => {
18 const ticket = ++copyTicket.current;
19 setCopy({ text: codeText, status: 'copying' });
20 try {
21 if (!navigator.clipboard?.writeText) throw new Error('Clipboard unavailable');
22 await navigator.clipboard.writeText(codeText);
23 if (ticket === copyTicket.current) setCopy({ text: codeText, status: 'copied' });
24 } catch {
25 if (ticket === copyTicket.current) setCopy({ text: codeText, status: 'failed' });
26 }
27 };
28 return <div className="cbm-chat-code-block">
29 <div className="cbm-chat-code-header"><span className="cbm-chat-code-language">{language}</span><div>
30 {status === 'failed' && <span className="cbm-chat-code-copy-error" role="status">Copy unavailable</span>}

Callers 1

CodeBlockFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected