fix(coding): serialize agent server sleep restart

This commit is contained in:
2026-09-01 14:36:18 +08:00
parent 850947c092
commit 12d7588b3e
5 changed files with 141 additions and 0 deletions

View File

@@ -133,6 +133,30 @@ describe('Pi Agent Server real process', () => {
}
}, 10_000);
it('restarts when start races with a graceful background stop', async () => {
const root = await mkdtemp(path.join(tmpdir(), 'makelore-pi-agent-server-restart-'));
roots.push(root);
const layout = await materializePackagedAgentServerLayout(root);
const server = new PiAgentServerProcess({
executablePath: electronExecutable,
...layout,
});
try {
await server.start();
const firstProcessId = server.processId;
expect(firstProcessId).toBeTypeOf('number');
const stopping = server.stop();
const restarting = server.start();
await Promise.all([stopping, restarting]);
expect(server.processId).toBeTypeOf('number');
expect(server.processId).not.toBe(firstProcessId);
} finally {
await server.stop();
}
}, 20_000);
it('hosts isolated Conversation threads in one long-lived process', async () => {
const root = await mkdtemp(path.join(tmpdir(), 'makelore-pi-agent-server-'));
roots.push(root);