diff options
| author | Dillon Mulroy <dillon.mulroy@gmail.com> | 2026-06-25 10:59:17 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-06-25 17:59:17 +0300 |
| commit | 3c7327c267a352023797c8a13fd0b7f4a7a40591 (patch) | |
| tree | 5476b4de45d429d2fc245869233f30cb9232f803 /src/integration/assets/omp | |
| parent | 7a1578d9493b2a36cc765bdb96db99cca8bae643 (diff) | |
fix: avoid pi release on internal session reloads (#800)
* fix: avoid pi release on internal session reloads
* fix: align omp session shutdown release with pi
---------
Co-authored-by: Can Celik <ogulcancelik@gmail.com>
Diffstat (limited to 'src/integration/assets/omp')
| -rw-r--r-- | src/integration/assets/omp/herdr-agent-state.ts | 22 |
1 files changed, 18 insertions, 4 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(); + } }); } |
