Reviews
ChangeAfter
- Lines from 14
- * lie with a timestamp on it. Anything older than the window is dropped.
- */
- Removed: const STALE_AFTER_MS = 90_000;
- Added: export const STALE_AFTER_MS = 90_000;
- Added:
- Added: /** True once a status has outlived the window. The header greys it, then drops it. */
- Added: export function isStale(status: AgentStatus, now = Date.now()): boolean {
- Added: return now - status.ts > STALE_AFTER_MS;
- Added: }
- export interface AgentStatus {
- agentId: AgentId;
- Lines from 50
- export async function getStatuses(channelId: string): Promise<AgentStatus[]> {
- Removed: const cutoff = Date.now() - STALE_AFTER_MS;
- Added: const now = Date.now();
- let all: AgentStatus[];
- if (redisEnabled) {
- Lines from 69
- all = [...(memory.get(channelId)?.values() ?? [])];
- }
- Removed: return all.filter((s) => s.ts >= cutoff);
- Added: return all.filter((s) => !isStale(s, now));
- }