aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/integration/assets/omp/herdr-agent-state.ts17
-rw-r--r--src/integration/mod.rs23
2 files changed, 40 insertions, 0 deletions
diff --git a/src/integration/assets/omp/herdr-agent-state.ts b/src/integration/assets/omp/herdr-agent-state.ts
index c2bec682..a6428cdd 100644
--- a/src/integration/assets/omp/herdr-agent-state.ts
+++ b/src/integration/assets/omp/herdr-agent-state.ts
@@ -197,6 +197,7 @@ export default function (pi) {
let lastMessage: string | undefined;
let idleTimer: ReturnType<typeof setTimeout> | undefined;
let retryTimer: ReturnType<typeof setTimeout> | undefined;
+ let rootSession = false;
function clearTimer(timer: ReturnType<typeof setTimeout> | undefined) {
if (timer) {
@@ -267,6 +268,9 @@ export default function (pi) {
}
pi.events.on("herdr:blocked", (data) => {
+ if (!rootSession) {
+ return;
+ }
if (!data?.active) {
blockedCount = Math.max(0, blockedCount - 1);
if (blockedCount === 0) {
@@ -283,11 +287,18 @@ export default function (pi) {
});
pi.on("session_start", (_event, ctx) => {
+ rootSession = ctx?.hasUI === true;
+ if (!rootSession) {
+ return;
+ }
updateSessionRef(ctx);
publishState(true);
});
pi.on("agent_start", () => {
+ if (!rootSession) {
+ return;
+ }
clearPendingTimers();
clearFailureState();
agentActive = true;
@@ -295,6 +306,9 @@ export default function (pi) {
});
pi.on("agent_end", (event) => {
+ if (!rootSession) {
+ return;
+ }
if (!agentActive) {
// OMP can emit duplicate/late end events while auto-retry is already
// holding the pane in Working. Do not let an unqualified duplicate end
@@ -314,6 +328,9 @@ export default function (pi) {
});
pi.on("session_shutdown", async () => {
+ if (!rootSession) {
+ return;
+ }
clearPendingTimers();
await releaseAgent();
});
diff --git a/src/integration/mod.rs b/src/integration/mod.rs
index d4c7265b..59eaebd9 100644
--- a/src/integration/mod.rs
+++ b/src/integration/mod.rs
@@ -6035,6 +6035,29 @@ mod tests {
}
#[test]
+ fn omp_root_session_guard_is_instance_scoped() {
+ let export_start = OMP_EXTENSION_ASSET
+ .find("export default function (pi)")
+ .expect("omp extension exports a function");
+ let root_session_decl = OMP_EXTENSION_ASSET
+ .find("let rootSession = false")
+ .expect("omp extension declares root session guard");
+ let session_start_handler = OMP_EXTENSION_ASSET
+ .find("pi.on(\"session_start\"")
+ .expect("omp extension registers session_start handler");
+
+ assert_eq!(
+ OMP_EXTENSION_ASSET
+ .matches("let rootSession = false")
+ .count(),
+ 1
+ );
+ assert!(OMP_EXTENSION_ASSET.contains("rootSession = ctx?.hasUI === true"));
+ assert!(export_start < root_session_decl);
+ assert!(root_session_decl < session_start_handler);
+ }
+
+ #[test]
fn install_qodercli_writes_hook_and_updates_settings() {
let _lock = integration_env_lock();
let base = unique_base();