Skip to content

Commit f29ad27

Browse files
authored
Merge branch 'main' into falcon-p1
2 parents 84b537e + dd49420 commit f29ad27

File tree

8 files changed

+280
-82
lines changed

8 files changed

+280
-82
lines changed

package-lock.json

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

server/aws-lsp-codewhisperer/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,13 @@
4242
"deepmerge": "^4.3.1",
4343
"diff": "^7.0.0",
4444
"fastest-levenshtein": "^1.0.16",
45+
"fdir": "^6.4.3",
4546
"got": "^11.8.5",
4647
"hpagent": "^1.2.0",
48+
"ignore": "^7.0.3",
4749
"js-md5": "^0.8.3",
4850
"lokijs": "^1.5.12",
51+
"picomatch": "^4.0.2",
4952
"shlex": "2.1.2",
5053
"uuid": "^11.0.5",
5154
"vscode-uri": "^3.1.0"

server/aws-lsp-codewhisperer/src/language-server/agenticChat/tools/chatDb/util.test.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -237,11 +237,15 @@ describe('ChatDb Utilities', () => {
237237

238238
it('should sort tabs by updatedAt in descending order within groups', () => {
239239
const now = new Date()
240-
const today1 = new Date(now)
241-
const today2 = new Date(now)
242-
today2.setHours(today2.getHours() - 1)
243-
const today3 = new Date(now)
244-
today3.setHours(today3.getHours() - 2)
240+
241+
const endOfDay = new Date(now)
242+
endOfDay.setHours(23, 59, 59, 999)
243+
244+
const today1 = new Date(endOfDay)
245+
const today2 = new Date(endOfDay)
246+
today2.setHours(endOfDay.getHours() - 1)
247+
const today3 = new Date(endOfDay)
248+
today3.setHours(endOfDay.getHours() - 2)
245249

246250
const tabs = [
247251
{

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

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export const LocalProjectContextServer = (): Server => features => {
1111
let localProjectContextController: LocalProjectContextController
1212
let amazonQServiceManager: AmazonQTokenServiceManager
1313
let telemetryService: TelemetryService
14+
let localProjectContextEnabled: boolean = false
1415

1516
lsp.addInitializer((params: InitializeParams) => {
1617
amazonQServiceManager = AmazonQTokenServiceManager.getInstance(features)
@@ -119,10 +120,18 @@ export const LocalProjectContextServer = (): Server => features => {
119120
const updateConfigurationHandler = async (updatedConfig: AmazonQWorkspaceConfig) => {
120121
logging.log('Updating configuration of local context server')
121122
try {
122-
logging.log(`Setting project context enabled to ${updatedConfig.projectContext?.enableLocalIndexing}`)
123-
updatedConfig.projectContext?.enableLocalIndexing
124-
? await localProjectContextController.init()
125-
: await localProjectContextController.dispose()
123+
if (localProjectContextEnabled !== updatedConfig.projectContext?.enableLocalIndexing) {
124+
localProjectContextEnabled = updatedConfig.projectContext?.enableLocalIndexing === true
125+
126+
logging.log(`Setting project context enabled to ${updatedConfig.projectContext?.enableLocalIndexing}`)
127+
localProjectContextEnabled
128+
? await localProjectContextController.init({
129+
ignoreFilePatterns: updatedConfig.projectContext?.localIndexing?.ignoreFilePatterns,
130+
maxFileSizeMB: updatedConfig.projectContext?.localIndexing?.maxFileSizeMB,
131+
maxIndexSizeMB: updatedConfig.projectContext?.localIndexing?.maxIndexSizeMB,
132+
})
133+
: await localProjectContextController.dispose()
134+
}
126135
} catch (error) {
127136
logging.error(`Error handling configuration change: ${error}`)
128137
}

server/aws-lsp-codewhisperer/src/shared/amazonQServiceManager/configurationUtils.test.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ describe('getAmazonQRelatedWorkspaceConfigs', () => {
1919
},
2020
projectContext: {
2121
enableLocalIndexing: true,
22+
localIndexing: {
23+
ignoreFilePatterns: [],
24+
maxFileSizeMB: 10,
25+
maxIndexSizeMB: 2048,
26+
indexCacheDirPath: undefined,
27+
},
2228
},
2329
}
2430

@@ -43,7 +49,10 @@ describe('getAmazonQRelatedWorkspaceConfigs', () => {
4349
inlineSuggestions: { extraContext: MOCKED_AWS_Q_SECTION.inlineSuggestions.extraContext },
4450
includeSuggestionsWithCodeReferences: MOCKED_AWS_CODEWHISPERER_SECTION.includeSuggestionsWithCodeReferences,
4551
shareCodeWhispererContentWithAWS: MOCKED_AWS_CODEWHISPERER_SECTION.shareCodeWhispererContentWithAWS,
46-
projectContext: { enableLocalIndexing: MOCKED_AWS_Q_SECTION.projectContext.enableLocalIndexing },
52+
projectContext: {
53+
enableLocalIndexing: MOCKED_AWS_Q_SECTION.projectContext.enableLocalIndexing,
54+
localIndexing: MOCKED_AWS_Q_SECTION.projectContext.localIndexing,
55+
},
4756
}
4857

4958
const amazonQConfig = await getAmazonQRelatedWorkspaceConfigs(features.lsp, features.logging)
@@ -87,6 +96,12 @@ describe('AmazonQConfigurationCache', () => {
8796
shareCodeWhispererContentWithAWS: true,
8897
projectContext: {
8998
enableLocalIndexing: true,
99+
localIndexing: {
100+
ignoreFilePatterns: [],
101+
maxFileSizeMB: 10,
102+
maxIndexSizeMB: 2048,
103+
indexCacheDirPath: undefined,
104+
},
90105
},
91106
}
92107
})

server/aws-lsp-codewhisperer/src/shared/amazonQServiceManager/configurationUtils.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,16 @@ interface QInlineSuggestionsConfig {
6767
extraContext: string | undefined // aws.q.inlineSuggestions.extraContext
6868
}
6969

70+
interface LocalIndexConfig {
71+
ignoreFilePatterns?: string[]
72+
maxFileSizeMB?: number
73+
maxIndexSizeMB?: number
74+
indexCacheDirPath?: string
75+
}
76+
7077
interface QProjectContextConfig {
7178
enableLocalIndexing: boolean // aws.q.projectContext.enableLocalIndexing
79+
localIndexing?: LocalIndexConfig
7280
}
7381

7482
interface QConfigSection {
@@ -112,6 +120,12 @@ export async function getAmazonQRelatedWorkspaceConfigs(
112120
},
113121
projectContext: {
114122
enableLocalIndexing: newQConfig.projectContext?.enableLocalIndexing === true,
123+
localIndexing: {
124+
ignoreFilePatterns: newQConfig.projectContext?.localIndexing?.ignoreFilePatterns ?? [],
125+
maxFileSizeMB: newQConfig.projectContext?.localIndexing?.maxFileSizeMb ?? 10,
126+
maxIndexSizeMB: newQConfig.projectContext?.localIndexing?.maxIndexSizeMb ?? 2048,
127+
indexCacheDirPath: newQConfig.projectContext?.localIndexing?.indexCacheDirPath ?? undefined,
128+
},
115129
},
116130
}
117131

@@ -160,6 +174,12 @@ export const defaultAmazonQWorkspaceConfigFactory = (): AmazonQWorkspaceConfig =
160174
shareCodeWhispererContentWithAWS: false,
161175
projectContext: {
162176
enableLocalIndexing: false,
177+
localIndexing: {
178+
ignoreFilePatterns: [],
179+
maxFileSizeMB: 10,
180+
maxIndexSizeMB: 2048,
181+
indexCacheDirPath: undefined,
182+
},
163183
},
164184
}
165185
}

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ describe('LocalProjectContextController', () => {
8080

8181
describe('init', () => {
8282
it('should initialize vector library successfully', async () => {
83-
await controller.init(vectorLibMock)
83+
await controller.init({ vectorLib: vectorLibMock })
8484

8585
sinonAssert.notCalled(logging.error)
8686
sinonAssert.called(vectorLibMock.start)
@@ -91,15 +91,15 @@ describe('LocalProjectContextController', () => {
9191
it('should handle initialization errors', async () => {
9292
vectorLibMock.start.rejects(new Error('Init failed'))
9393

94-
await controller.init(vectorLibMock)
94+
await controller.init({ vectorLib: vectorLibMock })
9595

9696
sinonAssert.called(logging.error)
9797
})
9898
})
9999

100100
describe('queryVectorIndex', () => {
101101
beforeEach(async () => {
102-
await controller.init(vectorLibMock)
102+
await controller.init({ vectorLib: vectorLibMock })
103103
})
104104

105105
it('should return empty array when vector library is not initialized', async () => {
@@ -132,7 +132,7 @@ describe('LocalProjectContextController', () => {
132132

133133
describe('queryInlineProjectContext', () => {
134134
beforeEach(async () => {
135-
await controller.init(vectorLibMock)
135+
await controller.init({ vectorLib: vectorLibMock })
136136
})
137137

138138
it('should return empty array when vector library is not initialized', async () => {
@@ -177,7 +177,7 @@ describe('LocalProjectContextController', () => {
177177

178178
describe('updateIndex', () => {
179179
beforeEach(async () => {
180-
await controller.init(vectorLibMock)
180+
await controller.init({ vectorLib: vectorLibMock })
181181
})
182182

183183
it('should do nothing when vector library is not initialized', async () => {
@@ -210,7 +210,7 @@ describe('LocalProjectContextController', () => {
210210

211211
describe('dispose', () => {
212212
it('should clear and remove vector library reference', async () => {
213-
await controller.init(vectorLibMock)
213+
await controller.init({ vectorLib: vectorLibMock })
214214
await controller.dispose()
215215

216216
const vecLib = await vectorLibMock.start()

0 commit comments

Comments
 (0)