Skip to content

Commit 89aa1ef

Browse files
authored
fix: model doesn't update in session for new tabs (#1506)
1 parent f4f66fa commit 89aa1ef

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,18 @@ describe('AgenticChatController', () => {
305305
sinon.assert.calledWithExactly(activeTabSpy.set, mockTabId)
306306
})
307307

308+
it('onTabAdd updates model ID in chat options and session', () => {
309+
const modelId = 'test-model-id'
310+
sinon.stub(ChatDatabase.prototype, 'getModelId').returns(modelId)
311+
312+
chatController.onTabAdd({ tabId: mockTabId })
313+
314+
sinon.assert.calledWithExactly(testFeatures.chat.chatOptionsUpdate, { modelId, tabId: mockTabId })
315+
316+
const session = chatSessionManagementService.getSession(mockTabId).data
317+
assert.strictEqual(session!.modelId, modelId)
318+
})
319+
308320
it('onTabChange sets active tab id in telemetryController and emits metrics', () => {
309321
chatController.onTabChange({ tabId: mockTabId })
310322

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2233,10 +2233,15 @@ export class AgenticChatController implements ChatHandlers {
22332233
onTabAdd(params: TabAddParams) {
22342234
this.#telemetryController.activeTabId = params.tabId
22352235

2236-
this.#chatSessionManagementService.createSession(params.tabId)
2237-
22382236
const modelId = this.#chatHistoryDb.getModelId()
22392237
this.#features.chat.chatOptionsUpdate({ modelId: modelId, tabId: params.tabId })
2238+
2239+
const sessionResult = this.#chatSessionManagementService.createSession(params.tabId)
2240+
const { data: session, success } = sessionResult
2241+
if (!success) {
2242+
return new ResponseError<ChatResult>(ErrorCodes.InternalError, sessionResult.error)
2243+
}
2244+
session.modelId = modelId
22402245
}
22412246

22422247
onTabChange(params: TabChangeParams) {

0 commit comments

Comments
 (0)