Skip to content

Commit 985bb29

Browse files
committed
Changes according to mynah Version 4.6.0
1 parent 7351ea6 commit 985bb29

File tree

3 files changed

+9
-31
lines changed

3 files changed

+9
-31
lines changed

package-lock.json

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

packages/core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4315,7 +4315,7 @@
43154315
"@aws-sdk/property-provider": "3.46.0",
43164316
"@aws-sdk/smithy-client": "^3.46.0",
43174317
"@aws-sdk/util-arn-parser": "^3.46.0",
4318-
"@aws/mynah-ui": "^4.5.5",
4318+
"@aws/mynah-ui": "^4.6.0",
43194319
"@gerhobbelt/gitignore-parser": "^0.2.0-9",
43204320
"@iarna/toml": "^2.2.5",
43214321
"@smithy/shared-ini-file-loader": "^2.2.8",

packages/core/src/amazonq/webview/ui/main.ts

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -34,28 +34,6 @@ export const createMynahUI = (ideApi: any, amazonQEnabled: boolean) => {
3434
})
3535
},
3636
})
37-
/*
38-
function countNumberOfCodeBlocks(messageGenerated: string | undefined): number {
39-
if (messageGenerated === undefined) {
40-
return 0
41-
}
42-
let totalCodeBlocks = 0
43-
let codeBlockIndex = messageGenerated.indexOf('```')
44-
while (codeBlockIndex !== -1) {
45-
totalCodeBlocks++
46-
codeBlockIndex = messageGenerated.indexOf('```', codeBlockIndex + 1)
47-
}
48-
return Math.floor(totalCodeBlocks / 2)
49-
}
50-
*/
51-
function countNumberOfCodeBlocks(messageGenerated: string): number {
52-
if (messageGenerated === undefined) {
53-
return 0
54-
}
55-
const matches = messageGenerated.match(/```/g)
56-
const totalCodeBlockOpenAndClose = matches ? matches.length : 0 //totalCodeBlockOpenAndClose
57-
return Math.floor(totalCodeBlockOpenAndClose / 2)
58-
}
5937

6038
// Adding the first tab as CWC tab
6139
tabsStorage.addTab({
@@ -207,10 +185,6 @@ export const createMynahUI = (ideApi: any, amazonQEnabled: boolean) => {
207185
},
208186
onChatAnswerReceived: (tabID: string, item: ChatItem) => {
209187
if (item.type === ChatItemType.ANSWER_PART || item.type === ChatItemType.CODE_RESULT) {
210-
if (item.body !== undefined && item.messageId !== undefined) {
211-
const totalCodeBlocks = countNumberOfCodeBlocks(item.body)
212-
connector.handleMessageofStreamedData(tabID, totalCodeBlocks, item.messageId)
213-
}
214188
mynahUI.updateLastChatAnswer(tabID, {
215189
...(item.messageId !== undefined ? { messageId: item.messageId } : {}),
216190
...(item.canBeVoted !== undefined ? { canBeVoted: item.canBeVoted } : {}),
@@ -249,6 +223,10 @@ export const createMynahUI = (ideApi: any, amazonQEnabled: boolean) => {
249223
}
250224

251225
if (item.type === ChatItemType.ANSWER) {
226+
if (item.messageId !== undefined) {
227+
const count = mynahUI.endMessageStream(tabID, item.messageId).totalNumberOfCodeBlocks
228+
connector.handleMessageofStreamedData(tabID, count === undefined ? 0 : count, item.messageId)
229+
}
252230
mynahUI.updateStore(tabID, {
253231
loadingChat: false,
254232
promptInputDisabledState: tabsStorage.isTabDead(tabID),

0 commit comments

Comments
 (0)