MCPcopy Create free account
hub / github.com/experdot/pointer / getDescendantIds

Function getDescendantIds

src/renderer/src/services/messagesService.ts:110–127  ·  view source on GitHub ↗
(
  childrenMap: Map<string | undefined, ChatMessage[]>,
  messageId: string
)

Source from the content-addressed store, hash-verified

108}
109
110function getDescendantIds(
111 childrenMap: Map<string | undefined, ChatMessage[]>,
112 messageId: string
113): Set<string> {
114 const ids = new Set<string>()
115 const stack = [messageId]
116
117 while (stack.length > 0) {
118 const currentId = stack.pop()!
119 const children = childrenMap.get(currentId) ?? []
120 for (const child of children) {
121 ids.add(child.id)
122 stack.push(child.id)
123 }
124 }
125
126 return ids
127}
128
129export function getNextBranchIndex(messages: ChatMessage[], parentId: string | undefined): number {
130 const children = getChildMessages(messages, parentId)

Callers 1

deleteMessageFunction · 0.70

Calls 1

getMethod · 0.65

Tested by

no test coverage detected