fixed abort trigger persisting across sessions

This commit is contained in:
Amos
2026-06-28 16:35:30 +03:00
parent af4e032ed4
commit e5ffd62199
4 changed files with 12 additions and 11 deletions
+8
View File
@@ -1500,6 +1500,14 @@ export default function subagentsExtension(pi: ExtensionAPI) {
// Capture the UI context for widget updates
pi.on("session_start", (_event, ctx) => {
latestCtx = ctx;
// pi runs multiple sessions in one process. A prior session's shutdown
// aborts the shared module poll-abort controller; install a fresh one so
// subagents spawned in this session aren't watched against a dead signal.
// See https://github.com/HazAT/pi-interactive-subagents/issues/5
const prevAbort = (globalThis as any)[POLL_ABORT_KEY] as AbortController | undefined;
if (!prevAbort || prevAbort.signal.aborted) {
(globalThis as any)[POLL_ABORT_KEY] = new AbortController();
}
});
// Clean up on session shutdown