MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / copyTextOf

Function copyTextOf

source code/components/messageActions.tsx:411–443  ·  view source on GitHub ↗
(msg: NavigableMessage)

Source from the content-addressed store, hash-verified

409 return t;
410}
411export function copyTextOf(msg: NavigableMessage): string {
412 switch (msg.type) {
413 case 'user':
414 {
415 const b = msg.message.content[0];
416 return b?.type === 'text' ? stripSystemReminders(b.text) : '';
417 }
418 case 'assistant':
419 {
420 const b = msg.message.content[0];
421 if (b?.type === 'text') return b.text;
422 const tc = toolCallOf(msg);
423 return tc ? PRIMARY_INPUT[tc.name]?.extract(tc.input) ?? '' : '';
424 }
425 case 'grouped_tool_use':
426 return msg.results.map(toolResultText).filter(Boolean).join('\n\n');
427 case 'collapsed_read_search':
428 return msg.messages.flatMap(m => m.type === 'user' ? [toolResultText(m)] : m.type === 'grouped_tool_use' ? m.results.map(toolResultText) : []).filter(Boolean).join('\n\n');
429 case 'system':
430 if ('content' in msg) return msg.content;
431 if ('error' in msg) return String(msg.error);
432 return msg.subtype;
433 case 'attachment':
434 {
435 const a = msg.attachment;
436 if (a.type === 'queued_command') {
437 const p = a.prompt;
438 return typeof p === 'string' ? p : p.flatMap(b => b.type === 'text' ? [b.text] : []).join('\n');
439 }
440 return `[${a.type}]`;
441 }
442 }
443}
444function toolResultText(r: NormalizedUserMessage): string {
445 const b = r.message.content[0];
446 if (b?.type !== 'tool_result') return '';

Callers 1

messageActions.tsxFile · 0.85

Calls 3

stripSystemRemindersFunction · 0.85
toolCallOfFunction · 0.85
toolResultTextFunction · 0.85

Tested by

no test coverage detected