aboutsummaryrefslogtreecommitdiff
path: root/src/integration/assets/opencode/herdr-agent-state.js
diff options
context:
space:
mode:
authorCan Celik <ogulcancelik@gmail.com>2026-09-22 16:25:17 +0300
committerGitHub <noreply@github.com>2026-09-22 16:25:17 +0300
commitf6390752a57a5ac3256f3213af870c0b62e224d7 (patch)
tree5b622345c5b274d82a9ff8a80a2be8adf7f67968 /src/integration/assets/opencode/herdr-agent-state.js
parent46a5091838de66c1be193990afc3ad9145e6b4f5 (diff)
fix: track opencode subagent status per pane (#4357)
refs #1362
Diffstat (limited to 'src/integration/assets/opencode/herdr-agent-state.js')
-rw-r--r--src/integration/assets/opencode/herdr-agent-state.js22
1 files changed, 18 insertions, 4 deletions
diff --git a/src/integration/assets/opencode/herdr-agent-state.js b/src/integration/assets/opencode/herdr-agent-state.js
index 73a70534..09c00704 100644
--- a/src/integration/assets/opencode/herdr-agent-state.js
+++ b/src/integration/assets/opencode/herdr-agent-state.js
@@ -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=opencode
-// HERDR_INTEGRATION_VERSION=12
+// HERDR_INTEGRATION_VERSION=13
import net from "node:net";
@@ -118,8 +118,23 @@ function reportState(state, sessionID) {
return request("pane.report_agent", params);
}
+function ownsLocalLifecycle() {
+ const args = process.argv.slice(2);
+ const separator = args.indexOf("--");
+ if (separator !== -1) args.splice(separator);
+ if (args.some((arg) => arg === "--attach" || arg.startsWith("--attach="))) return false;
+ while (args[0] === "--print-logs" || args[0] === "--log-level" || args[0]?.startsWith("--log-level=")) {
+ args.splice(0, args[0] === "--log-level" ? 2 : 1);
+ }
+ // These local clients have no TUI plugin. Shared servers and the TUI worker
+ // cannot identify their attached panes; their lifecycle belongs to each TUI.
+ return args[0] === "run" ||
+ (!["serve", "web", "attach"].includes(args[0]) && args.includes("--mini"));
+}
+
export const HerdrAgentStatePlugin = async () => {
if (
+ !ownsLocalLifecycle() ||
process.env.HERDR_ENV !== "1" ||
!process.env.HERDR_SOCKET_PATH ||
!process.env.HERDR_PANE_ID
@@ -200,9 +215,8 @@ export const HerdrAgentStatePlugin = async () => {
};
};
-// V1 (1.18.29+) calls server(). V2 calls setup() instead. Its shared server
-// cannot attribute sessions using its process environment: the pane-local TUI
-// owns both selection and lifecycle reporting there, including remote servers.
+// V1 local run/Mini retain their server hooks. V1/V2 full TUIs own both
+// selection and lifecycle, including when attached to a shared remote server.
export default {
id: "herdr.opencode",
server: HerdrAgentStatePlugin,