Skip to content

fix(amazonq): /help does nothing in welcome page v2 #5588

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"type" : "bugfix",
"description" : "/help does nothing in Q welcome page"
}
19 changes: 16 additions & 3 deletions plugins/amazonq/mynah-ui/src/mynah-ui/ui/connector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export interface ConnectorProps {
sendMessageToExtension: (message: ExtensionMessage) => void
onMessageReceived?: (tabID: string, messageData: any, needToShowAPIDocsTab: boolean) => void
onChatAnswerReceived?: (tabID: string, message: ChatItem) => void
onChatAnswerUpdated?: (tabID: string, message:ChatItem) => void
onChatAnswerUpdated?: (tabID: string, message: ChatItem) => void
onCodeTransformChatDisabled: (tabID: string) => void
onCodeTransformMessageReceived: (
tabID: string,
Expand Down Expand Up @@ -224,6 +224,19 @@ export class Connector {
case 'codescan':
this.codeScanChatConnector.help(tabID)
break
case 'welcome':
this.tabsStorage.updateTabTypeFromUnknown(tabID, 'cwc')
this.tabsStorage.updateTabContent(tabID, {
tabHeaderDetails: void 0,
compactMode: false,
tabBackground: false,
promptInputText: '',
promptInputLabel: void 0,
chatItems: [],
tabTitle: 'Chat',
})
this.cwChatConnector.help(tabID)
break
Comment on lines +227 to +239
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}
}

Expand Down Expand Up @@ -594,7 +607,7 @@ export class Connector {
this.cwChatConnector.onSendFeedback(tabId, feedbackPayload)
break
case 'codetest':
this.codeTestChatConnector.sendFeedback(tabId,feedbackPayload)
this.codeTestChatConnector.sendFeedback(tabId, feedbackPayload)
break
}
}
Expand All @@ -608,7 +621,7 @@ export class Connector {
this.featureDevChatConnector.onChatItemVoted(tabId, messageId, vote)
break
case 'codetest' :
this.codeTestChatConnector.onChatItemVoted(tabId,messageId,vote)
this.codeTestChatConnector.onChatItemVoted(tabId, messageId, vote)
break
}
}
Expand Down
3 changes: 3 additions & 0 deletions plugins/amazonq/mynah-ui/src/mynah-ui/ui/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ export const createMynahUI = (
promptInputPlaceholder: 'Session ended.',
})
},
tabMutator: (tabId, data) => {
mynahUI.updateStore(tabId, data)
}
})
// Adding the first tab as CWC tab
tabsStorage.addTab({
Expand Down
17 changes: 16 additions & 1 deletion plugins/amazonq/mynah-ui/src/mynah-ui/ui/storages/tabsStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
* SPDX-License-Identifier: Apache-2.0
*/

import { MynahUIDataModel } from "@aws/mynah-ui-chat";

export type TabStatus = 'free' | 'busy' | 'dead'
const TabTypes = [
'cwc',
Expand Down Expand Up @@ -53,9 +55,11 @@ export class TabsStorage {
private lastSelectedTab: Tab | undefined = undefined
private tabActivityTimers: Record<string, ReturnType<typeof setTimeout>> = {}
private onTabTimeout?: (tabId: string) => void
private tabMutator?: (tabId: string, data: MynahUIDataModel) => void

constructor(props?: { onTabTimeout: (tabId: string) => void }) {
constructor(props?: { onTabTimeout: (tabId: string) => void, tabMutator: (tabId: string, data: MynahUIDataModel) => void }) {
this.onTabTimeout = props?.onTabTimeout
this.tabMutator = props?.tabMutator
}

public addTab(tab: Tab) {
Expand Down Expand Up @@ -102,6 +106,17 @@ export class TabsStorage {
this.tabs.set(tabID, currentTabValue)
}

public updateTabContent(tabId: string, dataModel: MynahUIDataModel) {
const currentTabValue = this.tabs.get(tabId)
if (currentTabValue === undefined || currentTabValue.status === 'dead') {
return
}

if (this.tabMutator) {
this.tabMutator(tabId, dataModel)
}
}

public updateTabTypeFromUnknown(tabID: string, tabType: TabType) {
const currentTabValue = this.tabs.get(tabID)
if (
Expand Down
Loading