From 65d0fb8999155bd09267dc1ef257c56fdfb90693 Mon Sep 17 00:00:00 2001 From: Grant Gurvis Date: Thu, 7 Nov 2024 10:59:45 -0800 Subject: [PATCH 1/2] fix(amazonq): Resolve tutorial always showing on start --- ...ix-46c5fb9b-1b36-4826-8520-ec03409bce79.json | 4 ++++ .../controller/inlineChatController.ts | 5 ++++- .../views/lineAnnotationController.ts | 17 ++++++++++++----- 3 files changed, 20 insertions(+), 6 deletions(-) create mode 100644 packages/amazonq/.changes/next-release/Bug Fix-46c5fb9b-1b36-4826-8520-ec03409bce79.json diff --git a/packages/amazonq/.changes/next-release/Bug Fix-46c5fb9b-1b36-4826-8520-ec03409bce79.json b/packages/amazonq/.changes/next-release/Bug Fix-46c5fb9b-1b36-4826-8520-ec03409bce79.json new file mode 100644 index 00000000000..cf04cc57d37 --- /dev/null +++ b/packages/amazonq/.changes/next-release/Bug Fix-46c5fb9b-1b36-4826-8520-ec03409bce79.json @@ -0,0 +1,4 @@ +{ + "type": "Bug Fix", + "description": "Resolve tutorial always showing on start" +} diff --git a/packages/amazonq/src/inlineChat/controller/inlineChatController.ts b/packages/amazonq/src/inlineChat/controller/inlineChatController.ts index 7f692e5acf1..a4bea64a0ea 100644 --- a/packages/amazonq/src/inlineChat/controller/inlineChatController.ts +++ b/packages/amazonq/src/inlineChat/controller/inlineChatController.ts @@ -122,6 +122,9 @@ export class InlineChatController { } public async updateTaskAndLenses(task: InlineTask, taskState?: TaskState) { + if (!task) { + return + } if (taskState) { task.state = taskState } else if (!task.diff || task.diff.length === 0) { @@ -200,7 +203,7 @@ export class InlineChatController { this.task = await this.createTask(query, editor.document, editor.selection) await this.inlineLineAnnotationController.disable(editor) await this.computeDiffAndRenderOnEditor(query, editor.document).catch(async (err) => { - getLogger().error(err) + getLogger().error('computeDiffAndRenderOnEditor error: %s', (err as Error)?.message) if (err instanceof Error) { void vscode.window.showErrorMessage(`Amazon Q: ${err.message}`) } else { diff --git a/packages/core/src/codewhisperer/views/lineAnnotationController.ts b/packages/core/src/codewhisperer/views/lineAnnotationController.ts index df00b6fe7ac..21e4045b113 100644 --- a/packages/core/src/codewhisperer/views/lineAnnotationController.ts +++ b/packages/core/src/codewhisperer/views/lineAnnotationController.ts @@ -38,6 +38,8 @@ function fromId(id: string | undefined): AnnotationState | undefined { return new TryMoreExState() case EndState.id: return new EndState() + case InlineChatState.id: + return new InlineChatState() default: return undefined } @@ -201,16 +203,15 @@ export class EndState implements AnnotationState { } export class InlineChatState implements AnnotationState { - static static = 'amazonq_annotation_inline_chat' - id = InlineChatState.static + static id = 'amazonq_annotation_inline_chat' + id = InlineChatState.id suppressWhileRunning = false text = () => { if (os.platform() === 'darwin') { return 'Amazon Q: Edit \u2318I' - } else { - return 'Amazon Q: Edit (Ctrl+I)' } + return 'Amazon Q: Edit (Ctrl+I)' } updateState(_changeSource: AnnotationChangeSource, _force: boolean): AnnotationState { return this @@ -329,6 +330,10 @@ export class LineAnnotationController implements vscode.Disposable { return this._currentState.id === new EndState().id } + isInlineChatHint(): boolean { + return this._currentState.id === new InlineChatState().id + } + async dismissTutorial() { this._currentState = new EndState() await setContext('aws.codewhisperer.tutorial.workInProgress', false) @@ -467,7 +472,9 @@ export class LineAnnotationController implements vscode.Disposable { decorationOptions.range = range await globals.globalState.update(inlinehintKey, this._currentState.id) - await setContext('aws.codewhisperer.tutorial.workInProgress', true) + if (!this.isInlineChatHint()) { + await setContext('aws.codewhisperer.tutorial.workInProgress', true) + } editor.setDecorations(this.cwLineHintDecoration, [decorationOptions]) } From a61506ffbf20f34a583442c7c53b52a2305facc2 Mon Sep 17 00:00:00 2001 From: Grant Gurvis Date: Tue, 12 Nov 2024 09:14:02 -0800 Subject: [PATCH 2/2] Make task optional --- .../Bug Fix-46c5fb9b-1b36-4826-8520-ec03409bce79.json | 2 +- .../amazonq/src/inlineChat/controller/inlineChatController.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/amazonq/.changes/next-release/Bug Fix-46c5fb9b-1b36-4826-8520-ec03409bce79.json b/packages/amazonq/.changes/next-release/Bug Fix-46c5fb9b-1b36-4826-8520-ec03409bce79.json index cf04cc57d37..f31507aa8f3 100644 --- a/packages/amazonq/.changes/next-release/Bug Fix-46c5fb9b-1b36-4826-8520-ec03409bce79.json +++ b/packages/amazonq/.changes/next-release/Bug Fix-46c5fb9b-1b36-4826-8520-ec03409bce79.json @@ -1,4 +1,4 @@ { "type": "Bug Fix", - "description": "Resolve tutorial always showing on start" + "description": "tutorial always showing on start" } diff --git a/packages/amazonq/src/inlineChat/controller/inlineChatController.ts b/packages/amazonq/src/inlineChat/controller/inlineChatController.ts index a4bea64a0ea..2817f2140c2 100644 --- a/packages/amazonq/src/inlineChat/controller/inlineChatController.ts +++ b/packages/amazonq/src/inlineChat/controller/inlineChatController.ts @@ -121,7 +121,7 @@ export class InlineChatController { await this.reset() } - public async updateTaskAndLenses(task: InlineTask, taskState?: TaskState) { + public async updateTaskAndLenses(task?: InlineTask, taskState?: TaskState) { if (!task) { return }