fix(agent-hooks): discover endpoint file from script location so daemon-revived PTYs keep reporting#1229
Open
brennanb2025 wants to merge 2 commits intomainfrom
Conversation
Co-authored-by: Orca <help@stably.ai>
- Extract AGENT_HOOKS_DIR_NAME so getAgentHooksDir and createManagedCommandMatcher cannot drift. - Windows snippet: gate the fallback via `&&` so a parse error in the env-var endpoint falls through to the script-adjacent file instead of being masked. - Add a matcher test that a command built from getAgentHooksDir is swept by createManagedCommandMatcher. - Drop stray 00-review-context.md artifact. Co-authored-by: Orca <help@stably.ai>
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.
Summary
ORCA_AGENT_HOOK_PORT/TOKENbaked into their env at spawn go stale the moment Orca restarts and rebinds the hook server. PTYs spawned before feat(agent-hooks): on-disk endpoint discovery for surviving PTYs (v2) #1196 also have noORCA_AGENT_HOOK_ENDPOINTat all, so their managed hook scripts post to a dead port and the dashboard silently stops updating.$(dirname "$0")/endpoint.envon POSIX,%~dp0endpoint.cmdon Windows) as a fallback when the env var is absent. Co-location of the endpoint file and managed scripts inuserData/agent-hooks/is what makes this discovery work.installer-utils.ts(getAgentHooksDir,getEndpointFileName,getEndpointFilePath,getManagedScriptPathForAgent,getEndpointDiscoveryShellSnippet,getEndpointDiscoveryCmdSnippet) so the server (writer) and all four hook-services (readers) share one source of truth;createManagedCommandMatchernow uses the sameAGENT_HOOKS_DIR_NAMEconstant._orca_loadedflag oncall … && set _orca_loaded=1so a parse error in the env-var endpoint correctly falls through to the script-adjacent file instead of being masked.Test plan
pnpm test src/main/agent-hooks/installer-utils.test.ts— new tests cover both discovery snippets and the co-location invariant.Cmd+QOrca, relaunchpnpm dev, send another message in the revived terminal → dashboard updates. Confirmed staleness directly in the revived PTY:ORCA_AGENT_HOOK_PORT=63237(old)ORCA_AGENT_HOOK_PORT=63407(new, rewritten on relaunch)%~dp0endpoint.cmdloads and_orca_loadedgating falls through on a malformed env-var endpoint. (not verified — no Windows environment available)