MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / formatQueuedPreview

Function formatQueuedPreview

cli/src/utils/helpers.ts:24–47  ·  view source on GitHub ↗
(
  messages: Array<{ content: string }>,
  maxChars: number = 60,
)

Source from the content-addressed store, hash-verified

22}
23
24export function formatQueuedPreview(
25 messages: Array<{ content: string }>,
26 maxChars: number = 60,
27): string {
28 if (messages.length === 0) return ''
29
30 const latestMessage = messages[messages.length - 1].content
31 const singleLine = latestMessage.replace(/\s+/g, ' ').trim()
32 if (!singleLine) return ''
33
34 const countSuffix = messages.length > 1 ? ` (+ ${messages.length - 1})` : ''
35 const prefix = '↑ '
36 const suffix = ' ↑'
37 const availableChars =
38 maxChars - prefix.length - suffix.length - countSuffix.length
39
40 let messagePreview = singleLine
41 if (singleLine.length > availableChars) {
42 messagePreview =
43 singleLine.slice(0, Math.max(0, availableChars - 3)) + '...'
44 }
45
46 return `${prefix}${messagePreview}${countSuffix}${suffix}`
47}

Callers 1

useQueueUiFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected