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

Function remote_open_workspace

src/apps/desktop/src/api/ssh_api.rs:396–449  ·  view source on GitHub ↗
(
    state: State<'_, AppState>,
    connection_id: String,
    remote_path: String,
)

Source from the content-addressed store, hash-verified

394
395#[tauri::command]
396pub async fn remote_open_workspace(
397 state: State<'_, AppState>,
398 connection_id: String,
399 remote_path: String,
400) -> Result<(), String> {
401 let remote_path =
402 bitfun_core::service::remote_ssh::normalize_remote_workspace_path(&remote_path);
403 let manager = state.get_ssh_manager_async().await?;
404
405 // Verify connection exists
406 if !manager.is_connected(&connection_id).await {
407 return Err("Not connected to remote server".to_string());
408 }
409
410 // Verify remote path exists
411 let remote_fs = state.get_remote_file_service_async().await?;
412 let exists = remote_fs
413 .exists(&connection_id, &remote_path)
414 .await
415 .map_err(|e| e.to_string())?;
416
417 if !exists {
418 return Err(format!("Remote path does not exist: {}", remote_path));
419 }
420
421 // Get connection info for workspace
422 let connections = manager.get_saved_connections().await;
423 let conn = connections.iter().find(|c| c.id == connection_id);
424
425 let ssh_host = manager
426 .get_connection_config(&connection_id)
427 .await
428 .map(|c| c.host)
429 .unwrap_or_default();
430
431 let workspace = crate::api::RemoteWorkspace {
432 connection_id: connection_id.clone(),
433 connection_name: conn.map(|c| c.name.clone()).unwrap_or_default(),
434 remote_path: remote_path.clone(),
435 ssh_host,
436 };
437
438 state
439 .set_remote_workspace(workspace)
440 .await
441 .map_err(|e| e.to_string())?;
442
443 log::info!(
444 "Opened remote workspace: {} on connection {}",
445 remote_path,
446 connection_id
447 );
448 Ok(())
449}
450
451#[tauri::command]
452pub async fn remote_close_workspace(state: State<'_, AppState>) -> Result<(), String> {

Callers

nothing calls this directly

Calls 10

get_ssh_manager_asyncMethod · 0.80
iterMethod · 0.80
is_connectedMethod · 0.45
existsMethod · 0.45
get_saved_connectionsMethod · 0.45
get_connection_configMethod · 0.45
cloneMethod · 0.45
set_remote_workspaceMethod · 0.45

Tested by

no test coverage detected