From 0d9b084ffba392040264e259a25bbffe71769ffc Mon Sep 17 00:00:00 2001 From: Lei Gao Date: Wed, 26 Feb 2025 10:32:23 -0800 Subject: [PATCH 1/4] update mynahUI to beta 11 --- package-lock.json | 8 ++++---- packages/core/package.json | 2 +- packages/core/src/amazonq/webview/ui/main.ts | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index 679848c43db..1b6007d946b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4935,9 +4935,9 @@ } }, "node_modules/@aws/mynah-ui": { - "version": "4.23.0-beta.7", - "resolved": "https://registry.npmjs.org/@aws/mynah-ui/-/mynah-ui-4.23.0-beta.7.tgz", - "integrity": "sha512-qRwy8bP8inhbTb94xv9tJvqrmvv+PDcGyOKuPE9vx4+cwymNtf8HVp5IcIjJ/oTWV5bWA7M3o0mm9qEFFYdB6w==", + "version": "4.23.0-beta.11", + "resolved": "https://registry.npmjs.org/@aws/mynah-ui/-/mynah-ui-4.23.0-beta.11.tgz", + "integrity": "sha512-3ZwOSM7UZ1aNO/SyGRhBdrr7Fj2MOcqmT5zzbTCRKrfNmQXMJBCm+lFh54bc2B0S4OskzE2vcvrI16+dBm7WGg==", "hasInstallScript": true, "dependencies": { "escape-html": "^1.0.3", @@ -18925,7 +18925,7 @@ "@aws-sdk/property-provider": "<3.696.0", "@aws-sdk/smithy-client": "<3.696.0", "@aws-sdk/util-arn-parser": "<3.696.0", - "@aws/mynah-ui": "^4.23.0-beta.7", + "@aws/mynah-ui": "^4.23.0-beta.11", "@gerhobbelt/gitignore-parser": "^0.2.0-9", "@iarna/toml": "^2.2.5", "@smithy/middleware-retry": "^3.0.0", diff --git a/packages/core/package.json b/packages/core/package.json index c86b4f0fd1a..5ec69a7e1c6 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -510,7 +510,7 @@ "@aws-sdk/property-provider": "<3.696.0", "@aws-sdk/smithy-client": "<3.696.0", "@aws-sdk/util-arn-parser": "<3.696.0", - "@aws/mynah-ui": "^4.23.0-beta.7", + "@aws/mynah-ui": "^4.23.0-beta.11", "@gerhobbelt/gitignore-parser": "^0.2.0-9", "@iarna/toml": "^2.2.5", "@smithy/middleware-retry": "^3.0.0", diff --git a/packages/core/src/amazonq/webview/ui/main.ts b/packages/core/src/amazonq/webview/ui/main.ts index 2305f35c734..be3adbd2592 100644 --- a/packages/core/src/amazonq/webview/ui/main.ts +++ b/packages/core/src/amazonq/webview/ui/main.ts @@ -375,7 +375,7 @@ export const createMynahUI = ( fileTreeTitle: '', filePaths: item.contextList.map((file) => file.relativeFilePath), rootFolderTitle: 'Context', - collapsedByDefault: true, + collapsed: true, hideFileCount: true, details: Object.fromEntries( item.contextList.map((file) => [ From 06876e2d456294e4ec65627e279d79173ae9d1c2 Mon Sep 17 00:00:00 2001 From: Lei Gao Date: Wed, 26 Feb 2025 13:27:01 -0800 Subject: [PATCH 2/4] fix edge cases of index update --- packages/core/src/amazonq/lsp/lspClient.ts | 75 +++++++++++++--------- 1 file changed, 43 insertions(+), 32 deletions(-) diff --git a/packages/core/src/amazonq/lsp/lspClient.ts b/packages/core/src/amazonq/lsp/lspClient.ts index 080ede81462..61dd5bcca3e 100644 --- a/packages/core/src/amazonq/lsp/lspClient.ts +++ b/packages/core/src/amazonq/lsp/lspClient.ts @@ -315,6 +315,37 @@ export async function activate(extensionContext: ExtensionContext) { let savedDocument: vscode.Uri | undefined = undefined + const onAdd = async (filePaths: string[]) => { + const indexSeqNum = await LspClient.instance.getIndexSequenceNumber() + await LspClient.instance.updateIndex(filePaths, 'add') + await waitUntil( + async () => { + const newIndexSeqNum = await LspClient.instance.getIndexSequenceNumber() + if (newIndexSeqNum > indexSeqNum) { + await vscode.commands.executeCommand(`aws.amazonq.updateContextCommandItems`) + return true + } + return false + }, + { interval: 500, timeout: 10_000, truthy: true } + ) + } + const onRemove = async (filePaths: string[]) => { + const indexSeqNum = await LspClient.instance.getIndexSequenceNumber() + await LspClient.instance.updateIndex(filePaths, 'remove') + await waitUntil( + async () => { + const newIndexSeqNum = await LspClient.instance.getIndexSequenceNumber() + if (newIndexSeqNum > indexSeqNum) { + await vscode.commands.executeCommand(`aws.amazonq.updateContextCommandItems`) + return true + } + return false + }, + { interval: 500, timeout: 10_000, truthy: true } + ) + } + toDispose.push( vscode.workspace.onDidSaveTextDocument((document) => { if (document.uri.scheme !== 'file') { @@ -326,42 +357,22 @@ export async function activate(extensionContext: ExtensionContext) { if (savedDocument && editor && editor.document.uri.fsPath !== savedDocument.fsPath) { void LspClient.instance.updateIndex([savedDocument.fsPath], 'update') } + // user created a new empty file using File -> New File + // these events will not be captured by vscode.workspace.onDidCreateFiles + // because it was created by File Explorer(Win) or Finder(MacOS) + if (editor?.document.getText().length === 0) { + onAdd([editor.document.uri.fsPath]) + } }), vscode.workspace.onDidCreateFiles(async (e) => { - const indexSeqNum = await LspClient.instance.getIndexSequenceNumber() - await LspClient.instance.updateIndex( - e.files.map((f) => f.fsPath), - 'add' - ) - await waitUntil( - async () => { - const newIndexSeqNum = await LspClient.instance.getIndexSequenceNumber() - if (newIndexSeqNum > indexSeqNum) { - await vscode.commands.executeCommand(`aws.amazonq.updateContextCommandItems`) - return true - } - return false - }, - { interval: 500, timeout: 10_000, truthy: true } - ) + onAdd(e.files.map((f) => f.fsPath)) }), vscode.workspace.onDidDeleteFiles(async (e) => { - const indexSeqNum = await LspClient.instance.getIndexSequenceNumber() - await LspClient.instance.updateIndex( - e.files.map((f) => f.fsPath), - 'remove' - ) - await waitUntil( - async () => { - const newIndexSeqNum = await LspClient.instance.getIndexSequenceNumber() - if (newIndexSeqNum > indexSeqNum) { - await vscode.commands.executeCommand(`aws.amazonq.updateContextCommandItems`) - return true - } - return false - }, - { interval: 500, timeout: 10_000, truthy: true } - ) + onRemove(e.files.map((f) => f.fsPath)) + }), + vscode.workspace.onDidRenameFiles(async (e) => { + await onRemove(e.files.map((f) => f.oldUri.fsPath)) + await onAdd(e.files.map((f) => f.newUri.fsPath)) }) ) From cab8a6f9e42f562741fcf2152e754ad881f64359 Mon Sep 17 00:00:00 2001 From: Lei Gao Date: Wed, 26 Feb 2025 13:33:46 -0800 Subject: [PATCH 3/4] adjust timeout --- packages/core/src/amazonq/lsp/lspClient.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/core/src/amazonq/lsp/lspClient.ts b/packages/core/src/amazonq/lsp/lspClient.ts index 61dd5bcca3e..978f588cb64 100644 --- a/packages/core/src/amazonq/lsp/lspClient.ts +++ b/packages/core/src/amazonq/lsp/lspClient.ts @@ -327,7 +327,7 @@ export async function activate(extensionContext: ExtensionContext) { } return false }, - { interval: 500, timeout: 10_000, truthy: true } + { interval: 500, timeout: 5_000, truthy: true } ) } const onRemove = async (filePaths: string[]) => { @@ -342,7 +342,7 @@ export async function activate(extensionContext: ExtensionContext) { } return false }, - { interval: 500, timeout: 10_000, truthy: true } + { interval: 500, timeout: 5_000, truthy: true } ) } From 83b9032cea401eb32da50cfb39e5023523f8dad1 Mon Sep 17 00:00:00 2001 From: Lei Gao Date: Wed, 26 Feb 2025 14:51:02 -0800 Subject: [PATCH 4/4] github actions --- packages/core/src/amazonq/lsp/lspClient.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/core/src/amazonq/lsp/lspClient.ts b/packages/core/src/amazonq/lsp/lspClient.ts index 978f588cb64..5d96650ebf8 100644 --- a/packages/core/src/amazonq/lsp/lspClient.ts +++ b/packages/core/src/amazonq/lsp/lspClient.ts @@ -360,15 +360,16 @@ export async function activate(extensionContext: ExtensionContext) { // user created a new empty file using File -> New File // these events will not be captured by vscode.workspace.onDidCreateFiles // because it was created by File Explorer(Win) or Finder(MacOS) + // TODO: consider using a high performance fs watcher if (editor?.document.getText().length === 0) { - onAdd([editor.document.uri.fsPath]) + void onAdd([editor.document.uri.fsPath]) } }), vscode.workspace.onDidCreateFiles(async (e) => { - onAdd(e.files.map((f) => f.fsPath)) + await onAdd(e.files.map((f) => f.fsPath)) }), vscode.workspace.onDidDeleteFiles(async (e) => { - onRemove(e.files.map((f) => f.fsPath)) + await onRemove(e.files.map((f) => f.fsPath)) }), vscode.workspace.onDidRenameFiles(async (e) => { await onRemove(e.files.map((f) => f.oldUri.fsPath))