Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ package software.aws.toolkits.jetbrains.services.amazonq.lsp

import org.eclipse.lsp4j.jsonrpc.services.JsonRequest
import org.eclipse.lsp4j.services.LanguageClient
import software.aws.toolkits.jetbrains.services.amazonq.lsp.model.aws.chat.OpenTabParams
import software.aws.toolkits.jetbrains.services.amazonq.lsp.model.aws.chat.OpenTabResult
import software.aws.toolkits.jetbrains.services.amazonq.lsp.model.aws.credentials.ConnectionMetadata
import java.util.concurrent.CompletableFuture

Expand All @@ -15,4 +17,7 @@ import java.util.concurrent.CompletableFuture
interface AmazonQLanguageClient : LanguageClient {
@JsonRequest("aws/credentials/getConnectionMetadata")
fun getConnectionMetadata(): CompletableFuture<ConnectionMetadata>

@JsonRequest("aws/chat/openTab")
fun openTab(params: OpenTabParams): CompletableFuture<OpenTabResult>
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import software.aws.toolkits.jetbrains.core.credentials.AwsBearerTokenConnection
import software.aws.toolkits.jetbrains.core.credentials.ToolkitConnectionManager
import software.aws.toolkits.jetbrains.core.credentials.pinning.QConnection
import software.aws.toolkits.jetbrains.services.amazonq.lsp.flareChat.ChatCommunicationManager
import software.aws.toolkits.jetbrains.services.amazonq.lsp.model.aws.chat.OpenTabParams
import software.aws.toolkits.jetbrains.services.amazonq.lsp.model.aws.chat.OpenTabResult
import software.aws.toolkits.jetbrains.services.amazonq.lsp.model.aws.credentials.ConnectionMetadata
import software.aws.toolkits.jetbrains.services.amazonq.lsp.model.aws.credentials.SsoProfileData
import software.aws.toolkits.jetbrains.settings.CodeWhispererSettings
Expand Down Expand Up @@ -72,6 +74,11 @@ class AmazonQLanguageClientImpl(private val project: Project) : AmazonQLanguageC
}
}

override fun openTab(params: OpenTabParams): CompletableFuture<OpenTabResult> {
//TODO implement chat history, this is here to unblock chat functionality
return CompletableFuture.completedFuture(OpenTabResult(""))
}

