Skip to content

Commit

Permalink
Merge branch 'main' into samgst/updateNotifEndpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
samgst-amazon authored Dec 6, 2024
2 parents 12e50ee + 370a245 commit 339d14f
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import com.intellij.openapi.util.Disposer
import com.intellij.ui.jcef.JBCefJSQuery
import org.cef.CefApp
import software.aws.toolkits.jetbrains.services.amazonq.util.createBrowser
import software.aws.toolkits.jetbrains.settings.MeetQSettings

/*
Displays the web view for the Amazon Q tool window
Expand Down Expand Up @@ -85,6 +86,7 @@ class Browser(parent: Disposable) : Disposable {
$postMessageToJavaJsCode
}
},
${MeetQSettings.getInstance().reinvent2024OnboardingCount < MAX_ONBOARDING_PAGE_COUNT},
$isFeatureDevAvailable, // whether /dev is available
$isCodeTransformAvailable, // whether /transform is available
$isDocAvailable, // whether /doc is available
Expand All @@ -110,5 +112,6 @@ class Browser(parent: Disposable) : Disposable {

companion object {
private const val WEB_SCRIPT_URI = "http://mynah/js/mynah-ui.js"
private const val MAX_ONBOARDING_PAGE_COUNT = 3
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package software.aws.toolkits.jetbrains.services.amazonq.webview

import com.intellij.ide.BrowserUtil
import com.intellij.ide.util.RunOnceUtil
import com.intellij.ui.jcef.JBCefJSQuery.Response
import kotlinx.coroutines.CompletableDeferred
import kotlinx.coroutines.channels.awaitClose
Expand All @@ -22,6 +23,7 @@ import software.aws.toolkits.jetbrains.services.amazonq.util.command
import software.aws.toolkits.jetbrains.services.amazonq.util.tabType
import software.aws.toolkits.jetbrains.services.amazonq.webview.theme.AmazonQTheme
import software.aws.toolkits.jetbrains.services.amazonq.webview.theme.ThemeBrowserAdapter
import software.aws.toolkits.jetbrains.settings.MeetQSettings
import software.aws.toolkits.telemetry.Telemetry
import java.util.function.Function

Expand All @@ -40,7 +42,12 @@ class BrowserConnector(
.onEach { json ->
val node = serializer.toNode(json)
when (node.command) {
"ui-is-ready" -> uiReady.complete(true)
"ui-is-ready" -> {
uiReady.complete(true)
RunOnceUtil.runOnceForApp("AmazonQ-UI-Ready") {
MeetQSettings.getInstance().reinvent2024OnboardingCount += 1
}
}

// some weird issue preventing deserialization from working
"open-user-guide" -> {
Expand Down
18 changes: 16 additions & 2 deletions plugins/amazonq/mynah-ui/src/mynah-ui/ui/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import {createClickTelemetry, createOpenAgentTelemetry} from "./telemetry/action

export const createMynahUI = (
ideApi: any,
showWelcomePage: boolean,
featureDevInitEnabled: boolean,
codeTransformInitEnabled: boolean,
docInitEnabled: boolean,
Expand Down Expand Up @@ -61,7 +62,7 @@ export const createMynahUI = (
tabsStorage.addTab({
id: 'tab-1',
status: 'free',
type: 'cwc',
type: showWelcomePage ? 'welcome' : 'cwc',
isSelected: true,
})

Expand Down Expand Up @@ -598,6 +599,17 @@ export const createMynahUI = (
}
}

if (tabsStorage.getTab(tabID)?.type === 'welcome') {
mynahUI.updateStore(tabID, {
tabHeaderDetails: void 0,
compactMode: false,
tabBackground: false,
promptInputText: '',
promptInputLabel: void 0,
chatItems: [],
})
}

if (prompt.command !== undefined && prompt.command.trim() !== '') {
quickActionHandler.handleCommand(prompt, tabID, eventId)

Expand Down Expand Up @@ -678,7 +690,9 @@ export const createMynahUI = (
tabs: {
'tab-1': {
isSelected: true,
store: welcomeScreenTabData(tabDataGenerator).store,
store: showWelcomePage
? welcomeScreenTabData(tabDataGenerator).store
: tabDataGenerator.getTabData('cwc', true),
},
},
onInBodyButtonClicked: (tabId, messageId, action, eventId) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,17 @@ class MeetQSettings : PersistentStateComponent<MeetQSettingsConfiguration> {
state.shouldDisplayPage = value
}

var reinvent2024OnboardingCount: Int
get() = state.reinvent2024OnboardingCount
set(value) {
state.reinvent2024OnboardingCount = value
}

companion object {
fun getInstance(): MeetQSettings = service()
}
}
data class MeetQSettingsConfiguration(
var shouldDisplayPage: Boolean = true,
var reinvent2024OnboardingCount: Int = 0,
)

0 comments on commit 339d14f

Please sign in to comment.