Skip to content

Commit 82708b7

Browse files
Merge branch 'main' into samgst/emitAuthScopesInUserState
2 parents 1404bb1 + 0b83303 commit 82708b7

File tree

7 files changed

+186
-158
lines changed

7 files changed

+186
-158
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type" : "bugfix",
3+
"description" : "Fixed an issue where Q inline won't appear in JetBrains remote 2024.2+"
4+
}

plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/cwc/controller/chat/telemetry/TelemetryHelper.kt

Lines changed: 109 additions & 116 deletions
Large diffs are not rendered by default.

plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/cwc/messages/CwcMessage.kt

Lines changed: 46 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -24,60 +24,68 @@ sealed interface CwcMessage : AmazonQMessage
2424

2525
// === UI -> App Messages ===
2626
sealed interface IncomingCwcMessage : CwcMessage {
27+
interface TabId {
28+
val tabId: String?
29+
}
30+
31+
interface MessageId {
32+
val messageId: String?
33+
}
34+
2735
data class ClearChat(
28-
@JsonProperty("tabID") val tabId: String,
29-
) : IncomingCwcMessage
36+
@JsonProperty("tabID") override val tabId: String,
37+
) : IncomingCwcMessage, TabId
3038

3139
data class Help(
32-
@JsonProperty("tabID") val tabId: String,
33-
) : IncomingCwcMessage
40+
@JsonProperty("tabID") override val tabId: String,
41+
) : IncomingCwcMessage, TabId
3442

3543
data class ChatPrompt(
3644
val chatMessage: String,
3745
val command: String,
38-
@JsonProperty("tabID") val tabId: String,
46+
@JsonProperty("tabID") override val tabId: String,
3947
val userIntent: String?,
40-
) : IncomingCwcMessage
48+
) : IncomingCwcMessage, TabId
4149

4250
data class TabAdded(
43-
@JsonProperty("tabID") val tabId: String,
51+
@JsonProperty("tabID") override val tabId: String,
4452
val tabType: String,
45-
) : IncomingCwcMessage
53+
) : IncomingCwcMessage, TabId
4654

4755
data class TabRemoved(
48-
@JsonProperty("tabID") val tabId: String,
56+
@JsonProperty("tabID") override val tabId: String,
4957
val tabType: String,
50-
) : IncomingCwcMessage
58+
) : IncomingCwcMessage, TabId
5159

5260
data class TabChanged(
53-
@JsonProperty("tabID") val tabId: String,
61+
@JsonProperty("tabID") override val tabId: String,
5462
@JsonProperty("prevTabID") val prevTabId: String?,
55-
) : IncomingCwcMessage
63+
) : IncomingCwcMessage, TabId
5664

5765
data class FollowupClicked(
5866
val followUp: FollowUp,
59-
@JsonProperty("tabID") val tabId: String,
60-
val messageId: String?,
67+
@JsonProperty("tabID") override val tabId: String,
68+
override val messageId: String?,
6169
val command: String,
6270
val tabType: String,
63-
) : IncomingCwcMessage
71+
) : IncomingCwcMessage, TabId, MessageId
6472

6573
data class CopyCodeToClipboard(
6674
val command: String?,
67-
@JsonProperty("tabID") val tabId: String,
68-
val messageId: String,
75+
@JsonProperty("tabID") override val tabId: String,
76+
override val messageId: String,
6977
val userIntent: UserIntent?,
7078
val code: String,
7179
val insertionTargetType: String?,
7280
val eventId: String?,
7381
val codeBlockIndex: Int?,
7482
val totalCodeBlocks: Int?,
7583
val codeBlockLanguage: String?,
76-
) : IncomingCwcMessage
84+
) : IncomingCwcMessage, TabId, MessageId
7785

7886
data class InsertCodeAtCursorPosition(
79-
@JsonProperty("tabID") val tabId: String,
80-
val messageId: String,
87+
@JsonProperty("tabID") override val tabId: String,
88+
override val messageId: String,
8189
val userIntent: UserIntent?,
8290
val code: String,
8391
val insertionTargetType: String?,
@@ -86,29 +94,29 @@ sealed interface IncomingCwcMessage : CwcMessage {
8694
val codeBlockIndex: Int?,
8795
val totalCodeBlocks: Int?,
8896
val codeBlockLanguage: String?,
89-
) : IncomingCwcMessage
97+
) : IncomingCwcMessage, TabId, MessageId
9098

9199
data class TriggerTabIdReceived(
92100
@JsonProperty("triggerID") val triggerId: String,
93-
@JsonProperty("tabID") val tabId: String,
94-
) : IncomingCwcMessage
101+
@JsonProperty("tabID") override val tabId: String,
102+
) : IncomingCwcMessage, TabId
95103

96104
data class StopResponse(
97-
@JsonProperty("tabID") val tabId: String,
98-
) : IncomingCwcMessage
105+
@JsonProperty("tabID") override val tabId: String,
106+
) : IncomingCwcMessage, TabId
99107

100108
data class ChatItemVoted(
101-
@JsonProperty("tabID") val tabId: String,
102-
val messageId: String,
109+
@JsonProperty("tabID") override val tabId: String,
110+
override val messageId: String,
103111
val vote: String, // upvote / downvote
104-
) : IncomingCwcMessage
112+
) : IncomingCwcMessage, TabId, MessageId
105113

