Skip to content

Commit 9caf22d

Browse files
committed
push local changes
1 parent d9620cf commit 9caf22d

File tree

10 files changed

+89
-24
lines changed

10 files changed

+89
-24
lines changed

packages/core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@
522522
"@aws-sdk/s3-request-presigner": "<3.696.0",
523523
"@aws-sdk/smithy-client": "<3.696.0",
524524
"@aws-sdk/util-arn-parser": "<3.696.0",
525-
"@aws/mynah-ui": "^4.26.1",
525+
"@aws/mynah-ui": "^4.27.0",
526526
"@gerhobbelt/gitignore-parser": "^0.2.0-9",
527527
"@iarna/toml": "^2.2.5",
528528
"@smithy/fetch-http-handler": "^3.0.0",

packages/core/src/amazonq/webview/ui/apps/cwChatConnector.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,17 @@ export class Connector extends BaseConnector {
109109
title: messageData.title,
110110
buttons: messageData.buttons ?? undefined,
111111
fileList: messageData.fileList ?? undefined,
112+
header: messageData.header ?? undefined,
113+
padding: messageData.padding ?? false,
114+
fullWidth: messageData.fullWidth ?? undefined,
115+
codeBlockActions: messageData.codeBlockActions ?? undefined,
112116
}
113117

