diff options
| author | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-07-07 21:12:44 +0300 |
|---|---|---|
| committer | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-07-07 21:13:34 +0300 |
| commit | 0a684b4130e7e82074831a7af8db5f1af8fed84d (patch) | |
| tree | b0537fe0a8c494ce399f89a1c5399e3c048ed2dc /src/app/api/agents.rs | |
| parent | 1e1d06328cc9aefa354b7ce463f9f2d254395662 (diff) | |
fix: clear done status on repeated pane focus
Diffstat (limited to 'src/app/api/agents.rs')
| -rw-r--r-- | src/app/api/agents.rs | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/src/app/api/agents.rs b/src/app/api/agents.rs index 7293823f..b66924ec 100644 --- a/src/app/api/agents.rs +++ b/src/app/api/agents.rs @@ -202,3 +202,67 @@ fn agent_not_found(id: String, target: &str) -> String { format!("agent target {target} not found"), ) } + +#[cfg(test)] +mod tests { + use super::*; + use crate::{ + api::schema::{AgentStatus, SuccessResponse}, + app::Mode, + config::Config, + detect::{Agent, AgentState}, + workspace::Workspace, + }; + + fn app_with_agent() -> App { + let (_api_tx, api_rx) = tokio::sync::mpsc::unbounded_channel(); + let mut app = App::new( + &Config::default(), + true, + None, + api_rx, + crate::api::EventHub::default(), + ); + app.state.workspaces = vec![Workspace::test_new("agent")]; + app.state.ensure_test_terminals(); + app.state.active = Some(0); + app.state.selected = 0; + app.state.mode = Mode::Terminal; + app + } + + #[test] + fn agent_focus_marks_already_focused_done_agent_seen() { + let mut app = app_with_agent(); + app.state.outer_terminal_focus = Some(false); + + let pane_id = app.state.workspaces[0].tabs[0].root_pane; + let terminal_id = app.state.workspaces[0].tabs[0].panes[&pane_id] + .attached_terminal_id + .clone(); + app.state + .terminals + .get_mut(&terminal_id) + .unwrap() + .set_detected_state(Some(Agent::Pi), AgentState::Idle); + app.state.workspaces[0].tabs[0] + .panes + .get_mut(&pane_id) + .unwrap() + .seen = false; + app.state.workspaces[0].tabs[0].layout.focus_pane(pane_id); + + let response = app.handle_agent_focus( + "req".into(), + AgentTarget { + target: "pi".into(), + }, + ); + + let success: SuccessResponse = serde_json::from_str(&response).unwrap(); + let ResponseResult::AgentInfo { agent } = success.result else { + panic!("expected agent info response"); + }; + assert_eq!(agent.agent_status, AgentStatus::Idle); + } +} |
