MCPcopy Create free account
hub / github.com/WJX20/claude-code / deduplicateLogsBySessionId

Function deduplicateLogsBySessionId

src/utils/sessionStorage.ts:4956–4969  ·  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

4954 * modified time. Returns sorted logs with sequential value indices.
4955 */
4956function deduplicateLogsBySessionId(logs: LogOption[]): LogOption[] {
4957 const deduped = new Map<string, LogOption>()
4958 for (const log of logs) {
4959 if (!log.sessionId) continue
4960 const existing = deduped.get(log.sessionId)
4961 if (!existing || log.modified.getTime() > existing.modified.getTime()) {
4962 deduped.set(log.sessionId, log)
4963 }
4964 }
4965 return sortLogs([...deduped.values()]).map((log, i) => ({
4966 ...log,
4967 value: i,
4968 }))
4969}
4970
4971/**
4972 * Returns lite LogOption[] from pure filesystem metadata (stat only).

Calls 3

sortLogsFunction · 0.85
setMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected