MCPcopy Index your code
hub / github.com/ChatLab/ChatLab / getActivePathRows

Method getActivePathRows

packages/node-runtime/src/ai/chats.ts:416–436  ·  view source on GitHub ↗
(aiChatId: string, leafMessageId?: string | null)

Source from the content-addressed store, hash-verified

414 }
415
416 private getActivePathRows(aiChatId: string, leafMessageId?: string | null): AIMessageRow[] {
417 if (leafMessageId === null) return []
418
419 const allRows = this.getAllMessageRows(aiChatId)
420 if (allRows.length === 0) return []
421
422 const rowMap = new Map(allRows.map((row) => [row.id, row]))
423 let currentId = leafMessageId ?? this.getActiveMessageId(aiChatId)
424 const path: AIMessageRow[] = []
425 const seen = new Set<string>()
426
427 while (currentId && !seen.has(currentId)) {
428 seen.add(currentId)
429 const row = rowMap.get(currentId)
430 if (!row) break
431 path.push(row)
432 currentId = row.parentId
433 }
434
435 return path.length > 0 ? path.reverse() : allRows
436 }
437
438 // ==================== 生命周期 ====================
439

Callers 9

getMessagesMethod · 0.95
deleteMessagesFromMethod · 0.95
forkAIChatMethod · 0.95
getAIChatTokenUsageMethod · 0.95
getHistoryForAgentMethod · 0.95
getLatestSummaryMethod · 0.95

Calls 4

getAllMessageRowsMethod · 0.95
getActiveMessageIdMethod · 0.95
getMethod · 0.65
addMethod · 0.45

Tested by

no test coverage detected