Prioritize conversation replies

This commit is contained in:
jjbrunton committed 2026-08-09 16:04:39 +01:00
1 parent f55ae7ddf8
commit 9b86cee9be
13 files changed
+535 -39

No files matched your search

+19
View File
@@ -105,6 +105,25 @@ describe('RateLimiter', () => {
expect(order).toEqual([1, 2, 3]);
});
it('runs a queued high-priority reply before queued outreach', async () => {
const order: string[] = [];
let release!: () => void;
const blocker = new Promise<void>((resolve) => { release = resolve; });
const active = limiter.throttle(async () => {
order.push('active');
await blocker;
return 'active';
});
await vi.waitFor(() => expect(order).toEqual(['active']));
const outreach = limiter.throttle(async () => { order.push('outreach'); return 'outreach'; });
const reply = limiter.throttle(async () => { order.push('reply'); return 'reply'; }, () => true, undefined, 100);
release();
await Promise.all([active, outreach, reply]);
expect(order).toEqual(['active', 'reply', 'outreach']);
});
describe('getStats', () => {
it('returns initial stats', () => {
const stats = limiter.getStats();