-
Couldn't load subscription status.
- Fork 10
feature/Notifications #390
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
base: main
Are you sure you want to change the base?
Changes from 4 commits
0730975
ff4e3bf
005b6ee
a747467
85a3f4b
d89007e
6c5a9cd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,8 +18,11 @@ | |
| import org.eclipse.lsp4j.ProgressParams; | ||
| import org.eclipse.lsp4j.ShowDocumentParams; | ||
| import org.eclipse.lsp4j.ShowDocumentResult; | ||
| import org.eclipse.swt.widgets.Display; | ||
| import org.eclipse.ui.PartInitException; | ||
| import org.eclipse.ui.PlatformUI; | ||
| import org.eclipse.jface.dialogs.MessageDialog; | ||
| import org.eclipse.lsp4j.MessageType; | ||
|
|
||
| import software.amazon.awssdk.services.toolkittelemetry.model.Sentiment; | ||
| import software.aws.toolkits.eclipse.amazonq.chat.ChatCommunicationManager; | ||
|
|
@@ -28,6 +31,7 @@ | |
| import software.aws.toolkits.eclipse.amazonq.lsp.auth.model.SsoTokenChangedKind; | ||
| import software.aws.toolkits.eclipse.amazonq.lsp.auth.model.SsoTokenChangedParams; | ||
| import software.aws.toolkits.eclipse.amazonq.lsp.model.ConnectionMetadata; | ||
| import software.aws.toolkits.eclipse.amazonq.lsp.model.NotificationParams; | ||
| import software.aws.toolkits.eclipse.amazonq.lsp.model.SsoProfileData; | ||
| import software.aws.toolkits.eclipse.amazonq.lsp.model.TelemetryEvent; | ||
| import software.aws.toolkits.eclipse.amazonq.plugin.Activator; | ||
|
|
@@ -37,6 +41,10 @@ | |
| import software.aws.toolkits.eclipse.amazonq.util.ObjectMapperFactory; | ||
| import software.aws.toolkits.eclipse.amazonq.views.model.Customization; | ||
| import software.aws.toolkits.eclipse.amazonq.util.ThreadingUtils; | ||
| import org.eclipse.mylyn.commons.ui.dialogs.AbstractNotificationPopup; | ||
| import software.aws.toolkits.eclipse.amazonq.util.PersistentToolkitNotification; | ||
| import software.aws.toolkits.eclipse.amazonq.util.ToolkitNotification; | ||
|
|
||
|
|
||
| @SuppressWarnings("restriction") | ||
| public class AmazonQLspClientImpl extends LanguageClientImpl implements AmazonQLspClient { | ||
|
|
@@ -170,4 +178,92 @@ public final void ssoTokenChanged(final SsoTokenChangedParams params) { | |
| Activator.getLogger().error("Error processing " + kind + " ssoTokenChanged notification", ex); | ||
| } | ||
| } | ||
| public enum NotificationSeverity { | ||
| LOW, MEDIUM, HIGH | ||
| } | ||
|
|
||
| /** | ||
| * Shows a notification to the user with the specified content and severity. | ||
| * This method is designed to be overridden by subclasses that need to customize | ||
| * the notification behavior. | ||
| * | ||
| * @param params The notification parameters containing the message type and content | ||
| */ | ||
| @Override | ||
| public final void showNotification(final NotificationParams params) { | ||
| Activator.getLogger().info("Received notification JSON: " + params.type().toString()); | ||
aseemxs marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| Display.getDefault().asyncExec(() -> { | ||
| String title = params.content().title() != null | ||
| ? params.content().title() | ||
| : "AWS Notification"; | ||
aseemxs marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| String message = params.content().text(); | ||
| NotificationSeverity severity = determineNotificationSeverity(params.type()); | ||
| handleNotification(severity, title, message); | ||
| }); | ||
| } | ||
aseemxs marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| private NotificationSeverity determineNotificationSeverity(final MessageType type) { | ||
|
||
| if (type == MessageType.Error) { | ||
| return NotificationSeverity.HIGH; | ||
| } | ||
| if (type == MessageType.Warning) { | ||
| return NotificationSeverity.MEDIUM; | ||
| } | ||
| if (type == MessageType.Info) { | ||
| return NotificationSeverity.LOW; | ||
| } | ||
| return null; | ||
| } | ||
aseemxs marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| private void handleNotification(NotificationSeverity severity, final String title, final String message) { | ||
| if (severity == null) { | ||
| severity = NotificationSeverity.LOW; // Default to LOW if severity is null | ||
| Activator.getLogger().info("Null severity detected, defaulting to LOW"); | ||
| } | ||
|
|
||
| switch (severity) { | ||
| case LOW: | ||
| AbstractNotificationPopup transientNotification = new ToolkitNotification( | ||
| Display.getCurrent(), title, message | ||
| ); | ||
| transientNotification.open(); | ||
| break; | ||
|
|
||
| case MEDIUM: | ||
| AbstractNotificationPopup persistentNotification = new PersistentToolkitNotification( | ||
| Display.getCurrent(), | ||
| title, | ||
| message, | ||
| checked -> { | ||
| if (checked) { | ||
| Activator.getPluginStore().put("notificationSkipFlag", "true"); | ||
|
||
| } else { | ||
| Activator.getPluginStore().remove("notificationSkipFlag"); | ||
| } | ||
| } | ||
| ); | ||
| persistentNotification.setDelayClose(60000); | ||
aseemxs marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| persistentNotification.open(); | ||
| break; | ||
|
|
||
| case HIGH: | ||
| Display.getDefault().syncExec(() -> { | ||
| MessageDialog dialog = new MessageDialog( | ||
| Display.getCurrent().getActiveShell(), | ||
| title, | ||
| null, | ||
| message, | ||
| MessageDialog.WARNING, | ||
| new String[] {"Acknowledge"}, | ||
| 0 | ||
| ); | ||
| dialog.open(); | ||
| }); | ||
| break; | ||
|
|
||
| default: | ||
| Activator.getLogger().warn("Unexpected severity level encountered"); | ||
| break; | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,7 +36,10 @@ public QLspConnectionProvider() throws IOException { | |
| var serverCommand = Paths.get(lspInstallResult.getServerDirectory(), lspInstallResult.getServerCommand()); | ||
| List<String> commands = new ArrayList<>(); | ||
| commands.add(serverCommand.toString()); | ||
| commands.add(lspInstallResult.getServerCommandArgs()); | ||
| //commands.add(lspInstallResult.getServerCommandArgs()); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Be sure to add a comment here about you're doing this for development on the feature branch and this should not be checked into main. We don't want this making it into prod. |
||
| commands.add("--inspect=6012"); | ||
| commands.add("/Users/aseemxs/Language-servers/language-servers/app/aws-lsp-notification-runtimes/out/standalone.js"); | ||
| commands.add("--nolazy"); | ||
| commands.add("--stdio"); | ||
| commands.add("--set-credentials-encryption-key"); | ||
| setCommands(commands); | ||
|
|
@@ -55,6 +58,7 @@ protected final void addEnvironmentVariables(final Map<String, String> env) { | |
| } | ||
| env.put("ENABLE_INLINE_COMPLETION", "true"); | ||
| env.put("ENABLE_TOKEN_PROVIDER", "true"); | ||
| env.put("AWS_Q_ENDPOINT_URL", "https://rts.gamma-us-east-1.codewhisperer.ai.aws.dev/"); | ||
| } | ||
|
|
||
| @Override | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| package software.aws.toolkits.eclipse.amazonq.lsp.model; | ||
aseemxs marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| public record EventIdentifier(String id) { } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| package software.aws.toolkits.eclipse.amazonq.lsp.model; | ||
|
|
||
| public record NotificationAction(String text, String type) { } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Notification actions may include a URI property (wait for the Flare protocol updates). |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| package software.aws.toolkits.eclipse.amazonq.lsp.model; | ||
|
|
||
|
|
||
| public record NotificationContent(String text, String title) { } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| package software.aws.toolkits.eclipse.amazonq.lsp.model; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| import org.eclipse.lsp4j.MessageType; | ||
|
|
||
| public record NotificationParams( | ||
| MessageType type, | ||
| NotificationContent content, | ||
| String id, | ||
| List<NotificationAction> actions | ||
| ) { } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing to worry about now, but I may try to convert this to showNotifications (if Flare will agree) and send an array of Notification instead of just one.