Skip to content

Commit ee8e7ff

Browse files
committed
Surface error when listing editors
Also my IDE tells me `is TimeoutCancellationException` is unreachable so I removed it.
1 parent a83b0bc commit ee8e7ff

File tree

2 files changed

+11
-22
lines changed

2 files changed

+11
-22
lines changed

src/main/kotlin/com/coder/gateway/views/steps/CoderLocateRemoteProjectStepView.kt

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import com.intellij.openapi.util.Disposer
2727
import com.intellij.openapi.wm.impl.welcomeScreen.WelcomeScreenUIManager
2828
import com.intellij.remote.AuthType
2929
import com.intellij.remote.RemoteCredentialsHolder
30-
import com.intellij.ssh.SshException
3130
import com.intellij.ui.AnimatedIcon
3231
import com.intellij.ui.ColoredListCellRenderer
3332
import com.intellij.ui.DocumentAdapter
@@ -57,7 +56,6 @@ import kotlinx.coroutines.CancellationException
5756
import kotlinx.coroutines.CoroutineScope
5857
import kotlinx.coroutines.Dispatchers
5958
import kotlinx.coroutines.Job
60-
import kotlinx.coroutines.TimeoutCancellationException
6159
import kotlinx.coroutines.async
6260
import kotlinx.coroutines.cancel
6361
import kotlinx.coroutines.cancelAndJoin
@@ -107,6 +105,7 @@ class CoderLocateRemoteProjectStepView(private val setNextButtonEnabled: (Boolea
107105
setNextButtonEnabled(this.selectedItem != null)
108106
ApplicationManager.getApplication().invokeLater {
109107
logger.info("Selected IDE: ${this.selectedItem}")
108+
cbIDEComment.foreground = UIUtil.getContextHelpForeground()
110109
when (this.selectedItem?.status) {
111110
IdeStatus.ALREADY_INSTALLED ->
112111
cbIDEComment.text =
@@ -156,6 +155,10 @@ class CoderLocateRemoteProjectStepView(private val setNextButtonEnabled: (Boolea
156155
override val nextActionText = CoderGatewayBundle.message("gateway.connector.view.coder.remoteproject.next.text")
157156

158157
override fun onInit(wizardModel: CoderWorkspacesWizardModel) {
158+
// Clear error message as it might still be displaying.
159+
cbIDEComment.foreground = UIUtil.getContextHelpForeground()
160+
cbIDEComment.text = CoderGatewayBundle.message("gateway.connector.view.coder.remoteproject.ide.none.comment")
161+
159162
cbIDE.renderer = IDECellRenderer()
160163
ideComboBoxModel.removeAllElements()
161164
val deploymentURL = wizardModel.coderURL.toURL()
@@ -183,30 +186,17 @@ class CoderLocateRemoteProjectStepView(private val setNextButtonEnabled: (Boolea
183186
when (e) {
184187
is InterruptedException -> Unit
185188
is CancellationException -> Unit
186-
is TimeoutCancellationException,
187-
is SshException -> {
188-
logger.error("Can't connect to workspace ${selectedWorkspace.name}. Reason: $e")
189-
withContext(Dispatchers.Main) {
190-
setNextButtonEnabled(false)
191-
cbIDE.renderer = object : ColoredListCellRenderer<IdeWithStatus>() {
192-
override fun customizeCellRenderer(list: JList<out IdeWithStatus>, value: IdeWithStatus?, index: Int, isSelected: Boolean, cellHasFocus: Boolean) {
193-
background = UIUtil.getListBackground(isSelected, cellHasFocus)
194-
icon = UIUtil.getBalloonErrorIcon()
195-
append(CoderGatewayBundle.message("gateway.connector.view.coder.remoteproject.ssh.error.text"))
196-
}
197-
}
198-
}
199-
}
200-
201189
else -> {
202-
logger.error("Could not resolve any IDE for workspace ${selectedWorkspace.name}. Reason: $e")
190+
logger.error("Failed to retrieve IDEs for workspace ${selectedWorkspace.name}", e)
203191
withContext(Dispatchers.Main) {
204192
setNextButtonEnabled(false)
193+
cbIDEComment.foreground = UIUtil.getErrorForeground()
194+
cbIDEComment.text = e.message ?: "The error did not provide any further details"
205195
cbIDE.renderer = object : ColoredListCellRenderer<IdeWithStatus>() {
206196
override fun customizeCellRenderer(list: JList<out IdeWithStatus>, value: IdeWithStatus?, index: Int, isSelected: Boolean, cellHasFocus: Boolean) {
207197
background = UIUtil.getListBackground(isSelected, cellHasFocus)
208198
icon = UIUtil.getBalloonErrorIcon()
209-
append(CoderGatewayBundle.message("gateway.connector.view.coder.remoteproject.ide.error.text"))
199+
append(CoderGatewayBundle.message("gateway.connector.view.coder.remoteproject.error.text"))
210200
}
211201
}
212202
}
@@ -217,7 +207,7 @@ class CoderLocateRemoteProjectStepView(private val setNextButtonEnabled: (Boolea
217207
}
218208

219209
private fun installRemotePathValidator(executor: HighLevelHostAccessor) {
220-
var disposable = Disposer.newDisposable(ApplicationManager.getApplication(), CoderLocateRemoteProjectStepView.javaClass.name)
210+
val disposable = Disposer.newDisposable(ApplicationManager.getApplication(), CoderLocateRemoteProjectStepView::class.java.name)
221211
ComponentValidator(disposable).installOn(tfProject)
222212

223213
tfProject.document.addDocumentListener(object : DocumentAdapter() {

src/main/resources/messages/CoderGatewayBundle.properties

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ gateway.connector.view.workspaces.token.rejected=This token was rejected.
2929
gateway.connector.view.workspaces.token.injected=This token was pulled from your CLI config.
3030
gateway.connector.view.workspaces.token.none=No existing token found.
3131
gateway.connector.view.coder.remoteproject.loading.text=Retrieving products...
32-
gateway.connector.view.coder.remoteproject.ide.error.text=Could not retrieve any IDE because an error was encountered. Please check the logs for more details!
33-
gateway.connector.view.coder.remoteproject.ssh.error.text=Can't connect to the workspace. Please make sure Coder Agent is running!
32+
gateway.connector.view.coder.remoteproject.error.text=Failed to retrieve IDEs
3433
gateway.connector.view.coder.remoteproject.next.text=Start IDE and connect
3534
gateway.connector.view.coder.remoteproject.choose.text=Choose IDE and project for workspace {0}
3635
gateway.connector.view.coder.remoteproject.ide.download.comment=This IDE will be downloaded from jetbrains.com and installed to the default path on the remote host.

0 commit comments

Comments
 (0)