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