fix: keep an agent name through a process-exit observation - #3574
fix: keep an agent name through a process-exit observation#3574caner-akca wants to merge 1 commit into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (3)
Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review. 📝 WalkthroughWalkthroughThe change updates agent name handling after process-exit observations. Names remain associated with terminals when the agent is still detected or is detected again. A subsequent no-agent observation after a process exit still releases the name. Tests cover terminal state transitions, named live agents, idle agents, and hook-owned agent registrations. Suggested reviewers: Merge Risk: ⚪ Minimal · up to This change preserves agent names through false process-exit observations while still releasing names after a later no-agent observation confirms exit. The covered state and API scenarios indicate no current merge-blocking risk. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@coderabbitai review |
|
✅ Action performedReview finished.
|
Greptile SummaryThis PR delays clearing an assigned agent name until process-exit evidence is followed by a no-agent observation, preserving name-based API targeting when an exit observation proves false.
Confidence Score: 5/5The PR appears safe to merge, with the revised cleanup transition preserving name reachability while retaining confirmed-exit cleanup. The changed state transition is consistent with the production detection sequence: a renewed agent observation clears the exit marker, while a confirmed no-agent observation releases the name, and no concrete blocking failure remains.
|
| Filename | Overview |
|---|---|
| src/terminal/state.rs | Changes agent-name cleanup to require both recorded exit evidence and a subsequent no-agent observation, with focused state-machine regression tests. |
| src/app/api/agents.rs | Adds API-boundary coverage proving that a falsely reported exit does not make a re-detected live agent unreachable by its assigned name. |
| src/app/api.rs | Updates release-event tests to reflect that registration release no longer immediately clears the assigned agent name. |
Sequence Diagram
sequenceDiagram
participant D as Agent detection
participant T as TerminalState
participant API as Agent API
D->>T: Exit observation with agent present
T->>T: Record recent process exit
T->>T: Preserve assigned name
alt Agent detected again
D->>T: AgentProcessDetected
T->>T: Clear exit marker, retain name
API->>T: Resolve assigned name
T-->>API: Named live agent
else No agent confirmed
D->>T: "StateChanged(agent=None)"
T->>T: Clear assigned name
end
Reviews (1): Last reviewed commit: "fix: keep an agent name through a proces..." | Re-trigger Greptile
A process-exit observation is not proof the agent is gone: the same observation can be wrong while the agent keeps running, and the name is the only handle its owner has on the pane. Detection uncertainty already preserves the name, so releasing it on the observation alone contradicts that contract and leaves a live agent unreachable by name with a rename as the only recovery. Free the name at the point the agent actually leaves the pane - a recorded exit with no agent detected any more - so a wrong observation costs nothing and a real exit still releases the name for reuse. refs herdrdev#3225
065026e to
692e021
Compare
Summary
single process-exit observation
detection uncertainty is already handled
pane.agent_detected { released: true }event unchangedThis fixes the failure reported in the #3225 comment thread: a named pane stops
resolving by its name while its process keeps running, with a rename as the only
recovery. It does not address the failure in the issue body, so #3225 should stay
open.
Validation
just checkagent_not_found, plus state-layertests pinning both directions — a false exit keeps the name, a confirmed exit
frees it
live_handofftests fail identically onmasterand this branch on macOS26.2, before reaching changed code: their fake agent
execs/bin/sleep, andKERN_PROCARGS2there returns an empty environment section, soHERDR_AGENTis invisible to
process_agent_hint. Those run in CI.refs #3225