MCPcopy Create free account
hub / github.com/Zoo-Code-Org/Zoo-Code / findMessageIndices

Function findMessageIndices

src/core/webview/webviewMessageHandler.ts:219–233  ·  view source on GitHub ↗
(messageTs: number, currentCline: any)

Source from the content-addressed store, hash-verified

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.

Callers 4

handleDeleteOperationFunction · 0.85
handleEditOperationFunction · 0.85
handleEditMessageConfirmFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected