(messageTs: number, currentCline: any)
| 217 | * target the intended message rather than the summary. |
| 218 | */ |
| 219 | const findMessageIndices = (messageTs: number, currentCline: any) => { |
| 220 | // Find the exact message by timestamp, not the first one after a cutoff |
| 221 | const messageIndex = currentCline.clineMessages.findIndex((msg: ClineMessage) => msg.ts === messageTs) |
| 222 | |
| 223 | // Find all matching API messages by timestamp |
| 224 | const allApiMatches = currentCline.apiConversationHistory |
| 225 | .map((msg: ApiMessage, idx: number) => ({ msg, idx })) |
| 226 | .filter(({ msg }: { msg: ApiMessage }) => msg.ts === messageTs) |
| 227 | |
| 228 | // Prefer non-summary message if multiple matches exist (handles timestamp collision after condense) |
| 229 | const preferred = allApiMatches.find(({ msg }: { msg: ApiMessage }) => !msg.isSummary) || allApiMatches[0] |
| 230 | const apiConversationHistoryIndex = preferred?.idx ?? -1 |
| 231 | |
| 232 | return { messageIndex, apiConversationHistoryIndex } |
| 233 | } |
| 234 | |
| 235 | /** |
| 236 | * Fallback: find first API history index at or after a timestamp. |
no outgoing calls
no test coverage detected