File tree Expand file tree Collapse file tree 3 files changed +37
-2
lines changed
server/aws-lsp-codewhisperer/src/language-server/agenticChat Expand file tree Collapse file tree 3 files changed +37
-2
lines changed Original file line number Diff line number Diff line change @@ -60,7 +60,7 @@ import {
6060} from './utils'
6161import { ChatHistory , ChatHistoryList } from './features/history'
6262import { pairProgrammingModeOff , pairProgrammingModeOn , programmerModeCard } from './texts/pairProgramming'
63- import { getModelSelectionChatItem } from './texts/modelSelection'
63+ import { getModelSelectionChatItem , modelUnavailableBanner } from './texts/modelSelection'
6464import {
6565 freeTierLimitSticky ,
6666 upgradeSuccessSticky ,
@@ -877,7 +877,7 @@ export const createMynahUi = (
877877 return false // invalid mode
878878 }
879879
880- tabId = ! ! tabId ? tabId : getOrCreateTabId ( ) !
880+ tabId = tabId ? tabId : getOrCreateTabId ( ) !
881881 const store = mynahUi . getTabData ( tabId ) . getStore ( ) || { }
882882
883883 // Detect if the tab is already showing the "Upgrade Q" UI.
@@ -979,6 +979,13 @@ export const createMynahUi = (
979979 return
980980 }
981981
982+ if ( updatedMessage . messageId === 'modelUnavailable' ) {
983+ mynahUi . updateStore ( tabId , {
984+ promptInputStickyCard : modelUnavailableBanner ,
985+ } )
986+ return
987+ }
988+
982989 const oldMessage = chatItems . find ( ci => ci . messageId === updatedMessage . messageId )
983990 if ( ! oldMessage ) return
984991
Original file line number Diff line number Diff line change @@ -35,3 +35,14 @@ export const getModelSelectionChatItem = (modelId: string): ChatItem => ({
3535 fullWidth : true ,
3636 body : `Switched model to ${ modelRecord [ modelId as BedrockModel ] . label } ` ,
3737} )
38+
39+ export const modelUnavailableBanner : Partial < ChatItem > = {
40+ messageId : 'model-unavailable-banner' ,
41+ header : {
42+ icon : 'warning' ,
43+ iconStatus : 'warning' ,
44+ body : '### Model Unavailable' ,
45+ } ,
46+ body : `The model you selected is temporarily unavailable. Please switch to a different model and try again.` ,
47+ canBeDismissed : true ,
48+ }
Original file line number Diff line number Diff line change @@ -2203,6 +2203,23 @@ export class AgenticChatController implements ChatHandlers {
22032203 buttons : [ ] ,
22042204 }
22052205 if ( err . code === 'QModelResponse' ) {
2206+ // special case for throttling where we show error card instead of chat message
2207+ if (
2208+ err . message ===
2209+ `The model you selected is temporarily unavailable. Please switch to a different model and try again.`
2210+ ) {
2211+ this . #features. chat . sendChatUpdate ( {
2212+ tabId : tabId ,
2213+ data : { messages : [ { messageId : 'modelUnavailable' } ] } ,
2214+ } )
2215+ const emptyChatResult : ChatResult = {
2216+ type : 'answer' ,
2217+ body : '' ,
2218+ messageId : errorMessageId ,
2219+ buttons : [ ] ,
2220+ }
2221+ return emptyChatResult
2222+ }
22062223 return responseData
22072224 }
22082225 return new ResponseError < ChatResult > ( LSPErrorCodes . RequestFailed , err . message , responseData )
You can’t perform that action at this time.
0 commit comments