Skip to content

Commit 1bec3c3

Browse files
authored
Amazon Q: multiple issues fixes (aws#5306)
* Amazon Q: multiple issues fixes 1. Updated wording of data option settings to say " Amazon Q Developer Pro Tier instead of Business Tier" 2. Fixed an issue where SendTelemetryEvent call would fail due to undefined ProgrammingLanguage field 3. Fixed a chat hang issue from an infinite loop when trying to truncate chat context below limit. Updated wording of data optin settings 4. Make auto trigger by default true even if enableCodeSuggestion is not called * Amazon Q: multiple issues fixes 1. Updated wording of data option settings to say " Amazon Q Developer Pro Tier instead of Business Tier" 2. Fixed an issue where SendTelemetryEvent call would fail due to undefined ProgrammingLanguage field 3. Fixed a chat hang issue from an infinite loop when trying to truncate chat context below limit. Updated wording of data optin settings 4. Make auto trigger by default true even if enableCodeSuggestion is not called * test fix
1 parent cb2b396 commit 1bec3c3

File tree

6 files changed

+22
-21
lines changed

6 files changed

+22
-21
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "Bug Fix",
3+
"description": "Amazon Q: Corrected a miswording in the Amazon Q: Share Content With AWS setting."
4+
}

packages/core/package.nls.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
"AWS.configuration.description.awssam.debug.snippets.api.label.cn": "Amazon SAM: API Gateway lambda invoke",
7272
"AWS.configuration.description.awssam.debug.snippets.api.description.cn": "A new configuration for invoking an Amazon Lambda in a CloudFormation template, simulating API Gateway",
7373
"AWS.configuration.description.amazonq": "Amazon Q creates a code reference when you insert a code suggestion from Amazon Q that is similar to training data. When unchecked, Amazon Q will not show code suggestions that have code references. If you authenticate through IAM Identity Center, this setting is controlled by your Amazon Q administrator. [Learn More](https://docs.aws.amazon.com/amazonq/latest/qdeveloper-ug/code-reference.html)",
74-
"AWS.configuration.description.amazonq.shareContentWithAWS": "When checked, your content processed by Amazon Q may be used for service improvement (except for content processed by the Amazon Q Enterprise service tier). Unchecking this box will cause AWS to delete any of your content used for that purpose. The information used to provide the Amazon Q service to you will not be affected. See the [Service Terms](https://aws.amazon.com/service-terms) for more detail.",
74+
"AWS.configuration.description.amazonq.shareContentWithAWS": "When checked, your content processed by Amazon Q may be used for service improvement (except for content processed for users with the Amazon Q Developer Pro Tier). Unchecking this box will cause AWS to delete any of your content used for that purpose. The information used to provide the Amazon Q service to you will not be affected. See the [Service Terms](https://aws.amazon.com/service-terms) for more details.",
7575
"AWS.configuration.description.amazonq.importRecommendation": "Amazon Q will add import statements with inline code suggestions when necessary.",
7676
"AWS.configuration.description.amazonq.workspaceIndex": "This feature is in BETA. When you add @workspace to your question in Amazon Q chat, Amazon Q will index your open workspace files locally to use as context for its response. Extra CPU usage is expected while indexing a workspace. This will not impact Amazon Q features or your IDE, but you may manage CPU usage by setting the number of local threads in 'Local Workspace Index Threads'.",
7777
"AWS.configuration.description.amazonq.workspaceIndexWorkerThreads": "Number of worker threads of Amazon Q local index process. '0' will use the system default worker threads for balance performance. You may increase this number to more quickly index your workspace, but only up to your hardware's number of CPU cores. Please restart VS Code or reload the VS Code window after changing worker threads.",

