MCPcopy Index your code
hub / github.com/claude-code-best/claude-code / deduplicateLogsBySessionId

Function deduplicateLogsBySessionId

src/utils/sessionStorage.ts:5068–5081  ·  view source on GitHub ↗

* Deduplicates logs by sessionId, keeping the entry with the newest * modified time. Returns sorted logs with sequential value indices.

(logs: LogOption[])

Source from the content-addressed store, hash-verified

5066 * modified time. Returns sorted logs with sequential value indices.
5067 */
5068function deduplicateLogsBySessionId(logs: LogOption[]): LogOption[] {
5069 const deduped = new Map<string, LogOption>()
5070 for (const log of logs) {
5071 if (!log.sessionId) continue
5072 const existing = deduped.get(log.sessionId)
5073 if (!existing || log.modified.getTime() > existing.modified.getTime()) {
5074 deduped.set(log.sessionId, log)
5075 }
5076 }
5077 return sortLogs([...deduped.values()]).map((log, i) => ({
5078 ...log,
5079 value: i,
5080 }))
5081}
5082
5083/**
5084 * Returns lite LogOption[] from pure filesystem metadata (stat only).

Calls 3

sortLogsFunction · 0.85
setMethod · 0.80
getMethod · 0.65

Tested by

no test coverage detected