You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
val hasPreviousStatus = portsStatus.containsKey(port.localPort)
239
+
240
+
if (!hasPreviousStatus) {
241
+
portsStatus[port.localPort] = port
242
+
}
243
+
244
+
val wasServed = portsStatus[port.localPort]?.served!!
245
+
val wasExposed = portsStatus[port.localPort]?.hasExposed()!!
246
+
val wasServedExposed = wasServed && wasExposed
247
+
val isServedExposed = port.served && port.hasExposed()
248
+
249
+
// If the initial update received shows that the port is served and exposed, then notify
250
+
val isFirstUpdate =!hasPreviousStatus && wasServedExposed && isServedExposed
251
+
252
+
// If the port changes its status to served and exposed, notify the user
253
+
val shouldSendNotification = isFirstUpdate ||!wasServedExposed && isServedExposed
254
+
255
+
portsStatus[port.localPort] = port
256
+
257
+
if (shouldSendNotification) {
258
+
if (port.exposed.onExposed.number ==OnPortExposedAction.ignore_VALUE) {
259
+
continue
260
+
}
261
+
262
+
if (port.exposed.onExposed.number ==OnPortExposedAction.open_browser_VALUE) {
263
+
BrowserUtil.browse(port.exposed.url)
264
+
continue
265
+
}
266
+
267
+
if (port.exposed.onExposed.number ==OnPortExposedAction.open_preview_VALUE) {
268
+
BrowserUtil.browse(port.exposed.url)
269
+
continue
270
+
}
271
+
272
+
val message ="A service is available on port ${port.localPort}"
273
+
val notification = notificationGroup.createNotification(message, NotificationType.INFORMATION)
274
+
// TODO(andreafalzetti): add analytics event similar to https://github.com/gitpod-io/openvscode-server/blob/7c912399c70799e4e4452a63cf3c0f7cc8f5832c/extensions/gitpod-web/src/extension.ts#L582
275
+
val lambda = { BrowserUtil.browse(port.exposed.url) }
276
+
val action =NotificationAction.createSimpleExpiring("Open Browser", lambda)
277
+
notification.addAction(action)
278
+
notification.notify(null)
279
+
}
280
+
}
281
+
}
282
+
283
+
overridefunonError(t:Throwable) {
284
+
f.completeExceptionally(t)
285
+
}
286
+
287
+
overridefunonCompleted() {
288
+
f.complete(null)
289
+
}
290
+
})
291
+
f.await()
292
+
} catch (t:Throwable) {
293
+
if (t isCancellationException) {
294
+
throw t
295
+
}
296
+
thisLogger().error("gitpod: failed to stream ports status: ", t)
297
+
}
298
+
delay(1000L)
299
+
}
300
+
}
301
+
init {
302
+
lifetime.onTerminationOrNow {
303
+
portsObserveJob.cancel()
304
+
}
305
+
}
306
+
202
307
val pendingInfo =CompletableFuture<WorkspaceInfoResponse>()
0 commit comments