Repository navigation
feat(focus): open an event's own Herdr pane - #307
Merged
Merged
Conversation
hiskudin
reviewed
Dec 2, 2026
hiskudin
left a comment
Collaborator
There was a problem hiding this comment.
This checks out against Herdr's source. pane.get and pane.focus take pane_id, workspace.focus and tab.focus take their ids, the framing is newline-delimited JSON, and the pane_info reply has the shape location(fromReply:) reads. Also good:
- The socket work is all on background queues.
- The request JSON goes through
JSONSerialization, so nothing can be injected through it. - A stale socket falls through to the old behaviour.
- tmux events still return first.
The suite passes locally (2151), but gh pr checks shows no CI run on this branch yet.
Two things I'd fix are inline. Smaller ones:
- A hung Herdr delays Open. With a 1 s timeout per call and up to four calls before the terminal is raised, an approval keystroke can land about 2 s late. It's off the main thread, though.
- Extra work outside Herdr. Every Open now pays up to two
ps ewwforks, Herdr or not, including the activate-immediately path. - Test gaps. The tests cover the pure helpers.
call(a reply split acrossrecvs, a refused socket, the timeout),focusagainst a fake socket server, and the agent-then-shell fallback aren't covered. The description also says the switch hasn't been tried end to end. - Shared parser.
parseEnvValuesmatchesMY_HERDR_PANE_ID=, matches the same text in argv (which comes before env), and cuts values at a space. That's the same asTMUX_PANE, so it isn't new here.
Herdr runs agents under its own server, so the terminal the hook finds (Ghostty) is shared by every Herdr pane, and Open raised it on whatever pane Herdr last showed. Open now reads HERDR_PANE_ID and HERDR_SOCKET_PATH from the agent's environment (or its shell's, once the agent has exited) and asks Herdr to focus that pane's workspace, tab and pane, before the terminal is raised and any approval keystroke is sent. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Only read Herdr's env when a process named herdr is among the agent's ancestors, so agents that merely inherited HERDR_PANE_ID (e.g. from `code .`) no longer switch Herdr's view. The walk uses proc_pidinfo (no fork), is capped at 32 hops, and runs before the `ps eww` read. - Set SO_NOSIGPIPE on the socket so a Herdr that closes before the write cannot raise SIGPIPE. - Test the socket path against a fake Herdr server (request order and ids, refused socket, hang-up) and the ancestry rule through an injectable lookup. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CI's compiler resolved bind to an instance method in the test class. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
adefreitas
force-pushed
the
feat/herdr-focus
branch
from
December 3, 2026 11:00
9308b55 to
d40d4c3
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR makes Open on an event go to the agent's own pane when the agent runs inside Herdr, a terminal workspace manager.
Herdr runs agents under its own server, so the hook's process walk ends at the terminal around it (Ghostty, here), and every Herdr pane shares that terminal's session ID. Open raised Ghostty on whichever pane Herdr last showed.
Open now reads
HERDR_PANE_IDandHERDR_SOCKET_PATHfrom the agent's environment, or from its shell's once the agent has exited, the same way tmux focus readsTMUX_PANE. It then asks Herdr over its socket to focus the pane's workspace, tab and pane (pane.get, thenworkspace.focus,tab.focus,pane.focus). That happens before the terminal is raised, so an approval keystroke reaches the right pane. Outside Herdr nothing changes: noHERDR_PANE_ID, no call.Checks
make test-without-xcodepasses: 2151 tests, 0 failures. New tests cover reading the target fromps ewwoutput, no target outside Herdr or without a socket, the focus order, and a pane-only focus whenpane.getcan't be read.pane.getover a real Herdr 0.9.1 socket returns the workspace and tab IDs this code reads. The focus switch itself has not been tried end to end yet.🤖 Generated with Claude Code