diff options
| author | caner-akca <94343893+caner-akca@users.noreply.github.com> | 2026-09-13 20:00:57 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-09-13 19:00:57 +0200 |
| commit | f0cb0e0683953e7dbc32d911268931f25d3e448f (patch) | |
| tree | 070f7332285f6028cab9cb2b8a1ef5203ceb15e3 /src/app/api.rs | |
| parent | ff32bd450eb590c4134f8412e98315919cf896a4 (diff) | |
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 <jonathan.liebig@gmail.com>
Diffstat (limited to 'src/app/api.rs')
| -rw-r--r-- | src/app/api.rs | 12 |
1 files changed, 10 insertions, 2 deletions
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, .. } |
