fix(pi): keep active runs alive during background sleep

This commit is contained in:
2026-08-25 20:56:17 +08:00
parent 92f4c91088
commit 621ebb1781
22 changed files with 1061 additions and 68 deletions

View File

@@ -261,7 +261,7 @@ describe('Pi worker pool', () => {
await expect.poll(() => processBudget.waitingCount).toBe(1);
expect(opened).toEqual(['conversation-a', 'conversation-b']);
await pool.dispose('conversation-a');
await pool.dispose('conversation-a', 'test_injection');
await expect(third).resolves.toMatchObject({ conversationId: 'conversation-c', state: 'ready' });
expect(opened).toEqual(['conversation-a', 'conversation-b', 'conversation-c']);
expect(processBudget.activeCount).toBe(2);
@@ -292,7 +292,7 @@ describe('Pi worker pool', () => {
});
await pool.prepare(conversation('conversation-stop-failure'));
await expect(pool.dispose('conversation-stop-failure')).rejects.toThrow('stop failed');
await expect(pool.dispose('conversation-stop-failure', 'test_injection')).rejects.toThrow('stop failed');
expect(processBudget.activeCount).toBe(0);
expect(processBudget.waitingCount).toBe(0);
});
@@ -804,7 +804,7 @@ describe('Pi worker pool', () => {
expect(workers.get('conversation-a')![0]!.stopped).toBe(true);
expect(workers.get('conversation-b')![0]!.stopped).toBe(false);
await pool.dispose('conversation-a');
await pool.dispose('conversation-a', 'test_injection');
expect(workers.get('conversation-a')![1]!.stopped).toBe(true);
expect(pool.getState('conversation-a')).toBeNull();
expect(pool.getState('conversation-b')).toMatchObject({ state: 'ready', generation: 1 });