(
coordinator: &Arc<ConversationCoordinator>,
app_state: &AppState,
session_id: &str,
workspace_path: Option<&str>,
remote_connection_id: Option<&str>,
remote_ssh_host: Option<
| 977 | } |
| 978 | |
| 979 | async 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 | |
| 1019 | async fn resolve_thread_goal_storage_path( |
| 1020 | coordinator: &Arc<ConversationCoordinator>, |
no test coverage detected