aboutsummaryrefslogtreecommitdiff
path: root/src/integration/assets
diff options
context:
space:
mode:
Diffstat (limited to 'src/integration/assets')
-rw-r--r--src/integration/assets/herdr-agent-state.test.ts28
-rw-r--r--src/integration/assets/omp/herdr-agent-state.ts8
2 files changed, 34 insertions, 2 deletions
diff --git a/src/integration/assets/herdr-agent-state.test.ts b/src/integration/assets/herdr-agent-state.test.ts
index 48cc8708..19b36d94 100644
--- a/src/integration/assets/herdr-agent-state.test.ts
+++ b/src/integration/assets/herdr-agent-state.test.ts
@@ -11,6 +11,7 @@ const originalEnvironment = {
HERDR_OMP_IDLE_DEBOUNCE_MS: process.env.HERDR_OMP_IDLE_DEBOUNCE_MS,
HERDR_PANE_ID: process.env.HERDR_PANE_ID,
HERDR_SOCKET_PATH: process.env.HERDR_SOCKET_PATH,
+ OMPCODE: process.env.OMPCODE,
};
let server: Server | undefined;
@@ -229,6 +230,33 @@ for (const integration of integrations) {
});
}
+test("OMP ignores nested sessions launched inside another OMP shell", async () => {
+ const requests = await startRecordingServer("omp-nested");
+ process.env.OMPCODE = "1";
+ const { handlers, pi } = createExtensionHarness();
+
+ const { default: install } = await importFresh("./omp/herdr-agent-state.ts");
+ install(pi);
+
+ // OMP sets OMPCODE on every shell it spawns. A nested `omp` inherits it and
+ // must not claim the pane's session for its short-lived conversation.
+ expect(handlers.size).toBe(0);
+ await handlers.get("session_start")?.(
+ { reason: "startup" },
+ {
+ hasUI: true,
+ isIdle: () => true,
+ sessionManager: {
+ getSessionFile: () => "/tmp/omp-nested.jsonl",
+ getSessionId: () => "omp-nested",
+ },
+ },
+ );
+ await Bun.sleep(25);
+
+ expect(requests).toEqual([]);
+});
+
test("OMP accepts POSIX and Windows session paths", async () => {
const { isAbsoluteSessionPath } = await importFresh("./omp/herdr-agent-state.ts");
diff --git a/src/integration/assets/omp/herdr-agent-state.ts b/src/integration/assets/omp/herdr-agent-state.ts
index 0e493787..fce62106 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=9
+// HERDR_INTEGRATION_VERSION=10
// @ts-nocheck
import net from "node:net";
@@ -14,9 +14,13 @@ const socketEndpoint =
process.platform === "win32" && socketPath ? `\\\\.\\pipe\\${socketPath}` : socketPath;
const paneId = process.env.HERDR_PANE_ID;
const source = "herdr:omp";
+// OMP marks every shell it spawns with OMPCODE=1. A nested `omp` launched from
+// a parent session's shell inherits it, so that process is not the pane's root
+// agent and must not report its short-lived session over the parent's.
+const nestedOmpSession = process.env.OMPCODE === "1";
function enabled() {
- return HERDR_ENV === "1" && !!socketPath && !!paneId;
+ return HERDR_ENV === "1" && !!socketPath && !!paneId && !nestedOmpSession;
}
let requestQueue = Promise.resolve();