Skip to content

Commit

Permalink
feat: upgrade mynah-ui to latest version aws#4440
Browse files Browse the repository at this point in the history
Problem:
To support future chat features, it is necessary to update the dependent library
responsible for rendering the chat UI, `mynah-ui`.

The only breaking change that affects this codebase from upgrading from `3.x` to
`4.x` is that `ChatItemFollowUp` [is renamed to](aws/mynah-ui@631d87a)
`ChatItemAction`

Testing:
Manually tested Q chat and `/dev` functionality, paying particular attention to
behavior around the follow-up items 

`npm run testE2E` passed
  • Loading branch information
JuliaABurch authored Feb 15, 2024
1 parent 6f26948 commit 66cc926
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 24 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/toolkit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4340,7 +4340,7 @@
"@aws-sdk/property-provider": "3.46.0",
"@aws-sdk/smithy-client": "^3.46.0",
"@aws-sdk/util-arn-parser": "^3.46.0",
"@aws/mynah-ui": "3.3.3",
"@aws/mynah-ui": "4.0.3",
"@gerhobbelt/gitignore-parser": "^0.2.0-9",
"@iarna/toml": "^2.2.5",
"@smithy/shared-ini-file-loader": "^2.2.8",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

import { ChatItemFollowUp } from '@aws/mynah-ui'
import { ChatItemAction } from '@aws/mynah-ui'
import { ExtensionMessage } from '../commands'
import { AuthFollowUpType } from '../followUps/generator'

Expand Down Expand Up @@ -32,7 +32,7 @@ export class Connector {
this.onWelcomeFollowUpClicked = props.onWelcomeFollowUpClicked
}

