Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

## Unreleased

### Changed

- URI handling no longer waits for confirmation to use latest build if the provided build number is too old

### Fixed

- IDE is now launched when URI is handled by an already running Toolbox instance.

## 0.7.1 - 2025-10-13

### Fixed
Expand Down
18 changes: 14 additions & 4 deletions src/main/kotlin/com/coder/toolbox/util/CoderProtocolHandler.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import kotlinx.coroutines.time.withTimeout
import java.net.URI
import java.util.UUID
import kotlin.time.Duration
import kotlin.time.Duration.Companion.milliseconds
import kotlin.time.Duration.Companion.minutes
import kotlin.time.Duration.Companion.seconds
import kotlin.time.toJavaDuration
Expand Down Expand Up @@ -111,6 +112,18 @@ open class CoderProtocolHandler(
CoderCliSetupContext.token = token
}
CoderCliSetupWizardState.goToStep(WizardStep.CONNECT)

// If Toolbox is already opened and URI is executed the setup page
// from below is never called. I tried a couple of things, including
// yielding the coroutine - but it seems to be of no help. What works
// delaying the coroutine for 66 - to 100 milliseconds, these numbers
// were determined by trial and error.
// The only explanation that I have is that inspecting the TBX bytecode it seems the
// UI event is emitted via MutableSharedFlow(replay = 0) which has a buffer of 4 events
// and a drop oldest strategy. For some reason it seems that the UI collector
// is not yet active, causing the event to be lost unless we wait > 66 ms.
// I think this delay ensures the collector is ready before processEvent() is called.
delay(100.milliseconds)
context.ui.showUiPage(
CoderCliSetupWizardPage(
context, settingsPage, visibilityState, true,
Expand Down Expand Up @@ -369,10 +382,7 @@ open class CoderProtocolHandler(
val buildNumberIsNotAvailable = availableVersions.firstOrNull { it.contains(buildNumber) } == null
if (buildNumberIsNotAvailable) {
val selectedIde = availableVersions.maxOf { it }
context.logAndShowInfo(
"$productCode-$buildNumber not available",
"$productCode-$buildNumber is not available, we've selected the latest $selectedIde"
)
context.logger.info("$productCode-$buildNumber is not available, we've selected the latest $selectedIde")
return selectedIde
}
return "$productCode-$buildNumber"
Expand Down
Loading