diff --git a/packages/app/src/runtime/host-runtime.ts b/packages/app/src/runtime/host-runtime.ts index 193c07891..60e55c41a 100644 --- a/packages/app/src/runtime/host-runtime.ts +++ b/packages/app/src/runtime/host-runtime.ts @@ -254,20 +254,26 @@ function nextConnectionMachineState(input: { } if (event.type === "connect_failed") { + let failedConnectionId: string | null; + if (state.tag === "connecting" || state.tag === "online") { + failedConnectionId = state.activeConnectionId; + } else if (state.tag === "offline" || state.tag === "error") { + failedConnectionId = state.activeConnectionId; + } else { + failedConnectionId = null; + } + let failedConnection: ActiveConnection | null; + if (state.tag === "connecting" || state.tag === "online") { + failedConnection = state.activeConnection; + } else if (state.tag === "offline" || state.tag === "error") { + failedConnection = state.activeConnection; + } else { + failedConnection = null; + } return { tag: "error", - activeConnectionId: - state.tag === "connecting" || state.tag === "online" - ? state.activeConnectionId - : state.tag === "offline" || state.tag === "error" - ? state.activeConnectionId - : null, - activeConnection: - state.tag === "connecting" || state.tag === "online" - ? state.activeConnection - : state.tag === "offline" || state.tag === "error" - ? state.activeConnection - : null, + activeConnectionId: failedConnectionId, + activeConnection: failedConnection, message: event.message, }; } @@ -280,18 +286,22 @@ function nextConnectionMachineState(input: { }; } - const previousActiveConnectionId = - state.tag === "connecting" || state.tag === "online" - ? state.activeConnectionId - : state.tag === "offline" || state.tag === "error" - ? state.activeConnectionId - : null; - const previousActiveConnection = - state.tag === "connecting" || state.tag === "online" - ? state.activeConnection - : state.tag === "offline" || state.tag === "error" - ? state.activeConnection - : null; + let previousActiveConnectionId: string | null; + if (state.tag === "connecting" || state.tag === "online") { + previousActiveConnectionId = state.activeConnectionId; + } else if (state.tag === "offline" || state.tag === "error") { + previousActiveConnectionId = state.activeConnectionId; + } else { + previousActiveConnectionId = null; + } + let previousActiveConnection: ActiveConnection | null; + if (state.tag === "connecting" || state.tag === "online") { + previousActiveConnection = state.activeConnection; + } else if (state.tag === "offline" || state.tag === "error") { + previousActiveConnection = state.activeConnection; + } else { + previousActiveConnection = null; + } if (!previousActiveConnectionId || !previousActiveConnection) { return state.tag === "booting" diff --git a/packages/app/src/screens/settings/host-page.tsx b/packages/app/src/screens/settings/host-page.tsx index c08a6d4c3..0e8ac199d 100644 --- a/packages/app/src/screens/settings/host-page.tsx +++ b/packages/app/src/screens/settings/host-page.tsx @@ -94,22 +94,26 @@ export function HostPage({ serverId, onHostRemoved }: HostPageProps) { const lastError = snapshot?.lastError ?? null; const statusLabel = formatConnectionStatus(connectionStatus); const statusTone = getConnectionStatusTone(connectionStatus); - const statusColor = - statusTone === "success" - ? theme.colors.palette.green[400] - : statusTone === "warning" - ? theme.colors.palette.amber[500] - : statusTone === "error" - ? theme.colors.destructive - : theme.colors.foregroundMuted; - const statusPillBg = - statusTone === "success" - ? "rgba(74, 222, 128, 0.1)" - : statusTone === "warning" - ? "rgba(245, 158, 11, 0.1)" - : statusTone === "error" - ? "rgba(248, 113, 113, 0.1)" - : "rgba(161, 161, 170, 0.1)"; + let statusColor: string; + if (statusTone === "success") { + statusColor = theme.colors.palette.green[400]; + } else if (statusTone === "warning") { + statusColor = theme.colors.palette.amber[500]; + } else if (statusTone === "error") { + statusColor = theme.colors.destructive; + } else { + statusColor = theme.colors.foregroundMuted; + } + let statusPillBg: string; + if (statusTone === "success") { + statusPillBg = "rgba(74, 222, 128, 0.1)"; + } else if (statusTone === "warning") { + statusPillBg = "rgba(245, 158, 11, 0.1)"; + } else if (statusTone === "error") { + statusPillBg = "rgba(248, 113, 113, 0.1)"; + } else { + statusPillBg = "rgba(161, 161, 170, 0.1)"; + } const connectionBadge = formatActiveConnectionBadge(activeConnection, theme); const versionBadgeText = formatDaemonVersionBadge(daemonVersion); const connectionError = diff --git a/packages/app/src/screens/settings/providers-section.tsx b/packages/app/src/screens/settings/providers-section.tsx index d156322b7..7f13fcaca 100644 --- a/packages/app/src/screens/settings/providers-section.tsx +++ b/packages/app/src/screens/settings/providers-section.tsx @@ -15,6 +15,19 @@ import { RotateCw } from "lucide-react-native"; type ProviderDefinition = ReturnType[number]; type ProviderEntry = NonNullable["entries"]>[number]; +function getProviderStatusLabel(status: string): string { + if (status === "ready") return "Available"; + if (status === "error") return "Error"; + if (status === "loading") return "Loading..."; + return "Not installed"; +} + +function getProviderStatusVariant(status: string): "success" | "error" | "muted" { + if (status === "ready") return "success"; + if (status === "error") return "error"; + return "muted"; +} + interface ProviderRowProps { def: ProviderDefinition; entry: ProviderEntry | undefined; @@ -57,16 +70,8 @@ function ProviderRow({ def, entry, isFirst, onPress }: ProviderRowProps) { ) : null} );