fix(pi): settle delayed compact ownership

This commit is contained in:
2026-08-26 09:41:25 +08:00
parent f5e6a04c7d
commit 9f05e2d7e1
12 changed files with 334 additions and 25 deletions

View File

@@ -117,6 +117,12 @@ export type PiWorkerPoolEvent =
generation: number;
runId: string;
}
| {
type: 'top-level.settled';
conversationId: string;
generation: number;
runId: string;
}
| {
type: 'top-level.failed';
conversationId: string;
@@ -756,6 +762,15 @@ export class PiWorkerPool {
onLateResult: (result) => this.handleLateTopLevelResult(current!, run, result),
});
this.confirmTopLevel(current, run);
if (run.command.type === 'compact') {
this.settleTopLevel(current);
this.emit({
type: 'top-level.settled',
conversationId: run.conversationId,
generation: current.generation,
runId: run.runId,
});
}
run.resolve(response);
} catch (error) {
const active = this.activeRuns.get(run.conversationId);
@@ -823,6 +838,15 @@ export class PiWorkerPool {
generation: record.generation,
runId: run.runId,
});
if (run.command.type === 'compact') {
this.settleTopLevel(record);
this.emit({
type: 'top-level.settled',
conversationId: run.conversationId,
generation: record.generation,
runId: run.runId,
});
}
return;
}
if (result.error.code === 'PI_RPC_EXITED'