MCPcopy Create free account
hub / github.com/freecodexyz/free-code / isCollapsibleToolResult

Function isCollapsibleToolResult

src/utils/collapseReadSearch.ts:431–447  ·  view source on GitHub ↗

* Type predicate: Check if a message is a tool result for collapsible tools. * Returns true if ALL tool results in the message are for tracked collapsible tools.

(
  msg: RenderableMessage,
  collapsibleToolUseIds: Set<string>,
)

Source from the content-addressed store, hash-verified

429 * Returns true if ALL tool results in the message are for tracked collapsible tools.
430 */
431function isCollapsibleToolResult(
432 msg: RenderableMessage,
433 collapsibleToolUseIds: Set<string>,
434): msg is CollapsibleMessage {
435 if (msg.type === 'user') {
436 const toolResults = msg.message.content.filter(
437 (c): c is { type: 'tool_result'; tool_use_id: string } =>
438 c.type === 'tool_result',
439 )
440 // Only return true if there are tool results AND all of them are for collapsible tools
441 return (
442 toolResults.length > 0 &&
443 toolResults.every(r => collapsibleToolUseIds.has(r.tool_use_id))
444 )
445 }
446 return false
447}
448
449/**
450 * Get all tool use IDs from a single message (handles grouped tool uses).

Callers 1

collapseReadSearchGroupsFunction · 0.85

Calls 1

hasMethod · 0.45

Tested by

no test coverage detected