summaryrefslogtreecommitdiff
path: root/src/integration/assets/opencode/herdr-agent-state.test.ts
diff options
context:
space:
mode:
authorMark Jaquith <mark@jaquith.me>2026-09-05 17:08:19 -0400
committerGitHub <noreply@github.com>2026-09-06 00:08:19 +0300
commitec05328a4413e38ebdcb84365938345e9cf47431 (patch)
tree3f280531f2c81d00d2204ca7e7fb0d3b161072a6 /src/integration/assets/opencode/herdr-agent-state.test.ts
parent6f57f2f62c5d2591647262caf15bc3c962b9c9f8 (diff)
fix: prevent OpenCode child prompts from leaving status blocked (#3669)
Child permission and question reports omitted the session ID, clearing Herdr’s root session identity and preventing later lifecycle reports from clearing the blocked state. Track child-to-parent relationships and report prompt transitions with their root session ID, including for nested children. This preserves identity and lets existing ownership checks reject unrelated sessions. Add regression coverage for prompt routing and lifecycle transitions, and bump the OpenCode integration version to 11.
Diffstat (limited to 'src/integration/assets/opencode/herdr-agent-state.test.ts')
-rw-r--r--src/integration/assets/opencode/herdr-agent-state.test.ts39
1 files changed, 33 insertions, 6 deletions
diff --git a/src/integration/assets/opencode/herdr-agent-state.test.ts b/src/integration/assets/opencode/herdr-agent-state.test.ts
index 6f8ee590..a3eea848 100644
--- a/src/integration/assets/opencode/herdr-agent-state.test.ts
+++ b/src/integration/assets/opencode/herdr-agent-state.test.ts
@@ -167,7 +167,6 @@ test("reports child prompts without replacing the root session", async () => {
event: {
type: "session.created",
properties: {
- sessionID: "child-session",
info: { id: "child-session", parentID: "root-session" },
},
},
@@ -188,11 +187,39 @@ test("reports child prompts without replacing the root session", async () => {
"working",
]);
expect(requests.map(requestSessionID)).toEqual([
- undefined,
- undefined,
- undefined,
- undefined,
- undefined,
+ "root-session",
+ "root-session",
+ "root-session",
+ "root-session",
+ "root-session",
+ ]);
+});
+
+test("routes nested child prompts to their own root, not the last active root", async () => {
+ const plugin = await loadPlugin();
+ for (const info of [
+ { id: "child-session", parentID: "root-session" },
+ { id: "nested-session", parentID: "child-session" },
+ ]) {
+ await plugin.event({ event: { type: "session.created", properties: { info } } });
+ }
+ await plugin["chat.message"]({ sessionID: "other-root" });
+ await plugin.event({
+ event: { type: "permission.asked", properties: { sessionID: "nested-session" } },
+ });
+ await plugin.event({
+ event: { type: "permission.replied", properties: { sessionID: "nested-session" } },
+ });
+ await plugin.event({
+ event: { type: "session.idle", properties: { sessionID: "nested-session" } },
+ });
+ await plugin["chat.message"]({ sessionID: "nested-session" });
+
+ expect(requests.map(requestState)).toEqual(["working", "blocked", "working"]);
+ expect(requests.map(requestSessionID)).toEqual([
+ "other-root",
+ "root-session",
+ "root-session",
]);
});