()
| 334 | } |
| 335 | |
| 336 | private expireInactive(): void { |
| 337 | const expired = this.sessionCache.expireInactive() |
| 338 | // Sort by most recent first so dedup keeps the newest session when multiple |
| 339 | // duplicates for the same agent thread expire in the same sweep. |
| 340 | const sorted = expired |
| 341 | .map((id) => this.sessionCache.getSession(id)) |
| 342 | .filter((s): s is NonNullable<typeof s> => s != null) |
| 343 | .sort((a, b) => (b.activeAt - a.activeAt) || (b.updatedAt - a.updatedAt)) |
| 344 | for (const session of sorted) { |
| 345 | this.triggerDedupIfNeeded(session.id) |
| 346 | } |
| 347 | this.machineCache.expireInactive() |
| 348 | // Piggybacked on the inactivity tick; not a logical part of expireInactive |
| 349 | // but shares its 5s cadence (avoids a second timer). |
| 350 | this.messageService.releaseMatureScheduledMessages(Date.now()) |
| 351 | } |
| 352 | |
| 353 | private reloadAll(): void { |
| 354 | this.sessionCache.reloadAll() |
no test coverage detected