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

Function buildMessageContext

cli/src/utils/feedback-helpers.ts:26–47  ·  view source on GitHub ↗
(
  messages: ChatMessage[],
  targetMessageId: string | null,
)

Source from the content-addressed store, hash-verified

24}
25
26export function buildMessageContext(
27 messages: ChatMessage[],
28 targetMessageId: string | null,
29): {
30 target: ChatMessage | null
31 recentMessages: RecentMessageSummary[]
32} {
33 if (!targetMessageId) {
34 const startIndex = Math.max(0, messages.length - MAX_RECENT_MESSAGES)
35 return { target: null, recentMessages: messages.slice(startIndex).map(toRecentMessageSummary) }
36 }
37
38 const target = messages.find((m: ChatMessage) => m.id === targetMessageId) ?? null
39
40 if (!target) {
41 return { target: null, recentMessages: [] }
42 }
43
44 const targetIndex = messages.indexOf(target)
45 const startIndex = Math.max(0, targetIndex - (MAX_RECENT_MESSAGES - 1))
46 return { target, recentMessages: messages.slice(startIndex, targetIndex + 1).map(toRecentMessageSummary) }
47}
48
49export interface BuildFeedbackPayloadParams {
50 text: string

Callers 2

FeedbackContainerFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected