MCPcopy
hub / github.com/codeaashu/claude-code / hasOnlyWhitespaceTextContent

Function hasOnlyWhitespaceTextContent

src/utils/messages.ts:4835–4855  ·  view source on GitHub ↗

* Check if an assistant message has only whitespace-only text content blocks. * Returns true if all content blocks are text blocks with only whitespace. * Returns false if there are any non-text blocks (like tool_use) or text with actual content.

(
  content: Array<{ type: string; text?: string }>,
)

Source from the content-addressed store, hash-verified

4833 * Returns false if there are any non-text blocks (like tool_use) or text with actual content.
4834 */
4835function hasOnlyWhitespaceTextContent(
4836 content: Array<{ type: string; text?: string }>,
4837): boolean {
4838 if (content.length === 0) {
4839 return false
4840 }
4841
4842 for (const block of content) {
4843 // If there's any non-text block (tool_use, thinking, etc.), the message is valid
4844 if (block.type !== 'text') {
4845 return false
4846 }
4847 // If there's a text block with non-whitespace content, the message is valid
4848 if (block.text !== undefined && block.text.trim() !== '') {
4849 return false
4850 }
4851 }
4852
4853 // All blocks are text blocks with only whitespace
4854 return true
4855}
4856
4857/**
4858 * Filter out assistant messages with only whitespace-only text content.

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected