(aiChatId: string, leafMessageId?: string | null)
| 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 |
no test coverage detected