106114
data class ChatItemFeedback(
107-
@JsonProperty("tabID") val tabId: String,
115+
@JsonProperty("tabID") override val tabId: String,
108116
val selectedOption: String,
109117
val comment: String?,
110-
val messageId: String,
111-
) : IncomingCwcMessage
118+
override val messageId: String,
119+
) : IncomingCwcMessage, TabId, MessageId
112120

113121
data class UIFocus(
114122
val command: String,
@@ -119,19 +127,19 @@ sealed interface IncomingCwcMessage : CwcMessage {
119127

120128
data class ClickedLink(
121129
@JsonProperty("command") val type: LinkType,
122-
@JsonProperty("tabID") val tabId: String,
123-
val messageId: String?,
130+
@JsonProperty("tabID") override val tabId: String,
131+
override val messageId: String?,
124132
val link: String,
125-
) : IncomingCwcMessage
133+
) : IncomingCwcMessage, TabId, MessageId
126134

127135
data class AuthFollowUpWasClicked(
128-
@JsonProperty("tabID") val tabId: String,
136+
@JsonProperty("tabID") override val tabId: String,
129137
val authType: AuthFollowUpType,
130-
) : IncomingCwcMessage
138+
) : IncomingCwcMessage, TabId
131139

132140
data class OpenSettings(
133-
@JsonProperty("tabID") val tabId: String? = null,
134-
) : IncomingCwcMessage
141+
@JsonProperty("tabID") override val tabId: String? = null,
142+
) : IncomingCwcMessage, TabId
135143
}
136144

137145
enum class FocusType {

plugins/amazonq/chat/jetbrains-community/tst/software/aws/toolkits/jetbrains/services/amazonq/TelemetryHelperTest.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import org.mockito.kotlin.doReturn
2222
import org.mockito.kotlin.eq
2323
import org.mockito.kotlin.mock
2424
import org.mockito.kotlin.stub
25+
import org.mockito.kotlin.times
2526
import org.mockito.kotlin.verify
2627
import software.amazon.awssdk.awscore.DefaultAwsResponseMetadata
2728
import software.amazon.awssdk.awscore.util.AwsHeader.AWS_REQUEST_ID
@@ -608,7 +609,7 @@ class TelemetryHelperTest {
608609

609610
// Toolkit telemetry
610611
argumentCaptor<MetricEvent> {
611-
verify(mockBatcher).enqueue(capture())
612+
verify(mockBatcher, times(2)).enqueue(capture())
612613
val event = firstValue.data.find { it.name == "feedback_result" }
613614
assertNotNull(event)
614615
assertThat(event).matches { it.metadata["result"] == "Succeeded" }

plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/service/CodeWhispererService.kt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ import software.aws.toolkits.core.utils.debug
4646
import software.aws.toolkits.core.utils.getLogger
4747
import software.aws.toolkits.core.utils.info
4848
import software.aws.toolkits.core.utils.warn
49+
import software.aws.toolkits.jetbrains.core.coroutines.EDT
4950
import software.aws.toolkits.jetbrains.core.coroutines.disposableCoroutineScope
5051
import software.aws.toolkits.jetbrains.core.coroutines.getCoroutineBgContext
5152
import software.aws.toolkits.jetbrains.core.coroutines.projectCoroutineScope
@@ -206,9 +207,12 @@ class CodeWhispererService(private val cs: CoroutineScope) : Disposable {
206207
invokeCodeWhispererInBackground(requestContext)
207208
}
208209

209-
internal fun invokeCodeWhispererInBackground(requestContext: RequestContext): Job {
210-
val popup = CodeWhispererPopupManager.getInstance().initPopup()
211-
Disposer.register(popup) { CodeWhispererInvocationStatus.getInstance().finishInvocation() }
210+
internal suspend fun invokeCodeWhispererInBackground(requestContext: RequestContext): Job {
211+
val popup = withContext(EDT) {
212+
CodeWhispererPopupManager.getInstance().initPopup().also {
213+
Disposer.register(it) { CodeWhispererInvocationStatus.getInstance().finishInvocation() }
214+
}
215+
}
212216

213217
val workerContexts = mutableListOf<WorkerContext>()
214218
// When popup is disposed we will cancel this coroutine. The only places popup can get disposed should be
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
package software.aws.toolkits.jetbrains.services.telemetry
5+
6+
import com.intellij.ide.util.RunOnceUtil
7+
import com.intellij.openapi.project.Project
8+
import com.intellij.openapi.startup.ProjectActivity
9+
import software.aws.toolkits.telemetry.SessionTelemetry
10+
11+
internal class AwsToolkitStartupMetrics : ProjectActivity {
12+
override suspend fun execute(project: Project) {
13+
RunOnceUtil.runOnceForApp(this::class.qualifiedName.toString()) {
14+
SessionTelemetry.start(project)
15+
}
16+
}
17+
}

plugins/toolkit/jetbrains-core/resources/META-INF/plugin.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@
196196
<statusBarWidgetFactory id="CawsSpaceProjectInfo" implementation="software.aws.toolkits.jetbrains.services.caws.CawsStatusBarInstaller"/>
197197

198198
<postStartupActivity implementation="software.aws.toolkits.jetbrains.core.executables.ExecutableLoader"/>
199+
<postStartupActivity implementation="software.aws.toolkits.jetbrains.services.telemetry.AwsToolkitStartupMetrics"/>
199200
<postStartupActivity implementation="software.aws.toolkits.jetbrains.core.startup.QMigrationActivity"/>
200201
<postStartupActivity implementation="software.aws.toolkits.jetbrains.core.startup.ToolWindowStartupActivity"/>
201202

0 commit comments

Comments
 (0)