Reviews
Work agents have handed to a person, and what became of it.
ChangeAfter
- ⋯ Lines from 14
- 1414 * lie with a timestamp on it. Anything older than the window is dropped.14 * lie with a timestamp on it. Anything older than the window is dropped.
- 1515 */15 */
- 16−Removed: const STALE_AFTER_MS = 90_000;
- 16+Added: export const STALE_AFTER_MS = 90_000;16export const STALE_AFTER_MS = 90_000;
- 17+Added:17
- 18+Added: /** True once a status has outlived the window. The header greys it, then drops it. */18/** True once a status has outlived the window. The header greys it, then drops it. */
- 19+Added: export function isStale(status: AgentStatus, now = Date.now()): boolean {19export function isStale(status: AgentStatus, now = Date.now()): boolean {
- 20+Added: return now - status.ts > STALE_AFTER_MS;20 return now - status.ts > STALE_AFTER_MS;
- 21+Added: }21}
- 172222
- 1823 export interface AgentStatus {23export interface AgentStatus {
- 1924 agentId: AgentId;24 agentId: AgentId;
- ⋯ Lines from 50
- 4550 export async function getStatuses(channelId: string): Promise<AgentStatus[]> {50export async function getStatuses(channelId: string): Promise<AgentStatus[]> {
- 46−Removed: const cutoff = Date.now() - STALE_AFTER_MS;
- 51+Added: const now = Date.now();51 const now = Date.now();
- 4752 let all: AgentStatus[];52 let all: AgentStatus[];
- 485353
- 4954 if (redisEnabled) {54 if (redisEnabled) {
- ⋯ Lines from 69
- 6469 all = [...(memory.get(channelId)?.values() ?? [])];69 all = [...(memory.get(channelId)?.values() ?? [])];
- 6570 }70 }
- 66−Removed: return all.filter((s) => s.ts >= cutoff);
- 71+Added: return all.filter((s) => !isStale(s, now));71 return all.filter((s) => !isStale(s, now));
- 6772 }72}