From 3e881d073b471eb2fbae11ebea43d447960337a3 Mon Sep 17 00:00:00 2001 From: Bryan Helmkamp Date: Mon, 20 Apr 2026 14:54:33 -0400 Subject: [PATCH] refactor(cli): rename ServerStoreClient to Client Finish the rename started with the Client alias: drop the alias and use the Client name directly for the server-facing CLI client struct. Co-Authored-By: Claude Opus 4.7 (1M context) --- lib/crates/fabro-cli/src/commands/exec.rs | 4 +-- lib/crates/fabro-cli/src/server_client.rs | 38 ++++++++++------------- 2 files changed, 18 insertions(+), 24 deletions(-) diff --git a/lib/crates/fabro-cli/src/commands/exec.rs b/lib/crates/fabro-cli/src/commands/exec.rs index 7e6c1f95a..758ba1440 100644 --- a/lib/crates/fabro-cli/src/commands/exec.rs +++ b/lib/crates/fabro-cli/src/commands/exec.rs @@ -108,13 +108,13 @@ fn runtime_mcp_server(name: &str, entry: &McpEntryLayer) -> McpServerSettings { } struct AuthenticatedFabroServerAdapter { - client: server_client::ServerStoreClient, + client: server_client::Client, base_url: String, provider_name: String, } impl AuthenticatedFabroServerAdapter { - fn new(client: server_client::ServerStoreClient, provider_name: impl Into) -> Self { + fn new(client: server_client::Client, provider_name: impl Into) -> Self { let base_url = client.base_url().to_string(); Self { client, diff --git a/lib/crates/fabro-cli/src/server_client.rs b/lib/crates/fabro-cli/src/server_client.rs index 28c4bfd32..b59b0a3ed 100644 --- a/lib/crates/fabro-cli/src/server_client.rs +++ b/lib/crates/fabro-cli/src/server_client.rs @@ -34,15 +34,13 @@ use crate::user_config::cli_http_client_builder; use crate::{sse, user_config}; #[derive(Clone)] -pub(crate) struct ServerStoreClient { +pub(crate) struct Client { state: Arc>, base_url: String, refreshable_oauth: Option, refresh_lock: Arc>, } -pub(crate) type Client = ServerStoreClient; - #[derive(Clone)] struct ClientBundle { client: fabro_api::ApiClient, @@ -178,17 +176,15 @@ fn refreshable_oauth( Ok(None) } -pub(crate) async fn connect_server(storage_dir: &Path) -> Result { +pub(crate) async fn connect_server(storage_dir: &Path) -> Result { connect_api_client_bundle(storage_dir).await } -pub(crate) async fn connect_server_target( - target: &user_config::ServerTarget, -) -> Result { +pub(crate) async fn connect_server_target(target: &user_config::ServerTarget) -> Result { connect_target_api_client_bundle(target).await } -pub(crate) async fn connect_server_target_direct(target: &str) -> Result { +pub(crate) async fn connect_server_target_direct(target: &str) -> Result { if target.starts_with("http://") || target.starts_with("https://") { connect_server_target(&user_config::ServerTarget::HttpUrl { api_url: target.to_string(), @@ -208,7 +204,7 @@ pub(crate) async fn connect_server_with_settings( args: &ServerTargetArgs, settings: &SettingsLayer, base_config_path: &Path, -) -> Result { +) -> Result { if let Some(target) = user_config::resolve_nondefault_server_target(args, settings)? { if let user_config::ServerTarget::UnixSocket(path) = &target { return connect_managed_unix_socket_api_client_bundle( @@ -228,7 +224,7 @@ async fn connect_managed_unix_socket_api_client_bundle( path: &Path, storage_dir: &Path, active_config_path: &Path, -) -> Result { +) -> Result { let target = user_config::ServerTarget::UnixSocket(path.to_path_buf()); let bearer = resolve_target_bearer( &target, @@ -251,7 +247,7 @@ async fn connect_managed_unix_socket_api_client_bundle( .with_context(|| format!("Failed to connect to fabro server at {}", path.display()))? }; - Ok(ServerStoreClient::from_bundle( + Ok(Client::from_bundle( bundle, "http://fabro".to_string(), refreshable_oauth, @@ -261,7 +257,7 @@ async fn connect_managed_unix_socket_api_client_bundle( async fn connect_local_api_client_bundle( storage_dir: &Path, active_config_path: &Path, -) -> Result { +) -> Result { let bind = start::ensure_server_running_for_storage(storage_dir, active_config_path) .await .with_context(|| format!("Failed to start fabro server for {}", storage_dir.display()))?; @@ -269,7 +265,7 @@ async fn connect_local_api_client_bundle( Bind::Unix(path) => { let bundle = connect_unix_socket_api_client_bundle(&path, Some(storage_dir), None).await?; - Ok(ServerStoreClient::from_bundle( + Ok(Client::from_bundle( bundle, "http://fabro".to_string(), None, @@ -280,7 +276,7 @@ async fn connect_local_api_client_bundle( let builder = cli_http_client_builder().no_proxy(); let http_client = apply_bearer_token_auth(builder, &token)?.build()?; let base_url = format!("http://{addr}"); - Ok(ServerStoreClient::from_bundle( + Ok(Client::from_bundle( client_bundle(&base_url, http_client, Some(token)), base_url, None, @@ -289,7 +285,7 @@ async fn connect_local_api_client_bundle( } } -async fn connect_api_client_bundle(storage_dir: &Path) -> Result { +async fn connect_api_client_bundle(storage_dir: &Path) -> Result { connect_local_api_client_bundle(storage_dir, &user_config::active_settings_path(None)).await } @@ -303,9 +299,7 @@ pub(crate) async fn connect_api_client(storage_dir: &Path) -> Result Result { +async fn connect_target_api_client_bundle(target: &user_config::ServerTarget) -> Result { match target { user_config::ServerTarget::HttpUrl { api_url, tls } => { let bearer = resolve_target_bearer(target, None, local_dev_token_fallback(target))?; @@ -315,7 +309,7 @@ async fn connect_target_api_client_bundle( tls.as_ref(), bearer.as_ref().map(ResolvedBearer::bearer_token), )?; - Ok(ServerStoreClient::from_bundle( + Ok(Client::from_bundle( bundle, user_config::normalized_http_base_url(api_url).to_string(), refreshable_oauth, @@ -331,7 +325,7 @@ async fn connect_target_api_client_bundle( ) .await .with_context(|| format!("Failed to connect to fabro server at {}", path.display()))?; - Ok(ServerStoreClient::from_bundle( + Ok(Client::from_bundle( bundle, "http://fabro".to_string(), refreshable_oauth, @@ -569,7 +563,7 @@ struct ArtifactBatchUploadEntry { content_type: Option, } -impl ServerStoreClient { +impl Client { fn from_bundle( bundle: ClientBundle, base_url: String, @@ -1930,7 +1924,7 @@ mod tests { auth_store.put(&key, oauth_entry("octocat")).unwrap(); let http_client = cli_http_client_builder().no_proxy().build().unwrap(); - let client = ServerStoreClient { + let client = Client { state: Arc::new(RwLock::new(client_bundle( "http://fabro.example.com", http_client,