Wait until WebUI is ready to open in browser (#2010)

* Wait until WebUI is ready

* Changelog

* Move openInBrowser out of timeout
This commit is contained in:
Mitchell Syer
2026-05-09 18:15:43 -04:00
committed by GitHub
parent 505e966653
commit 6fef27bb56
3 changed files with 15 additions and 4 deletions
+1
View File
@@ -14,6 +14,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
### Fixed ### Fixed
- (WebUI) Handle serving non-default webui with "bundled" - (WebUI) Handle serving non-default webui with "bundled"
- (WebUI) Wait until WebUI is ready to open in browser
## [v2.2.2100] + [WebUI: v20260508.01] - 2026-05-08 ## [v2.2.2100] + [WebUI: v20260508.01] - 2026-05-08
@@ -27,7 +27,10 @@ import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.SupervisorJob import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.future.future import kotlinx.coroutines.future.future
import kotlinx.coroutines.launch
import kotlinx.coroutines.withTimeoutOrNull
import org.eclipse.jetty.server.ServerConnector import org.eclipse.jetty.server.ServerConnector
import suwayomi.tachidesk.global.GlobalAPI import suwayomi.tachidesk.global.GlobalAPI
import suwayomi.tachidesk.graphql.GraphQL import suwayomi.tachidesk.graphql.GraphQL
@@ -51,6 +54,7 @@ import java.util.concurrent.CompletableFuture
import kotlin.concurrent.thread import kotlin.concurrent.thread
import kotlin.text.get import kotlin.text.get
import kotlin.time.Duration.Companion.days import kotlin.time.Duration.Companion.days
import kotlin.time.Duration.Companion.seconds
object JavalinSetup { object JavalinSetup {
private val logger = KotlinLogging.logger {} private val logger = KotlinLogging.logger {}
@@ -132,7 +136,12 @@ object JavalinSetup {
config.events.serverStarted { config.events.serverStarted {
if (serverConfig.initialOpenInBrowserEnabled.value) { if (serverConfig.initialOpenInBrowserEnabled.value) {
Browser.openInBrowser() scope.launch {
withTimeoutOrNull(10.seconds) {
WebInterfaceManager.isSetupComplete.first { it }
}
Browser.openInBrowser()
}
} }
} }
} }
@@ -27,6 +27,7 @@ import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.SupervisorJob import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.delay import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.SharingStarted import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.sample import kotlinx.coroutines.flow.sample
@@ -90,7 +91,7 @@ object WebInterfaceManager {
private val preferences = Injekt.get<Application>().getSharedPreferences("server_util", Context.MODE_PRIVATE) private val preferences = Injekt.get<Application>().getSharedPreferences("server_util", Context.MODE_PRIVATE)
private var currentUpdateTaskId: String = "" private var currentUpdateTaskId: String = ""
private var isSetupComplete = false val isSetupComplete = MutableStateFlow(false)
private val json: Json by injectLazy() private val json: Json by injectLazy()
private val network: NetworkHelper by injectLazy() private val network: NetworkHelper by injectLazy()
@@ -196,7 +197,7 @@ object WebInterfaceManager {
@OptIn(DelicateCoroutinesApi::class) @OptIn(DelicateCoroutinesApi::class)
GlobalScope.launchIO { GlobalScope.launchIO {
setupWebUI() setupWebUI()
isSetupComplete = true isSetupComplete.value = true
} }
} }
@@ -260,7 +261,7 @@ object WebInterfaceManager {
val lastAutomatedUpdate = preferences.getLong(LAST_WEBUI_UPDATE_CHECK_KEY, System.currentTimeMillis()) val lastAutomatedUpdate = preferences.getLong(LAST_WEBUI_UPDATE_CHECK_KEY, System.currentTimeMillis())
val task = { val task = {
if (isSetupComplete) { if (isSetupComplete.value) {
val log = val log =
KotlinLogging.logger( KotlinLogging.logger(
"${logger.name}::scheduleWebUIUpdateCheck(" + "${logger.name}::scheduleWebUIUpdateCheck(" +