fix(#545): fix gated ws auth loop and ticket refresh (#546)

Fix gated close codes, run ticket refresh on Dispatchers.IO, prevent scope race on startup, and auto-format files.
This commit is contained in:
M57 authored and GitHub committed 2026-07-11 00:21:23 +03:00
1 parent 53b3966931
commit 480d29e481
12 files changed
+118 -24

No files matched your search

@@ -119,6 +119,7 @@ fun McpServersScreen(
state.isLoading && state.servers.isEmpty() -> {
LoadingState(modifier = Modifier.padding(paddingValues))
}
state.errorMessage != null -> {
ErrorState(
message = state.errorMessage ?: "",
@@ -126,6 +127,7 @@ fun McpServersScreen(
modifier = Modifier.padding(paddingValues),
)
}
else -> {
LazyColumn(
modifier = Modifier.fillMaxSize(),
@@ -557,12 +559,14 @@ private fun CatalogSection(
}
Spacer(modifier = Modifier.height(spacing.sm))
}
state.catalogError != null -> {
ErrorState(
message = state.catalogError ?: "",
onRetry = { viewModel.loadCatalog() },
)
}
filteredCatalog.isEmpty() -> {
Text(
text = stringResource(R.string.mcp_servers_catalog_empty),
@@ -571,6 +575,7 @@ private fun CatalogSection(
modifier = Modifier.padding(vertical = spacing.md),
)
}
else -> {
filteredCatalog.forEach { entry ->
CatalogEntryCard(
@@ -112,6 +112,7 @@ class McpServersViewModel :
)
}
}
is NetworkResult.Failure -> {
revertToggle(server.name, originalEnabled, "Failed to toggle server: ${result.error.message}")
}
@@ -130,6 +131,7 @@ class McpServersViewModel :
is NetworkResult.Success -> {
_uiState.update { it.copy(toastMessage = "Server '$name' tested — OK") }
}
is NetworkResult.Failure -> {
_uiState.update { it.copy(toastMessage = "Server '$name' test failed: ${result.error.message}") }
}
@@ -148,6 +150,7 @@ class McpServersViewModel :
_uiState.update { it.copy(toastMessage = "Server '$name' deleted") }
loadServers()
}
is NetworkResult.Failure -> {
_uiState.update { it.copy(toastMessage = "Failed to delete server: ${result.error.message}") }
}
@@ -167,6 +170,7 @@ class McpServersViewModel :
_uiState.update { it.copy(toastMessage = "Server '$name' restarted") }
loadServers()
}
is NetworkResult.Failure -> {
_uiState.update { it.copy(toastMessage = "Failed to restart server: ${result.error.message}") }
}
@@ -220,7 +224,10 @@ class McpServersViewModel :
},
args =
if (state.addMode == AddServerMode.Stdio && state.addServerArgs.isNotBlank()) {
state.addServerArgs.trim().split("\\s+".toRegex()).filter { it.isNotEmpty() }
state.addServerArgs
.trim()
.split("\\s+".toRegex())
.filter { it.isNotEmpty() }
} else {
null
},
@@ -244,6 +251,7 @@ class McpServersViewModel :
}
loadServers()
}
is NetworkResult.Failure -> {
_uiState.update {
it.copy(
@@ -300,6 +308,7 @@ class McpServersViewModel :
}
loadServers()
}
is NetworkResult.Failure -> {
_uiState.update { it.copy(toastMessage = "Failed to add env var: ${result.error.message}") }
}
@@ -324,6 +333,7 @@ class McpServersViewModel :
_uiState.update { it.copy(toastMessage = "Env var '$key' removed") }
loadServers()
}
is NetworkResult.Failure -> {
_uiState.update { it.copy(toastMessage = "Failed to remove env var: ${result.error.message}") }
}
@@ -349,6 +359,7 @@ class McpServersViewModel :
)
}
}
is NetworkResult.Failure -> {
_uiState.update {
it.copy(
@@ -389,6 +400,7 @@ class McpServersViewModel :
}
loadServers()
}
is NetworkResult.Failure -> {
_uiState.update {
it.copy(