@@ -23,6 +23,7 @@ import com.intellij.openapi.util.Disposer
23
23
import com.intellij.openapi.wm.impl.welcomeScreen.WelcomeScreenUIManager
24
24
import com.intellij.remote.AuthType
25
25
import com.intellij.remote.RemoteCredentialsHolder
26
+ import com.intellij.ssh.SshException
26
27
import com.intellij.ui.AnimatedIcon
27
28
import com.intellij.ui.ColoredListCellRenderer
28
29
import com.intellij.ui.DocumentAdapter
@@ -49,14 +50,17 @@ import kotlinx.coroutines.CancellationException
49
50
import kotlinx.coroutines.CoroutineScope
50
51
import kotlinx.coroutines.Dispatchers
51
52
import kotlinx.coroutines.Job
53
+ import kotlinx.coroutines.TimeoutCancellationException
52
54
import kotlinx.coroutines.async
53
55
import kotlinx.coroutines.cancel
54
56
import kotlinx.coroutines.cancelAndJoin
55
57
import kotlinx.coroutines.launch
56
58
import kotlinx.coroutines.runBlocking
59
+ import kotlinx.coroutines.time.withTimeout
57
60
import kotlinx.coroutines.withContext
58
61
import java.awt.Component
59
62
import java.awt.FlowLayout
63
+ import java.time.Duration
60
64
import java.util.Locale
61
65
import javax.swing.ComboBoxModel
62
66
import javax.swing.DefaultComboBoxModel
@@ -134,7 +138,7 @@ class CoderLocateRemoteProjectStepView(private val disableNextAction: () -> Unit
134
138
135
139
ideResolvingJob = cs.launch {
136
140
try {
137
- val executor = withContext( Dispatchers . IO ) { createRemoteExecutor() }
141
+ val executor = withTimeout( Duration .ofSeconds( 30 ) ) { createRemoteExecutor() }
138
142
retrieveIDES(executor, selectedWorkspace)
139
143
if (ComponentValidator .getInstance(tfProject).isEmpty) {
140
144
installRemotePathValidator(executor)
@@ -143,6 +147,21 @@ class CoderLocateRemoteProjectStepView(private val disableNextAction: () -> Unit
143
147
when (e) {
144
148
is InterruptedException -> Unit
145
149
is CancellationException -> Unit
150
+ is TimeoutCancellationException ,
151
+ is SshException -> {
152
+ logger.error(" Can't connect to workspace ${selectedWorkspace.name} . Reason: $e " )
153
+ withContext(Dispatchers .Main ) {
154
+ disableNextAction()
155
+ cbIDE.renderer = object : ColoredListCellRenderer <IdeWithStatus >() {
156
+ override fun customizeCellRenderer (list : JList <out IdeWithStatus >, value : IdeWithStatus ? , index : Int , isSelected : Boolean , cellHasFocus : Boolean ) {
157
+ background = UIUtil .getListBackground(isSelected, cellHasFocus)
158
+ icon = UIUtil .getBalloonErrorIcon()
159
+ append(" Can't connect to the workspace. Please make sure Coder Agent is running!" )
160
+ }
161
+ }
162
+ }
163
+ }
164
+
146
165
else -> {
147
166
logger.error(" Could not resolve any IDE for workspace ${selectedWorkspace.name} . Reason: $e " )
148
167
withContext(Dispatchers .Main ) {
0 commit comments