(
state: &AppState,
udid: &str,
frontmost_pid: Option<i64>,
)
| 3919 | } |
| 3920 | |
| 3921 | async fn connected_inspector_session( |
| 3922 | state: &AppState, |
| 3923 | udid: &str, |
| 3924 | frontmost_pid: Option<i64>, |
| 3925 | ) -> Result<InspectorSession, String> { |
| 3926 | let mut probed_inspectors = Vec::new(); |
| 3927 | let mut candidates = Vec::new(); |
| 3928 | for inspector in state.inspectors.connected().await { |
| 3929 | if frontmost_pid.is_some_and(|pid| pid != inspector.process_identifier) { |
| 3930 | probed_inspectors.push(format!( |
| 3931 | "background process {}", |
| 3932 | inspector.process_identifier |
| 3933 | )); |
| 3934 | continue; |
| 3935 | } |
| 3936 | if inspector_process_belongs_to_udid(udid, inspector.process_identifier).await? { |
| 3937 | candidates.push(InspectorSession { |
| 3938 | transport: InspectorSessionTransport::Connected, |
| 3939 | available_sources: inspector_available_sources(&inspector.info), |
| 3940 | info: inspector.info, |
| 3941 | process_identifier: inspector.process_identifier, |
| 3942 | }); |
| 3943 | continue; |
| 3944 | } |
| 3945 | |
| 3946 | probed_inspectors.push(format!("process {}", inspector.process_identifier)); |
| 3947 | } |
| 3948 | |
| 3949 | if let Some(session) = best_inspector_session(candidates) { |
| 3950 | return Ok(session); |
| 3951 | } |
| 3952 | |
| 3953 | if probed_inspectors.is_empty() { |
| 3954 | Err(format!( |
| 3955 | "No connected WebSocket inspector found for simulator {udid}." |
| 3956 | )) |
| 3957 | } else { |
| 3958 | Err(format!( |
| 3959 | "No connected WebSocket inspector matched simulator {udid}. Found inspectors for {}.", |
| 3960 | probed_inspectors.join(", ") |
| 3961 | )) |
| 3962 | } |
| 3963 | } |
| 3964 | |
| 3965 | async fn registry_inspector_session( |
| 3966 | state: &AppState, |
no test coverage detected