Skip to content

Commit 781f672

Browse files
committed
feat(web-admin): Phase 5 — Dead code cleanup + test coverage
Remove superseded export_config, connect_server, and disconnect_server_v2 apiCall/Tauri paths; extend admin-transport tests for builtins, config-export routes, direct SSE channels, and dead-command guard. Signed-off-by: crimsonsunset <jsangio1@gmail.com>
1 parent 4fd573c commit 781f672

7 files changed

Lines changed: 78 additions & 257 deletions

File tree

apps/desktop/src-tauri/src/commands/gateway.rs

Lines changed: 0 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -1619,114 +1619,6 @@ pub async fn generate_gateway_config(
16191619
serde_json::to_string_pretty(&config).map_err(|e| e.to_string())
16201620
}
16211621

1622-
/// Resolve the system's default space id (the `is_default` Space).
1623-
async fn get_default_space_id(app_state: &AppState) -> Result<String, String> {
1624-
let space = app_state
1625-
.space_service
1626-
.get_default()
1627-
.await
1628-
.map_err(|e: anyhow::Error| e.to_string())?
1629-
.ok_or("No default space found")?;
1630-
Ok(space.id.to_string())
1631-
}
1632-
1633-
/// Connect an installed server to the gateway
1634-
#[tauri::command]
1635-
pub async fn connect_server(
1636-
server_id: String,
1637-
space_id: Option<String>,
1638-
app_state: State<'_, AppState>,
1639-
gateway_state: State<'_, Arc<RwLock<GatewayAppState>>>,
1640-
) -> Result<(), String> {
1641-
info!("[Gateway] Connecting server: {}", server_id);
1642-
1643-
// Get space ID
1644-
let space_id_str = match space_id {
1645-
Some(sid) => sid,
1646-
None => get_default_space_id(&app_state).await?,
1647-
};
1648-
1649-
let space_uuid = Uuid::parse_str(&space_id_str).map_err(|e| e.to_string())?;
1650-
1651-
// Get the installed server from the database
1652-
let installed = app_state
1653-
.installed_server_repository
1654-
.get_by_server_id(&space_id_str, &server_id)
1655-
.await
1656-
.map_err(|e| {
1657-
error!(
1658-
"[Gateway] Failed to get installed server {}: {}",
1659-
server_id, e
1660-
);
1661-
e.to_string()
1662-
})?
1663-
.ok_or_else(|| {
1664-
warn!("[Gateway] Server not installed: {}", server_id);
1665-
format!("Server not installed: {}", server_id)
1666-
})?;
1667-
1668-
// Use cached definition (offline-first)
1669-
let server_definition = installed.get_definition().ok_or_else(|| {
1670-
warn!("[Gateway] Server has no cached definition: {}", server_id);
1671-
format!("Server has no cached definition: {}", server_id)
1672-
})?;
1673-
1674-
// Get pool service
1675-
let state = gateway_state.read().await;
1676-
if !state.running {
1677-
return Err("Gateway is not running".to_string());
1678-
}
1679-
let pool_service = state
1680-
.pool_service
1681-
.clone()
1682-
.ok_or("Pool service not initialized")?;
1683-
drop(state); // Release lock before async work
1684-
1685-
// Build transport config from cached definition + input values
1686-
let transport = mcpmux_gateway::pool::transport::resolution::build_transport_config(
1687-
&server_definition.transport,
1688-
&installed,
1689-
Some(app_state.data_dir()),
1690-
mcpmux_gateway::pool::transport::resolution::TransportResolutionOptions::default(),
1691-
);
1692-
1693-
// Connect using pool service (manual connect from API)
1694-
let ctx = ConnectionContext::new(space_uuid, server_id.clone(), transport);
1695-
let result = pool_service.connect_server(&ctx).await;
1696-
1697-
match result {
1698-
ConnectionResult::Connected { reused, features } => {
1699-
info!(
1700-
"[Gateway] Server {} connected (reused: {}, features: {})",
1701-
server_id,
1702-
reused,
1703-
features.total_count()
1704-
);
1705-
1706-
Ok(())
1707-
}
1708-
ConnectionResult::Failed { error } => {
1709-
error!(
1710-
"[Gateway] Failed to connect server {}: {}",
1711-
server_id, error
1712-
);
1713-
1714-
Err(error)
1715-
}
1716-
ConnectionResult::OAuthRequired { auth_url } => {
1717-
warn!(
1718-
"[Gateway] Server {} requires OAuth authentication",
1719-
server_id
1720-
);
1721-
1722-
Err(format!(
1723-
"OAuth required. Please authenticate at: {}",
1724-
auth_url
1725-
))
1726-
}
1727-
}
1728-
}
1729-
17301622
/// Disconnect a server from the gateway
17311623
#[tauri::command]
17321624
pub async fn disconnect_server(

apps/desktop/src-tauri/src/commands/server_manager.rs

Lines changed: 0 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -638,82 +638,3 @@ pub async fn logout_server(
638638

639639
Ok(())
640640
}
641-
642-
/// Disconnect server v2 - Stop connection but keep enabled and preserve all credentials
643-
///
644-
/// Preserves: Everything (tokens, DCR, inputs, enabled flag)
645-
/// Result: State = auth_required (for OAuth) or connecting attempt on next enable
646-
/// Use case: Temporary pause, quick reconnect possible
647-
#[tauri::command]
648-
pub async fn disconnect_server_v2(
649-
space_id: String,
650-
server_id: String,
651-
server_manager_state: State<'_, Arc<RwLock<ServerManagerState>>>,
652-
gateway_state: State<'_, Arc<RwLock<crate::commands::gateway::GatewayAppState>>>,
653-
app_state: State<'_, AppState>,
654-
) -> Result<(), String> {
655-
use mcpmux_core::AuthConfig;
656-
657-
let space_uuid = Uuid::parse_str(&space_id).map_err(|e| format!("Invalid space_id: {}", e))?;
658-
659-
let manager_state = server_manager_state.read().await;
660-
let manager = manager_state
661-
.manager
662-
.as_ref()
663-
.ok_or("ServerManager not initialized")?
664-
.clone();
665-
let pool_service = manager_state
666-
.pool_service
667-
.as_ref()
668-
.ok_or("PoolService not initialized")?
669-
.clone();
670-
drop(manager_state);
671-
672-
let key = ServerKey::new(space_uuid, &server_id);
673-
674-
// 1. Close active connection only
675-
pool_service.remove_instance(space_uuid, &server_id);
676-
677-
// 2. Cancel any pending OAuth flows
678-
pool_service
679-
.oauth_manager()
680-
.cancel_flow_for_space(space_uuid, &server_id);
681-
682-
// 3. Check if this is an OAuth server (use cached definition)
683-
let installed = app_state
684-
.installed_server_repository
685-
.get_by_server_id(&space_id, &server_id)
686-
.await
687-
.ok()
688-
.flatten();
689-
let is_oauth = installed
690-
.and_then(|i| i.get_definition())
691-
.map(|def| matches!(def.auth, Some(AuthConfig::Oauth)))
692-
.unwrap_or(false);
693-
694-
// 4. Set state based on server type
695-
if is_oauth {
696-
// OAuth server: go to auth_required (can reconnect with stored tokens)
697-
manager.set_auth_required(&key, None).await;
698-
} else {
699-
// Non-OAuth server: go to disconnected
700-
manager.set_disconnected(&key).await;
701-
}
702-
703-
// 5. Mark features unavailable - not connected
704-
if let Some(ref feature_service) = gateway_state.read().await.feature_service {
705-
if let Err(e) = feature_service
706-
.mark_unavailable(&space_id, &server_id)
707-
.await
708-
{
709-
warn!("[ServerManager] Failed to mark features unavailable: {}", e);
710-
}
711-
}
712-
713-
info!(
714-
"[ServerManager] Server {} disconnected (features unavailable, credentials preserved)",
715-
server_id
716-
);
717-
718-
Ok(())
719-
}

apps/desktop/src-tauri/src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1023,7 +1023,6 @@ pub fn run() {
10231023
commands::restart_gateway,
10241024
commands::reload_admin_server,
10251025
commands::generate_gateway_config,
1026-
commands::connect_server,
10271026
commands::disconnect_server,
10281027
commands::list_connected_servers,
10291028
commands::connect_all_enabled_servers,
@@ -1050,7 +1049,6 @@ pub fn run() {
10501049
commands::cancel_auth_v2,
10511050
commands::retry_connection,
10521051
commands::logout_server,
1053-
commands::disconnect_server_v2,
10541052
// Log commands
10551053
commands::get_server_logs,
10561054
commands::clear_server_logs,

apps/desktop/src/lib/api/gateway.ts

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -13,48 +13,13 @@ export interface GatewayStatus {
1313
connected_backends: number;
1414
}
1515

16-
/**
17-
* Public URL advertised by the gateway in OAuth metadata.
18-
*/
19-
export interface GatewayPublicUrlSettings {
20-
configuredPublicBaseUrl: string | null;
21-
activePublicBaseUrl: string | null;
22-
localBaseUrl: string | null;
23-
}
24-
25-
/**
26-
* Config export format.
27-
*/
28-
export type ExportFormat = 'cursor' | 'vscode' | 'claude';
29-
3016
/**
3117
* Get gateway status.
3218
*/
3319
export async function getGatewayStatus(spaceId?: string): Promise<GatewayStatus> {
3420
return apiCall('get_gateway_status', { spaceId });
3521
}
3622

37-
/**
38-
* Get the configured and currently-active public gateway URL settings.
39-
*/
40-
export async function getGatewayPublicUrlSettings(): Promise<GatewayPublicUrlSettings> {
41-
return invoke('get_gateway_public_url_settings');
42-
}
43-
44-
/**
45-
* Set the public base URL advertised in OAuth metadata. Pass null to clear it.
46-
*/
47-
export async function setGatewayPublicBaseUrl(publicBaseUrl: string | null): Promise<void> {
48-
return invoke('set_gateway_public_base_url', { publicBaseUrl });
49-
}
50-
51-
/**
52-
* Clear the public base URL and return to local-only localhost metadata.
53-
*/
54-
export async function resetGatewayPublicBaseUrl(): Promise<void> {
55-
return invoke('reset_gateway_public_base_url');
56-
}
57-
5823
/**
5924
* Probe result for a proposed gateway start.
6025
*
@@ -151,16 +116,6 @@ export async function restartGateway(opts?: {
151116
});
152117
}
153118

154-
/**
155-
* Export config for a client.
156-
*/
157-
export async function exportConfig(
158-
format: ExportFormat,
159-
clientId?: string
160-
): Promise<string> {
161-
return apiCall('export_config', { format, clientId });
162-
}
163-
164119
/**
165120
* Backend server status.
166121
*/
@@ -171,13 +126,6 @@ export interface BackendStatus {
171126
tools_count: number;
172127
}
173128

174-
/**
175-
* Connect an installed server to the gateway.
176-
*/
177-
export async function connectServer(serverId: string): Promise<void> {
178-
return apiCall('connect_server', { serverId });
179-
}
180-
181129
/**
182130
* Disconnect a server from the gateway.
183131
* @param serverId - The server ID to disconnect

apps/desktop/src/lib/api/serverManager.ts

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -190,20 +190,6 @@ export async function updateServerPackage(spaceId: string, serverId: string): Pr
190190
return apiCall('update_server_package', { spaceId, serverId });
191191
}
192192

193-
/**
194-
* Disconnect server - Stop connection but keep enabled and preserve credentials
195-
*
196-
* Preserves: Everything (tokens, DCR, inputs, enabled flag)
197-
* Result: State = auth_required (OAuth) or disconnected (non-OAuth)
198-
* Use case: Temporary pause, quick reconnect possible
199-
*/
200-
export async function disconnectServerV2(
201-
spaceId: string,
202-
serverId: string
203-
): Promise<void> {
204-
return apiCall("disconnect_server_v2", { spaceId, serverId });
205-
}
206-
207193
// ============================================================================
208194
// Event Listeners (Backend → UI)
209195
// ============================================================================

scripts/take-screenshots.cjs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,6 @@ function buildMockHandler() {
254254
case 'get_pool_stats': return { total_instances: 6, connected_instances: 6, total_space_server_mappings: 6 };
255255
case 'get_server_logs': return [];
256256
case 'get_server_log_file': return '/home/user/.local/share/com.mcpmux.desktop/logs';
257-
case 'export_config': return '{}';
258257
case 'init_preset_clients': return null;
259258
case 'get_logs_path': return '/home/user/.local/share/com.mcpmux.desktop/logs';
260259
case 'get_startup_settings': return { autoLaunch: true, startMinimized: false, closeToTray: true };

0 commit comments

Comments
 (0)