fix(daemon): re-arm the herdr reporter when a pane attaches a session - #2210
fix(daemon): re-arm the herdr reporter when a pane attaches a session#2210kevinjosethomas wants to merge 1 commit into
Conversation
Prime Agent performance — completedPR Overall: 0 regressed · 0 improved · 17 no clear change.
Python runtime
Sandbox cost: ~$0.0922 — no inference calls. Methodology and samplesMain resolved at 2026-09-11T02:18:36.738706+00:00. Harness
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit edeb993. Configure here.
| const clientEnv = filterClientEnv(command.env); | ||
| const deferClientEnv = this.updateRestart && this.updateRestart.phase !== "preparing"; | ||
| if (!deferClientEnv) this.adoptClientEnv(state, clientEnv); | ||
| if (!deferClientEnv) this.rebindClientEnv(state, clientEnv); |
There was a problem hiding this comment.
Failed attach still rebinds pane
Medium Severity
rebindClientEnv runs before createAttachResult succeeds and before the client joins state.clients. A thrown attach still overwrites clientEnv and emits herdr:rebind, so the session reports to a pane that never became a live viewer and disappears from the previous pane's herdr sidebar.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit edeb993. Configure here.
| if (state.runtime.metadata.kind === "subagent") { | ||
| return; | ||
| } | ||
| state.runtime.services.resourceLoader.emitExtensionEvent(HERDR_REBIND_EVENT, { env }); |
There was a problem hiding this comment.
Partial env clobbers pane identity
Medium Severity
rebindClientEnv replaces state.clientEnv and emits herdr:rebind for any non-empty filtered attach env. The reporter only arms or moves when HERDR_ENV is 1 with both socket and pane set. A partial or stray allowlisted key therefore wipes exec and reload env while the live reporter stays on the old pane, and a later /reload can disarm reporting entirely.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit edeb993. Configure here.


Problem
The built-in herdr reporter arms only at extension load, with
HERDR_*env in scope (withClientEnvwindow). A daemon-resident session created headless or in a pane that has since closed keeps its stale identity after being attached from another pane, so it never shows in herdr's agents sidebar. The only workaround is a manual/reload, which the TUI refuses while a response is executing.Proposal
rebindClientEnvoverwritesstate.clientEnvand propagates to subagents spawned before the rebind, sopi.exec(live read) and every runtime rebuild/reload keep load-time captures and subprocess env consistent with the new pane. The old adopt-if-absent contract remains for create-reuse.herdr:rebindon the session's shared extension bus (newResourceLoader.emitExtensionEvent). The reporter now registers its listener set even when unarmed and (re)arms its socket identity from the event, claiming the new pane with the live working/idle state immediately.Wire protocol is unchanged (attach already carried optional env), so this is backward-compatible; the env contract comments in
daemon-protocol.tsanddaemon-mode.tsare updated to the new semantics.Verification
npm run checkpasses (biome, tsgo, linear-ticket, installer, browser-smoke).npx tsx ../../node_modules/vitest/dist/cli.js --run test/herdr-agent-state.test.ts test/daemon-mode.test.ts test/daemon-client-env.test.ts test/daemon-extension-binding.test.ts test/daemon-supervisor-monitor.test.ts test/agent-connection-daemon.test.ts test/sdk-skills.test.tsherdr:rebindevent and reports live state, switches panes on later rebinds (last attach wins), ignores rebinds without a complete identity, and unsubscribes on shutdown; a daemon attach withHERDR_*env rebinds the session env and notifies extensions, an env-less attach changes nothing, and subagents inherit the rebind.origin/main(pre-existing, unrelated).Note
Medium Risk
Changes daemon attach semantics for Herdr pane identity and extension bus events; scope is integration/daemon attach paths with new test coverage, not auth or data handling.
Overview
Fixes daemon-resident sessions that never showed in Herdr’s agent sidebar after being opened from a pane, because the built-in reporter only captured pane identity at extension load.
Attach now rebinds pane identity (
rebindClientEnv): env-carrying attaches overwriteclientEnvwith the attaching client’s allowlistedHERDR_*vars (last pane wins), propagate to subagents, and emitherdr:rebindon the session extension bus via newResourceLoader.emitExtensionEvent. Env-less attaches (watchers, headless) leave identity unchanged. Session create still uses adopt-if-absent when reusing env-less sessions.Built-in herdr reporter stays loaded even without Herdr env at load: it tracks working/idle/blocked while unarmed, skips socket traffic until armed, then re-arms on
herdr:rebindand publishes live state to the new pane. Shutdown unsubscribes the rebind listener.Supervisor no longer injects its own env on env-less worker attaches (which could wrongly bind sessions to the daemon’s pane).
Wire protocol unchanged; tests cover rebind, env-less attach, subagent propagation, and reporter behavior.
Reviewed by Cursor Bugbot for commit edeb993. Bugbot is set up for automated code reviews on this repo. Configure here.