followUpClicked = (tabID: string, followUp: ChatItemFollowUp): void => {
followUpClicked = (tabID: string, followUp: ChatItemAction): void => {
if (followUp.type !== undefined && followUp.type === 'continue-to-chat') {
this.onWelcomeFollowUpClicked(tabID, followUp.type)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

import { ChatItem, ChatItemFollowUp, ChatItemType, FeedbackPayload } from '@aws/mynah-ui'
import { ChatItem, ChatItemAction, ChatItemType, FeedbackPayload } from '@aws/mynah-ui'
import { ExtensionMessage } from '../commands'
import { CodeReference } from './amazonqCommonsConnector'
import { TabOpenType, TabsStorage } from '../storages/tabsStorage'
Expand Down Expand Up @@ -68,7 +68,7 @@ export class Connector {
})
}

followUpClicked = (tabID: string, messageId: string, followUp: ChatItemFollowUp): void => {
followUpClicked = (tabID: string, messageId: string, followUp: ChatItemAction): void => {
this.sendMessageToExtension({
command: 'follow-up-was-clicked',
followUp,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

import { ChatItem, ChatItemFollowUp, ChatItemType, FeedbackPayload } from '@aws/mynah-ui'
import { ChatItem, ChatItemAction, ChatItemType, FeedbackPayload } from '@aws/mynah-ui'
import { ExtensionMessage } from '../commands'
import { TabType, TabsStorage } from '../storages/tabsStorage'
import { CodeReference } from './amazonqCommonsConnector'
Expand Down Expand Up @@ -93,7 +93,7 @@ export class Connector {
})
}

followUpClicked = (tabID: string, followUp: ChatItemFollowUp): void => {
followUpClicked = (tabID: string, followUp: ChatItemAction): void => {
this.sendMessageToExtension({
command: 'follow-up-was-clicked',
followUp,
Expand Down
4 changes: 2 additions & 2 deletions packages/toolkit/src/amazonq/webview/ui/connector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

import { ChatItem, ChatItemFollowUp, FeedbackPayload, Engagement } from '@aws/mynah-ui'
import { ChatItem, FeedbackPayload, Engagement, ChatItemAction } from '@aws/mynah-ui'
import { Connector as CWChatConnector } from './apps/cwChatConnector'
import { Connector as FeatureDevChatConnector } from './apps/featureDevChatConnector'
import { Connector as AmazonQCommonsConnector } from './apps/amazonqCommonsConnector'
Expand Down Expand Up @@ -280,7 +280,7 @@ export class Connector {
}
}

onFollowUpClicked = (tabID: string, messageId: string, followUp: ChatItemFollowUp): void => {
onFollowUpClicked = (tabID: string, messageId: string, followUp: ChatItemAction): void => {
switch (this.tabsStorage.getTab(tabID)?.type) {
// TODO: We cannot rely on the tabType here,
// It can come up at a later point depending on the future UX designs,
Expand Down
4 changes: 2 additions & 2 deletions packages/toolkit/src/amazonq/webview/ui/followUps/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

import { ChatItemFollowUp, ChatItemType, MynahUI } from '@aws/mynah-ui'
import { ChatItemAction, ChatItemType, MynahUI } from '@aws/mynah-ui'
import { Connector } from '../connector'
import { TabsStorage } from '../storages/tabsStorage'
import { WelcomeFollowupType } from '../apps/amazonqCommonsConnector'
Expand All @@ -26,7 +26,7 @@ export class FollowUpInteractionHandler {
this.tabsStorage = props.tabsStorage
}

public onFollowUpClicked(tabID: string, messageId: string, followUp: ChatItemFollowUp) {
public onFollowUpClicked(tabID: string, messageId: string, followUp: ChatItemAction) {
if (
followUp.type !== undefined &&
['full-auth', 're-auth', 'missing_scopes', 'use-supported-auth'].includes(followUp.type)
Expand Down
4 changes: 2 additions & 2 deletions packages/toolkit/src/amazonq/webview/ui/followUps/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
* SPDX-License-Identifier: Apache-2.0
*/

import { ChatItemFollowUp } from '@aws/mynah-ui'
import { ChatItemAction } from '@aws/mynah-ui'

export interface FollowUpsBlock {
text?: string
options?: ChatItemFollowUp[]
options?: ChatItemAction[]
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

import { ChatItemFollowUp } from '@aws/mynah-ui'
import { ChatItemAction } from '@aws/mynah-ui'
import { existsSync } from 'fs'
import * as path from 'path'
import * as vscode from 'vscode'
Expand Down Expand Up @@ -266,7 +266,7 @@ export class FeatureDevController {
}
}

private getFollowUpOptions(phase: SessionStatePhase | undefined): ChatItemFollowUp[] {
private getFollowUpOptions(phase: SessionStatePhase | undefined): ChatItemAction[] {
switch (phase) {
case 'Approach':
return [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ import {
OpenNewTabMessage,
} from '../../../views/connector/connector'
import { AppToWebViewMessageDispatcher } from '../../../views/connector/connector'
import { ChatItemFollowUp } from '@aws/mynah-ui'
import { ChatItemAction } from '@aws/mynah-ui'

export class Messenger {
public constructor(private readonly dispatcher: AppToWebViewMessageDispatcher) {}

public sendAnswer(params: {
message?: string
type: 'answer' | 'answer-part' | 'answer-stream' | 'system-prompt'
followUps?: ChatItemFollowUp[]
followUps?: ChatItemAction[]
tabID: string
canBeVoted?: boolean
}) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { AuthFollowUpType } from '../../../amazonq/auth/model'
import { MessagePublisher } from '../../../amazonq/messages/messagePublisher'
import { featureDevChat } from '../../constants'
import { ChatItemType } from '../../models'
import { ChatItemFollowUp, SourceLink } from '@aws/mynah-ui'
import { ChatItemAction, SourceLink } from '@aws/mynah-ui'

class UiMessage {
readonly time: number = Date.now()
Expand Down Expand Up @@ -95,15 +95,15 @@ export class AuthNeededException extends UiMessage {
export interface ChatMessageProps {
readonly message: string | undefined
readonly messageType: ChatItemType
readonly followUps: ChatItemFollowUp[] | undefined
readonly followUps: ChatItemAction[] | undefined
readonly relatedSuggestions: SourceLink[] | undefined
readonly canBeVoted: boolean
}

export class ChatMessage extends UiMessage {
readonly message: string | undefined
readonly messageType: ChatItemType
readonly followUps: ChatItemFollowUp[] | undefined
readonly followUps: ChatItemAction[] | undefined
readonly relatedSuggestions: SourceLink[] | undefined
readonly canBeVoted: boolean
readonly requestID!: string
Expand Down

0 comments on commit 66cc926

Please sign in to comment.