fix: release finalized Pi runtimes
This commit is contained in:
@@ -111,13 +111,21 @@ export function sessionRoutes(
|
||||
}
|
||||
}
|
||||
d.hub.publish(id, e.type, e);
|
||||
if (
|
||||
e.type === "system_event"
|
||||
&& e.event === "agent_end"
|
||||
&& d.mgr.get(id) !== rt
|
||||
&& boundRuntimes.get(id) === rt
|
||||
) {
|
||||
boundRuntimes.delete(id);
|
||||
if (e.type === "system_event" && e.event === "agent_end") {
|
||||
if (d.mgr.get(id) !== rt && boundRuntimes.get(id) === rt) {
|
||||
boundRuntimes.delete(id);
|
||||
} else if (typeof runner.sessionShow === "function") {
|
||||
void withSessionLifecycle(id, async () => {
|
||||
if (d.mgr.get(id) !== rt || boundRuntimes.get(id) !== rt) return;
|
||||
const manifest = await runner.sessionShow(id, workspace);
|
||||
if (manifest?.status !== "finalized") return;
|
||||
if (d.mgr.teardownIfCurrent(id, rt) && boundRuntimes.get(id) === rt) {
|
||||
boundRuntimes.delete(id);
|
||||
}
|
||||
}).catch((error: unknown) => {
|
||||
console.error(`[session:${id}] terminal runtime cleanup failed:`, error);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user