override fun configuration(params: ConfigurationParams): CompletableFuture<List<Any>> {
if (params.items.isEmpty()) {
return CompletableFuture.completedFuture(null)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
// Copyright 2025 Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

package software.aws.toolkits.jetbrains.services.amazonq.lsp.model.aws.chat

data class ChatMessage(
val type: MessageType? = MessageType.ANSWER,
val header: MessageHeader? = null,
val buttons: List<Button>? = null,
val body: String? = null,
val messageId: String? = null,
val canBeVoted: Boolean? = null,
val relatedContent: RelatedContent? = null,
val followUp: FollowUp? = null,
val codeReference: List<ReferenceTrackerInformation>? = null,
val fileList: FileList? = null,
val contextList: FileList? = null,
)

data class MessageHeader(
val type: MessageType? = MessageType.ANSWER,
val buttons: List<Button>? = null,
val body: String? = null,
val messageId: String? = null,
val canBeVoted: Boolean? = null,
val relatedContent: RelatedContent? = null,
val followUp: FollowUp? = null,
val codeReference: List<ReferenceTrackerInformation>? = null,
val fileList: FileList? = null,
val contextList: FileList? = null,
val icon: IconType? = null,
val status: MessageStatus? = null,
)

data class MessageStatus(
val status: Status? = null,
val icon: IconType? = null,
val text: String? = null,
)

data class Button(
val id: String,
val text: String? = null,
val description: String? = null,
val icon: IconType? = null,
val disabled: Boolean? = null,
val keepCardAfterClick: Boolean? = null,
val status: ButtonStatus? = null,
)

data class FileList(
val rootFolderTitle: String? = null,
val filePaths: List<String>? = null,
val deletedFiles: List<String>? = null,
val details: Map<String, FileDetails>? = null,
)

data class FileDetails(
val description: String? = null,
val lineRanges: List<Pair<Int, Int>>? = null,
val changes: Changes? = null,
)

data class Changes(
val added: Int? = null,
val deleted: Int? = null,
val total: Int? = null,
)

enum class IconType {
FILE,
FOLDER,
CODE_BLOCK,
LIST_ADD,
MAGIC,
HELP,
TRASH,
SEARCH,
CALENDAR,
;

val value: String
get() = name.lowercase().replace('_', '-')

companion object {
private val stringToEnum: Map<String, IconType> = entries.associateBy { it.name.lowercase() }

fun fromString(value: String): IconType = stringToEnum[value] ?: throw IllegalArgumentException("Unknown IconType: $value")

Check warning on line 88 in plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/lsp/model/aws/chat/ChatMessage.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unused symbol

Function "fromString" is never used

Check warning

Code scanning / QDJVMC

Unused symbol Warning

Function "fromString" is never used
}
}

enum class Status {
INFO,

Check warning on line 93 in plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/lsp/model/aws/chat/ChatMessage.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unused symbol

Class "INFO" is never used

Check warning

Code scanning / QDJVMC

Unused symbol Warning

Class "INFO" is never used
SUCCESS,

Check warning on line 94 in plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/lsp/model/aws/chat/ChatMessage.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unused symbol

Class "SUCCESS" is never used

Check warning

Code scanning / QDJVMC

Unused symbol Warning

Class "SUCCESS" is never used
WARNING,

Check warning on line 95 in plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/lsp/model/aws/chat/ChatMessage.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unused symbol

Class "WARNING" is never used

Check warning

Code scanning / QDJVMC

Unused symbol Warning

Class "WARNING" is never used
ERROR,

Check warning on line 96 in plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/lsp/model/aws/chat/ChatMessage.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unused symbol

Class "ERROR" is never used

Check warning

Code scanning / QDJVMC

Unused symbol Warning

Class "ERROR" is never used
;

val value: String
get() = name.lowercase()
}

enum class ButtonStatus {
MAIN,

Check warning on line 104 in plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/lsp/model/aws/chat/ChatMessage.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unused symbol

Class "MAIN" is never used

Check warning

Code scanning / QDJVMC

Unused symbol Warning

Class "MAIN" is never used
PRIMARY,

Check warning on line 105 in plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/lsp/model/aws/chat/ChatMessage.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unused symbol

Class "PRIMARY" is never used

Check warning

Code scanning / QDJVMC

Unused symbol Warning

Class "PRIMARY" is never used
CLEAR,

Check warning on line 106 in plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/lsp/model/aws/chat/ChatMessage.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unused symbol

Class "CLEAR" is never used

Check warning

Code scanning / QDJVMC

Unused symbol Warning

Class "CLEAR" is never used
INFO,

Check warning on line 107 in plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/lsp/model/aws/chat/ChatMessage.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unused symbol

Class "INFO" is never used

Check warning

Code scanning / QDJVMC

Unused symbol Warning

Class "INFO" is never used
SUCCESS,

Check warning on line 108 in plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/lsp/model/aws/chat/ChatMessage.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unused symbol

Class "SUCCESS" is never used

Check warning

Code scanning / QDJVMC

Unused symbol Warning

Class "SUCCESS" is never used
WARNING,

Check warning on line 109 in plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/lsp/model/aws/chat/ChatMessage.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unused symbol

Class "WARNING" is never used

Check warning

Code scanning / QDJVMC

Unused symbol Warning

Class "WARNING" is never used
ERROR,

Check warning on line 110 in plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/lsp/model/aws/chat/ChatMessage.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unused symbol

Class "ERROR" is never used

Check warning

Code scanning / QDJVMC

Unused symbol Warning

Class "ERROR" is never used
;

val value: String
get() = name.lowercase()
}

enum class MessageType {
ANSWER,
PROMPT,

Check warning on line 119 in plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/lsp/model/aws/chat/ChatMessage.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unused symbol

Class "PROMPT" is never used

Check warning

Code scanning / QDJVMC

Unused symbol Warning

Class "PROMPT" is never used
SYSTEM_PROMPT,

Check warning on line 120 in plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/lsp/model/aws/chat/ChatMessage.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unused symbol

Class "SYSTEM_PROMPT" is never used

Check warning

Code scanning / QDJVMC

Unused symbol Warning

Class "SYSTEM_PROMPT" is never used
DIRECTIVE,

Check warning on line 121 in plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/lsp/model/aws/chat/ChatMessage.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unused symbol

Class "DIRECTIVE" is never used

Check warning

Code scanning / QDJVMC

Unused symbol Warning

Class "DIRECTIVE" is never used
TOOL,

Check warning on line 122 in plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/lsp/model/aws/chat/ChatMessage.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unused symbol

Class "TOOL" is never used

Check warning

Code scanning / QDJVMC

Unused symbol Warning

Class "TOOL" is never used
;

val value: String
get() = name.lowercase().replace('_', '-')
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@
const val CHAT_TAB_ADD = "aws/chat/tabAdd"
const val CHAT_TAB_CHANGE = "aws/chat/tabChange"
const val CHAT_TAB_REMOVE = "aws/chat/tabRemove"
const val CHAT_OPEN_TAB = "aws/chat/openTab"

Check warning on line 17 in plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/lsp/model/aws/chat/FlareChatCommands.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unused symbol

Property "CHAT_OPEN_TAB" is never used

Check warning

Code scanning / QDJVMC

Unused symbol Warning

Property "CHAT_OPEN_TAB" is never used
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,27 @@ data class TabEventRequest(
data class TabEventParams(
val tabId: String,
)

data class OpenTabResult(
val tabId: String,
)

data class OpenTabParams(
val tabId: String? = null,
val newTabOptions: NewTabOptions? = null,
)

data class NewTabOptions(
val state: TabState? = null,
val data: TabData? = null,
)

data class TabState(
val inProgress: Boolean? = null,
val cancellable: Boolean? = null,
)

data class TabData(
val placeholderText: String? = null,
val messages: List<ChatMessage>,
)
Loading