118+
// eslint-disable-next-line aws-toolkits/no-console-log
119+
console.log('messageData', messageData)
120+
// eslint-disable-next-line aws-toolkits/no-console-log
121+
console.log('answer', answer)
122+
114123
if (messageData.relatedSuggestions !== undefined) {
115124
answer.relatedContent = {
116125
title: 'Sources',

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,11 @@ export const createMynahUI = (
353353
...(item.fileList !== undefined ? { fileList: item.fileList } : {}),
354354
...(item.header !== undefined ? { header: item.header } : { header: undefined }),
355355
...(item.buttons !== undefined ? { buttons: item.buttons } : { buttons: undefined }),
356+
...(item.fullWidth !== undefined ? { fullWidth: item.fullWidth } : { fullWidth: undefined }),
357+
...(item.padding !== undefined ? { padding: item.padding } : { padding: undefined }),
358+
...(item.codeBlockActions !== undefined
359+
? { codeBlockActions: item.codeBlockActions }
360+
: { codeBlockActions: undefined }),
356361
})
357362
if (
358363
item.messageId !== undefined &&

packages/core/src/codewhisperer/client/codewhisperer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ export interface CodeWhispererConfig {
3131
}
3232

3333
export const defaultServiceConfig: CodeWhispererConfig = {
34-
region: 'us-east-1',
35-
endpoint: 'https://codewhisperer.us-east-1.amazonaws.com/',
34+
region: 'us-west-2',
35+
endpoint: 'https://rts.alpha-us-west-2.codewhisperer.ai.aws.dev/',
3636
}
3737

3838
export function getCodewhispererConfig(): CodeWhispererConfig {

packages/core/src/codewhispererChat/controllers/chat/controller.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -957,7 +957,7 @@ export class ChatController {
957957
try {
958958
await ToolUtils.validate(tool)
959959

960-
const chatStream = new ChatStream(this.messenger, tabID, triggerID, toolUse.toolUseId)
960+
const chatStream = new ChatStream(this.messenger, tabID, triggerID, toolUse)
961961
const output = await ToolUtils.invoke(tool, chatStream)
962962

963963
toolResults.push({

packages/core/src/codewhispererChat/controllers/chat/messenger/messenger.ts

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ import { LspController } from '../../../../amazonq/lsp/lspController'
3939
import { extractCodeBlockLanguage } from '../../../../shared/markdown'
4040
import { extractAuthFollowUp } from '../../../../amazonq/util/authUtils'
4141
import { helpMessage } from '../../../../amazonq/webview/ui/texts/constants'
42-
import { ChatItemButton, ChatItemFormItem, MynahUIDataModel } from '@aws/mynah-ui'
42+
import { ChatItemButton, ChatItemFormItem, MynahIconsType, MynahUIDataModel } from '@aws/mynah-ui'
4343
import { ChatHistoryManager } from '../../../storages/chatHistory'
44-
import { ToolUtils } from '../../../tools/toolUtils'
44+
import { ToolType, ToolUtils } from '../../../tools/toolUtils'
4545
import { ChatStream } from '../../../tools/chatStream'
4646

4747
export type StaticTextResponseType = 'quick-action-help' | 'onboarding-help' | 'transform' | 'help'
@@ -217,13 +217,7 @@ export class Messenger {
217217
if ('type' in tool) {
218218
const requiresAcceptance = ToolUtils.requiresAcceptance(tool)
219219

220-
const chatStream = new ChatStream(
221-
this,
222-
tabID,
223-
triggerID,
224-
toolUse.toolUseId,
225-
requiresAcceptance
226-
)
220+
const chatStream = new ChatStream(this, tabID, triggerID, toolUse, requiresAcceptance)
227221
ToolUtils.queueDescription(tool, chatStream)
228222

229223
if (!requiresAcceptance) {
@@ -432,15 +426,16 @@ export class Messenger {
432426
message: string,
433427
tabID: string,
434428
triggerID: string,
435-
toolUseId: string | undefined,
429+
toolUse: ToolUse | undefined,
436430
requiresAcceptance = false
437431
) {
438432
const buttons: ChatItemButton[] = []
439433
if (requiresAcceptance) {
440434
buttons.push({
435+
icon: 'play' as MynahIconsType,
441436
id: 'confirm-tool-use',
442-
text: 'Confirm',
443-
position: 'outside',
437+
status: 'clear',
438+
text: 'Run',
444439
})
445440
}
446441

@@ -453,12 +448,25 @@ export class Messenger {
453448
followUpsHeader: undefined,
454449
relatedSuggestions: undefined,
455450
triggerID,
456-
messageID: toolUseId ?? `tool-output`,
451+
messageID: toolUse?.toolUseId ?? `tool-output`,
457452
userIntent: undefined,
458453
codeBlockLanguage: undefined,
459454
contextList: undefined,
460455
canBeVoted: false,
461-
buttons,
456+
buttons: toolUse?.name === ToolType.ExecuteBash ? undefined : buttons,
457+
fullWidth: true,
458+
header:
459+
toolUse?.name === ToolType.ExecuteBash
460+
? {
461+
icon: 'code-block' as MynahIconsType,
462+
body: 'Terminal command',
463+
buttons: buttons,
464+
}
465+
: undefined,
466+
codeBlockActions:
467+
// eslint-disable-next-line unicorn/no-null
468+
toolUse?.name === ToolType.ExecuteBash ? { 'insert-to-cursor': null, copy: null } : undefined,
469+
padding: toolUse?.name === ToolType.ExecuteBash ? true : false,
462470
},
463471
tabID
464472
)

packages/core/src/codewhispererChat/tools/chatStream.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import { Writable } from 'stream'
77
import { getLogger } from '../../shared/logger/logger'
88
import { Messenger } from '../controllers/chat/messenger/messenger'
9+
import { ToolUse } from '@amzn/codewhisperer-streaming'
910

1011
/**
1112
* A writable stream that feeds each chunk/line to the chat UI.
@@ -18,7 +19,7 @@ export class ChatStream extends Writable {
1819
private readonly messenger: Messenger,
1920
private readonly tabID: string,
2021
private readonly triggerID: string,
21-
private readonly toolUseId: string | undefined,
22+
private readonly toolUse: ToolUse | undefined,
2223
private readonly requiresAcceptance = false,
2324
private readonly logger = getLogger('chatStream')
2425
) {
@@ -35,19 +36,20 @@ export class ChatStream extends Writable {
3536
this.accumulatedLogs,
3637
this.tabID,
3738
this.triggerID,
38-
this.toolUseId,
39+
this.toolUse,
3940
this.requiresAcceptance
4041
)
4142
callback()
4243
}
4344

4445
override _final(callback: (error?: Error | null) => void): void {
46+
this.logger.info(`this.accumulatedLogs: ${this.accumulatedLogs}`)
4547
if (this.accumulatedLogs.trim().length > 0) {
4648
this.messenger.sendPartialToolLog(
4749
this.accumulatedLogs,
4850
this.tabID,
4951
this.triggerID,
50-
this.toolUseId,
52+
this.toolUse,
5153
this.requiresAcceptance
5254
)
5355
}

packages/core/src/codewhispererChat/tools/executeBash.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,7 @@ export class ExecuteBash {
205205
}
206206

207207
public queueDescription(updates: Writable): void {
208-
updates.write(`I will run the following shell command:\n`)
209-
updates.write('```bash\n' + this.command + '\n```')
208+
updates.write(`\n\`\`\`shell\n${this.command}\n\`\`\`\n`)
210209
updates.end()
211210
}
212211
}

packages/core/src/codewhispererChat/view/connector/connector.ts

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,17 @@ import { Timestamp } from 'aws-sdk/clients/apigateway'
77
import { MessagePublisher } from '../../../amazonq/messages/messagePublisher'
88
import { EditorContextCommandType } from '../../commands/registerCommands'
99
import { AuthFollowUpType } from '../../../amazonq/auth/model'
10-
import { ChatItemButton, ChatItemContent, ChatItemFormItem, MynahUIDataModel, QuickActionCommand } from '@aws/mynah-ui'
10+
import {
11+
ChatItemButton,
12+
ChatItemContent,
13+
ChatItemFormItem,
14+
CodeBlockActions,
15+
MynahIcons,
16+
MynahIconsType,
17+
MynahUIDataModel,
18+
QuickActionCommand,
19+
Status,
20+
} from '@aws/mynah-ui'
1121
import { DocumentReference } from '../../controllers/chat/model'
1222

1323
class UiMessage {
@@ -212,6 +222,19 @@ export interface ChatMessageProps {
212222
readonly buttons?: ChatItemButton[]
213223
readonly fileList?: ChatItemContent['fileList']
214224
readonly canBeVoted?: boolean
225+
readonly codeBlockActions?: CodeBlockActions | null
226+
readonly header?:
227+
| (ChatItemContent & {
228+
icon?: MynahIcons | MynahIconsType
229+
status?: {
230+
status?: Status
231+
icon?: MynahIcons | MynahIconsType
232+
text?: string
233+
}
234+
})
235+
| null
236+
readonly fullWidth?: boolean
237+
readonly padding?: boolean
215238
}
216239

217240
export class ChatMessage extends UiMessage {
@@ -232,6 +255,19 @@ export class ChatMessage extends UiMessage {
232255
readonly fileList?: ChatItemContent['fileList']
233256
readonly canBeVoted?: boolean = false
234257
override type = 'chatMessage'
258+
readonly codeBlockActions?: CodeBlockActions | null
259+
readonly header?:
260+
| (ChatItemContent & {
261+
icon?: MynahIcons | MynahIconsType
262+
status?: {
263+
status?: Status
264+
icon?: MynahIcons | MynahIconsType
265+
text?: string
266+
}
267+
})
268+
| null
269+
readonly fullWidth?: boolean
270+
readonly padding?: boolean
235271

236272
constructor(props: ChatMessageProps, tabID: string) {
237273
super(tabID)
@@ -250,6 +286,10 @@ export class ChatMessage extends UiMessage {
250286
this.buttons = props.buttons
251287
this.fileList = props.fileList
252288
this.canBeVoted = props.canBeVoted
289+
this.codeBlockActions = props.codeBlockActions
290+
this.header = props.header
291+
this.fullWidth = props.fullWidth
292+
this.padding = props.padding
253293
}
254294
}
255295

packages/core/src/codewhispererChat/view/messages/messageListener.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export class UIMessageListener {
3838
case 'clear':
3939
case 'transform':
4040
case 'chat-prompt':
41+
// listen here
4142
this.processChatMessage(msg)
4243
break
4344
case 'new-tab-was-created':
@@ -249,6 +250,7 @@ export class UIMessageListener {
249250
})
250251
}
251252

253+
// na yue create someting similar -> web view to mynah
252254
private processChatMessage(msg: any) {
253255
this.chatControllerMessagePublishers.processPromptChatMessage.publish({
254256
message: msg.chatMessage,

0 commit comments

Comments
 (0)