(
sessionId: UUID,
)
| 1313 | */ |
| 1314 | private existingSessionFiles = new Map<string, string>() |
| 1315 | private async getExistingSessionFile( |
| 1316 | sessionId: UUID, |
| 1317 | ): Promise<string | null> { |
| 1318 | const cached = this.existingSessionFiles.get(sessionId) |
| 1319 | if (cached) return cached |
| 1320 | |
| 1321 | const targetFile = getTranscriptPathForSession(sessionId) |
| 1322 | try { |
| 1323 | await stat(targetFile) |
| 1324 | // Evict oldest entry when at capacity so the Map stays bounded |
| 1325 | if (this.existingSessionFiles.size >= MAX_CACHED_SESSION_FILES) { |
| 1326 | const oldestKey = this.existingSessionFiles.keys().next().value |
| 1327 | if (oldestKey !== undefined) { |
| 1328 | this.existingSessionFiles.delete(oldestKey) |
| 1329 | } |
| 1330 | } |
| 1331 | this.existingSessionFiles.set(sessionId, targetFile) |
| 1332 | return targetFile |
| 1333 | } catch (e) { |
| 1334 | if (isFsInaccessible(e)) return null |
| 1335 | throw e |
| 1336 | } |
| 1337 | } |
| 1338 | |
| 1339 | private async persistToRemote(sessionId: UUID, entry: TranscriptMessage) { |
| 1340 | if (isShuttingDown()) { |
no test coverage detected