MCPcopy Create free account
hub / github.com/GCWing/BitFun / update_subagent_config

Function update_subagent_config

src/apps/desktop/src/api/subagent_api.rs:416–514  ·  view source on GitHub ↗
(
    state: State<'_, AppState>,
    request: UpdateSubagentConfigRequest,
)

Source from the content-addressed store, hash-verified

414
415#[tauri::command]
416pub async fn update_subagent_config(
417 state: State<'_, AppState>,
418 request: UpdateSubagentConfigRequest,
419) -> Result<UpdateSubagentConfigResponse, String> {
420 let subagent_id = &request.subagent_id;
421 let workspace = workspace_root_from_request(request.workspace_path.as_deref());
422 if let Some(workspace) = workspace.as_deref() {
423 state.agent_registry.load_custom_subagents(workspace).await;
424 }
425
426 let mut availability_updated = false;
427 let mut model_updated = false;
428
429 if let Some(enabled) = request.enabled {
430 let parent_agent_type = request.parent_agent_type.as_deref().ok_or_else(|| {
431 "parentAgentType is required when updating subagent availability".to_string()
432 })?;
433 state
434 .agent_registry
435 .update_subagent_override(
436 parent_agent_type,
437 subagent_id,
438 enabled,
439 workspace.as_deref(),
440 )
441 .await
442 .map_err(|e| format!("Failed to update subagent availability: {}", e))?;
443 availability_updated = true;
444 }
445
446 if state
447 .agent_registry
448 .get_custom_subagent_config(subagent_id, workspace.as_deref())
449 .is_some()
450 {
451 if request.model.is_some() {
452 state
453 .agent_registry
454 .update_and_save_custom_subagent_config(
455 subagent_id,
456 request.model,
457 workspace.as_deref(),
458 )
459 .map_err(|e| format!("Failed to update configuration: {}", e))?;
460 model_updated = true;
461 }
462 Ok(UpdateSubagentConfigResponse {
463 availability_updated,
464 model_updated,
465 })
466 } else {
467 if state
468 .agent_registry
469 .has_project_custom_subagent(subagent_id)
470 {
471 if let Some(workspace) = workspace.as_deref() {
472 return Err(format!(
473 "Project Sub-Agent '{}' was not found in workspace '{}'",

Callers

nothing calls this directly

Calls 11

load_custom_subagentsMethod · 0.80
set_configMethod · 0.80
reload_global_configFunction · 0.70
get_configMethod · 0.45
insertMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected