Skip to content

Commit 1c1fb06

Browse files
authored
fix(amazonq): tutorial always showing on start #5949
The LineAnnotationController could get stuck showing the tutorial for new users due to changes in the inline chat logic, this PR resolve that bug and prevents the `aws.codewhisperer.tutorial.workInProgress` from being set to `true` when using inline chat.
1 parent 1153658 commit 1c1fb06

File tree

3 files changed

+21
-7
lines changed

3 files changed

+21
-7
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": "tutorial always showing on start"
4+
}

packages/amazonq/src/inlineChat/controller/inlineChatController.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,10 @@ export class InlineChatController {
121121
await this.reset()
122122
}
123123

124-
public async updateTaskAndLenses(task: InlineTask, taskState?: TaskState) {
124+
public async updateTaskAndLenses(task?: InlineTask, taskState?: TaskState) {
125+
if (!task) {
126+
return
127+
}
125128
if (taskState) {
126129
task.state = taskState
127130
} else if (!task.diff || task.diff.length === 0) {
@@ -200,7 +203,7 @@ export class InlineChatController {
200203
this.task = await this.createTask(query, editor.document, editor.selection)
201204
await this.inlineLineAnnotationController.disable(editor)
202205
await this.computeDiffAndRenderOnEditor(query, editor.document).catch(async (err) => {
203-
getLogger().error(err)
206+
getLogger().error('computeDiffAndRenderOnEditor error: %s', (err as Error)?.message)
204207
if (err instanceof Error) {
205208
void vscode.window.showErrorMessage(`Amazon Q: ${err.message}`)
206209
} else {

packages/core/src/codewhisperer/views/lineAnnotationController.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ function fromId(id: string | undefined): AnnotationState | undefined {
3838
return new TryMoreExState()
3939
case EndState.id:
4040
return new EndState()
41+
case InlineChatState.id:
42+
return new InlineChatState()
4143
default:
4244
return undefined
4345
}
@@ -201,16 +203,15 @@ export class EndState implements AnnotationState {
201203
}
202204

203205
export class InlineChatState implements AnnotationState {
204-
static static = 'amazonq_annotation_inline_chat'
205-
id = InlineChatState.static
206+
static id = 'amazonq_annotation_inline_chat'
207+
id = InlineChatState.id
206208
suppressWhileRunning = false
207209

208210
text = () => {
209211
if (os.platform() === 'darwin') {
210212
return 'Amazon Q: Edit \u2318I'
211-
} else {
212-
return 'Amazon Q: Edit (Ctrl+I)'
213213
}
214+
return 'Amazon Q: Edit (Ctrl+I)'
214215
}
215216
updateState(_changeSource: AnnotationChangeSource, _force: boolean): AnnotationState {
216217
return this
@@ -329,6 +330,10 @@ export class LineAnnotationController implements vscode.Disposable {
329330
return this._currentState.id === new EndState().id
330331
}
331332

333+
isInlineChatHint(): boolean {
334+
return this._currentState.id === new InlineChatState().id
335+
}
336+
332337
async dismissTutorial() {
333338
this._currentState = new EndState()
334339
await setContext('aws.codewhisperer.tutorial.workInProgress', false)
@@ -467,7 +472,9 @@ export class LineAnnotationController implements vscode.Disposable {
467472
decorationOptions.range = range
468473

469474
await globals.globalState.update(inlinehintKey, this._currentState.id)
470-
await setContext('aws.codewhisperer.tutorial.workInProgress', true)
475+
if (!this.isInlineChatHint()) {
476+
await setContext('aws.codewhisperer.tutorial.workInProgress', true)
477+
}
471478
editor.setDecorations(this.cwLineHintDecoration, [decorationOptions])
472479
}
473480

0 commit comments

Comments
 (0)