* Deduplicates logs by sessionId, keeping the entry with the newest * modified time. Returns sorted logs with sequential value indices.
(logs: LogOption[])
| 5066 | * modified time. Returns sorted logs with sequential value indices. |
| 5067 | */ |
| 5068 | function 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). |
no test coverage detected