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

Function activate_session_goal

src/apps/desktop/src/api/agentic_api.rs:925–977  ·  view source on GitHub ↗
(
    coordinator: State<'_, Arc<ConversationCoordinator>>,
    app_state: State<'_, AppState>,
    request: ActivateSessionGoalRequest,
)

Source from the content-addressed store, hash-verified

923
924#[tauri::command]
925pub async fn activate_session_goal(
926 coordinator: State<'_, Arc<ConversationCoordinator>>,
927 app_state: State<'_, AppState>,
928 request: ActivateSessionGoalRequest,
929) -> Result<ActivateSessionGoalResponse, String> {
930 let session_id = request.session_id.trim();
931 if session_id.is_empty() {
932 return Err("session_id is required".to_string());
933 }
934
935 if coordinator
936 .get_session_manager()
937 .get_session(session_id)
938 .is_none()
939 {
940 let workspace_path = request
941 .workspace_path
942 .as_deref()
943 .map(str::trim)
944 .filter(|value| !value.is_empty())
945 .ok_or_else(|| {
946 "workspace_path is required when the session is not loaded".to_string()
947 })?;
948 let effective = desktop_effective_session_storage_path(
949 &app_state,
950 workspace_path,
951 request.remote_connection_id.as_deref(),
952 request.remote_ssh_host.as_deref(),
953 )
954 .await;
955 coordinator
956 .restore_session_from_storage_path(&effective, session_id)
957 .await
958 .map_err(|e| format!("Failed to restore session before activating goal mode: {e}"))?;
959 }
960
961 let user_hint = request
962 .user_hint
963 .as_deref()
964 .map(str::trim)
965 .filter(|value| !value.is_empty())
966 .map(str::to_string);
967
968 let activation = coordinator
969 .activate_session_goal(session_id.to_string(), user_hint)
970 .await
971 .map_err(|error| error.to_string())?;
972
973 Ok(ActivateSessionGoalResponse {
974 success: true,
975 goal: activation,
976 })
977}
978
979async fn ensure_session_for_thread_goal(
980 coordinator: &Arc<ConversationCoordinator>,

Callers

nothing calls this directly

Calls 7

trimMethod · 0.80
get_session_managerMethod · 0.80
activate_session_goalMethod · 0.80
is_emptyMethod · 0.45
get_sessionMethod · 0.45

Tested by

no test coverage detected