From f0cb0e0683953e7dbc32d911268931f25d3e448f Mon Sep 17 00:00:00 2001 From: caner-akca <94343893+caner-akca@users.noreply.github.com> Date: Sun, 13 Sep 2026 20:00:57 +0300 Subject: fix: keep an agent name through a process-exit observation (#3574) 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 #3225 Co-authored-by: JJ Liebig --- src/app/api.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/app/api.rs') diff --git a/src/app/api.rs b/src/app/api.rs index 9bd02481..30fc3be2 100644 --- a/src/app/api.rs +++ b/src/app/api.rs @@ -2067,7 +2067,13 @@ mod tests { observed_at: std::time::Instant::now(), }); - assert!(app.state.terminals[&terminal_id].agent_name.is_none()); + // The release event is this test's subject; the name outliving the + // observation is pinned by + // `a_process_exit_observation_alone_does_not_free_the_name`. + assert_eq!( + app.state.terminals[&terminal_id].agent_name.as_deref(), + agent_name + ); assert!(event_hub.events_after(0).iter().any(|(_, event)| matches!( &event.data, crate::api::schema::EventData::PaneAgentDetected { @@ -2123,7 +2129,9 @@ mod tests { let terminal = &app.state.terminals[&terminal_id]; assert_eq!(terminal.state, AgentState::Idle); - assert!(terminal.agent_name.is_none()); + // Releasing the registration does not free the name yet; a wrong + // observation must not cost a live agent the handle its owner gave it. + assert_eq!(terminal.agent_name.as_deref(), Some("reviewer")); assert!(event_hub.events_after(0).iter().any(|(_, event)| matches!( event.data, crate::api::schema::EventData::PaneAgentDetected { released: true, .. } -- cgit v1.2.3