diff options
Diffstat (limited to 'src/integration/assets')
| -rw-r--r-- | src/integration/assets/omp/herdr-agent-state.ts | 22 | ||||
| -rw-r--r-- | src/integration/assets/pi/herdr-agent-state.ts | 22 |
2 files changed, 36 insertions, 8 deletions
diff --git a/src/integration/assets/omp/herdr-agent-state.ts b/src/integration/assets/omp/herdr-agent-state.ts index ba97b1c7..e0cfab5e 100644 --- a/src/integration/assets/omp/herdr-agent-state.ts +++ b/src/integration/assets/omp/herdr-agent-state.ts @@ -2,7 +2,7 @@ // managed by herdr; reinstalling or updating the integration overwrites this file. // add custom hooks/plugins beside this file instead of editing it. // HERDR_INTEGRATION_ID=omp -// HERDR_INTEGRATION_VERSION=3 +// HERDR_INTEGRATION_VERSION=4 // @ts-nocheck import { createConnection } from "node:net"; @@ -157,6 +157,16 @@ function releaseAgent(): Promise<void> { }); } +function shouldReleaseOnSessionShutdown(event: any): boolean { + // OMP tears down and rebinds extension runtimes for internal lifecycle actions + // such as /reload, /new, /resume, and /fork. Those do not mean the pane's + // agent process has exited, and releasing hook authority there can suppress + // legitimate reports from the replacement runtime. Only a user/process quit + // should release Herdr's full-lifecycle authority. + const reason = event?.reason; + return reason === "quit"; +} + let sendInFlight = false; let queuedState: QueuedState | undefined; @@ -325,10 +335,12 @@ export default function (pi) { publishState(true); }); - pi.on("agent_start", () => { + pi.on("agent_start", (_event, ctx) => { if (!rootSession) { return; } + updateSessionRef(ctx); + void reportSession(); clearPendingTimers(); clearFailureState(); agentActive = true; @@ -357,11 +369,13 @@ export default function (pi) { scheduleIdle(); }); - pi.on("session_shutdown", async () => { + pi.on("session_shutdown", async (event) => { if (!rootSession) { return; } clearPendingTimers(); - await releaseAgent(); + if (shouldReleaseOnSessionShutdown(event)) { + await releaseAgent(); + } }); } diff --git a/src/integration/assets/pi/herdr-agent-state.ts b/src/integration/assets/pi/herdr-agent-state.ts index 6c9e1cae..4bee2763 100644 --- a/src/integration/assets/pi/herdr-agent-state.ts +++ b/src/integration/assets/pi/herdr-agent-state.ts @@ -2,7 +2,7 @@ // managed by herdr; reinstalling or updating the integration overwrites this file. // add custom hooks/plugins beside this file instead of editing it. // HERDR_INTEGRATION_ID=pi -// HERDR_INTEGRATION_VERSION=3 +// HERDR_INTEGRATION_VERSION=4 // @ts-nocheck import { createConnection } from "node:net"; @@ -157,6 +157,16 @@ function releaseAgent(): Promise<void> { }); } +function shouldReleaseOnSessionShutdown(event: any): boolean { + // Pi tears down and rebinds extension runtimes for internal lifecycle actions + // such as /reload, /new, /resume, and /fork. Those do not mean the pane's + // agent process has exited, and releasing hook authority there can suppress + // legitimate reports from the replacement runtime. Only a user/process quit + // should release Herdr's full-lifecycle authority. + const reason = event?.reason; + return reason === "quit"; +} + let sendInFlight = false; let queuedState: QueuedState | undefined; @@ -325,10 +335,12 @@ export default function (pi) { publishState(true); }); - pi.on("agent_start", () => { + pi.on("agent_start", (_event, ctx) => { if (!rootSession) { return; } + updateSessionRef(ctx); + void reportSession(); clearPendingTimers(); clearFailureState(); agentActive = true; @@ -357,11 +369,13 @@ export default function (pi) { scheduleIdle(); }); - pi.on("session_shutdown", async () => { + pi.on("session_shutdown", async (event) => { if (!rootSession) { return; } clearPendingTimers(); - await releaseAgent(); + if (shouldReleaseOnSessionShutdown(event)) { + await releaseAgent(); + } }); } |
