Skip to content

Commit

Permalink
Fall back to default chat options if LSP is unavailable
Browse files Browse the repository at this point in the history
  • Loading branch information
breedloj committed Jan 15, 2025
1 parent ead29a6 commit 44ff3d5
Showing 1 changed file with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,30 @@

package software.aws.toolkits.eclipse.amazonq.lsp;

import java.util.Arrays;
import java.util.Collections;

import software.aws.toolkits.eclipse.amazonq.lsp.model.AwsServerCapabilities;
import software.aws.toolkits.eclipse.amazonq.lsp.model.ChatOptions;
import software.aws.toolkits.eclipse.amazonq.lsp.model.Command;
import software.aws.toolkits.eclipse.amazonq.lsp.model.QuickActions;
import software.aws.toolkits.eclipse.amazonq.lsp.model.QuickActionsCommandGroup;

public final class AwsServerCapabiltiesProvider {
private static AwsServerCapabiltiesProvider instance;
private AwsServerCapabilities serverCapabilties;
private static final ChatOptions DEFAULT_CHAT_OPTIONS = new ChatOptions(
new QuickActions(
Collections.singletonList(
new QuickActionsCommandGroup(
Arrays.asList(
new Command("/help", "Learn more about Amazon Q"),
new Command("/clear", "Clear this session")
)
)
)
)
);

public static synchronized AwsServerCapabiltiesProvider getInstance() {
if (instance == null) {
Expand All @@ -24,6 +42,6 @@ public ChatOptions getChatOptions() {
if (serverCapabilties != null) {
return serverCapabilties.chatOptions();
}
return null;
return DEFAULT_CHAT_OPTIONS;
}
}

0 comments on commit 44ff3d5

Please sign in to comment.