Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 24 additions & 15 deletions apps/desktop/src/features/servers/ServersPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ function mergeDefinitionsWithStates(
(input: InputDefinition) => input.required && !inputValues[input.id]
);

// Calculate initial connection_status based on enabled state
// Calculate initial connection_status based on enabled state
// Actual runtime status comes from ServerManager events via useServerManager hook
const connection_status = state?.enabled ? 'connecting' : 'disconnected';
// Runtime status is in-memory only and comes from ServerManager.
// Do not infer `connecting` from persisted `enabled`; custom/offline servers can
// otherwise stay stuck in a synthetic Connecting state forever.
const connection_status = 'disconnected';

return {
...def,
Expand Down Expand Up @@ -95,11 +95,7 @@ function createOfflineServerViewModel(state: InstalledServerState): ServerViewMo
const inputValues = state.input_values;
const requiredInputs = definition.transport.metadata?.inputs?.filter((i) => i.required) || [];
const missing_required_inputs = requiredInputs.some((input) => !inputValues[input.id]);
const connection_status = state.enabled
? missing_required_inputs
? 'error'
: 'connecting'
: 'disconnected';
const connection_status = 'disconnected';

return {
...definition,
Expand Down Expand Up @@ -143,7 +139,7 @@ function createOfflineServerViewModel(state: InstalledServerState): ServerViewMo
enabled: state.enabled,
oauth_connected: state.oauth_connected,
input_values: state.input_values,
connection_status: state.enabled ? 'connecting' : 'disconnected',
connection_status: 'disconnected',
missing_required_inputs: false,
last_error: null,
created_at: state.created_at,
Expand Down Expand Up @@ -450,6 +446,7 @@ export function ServersPage() {
* - 'running': Server is connected and running
* - 'error': Server has an error
* - 'connected_auto': Non-OAuth server that's connected (no action buttons needed)
* - 'disconnected': Server is enabled but has no active runtime connection
*/
const getServerAction = (
server: ServerViewModel
Expand All @@ -461,7 +458,8 @@ export function ServersPage() {
| 'auth_required'
| 'running'
| 'error'
| 'connected_auto' => {
| 'connected_auto'
| 'disconnected' => {
if (!server.enabled) {
return 'enable';
}
Expand Down Expand Up @@ -489,8 +487,7 @@ export function ServersPage() {
case 'error':
return 'error';
case 'disconnected':
// Enabled but disconnected - try to connect
return server.auth?.type === 'oauth' ? 'auth_required' : 'connected_auto';
return server.auth?.type === 'oauth' ? 'auth_required' : 'disconnected';
}
}

Expand All @@ -515,8 +512,8 @@ export function ServersPage() {
return 'auth_required';
}

// Non-OAuth server that's enabled but not yet connected
return 'connected_auto';
// Enabled but no runtime connection exists yet. Let the user start/retry it.
return 'disconnected';
};

// Get display status for UI
Expand Down Expand Up @@ -544,6 +541,8 @@ export function ServersPage() {
return 'Connected';
case 'connected_auto':
return 'Connected';
case 'disconnected':
return 'Disconnected';
case 'error':
return 'Error';
}
Expand Down Expand Up @@ -1228,6 +1227,16 @@ export function ServersPage() {
</button>
)}

{serverAction === 'disconnected' && gatewayRunning && (
<button
onClick={() => handleRetry(server)}
disabled={retryLoading}
className="rounded-lg bg-[rgb(var(--success))] px-4 py-2 text-sm font-medium text-white shadow-sm transition-colors hover:bg-[rgb(var(--success))]/80 disabled:opacity-50"
>
{retryLoading ? 'Connecting...' : 'Connect'}
</button>
)}

{serverAction === 'error' && gatewayRunning && (
<button
onClick={() => handleRetry(server)}
Expand Down
5 changes: 3 additions & 2 deletions apps/desktop/src/stores/registryStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -363,8 +363,9 @@ function mergeServers(defs: ServerDefinition[], states: InstalledServerState[]):
input.required && !inputValues[input.id]
);

// Calculate initial connection_status based on enabled state
const connection_status = state?.enabled ? 'connecting' : 'disconnected';
// Runtime connection status is not persisted. Do not infer Connecting from
// the enabled flag; the ServerManager event/status stream owns that state.
const connection_status = 'disconnected';

return {
...def,
Expand Down