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

Function ensure_session_for_thread_goal

src/apps/desktop/src/api/agentic_api.rs:979–1017  ·  view source on GitHub ↗
(
    coordinator: &Arc<ConversationCoordinator>,
    app_state: &AppState,
    session_id: &str,
    workspace_path: Option<&str>,
    remote_connection_id: Option<&str>,
    remote_ssh_host: Option<

Source from the content-addressed store, hash-verified

977}
978
979async fn ensure_session_for_thread_goal(
980 coordinator: &Arc<ConversationCoordinator>,
981 app_state: &AppState,
982 session_id: &str,
983 workspace_path: Option<&str>,
984 remote_connection_id: Option<&str>,
985 remote_ssh_host: Option<&str>,
986) -> Result<PathBuf, String> {
987 if coordinator
988 .get_session_manager()
989 .get_session(session_id)
990 .is_none()
991 {
992 let workspace_path = workspace_path
993 .map(str::trim)
994 .filter(|value| !value.is_empty())
995 .ok_or_else(|| {
996 "workspace_path is required when the session is not loaded".to_string()
997 })?;
998 let effective = desktop_effective_session_storage_path(
999 app_state,
1000 workspace_path,
1001 remote_connection_id,
1002 remote_ssh_host,
1003 )
1004 .await;
1005 coordinator
1006 .restore_session_from_storage_path(&effective, session_id)
1007 .await
1008 .map_err(|e| format!("Failed to restore session before thread goal access: {e}"))?;
1009 }
1010
1011 coordinator
1012 .get_session_manager()
1013 .get_session(session_id)
1014 .and_then(|session| session.config.workspace_path.clone())
1015 .map(PathBuf::from)
1016 .ok_or_else(|| format!("Session workspace_path is missing: {session_id}"))
1017}
1018
1019async fn resolve_thread_goal_storage_path(
1020 coordinator: &Arc<ConversationCoordinator>,

Calls 6

get_session_managerMethod · 0.80
get_sessionMethod · 0.45
is_emptyMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected