(
coordinator: State<'_, Arc<ConversationCoordinator>>,
scheduler: State<'_, Arc<DialogScheduler>>,
app_state: State<'_, AppState>,
request: RunInitAgentsMdRequest,
)
| 1191 | |
| 1192 | #[tauri::command] |
| 1193 | pub async fn run_init_agents_md( |
| 1194 | coordinator: State<'_, Arc<ConversationCoordinator>>, |
| 1195 | scheduler: State<'_, Arc<DialogScheduler>>, |
| 1196 | app_state: State<'_, AppState>, |
| 1197 | request: RunInitAgentsMdRequest, |
| 1198 | ) -> Result<StartDialogTurnResponse, String> { |
| 1199 | let session_id = request.session_id.trim(); |
| 1200 | if session_id.is_empty() { |
| 1201 | return Err("session_id is required".to_string()); |
| 1202 | } |
| 1203 | |
| 1204 | if coordinator |
| 1205 | .get_session_manager() |
| 1206 | .get_session(session_id) |
| 1207 | .is_none() |
| 1208 | { |
| 1209 | let workspace_path = request |
| 1210 | .workspace_path |
| 1211 | .as_deref() |
| 1212 | .map(str::trim) |
| 1213 | .filter(|value| !value.is_empty()) |
| 1214 | .ok_or_else(|| { |
| 1215 | "workspace_path is required when the session is not loaded".to_string() |
| 1216 | })?; |
| 1217 | let effective = desktop_effective_session_storage_path( |
| 1218 | &app_state, |
| 1219 | workspace_path, |
| 1220 | request.remote_connection_id.as_deref(), |
| 1221 | request.remote_ssh_host.as_deref(), |
| 1222 | ) |
| 1223 | .await; |
| 1224 | coordinator |
| 1225 | .restore_session_from_storage_path(&effective, session_id) |
| 1226 | .await |
| 1227 | .map_err(|e| format!("Failed to restore session before running /init: {e}"))?; |
| 1228 | } |
| 1229 | |
| 1230 | let workspace_path = request |
| 1231 | .workspace_path |
| 1232 | .as_deref() |
| 1233 | .map(str::trim) |
| 1234 | .filter(|value| !value.is_empty()) |
| 1235 | .map(str::to_string); |
| 1236 | |
| 1237 | scheduler |
| 1238 | .submit_init_agents_md( |
| 1239 | session_id.to_string(), |
| 1240 | workspace_path, |
| 1241 | request.remote_connection_id.clone(), |
| 1242 | request.remote_ssh_host.clone(), |
| 1243 | DialogSubmissionPolicy::for_source(DialogTriggerSource::DesktopUi), |
| 1244 | ) |
| 1245 | .await |
| 1246 | .map_err(|e| format!("Failed to run /init: {e}"))?; |
| 1247 | |
| 1248 | Ok(StartDialogTurnResponse { |
| 1249 | success: true, |
| 1250 | message: "Init dialog turn started".to_string(), |
nothing calls this directly
no test coverage detected