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

Function open_remote_workspace

src/apps/desktop/src/api/commands.rs:1410–1538  ·  view source on GitHub ↗
(
    state: State<'_, AppState>,
    app: tauri::AppHandle,
    request: OpenRemoteWorkspaceRequest,
)

Source from the content-addressed store, hash-verified

1408
1409#[tauri::command]
1410pub async fn open_remote_workspace(
1411 state: State<'_, AppState>,
1412 app: tauri::AppHandle,
1413 request: OpenRemoteWorkspaceRequest,
1414) -> Result<WorkspaceInfoDto, String> {
1415 use bitfun_core::service::remote_ssh::normalize_remote_workspace_path;
1416 use bitfun_core::service::remote_ssh::workspace_state::remote_workspace_stable_id;
1417 use bitfun_core::service::workspace::WorkspaceCreateOptions;
1418
1419 let remote_path = normalize_remote_workspace_path(&request.remote_path);
1420
1421 let mut ssh_host = request
1422 .ssh_host
1423 .as_deref()
1424 .map(str::trim)
1425 .filter(|s| !s.is_empty())
1426 .map(|s| s.to_string());
1427
1428 if ssh_host.is_none() {
1429 if let Ok(mgr) = state.get_ssh_manager_async().await {
1430 ssh_host = mgr
1431 .get_saved_host_for_connection_id(&request.connection_id)
1432 .await;
1433 }
1434 }
1435 if ssh_host.is_none() {
1436 if let Ok(mgr) = state.get_ssh_manager_async().await {
1437 ssh_host = mgr
1438 .get_connection_config(&request.connection_id)
1439 .await
1440 .map(|c| c.host)
1441 .map(|h| h.trim().to_string())
1442 .filter(|s| !s.is_empty());
1443 }
1444 }
1445 let ssh_host = ssh_host.unwrap_or_else(|| {
1446 warn!(
1447 "open_remote_workspace: no ssh host from request, saved profile, or active connection; using connection_name (may not match session mirror): connection_id={}",
1448 request.connection_id
1449 );
1450 request.connection_name.clone()
1451 });
1452
1453 let stable_workspace_id = remote_workspace_stable_id(&ssh_host, &remote_path);
1454
1455 let display_name = remote_path
1456 .split('/')
1457 .rfind(|s| !s.is_empty())
1458 .unwrap_or(remote_path.as_str())
1459 .to_string();
1460
1461 let options = WorkspaceCreateOptions {
1462 scan_options: ScanOptions {
1463 calculate_statistics: false,
1464 ..ScanOptions::default()
1465 },
1466 auto_set_current: true,
1467 add_to_recent: true,

Callers

nothing calls this directly

Calls 15

get_ssh_manager_asyncMethod · 0.80
trimMethod · 0.80
get_mutMethod · 0.80
get_workspaces_mutMethod · 0.80
manual_saveMethod · 0.80
is_emptyMethod · 0.45
get_connection_configMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected