MCPcopy Index your code
hub / github.com/codeaashu/claude-code / collectRecentAssistantTexts

Function collectRecentAssistantTexts

src/commands/copy/copy.tsx:50–61  ·  view source on GitHub ↗
(messages: Message[])

Source from the content-addressed store, hash-verified

48 * Index 0 = latest, 1 = second-to-latest, etc. Caps at MAX_LOOKBACK.
49 */
50export function collectRecentAssistantTexts(messages: Message[]): string[] {
51 const texts: string[] = [];
52 for (let i = messages.length - 1; i >= 0 && texts.length < MAX_LOOKBACK; i--) {
53 const msg = messages[i];
54 if (msg?.type !== 'assistant' || msg.isApiErrorMessage) continue;
55 const content = (msg as AssistantMessage).message.content;
56 if (!Array.isArray(content)) continue;
57 const text = extractTextContent(content, '\n\n');
58 if (text) texts.push(text);
59 }
60 return texts;
61}
62export function fileExtension(lang: string | undefined): string {
63 if (lang) {
64 // Sanitize to prevent path traversal (e.g. ```../../etc/passwd)

Callers 1

callFunction · 0.85

Calls 2

extractTextContentFunction · 0.50
pushMethod · 0.45

Tested by

no test coverage detected