Skip to content

Commit a1a7619

Browse files
feat: enhancing user experience for file write. (#2468)
* feat(amazonq): send data to modifiedFilesTracker component as well * fix(amazon q): adding package-lock * fix(amazonq): removed unnecessary LocalProjectContextController and LocalProjectContextServer changes * fix(amazonq): Still seeing the same error, reverting --------- Co-authored-by: sacrodge <[email protected]>
1 parent 71a38ed commit a1a7619

File tree

8 files changed

+92
-44
lines changed

8 files changed

+92
-44
lines changed

chat-client/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@
2424
"package": "webpack"
2525
},
2626
"dependencies": {
27-
"@aws/chat-client-ui-types": "^0.1.63",
28-
"@aws/language-server-runtimes": "^0.3.1",
29-
"@aws/language-server-runtimes-types": "^0.1.57",
30-
"@aws/mynah-ui": "^4.36.8"
27+
"@aws/chat-client-ui-types": "^0.1.65",
28+
"@aws/language-server-runtimes": "^0.3.3",
29+
"@aws/language-server-runtimes-types": "^0.1.59",
30+
"@aws/mynah-ui": "4.36.9-beta.3"
3131
},
3232
"devDependencies": {
3333
"@types/jsdom": "^21.1.6",

chat-client/src/client/mynahUi.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1411,6 +1411,7 @@ export const createMynahUi = (
14111411
? { 'insert-to-cursor': null }
14121412
: undefined,
14131413
...(shouldMute ? { muted: true } : {}),
1414+
modifiedFilesTracker: message.modifiedFilesTracker,
14141415
}
14151416
}
14161417

package-lock.json

Lines changed: 22 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"ci:generate:agentic:attribution": "ts-node ./script/prepare-agentic-attribution-dependencies.ts && ./script/generate-agentic-attribution.sh && git restore package.json"
3737
},
3838
"dependencies": {
39-
"@aws/language-server-runtimes": "^0.3.1",
39+
"@aws/language-server-runtimes": "^0.3.3",
4040
"@smithy/types": "4.2.0",
4141
"clean": "^4.0.2",
4242
"typescript": "^5.8.2"

server/aws-lsp-codewhisperer/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@
3636
"@aws-sdk/types": "^3.734.0",
3737
"@aws-sdk/util-arn-parser": "^3.723.0",
3838
"@aws-sdk/util-retry": "^3.374.0",
39-
"@aws/chat-client-ui-types": "^0.1.63",
40-
"@aws/language-server-runtimes": "^0.3.1",
39+
"@aws/chat-client-ui-types": "^0.1.65",
40+
"@aws/language-server-runtimes": "^0.3.3",
4141
"@aws/lsp-core": "^0.0.16",
4242
"@modelcontextprotocol/sdk": "^1.15.0",
4343
"@smithy/node-http-handler": "^2.5.0",

server/aws-lsp-codewhisperer/src/language-server/agenticChat/agenticChatController.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,11 @@ export class AgenticChatController implements ChatHandlers {
494494
const fileList = cachedToolUse.chatResult?.header?.fileList
495495
const button = cachedToolUse.chatResult?.header?.buttons?.filter(button => button.id !== BUTTON_UNDO_CHANGES)
496496

497+
const updatedModifiedFilesTracker = {
498+
...cachedToolUse.chatResult?.modifiedFilesTracker,
499+
removeFile: true,
500+
}
501+
497502
const updatedHeader = {
498503
...cachedToolUse.chatResult?.header,
499504
buttons: button,
@@ -530,6 +535,7 @@ export class AgenticChatController implements ChatHandlers {
530535
{
531536
...cachedToolUse.chatResult,
532537
header: updatedHeader,
538+
modifiedFilesTracker: updatedModifiedFilesTracker,
533539
},
534540
],
535541
},
@@ -2517,6 +2523,9 @@ export class AgenticChatController implements ChatHandlers {
25172523
keepCardAfterClick: false,
25182524
},
25192525
],
2526+
modifiedFilesTracker: {
2527+
title: 'Following files were modified : ',
2528+
},
25202529
})
25212530
session.currentUndoAllId = undefined
25222531
}
@@ -3167,6 +3176,9 @@ export class AgenticChatController implements ChatHandlers {
31673176
},
31683177
buttons: [{ id: BUTTON_UNDO_CHANGES, text: 'Undo', icon: 'undo' }],
31693178
},
3179+
modifiedFilesTracker: {
3180+
title: 'Following files were modified : ',
3181+
},
31703182
}
31713183
}
31723184

