Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JetBrains] Show notification when port becomes available 🔔 #10107

Merged
merged 1 commit into from
May 30, 2022

Conversation

andreafalzetti
Copy link
Contributor

@andreafalzetti andreafalzetti commented May 18, 2022

Description

This PR introduces ports notification in JetBrains IDEs. 🔔

Context

Currently, when ports become available (e.g. a web server is ready to handle requests and the port is exposed to the internet), in VS Code you get a toast notification within the IDE, to inform you. Additionally, you get an action within the notification to open the browser or the preview (specifically for VS Code, as it supports preview windows). While, for JetBrains IDEs, we didn't yet show any notification when ports became available.

Example notification in VS Code

Screenshot 2022-05-25 at 15 41 49

Approach

The approach used is to listen to supervisor ports status updates (see status.proto).

Gitpod's JetBrains backend-plugin already integrates with supervisor generic notification, so this feature leverages the existing integration and re-uses the same notification group.

After this change, the notifications will appear in the native notifications panel. See example below:

Screenshot 2022-05-25 at 16 35 29

Additionally, we offer to "Make Public" a port when its visibility is private.

Screenshot 2022-05-26 at 22 00 33

Notes

  • To avoid noise and undesired notifications, certain ports are explicitly ignored. Most of those are ports used internally by the IDE itself.

Related Issue(s)

Fixes #9908

How to test

  1. Start a workspace using the following link: https://afalz-9908c5dfc24116.staging.gitpod-dev.com/#https://github.com/andreafalzetti/gitpod-experiments-b
  2. Choose a JetBrains product as your preferred editor
  3. Notice a prompt to open the browser on port 8080
  4. Notice a notification for port 8081 being available
  5. Notice a notification for port 8083 being available (set to be notify in .gitpod.yml)
  6. Port 8082 should not trigger a notification (set to be ignored in .gitpod.yml)
  7. Try exposing a new port, make it public, verify that it's accessible

Release Notes

[JetBrains] Show notification when port becomes available

Documentation


  • /werft with-vm
  • /werft without-vm
  • /werft with-clean-slate-deployment

@andreafalzetti andreafalzetti force-pushed the afalz/9908-jb-port-notifications branch 5 times, most recently from 57e3dee to d790f82 Compare May 25, 2022 15:00
@andreafalzetti andreafalzetti force-pushed the afalz/9908-jb-port-notifications branch from d790f82 to 66bafa0 Compare May 25, 2022 20:27
@andreafalzetti andreafalzetti changed the title [WIP] [JetBrains] Observe ports status and send notification [WIP] [JetBrains] Show notification when port becomes available 🔔 May 25, 2022
@andreafalzetti andreafalzetti force-pushed the afalz/9908-jb-port-notifications branch from 66bafa0 to cf6cf73 Compare May 25, 2022 21:45
@andreafalzetti andreafalzetti force-pushed the afalz/9908-jb-port-notifications branch from 5ab5547 to 7a10c72 Compare May 26, 2022 14:10
@andreafalzetti andreafalzetti marked this pull request as draft May 26, 2022 17:15
@andreafalzetti andreafalzetti force-pushed the afalz/9908-jb-port-notifications branch 3 times, most recently from 8426b15 to 2221755 Compare May 27, 2022 02:31
p.url = port.exposed.url

try {
manager.client.server.openPort(workspaceId, p).await()
Copy link
Contributor Author

@andreafalzetti andreafalzetti May 27, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

at the moment, pressing the button doesn't update the UI (in VS Code in the ports view you can see the text "private" change into "public"), so it looks a bit unfinished. We could consider adding an extra notification like:

val message = "The port ${port.localPort} is now public"
val notification = manager.notificationGroup.createNotification(message, NotificationType.INFORMATION)
ClientId.withClientId(session.clientId) {
   val project = RestService.getLastFocusedOrOpenedProject()
   notification.notify(project)
}

Thoughts?

cc @akosyakov @loujaybee

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Too many notification is also not nice. Is it possible to update an action? Maybe just make it expirable?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it was a good idea, unfortunately if I do "Make Public" createSimpleExpiring - when I click it, it expires all actions including "Open Browser" :(

@andreafalzetti andreafalzetti marked this pull request as ready for review May 27, 2022 03:00
@akosyakov
Copy link
Member

akosyakov commented May 27, 2022

@andreafalzetti I see these ports too:
Screenshot 2022-05-27 at 09 05 05

@akosyakov
Copy link
Member

akosyakov commented May 27, 2022

If I close a client and open again, I don't see notifications it is something with state management. But it is rather minor.

Copy link
Member

@akosyakov akosyakov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

/hold
because we need to filter out JB built-in server and CWM ports

@akosyakov
Copy link
Member

@andreafalzetti 5990 is a default port for SSH connection from JB GW. You can hardcore it as to ignore.

I'm not sure why built-in server port is not ignored. It seems you are waiting properly for it.

@andreafalzetti
Copy link
Contributor Author

andreafalzetti commented May 27, 2022

@andreafalzetti 5990 is a default port for SSH connection from JB GW. You can hardcore it as to ignore.

I'm not sure why built-in server port is not ignored. It seems you are waiting properly for it.

I think 6942 is also IntelliJ as I mentioned previously. There is mention of it here (not 100% sure it's the same port we are talking about tho)

Also, the backend port is 63343. It's the port that I get from BuiltInServerManager.getInstance().waitForStart().port. And I never got notification about that one.

@andreafalzetti andreafalzetti force-pushed the afalz/9908-jb-port-notifications branch from 2221755 to 1e84823 Compare May 27, 2022 18:36
@akosyakov
Copy link
Member

akosyakov commented May 28, 2022

I think 6942 is also IntelliJ as I mentioned previously. There is mention of it here (not 100% sure it's the same port we are talking about tho)

then you should also add something like to ignore it

const serverPort = StartupUtil.getServerFuture().await().port

@loujaybee loujaybee requested a review from a team May 30, 2022 09:30
@andreafalzetti andreafalzetti force-pushed the afalz/9908-jb-port-notifications branch 2 times, most recently from db680a3 to 96bb30d Compare May 30, 2022 19:35
@andreafalzetti
Copy link
Contributor Author

andreafalzetti commented May 30, 2022

I think 6942 is also IntelliJ as I mentioned previously. There is mention of it here (not 100% sure it's the same port we are talking about tho)

then you should also add something like to ignore it

const serverPort = StartupUtil.getServerFuture().await().port

Added 👍

@andreafalzetti andreafalzetti force-pushed the afalz/9908-jb-port-notifications branch from 96bb30d to 406ebf8 Compare May 30, 2022 20:32
@andreafalzetti
Copy link
Contributor Author

/unhold

@roboquat roboquat merged commit 8f5f7b6 into main May 30, 2022
@roboquat roboquat deleted the afalz/9908-jb-port-notifications branch May 30, 2022 21:07
@roboquat roboquat added deployed: IDE IDE change is running in production deployed Change is completely running in production labels May 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deployed: IDE IDE change is running in production deployed Change is completely running in production release-note size/L team: IDE
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Handle port notifications in JetBrains
4 participants