packages/core/src/codewhisperer/models/model.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ export class CodeSuggestionsState {
8888
return (this.#instance ??= new this())
8989
}
9090

91-
protected constructor(context: vscode.Memento = globals.context.globalState, fallback: boolean = false) {
91+
protected constructor(context: vscode.Memento = globals.context.globalState, fallback: boolean = true) {
9292
this.#context = context
9393
this.#fallback = fallback
9494
}

packages/core/src/codewhispererChat/controllers/chat/telemetryHelper.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,9 @@ export class CWCTelemetryHelper {
359359
}
360360

361361
telemetry.amazonq_addMessage.emit(event)
362+
const language = this.isProgrammingLanguageSupported(triggerPayload.fileLanguage)
363+
? { languageName: triggerPayload.fileLanguage as string }
364+
: undefined
362365
codeWhispererClient
363366
.sendTelemetryEvent({
364367
telemetryEvent: {
@@ -367,9 +370,7 @@ export class CWCTelemetryHelper {
367370
messageId: event.cwsprChatMessageId,
368371
userIntent: triggerPayload.userIntent,
369372
hasCodeSnippet: event.cwsprChatHasCodeSnippet,
370-
programmingLanguage: this.isProgrammingLanguageSupported(triggerPayload.fileLanguage)
371-
? { languageName: triggerPayload.fileLanguage as string }
372-
: undefined,
373+
...(language !== undefined ? { programmingLanguage: language } : {}),
373374
activeEditorTotalCharacters: event.cwsprChatActiveEditorTotalCharacters,
374375
timeToFirstChunkMilliseconds: event.cwsprChatTimeToFirstChunk,
375376
timeBetweenChunks: this.getResponseStreamTimeBetweenChunks(message.tabID),

packages/core/src/codewhispererChat/editor/context/focusArea/focusAreaExtractor.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ export class FocusAreaContextExtractor {
210210
range.end.line,
211211
charLimit - selectionSizeWithoutLastLine - 1
212212
)
213+
return range
213214
}
214215
}
215216
}

packages/core/src/test/codewhisperer/commands/basicCommands.test.ts

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -114,15 +114,13 @@ describe('CodeWhisperer-basicCommands', function () {
114114
codeSuggestionsState = new TestCodeSuggestionsState()
115115
})
116116

117-
it('has suggestions disabled by default', async function () {
117+
it('has suggestions enabled by default', async function () {
118118
targetCommand = testCommand(toggleCodeSuggestions, codeSuggestionsState)
119-
assert.strictEqual(codeSuggestionsState.isSuggestionsEnabled(), false)
119+
assert.strictEqual(codeSuggestionsState.isSuggestionsEnabled(), true)
120120
})
121121

122122
it('toggles states as expected', async function () {
123123
targetCommand = testCommand(toggleCodeSuggestions, codeSuggestionsState)
124-
assert.strictEqual(codeSuggestionsState.isSuggestionsEnabled(), false)
125-
await targetCommand.execute(placeholder, cwQuickPickSource)
126124
assert.strictEqual(codeSuggestionsState.isSuggestionsEnabled(), true)
127125
await targetCommand.execute(placeholder, cwQuickPickSource)
128126
assert.strictEqual(codeSuggestionsState.isSuggestionsEnabled(), false)
@@ -131,10 +129,7 @@ describe('CodeWhisperer-basicCommands', function () {
131129
})
132130

133131
it('setSuggestionsEnabled() works as expected', async function () {
134-
// initially false
135-
assert.strictEqual(codeSuggestionsState.isSuggestionsEnabled(), false)
136-
137-
await codeSuggestionsState.setSuggestionsEnabled(true)
132+
// initially true
138133
assert.strictEqual(codeSuggestionsState.isSuggestionsEnabled(), true)
139134

140135
// set new state to current state
@@ -160,28 +155,28 @@ describe('CodeWhisperer-basicCommands', function () {
160155
assert.strictEqual(eventListener.callCount, 1)
161156
})
162157

163-
it('emits aws_modifySetting event on user toggling autoSuggestion - deactivate', async function () {
164-
codeSuggestionsState = new TestCodeSuggestionsState(true)
165-
assert.strictEqual(codeSuggestionsState.isSuggestionsEnabled(), true)
158+
it('emits aws_modifySetting event on user toggling autoSuggestion - activate', async function () {
159+
codeSuggestionsState = new TestCodeSuggestionsState(false)
160+
assert.strictEqual(codeSuggestionsState.isSuggestionsEnabled(), false)
166161

167162
targetCommand = testCommand(toggleCodeSuggestions, codeSuggestionsState)
168163
await targetCommand.execute(placeholder, cwQuickPickSource)
169164

170-
assert.strictEqual(codeSuggestionsState.isSuggestionsEnabled(), false)
165+
assert.strictEqual(codeSuggestionsState.isSuggestionsEnabled(), true)
171166
assertTelemetryCurried('aws_modifySetting')({
172167
settingId: CodeWhispererConstants.autoSuggestionConfig.settingId,
173-
settingState: CodeWhispererConstants.autoSuggestionConfig.deactivated,
168+
settingState: CodeWhispererConstants.autoSuggestionConfig.activated,
174169
})
175170
})
176171

177-
it('emits aws_modifySetting event on user toggling autoSuggestion -- activate', async function () {
172+
it('emits aws_modifySetting event on user toggling autoSuggestion -- deactivate', async function () {
178173
targetCommand = testCommand(toggleCodeSuggestions, codeSuggestionsState)
179174
await targetCommand.execute(placeholder, cwQuickPickSource)
180175

181-
assert.strictEqual(codeSuggestionsState.isSuggestionsEnabled(), true)
176+
assert.strictEqual(codeSuggestionsState.isSuggestionsEnabled(), false)
182177
assertTelemetryCurried('aws_modifySetting')({
183178
settingId: CodeWhispererConstants.autoSuggestionConfig.settingId,
184-
settingState: CodeWhispererConstants.autoSuggestionConfig.activated,
179+
settingState: CodeWhispererConstants.autoSuggestionConfig.deactivated,
185180
})
186181
})
187182

0 commit comments

Comments
 (0)