server/aws-lsp-codewhisperer/src/language-server/localProjectContext/localProjectContextServer.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,14 @@ export const LocalProjectContextServer =
166166
try {
167167
localProjectContextEnabled = updatedConfig.projectContext?.enableLocalIndexing === true
168168
if (process.env.DISABLE_INDEXING_LIBRARY === 'true') {
169-
logging.log('Skipping local project context initialization')
169+
logging.log('Skipping local project context initialization due to DISABLE_INDEXING_LIBRARY=true')
170170
localProjectContextEnabled = false
171+
// Ensure instance is set even when disabled
172+
LocalProjectContextController.createFallbackInstance(
173+
'vscode',
174+
workspace.getAllWorkspaceFolders() || [],
175+
logging
176+
)
171177
} else {
172178
logging.log(
173179
`Setting project context indexing enabled to ${updatedConfig.projectContext?.enableLocalIndexing}`
@@ -183,7 +189,13 @@ export const LocalProjectContextServer =
183189
})
184190
}
185191
} catch (error) {
186-
logging.error(`Error handling configuration change: ${error}`)
192+
logging.error(`Error handling configuration change: ${error}. Creating fallback instance.`)
193+
// Create fallback instance if initialization fails
194+
LocalProjectContextController.createFallbackInstance(
195+
'vscode',
196+
workspace.getAllWorkspaceFolders() || [],
197+
logging
198+
)
187199
}
188200
}
189201

server/aws-lsp-codewhisperer/src/shared/localProjectContextController.ts

Lines changed: 36 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,19 @@ export class LocalProjectContextController {
101101
}
102102
}
103103

104+
public static createFallbackInstance(
105+
clientName: string,
106+
workspaceFolders: WorkspaceFolder[],
107+
logging: Logging
108+
): LocalProjectContextController {
109+
if (!this.instance) {
110+
const fallbackInstance = new LocalProjectContextController(clientName, workspaceFolders, logging)
111+
this.instance = fallbackInstance
112+
logging.warn('Created fallback LocalProjectContextController instance without vector library')
113+
}
114+
return this.instance
115+
}
116+
104117
public async init({
105118
vectorLib,
106119
ignoreFilePatterns = [],
@@ -159,22 +172,32 @@ export class LocalProjectContextController {
159172

160173
// initialize vecLib and index if needed
161174
const libraryPath = this.getVectorLibraryPath()
162-
const vecLib = vectorLib ?? (await eval(`import("${libraryPath}")`))
163-
if (vecLib) {
164-
this._vecLib = await vecLib.start(LIBRARY_DIR, this.clientName, this.indexCacheDirPath)
165-
if (enableIndexing) {
166-
this.buildIndex('all').catch(e => {
167-
this.log.error(`Error building index on init with indexing enabled: ${e}`)
168-
})
175+
try {
176+
const vecLib = vectorLib ?? (await eval(`import("${libraryPath}")`))
177+
if (vecLib) {
178+
this._vecLib = await vecLib.start(LIBRARY_DIR, this.clientName, this.indexCacheDirPath)
179+
if (enableIndexing) {
180+
this.buildIndex('all').catch(e => {
181+
this.log.error(`Error building index on init with indexing enabled: ${e}`)
182+
})
183+
} else {
184+
this.buildIndex('default').catch(e => {
185+
this.log.error(`Error building index on init with indexing disabled: ${e}`)
186+
})
187+
}
188+
this._isIndexingEnabled = enableIndexing
169189
} else {
170-
this.buildIndex('default').catch(e => {
171-
this.log.error(`Error building index on init with indexing disabled: ${e}`)
172-
})
190+
this.log.warn(`Vector library could not be imported from: ${libraryPath}`)
173191
}
192+
} catch (importError) {
193+
this.log.warn(
194+
`Failed to import vector library from ${libraryPath}: ${importError}. Local indexing will be disabled.`
195+
)
196+
}
197+
198+
// Always set the instance, even if vector library failed to load
199+
if (!LocalProjectContextController.instance) {
174200
LocalProjectContextController.instance = this
175-
this._isIndexingEnabled = enableIndexing
176-
} else {
177-
this.log.warn(`Vector library could not be imported from: ${libraryPath}`)
178201
}
179202
} catch (error) {
180203
this.log.error('Vector library failed to initialize:' + error)

0 commit comments

Comments
 (0)