MCPcopy Create free account
hub / github.com/codeaashu/claude-code / maybeTruncateInput

Function maybeTruncateInput

src/components/PromptInput/inputPaste.ts:61–90  ·  view source on GitHub ↗
(
  input: string,
  pastedContents: Record<number, PastedContent>,
)

Source from the content-addressed store, hash-verified

59}
60
61export function maybeTruncateInput(
62 input: string,
63 pastedContents: Record<number, PastedContent>,
64): { newInput: string; newPastedContents: Record<number, PastedContent> } {
65 // Get the next available ID for the truncated content
66 const existingIds = Object.keys(pastedContents).map(Number)
67 const nextPasteId = existingIds.length > 0 ? Math.max(...existingIds) + 1 : 1
68
69 // Apply truncation
70 const { truncatedText, placeholderContent } = maybeTruncateMessageForInput(
71 input,
72 nextPasteId,
73 )
74
75 if (!placeholderContent) {
76 return { newInput: input, newPastedContents: pastedContents }
77 }
78
79 return {
80 newInput: truncatedText,
81 newPastedContents: {
82 ...pastedContents,
83 [nextPasteId]: {
84 id: nextPasteId,
85 type: 'text',
86 content: placeholderContent,
87 },
88 },
89 }
90}
91

Callers 1

useMaybeTruncateInputFunction · 0.85

Calls 3

keysMethod · 0.80
maxMethod · 0.80

Tested by

no test coverage detected