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

Function computeSearchText

source code/utils/transcriptSearch.ts:34–130  ·  view source on GitHub ↗
(msg: RenderableMessage)

Source from the content-addressed store, hash-verified

32}
33
34function computeSearchText(msg: RenderableMessage): string {
35 let raw = ''
36 switch (msg.type) {
37 case 'user': {
38 const c = msg.message.content
39 if (typeof c === 'string') {
40 raw = RENDERED_AS_SENTINEL.has(c) ? '' : c
41 } else {
42 const parts: string[] = []
43 for (const b of c) {
44 if (b.type === 'text') {
45 if (!RENDERED_AS_SENTINEL.has(b.text)) parts.push(b.text)
46 } else if (b.type === 'tool_result') {
47 // b.content is the MODEL-facing serialization (from each tool's
48 // mapToolResultToToolResultBlockParam) — adds system-reminders,
49 // <persisted-output> wrappers, backgroundInfo strings,
50 // CYBER_RISK_MITIGATION_REMINDER. The UI
51 // renders msg.toolUseResult (the tool's native Out) via
52 // renderToolResultMessage — DIFFERENT text. Indexing b.content
53 // yields phantoms: /malware → matches the reminder, /background
54 // → matches the model-only ID string, none render.
55 //
56 // Duck-type the native Out instead. Covers the common shapes:
57 // Bash {stdout,stderr}, Grep {content,filenames}, Read
58 // {file.content}. Unknown shapes index empty — under-count is
59 // honest, phantom is a lie. Proper fix is per-tool
60 // extractSearchText(Out) on the Tool interface (TODO).
61 parts.push(toolResultSearchText(msg.toolUseResult))
62 }
63 }
64 raw = parts.join('\n')
65 }
66 break
67 }
68 case 'assistant': {
69 const c = msg.message.content
70 if (Array.isArray(c)) {
71 // text blocks + tool_use inputs. tool_use renders as "⏺ Bash(cmd)"
72 // — the command/pattern/path is visible and searchable-expected.
73 // Skip thinking (hidden by hidePastThinking in transcript mount).
74 raw = c
75 .flatMap(b => {
76 if (b.type === 'text') return [b.text]
77 if (b.type === 'tool_use') return [toolUseSearchText(b.input)]
78 return []
79 })
80 .join('\n')
81 }
82 break
83 }
84 case 'attachment': {
85 // relevant_memories renders full m.content in transcript mode
86 // (AttachmentMessage.tsx <Ansi>{m.content}</Ansi>). Visible but
87 // unsearchable without this — [ dump finds it, / doesn't.
88 if (msg.attachment.type === 'relevant_memories') {
89 raw = msg.attachment.memories.map(m => m.content).join('\n')
90 } else if (
91 // Mid-turn prompts — queued while an agent is running. Render via

Callers 1

renderableSearchTextFunction · 0.85

Calls 3

toolResultSearchTextFunction · 0.85
toolUseSearchTextFunction · 0.85
hasMethod · 0.45

Tested by

no test coverage detected