Skip to content

Commit 2b8ecf6

Browse files
Merge master into feature/q-utg
2 parents 143f9df + 621622b commit 2b8ecf6

File tree

2 files changed

+59
-40
lines changed

2 files changed

+59
-40
lines changed

packages/amazonq/src/lsp/chat/webviewProvider.ts

Lines changed: 51 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
Uri,
1414
} from 'vscode'
1515
import { LanguageServerResolver } from 'aws-core-vscode/shared'
16+
import { QuickActionCommandGroup } from '@aws/mynah-ui'
1617

1718
export class AmazonQChatViewProvider implements WebviewViewProvider {
1819
public static readonly viewType = 'aws.amazonq.AmazonQChatView'
@@ -21,6 +22,24 @@ export class AmazonQChatViewProvider implements WebviewViewProvider {
2122

2223
webview: Webview | undefined
2324

25+
private readonly quickActionCommands: QuickActionCommandGroup[] = [
26+
{
27+
groupName: 'Quick Actions',
28+
commands: [
29+
{
30+
command: '/help',
31+
icon: 'help',
32+
description: 'Learn more about Amazon Q',
33+
},
34+
{
35+
command: '/clear',
36+
icon: 'trash',
37+
description: 'Clear this session',
38+
},
39+
],
40+
},
41+
]
42+
2443
constructor(private readonly mynahUIPath: string) {}
2544

2645
public resolveWebviewView(webviewView: WebviewView, context: WebviewViewResolveContext, _token: CancellationToken) {
@@ -34,40 +53,40 @@ export class AmazonQChatViewProvider implements WebviewViewProvider {
3453
}
3554

3655
const uiPath = webviewView.webview.asWebviewUri(Uri.parse(this.mynahUIPath)).toString()
37-
webviewView.webview.html = getWebviewContent(uiPath)
56+
webviewView.webview.html = this.getWebviewContent(uiPath)
3857

3958
this.onDidResolveWebviewEmitter.fire()
4059
}
41-
}
4260

43-
function getWebviewContent(mynahUIPath: string) {
44-
return `
45-
<!DOCTYPE html>
46-
<html lang="en">
47-
<head>
48-
<meta charset="UTF-8">
49-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
50-
<title>Chat</title>
51-
<style>
52-
body,
53-
html {
54-
background-color: var(--mynah-color-bg);
55-
color: var(--mynah-color-text-default);
56-
height: 100%;
57-
width: 100%;
58-
overflow: hidden;
59-
margin: 0;
60-
padding: 0;
61-
}
62-
</style>
63-
</head>
64-
<body>
65-
<script type="text/javascript" src="${mynahUIPath.toString()}" defer onload="init()"></script>
66-
<script type="text/javascript">
67-
const init = () => {
68-
amazonQChat.createChat(acquireVsCodeApi(), {disclaimerAcknowledged: false});
69-
}
70-
</script>
71-
</body>
72-
</html>`
61+
private getWebviewContent(mynahUIPath: string) {
62+
return `
63+
<!DOCTYPE html>
64+
<html lang="en">
65+
<head>
66+
<meta charset="UTF-8">
67+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
68+
<title>Chat</title>
69+
<style>
70+
body,
71+
html {
72+
background-color: var(--mynah-color-bg);
73+
color: var(--mynah-color-text-default);
74+
height: 100%;
75+
width: 100%;
76+
overflow: hidden;
77+
margin: 0;
78+
padding: 0;
79+
}
80+
</style>
81+
</head>
82+
<body>
83+
<script type="text/javascript" src="${mynahUIPath.toString()}" defer onload="init()"></script>
84+
<script type="text/javascript">
85+
const init = () => {
86+
amazonQChat.createChat(acquireVsCodeApi(), { disclaimerAcknowledged: false, quickActionCommands: ${JSON.stringify(this.quickActionCommands)}});
87+
}
88+
</script>
89+
</body>
90+
</html>`
91+
}
7392
}

packages/amazonq/src/lsp/client.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,14 +93,7 @@ export async function startLanguageServer(
9393
const auth = new AmazonQLspAuth(client)
9494

9595
return client.onReady().then(async () => {
96-
await auth.init()
97-
const inlineManager = new InlineCompletionManager(client)
98-
inlineManager.registerInlineCompletion()
99-
if (Experiments.instance.get('amazonqChatLSP', false)) {
100-
activate(client, encryptionKey, resourcePaths.mynahUI)
101-
}
102-
103-
// Request handler for when the server wants to know about the clients auth connnection
96+
// Request handler for when the server wants to know about the clients auth connnection. Must be registered before the initial auth init call
10497
client.onRequest<ConnectionMetadata, Error>(notificationTypes.getConnectionMetadata.method, () => {
10598
return {
10699
sso: {
@@ -109,6 +102,13 @@ export async function startLanguageServer(
109102
}
110103
})
111104

105+
await auth.init()
106+
const inlineManager = new InlineCompletionManager(client)
107+
inlineManager.registerInlineCompletion()
108+
if (Experiments.instance.get('amazonqChatLSP', false)) {
109+
activate(client, encryptionKey, resourcePaths.mynahUI)
110+
}
111+
112112
// Temporary code for pen test. Will be removed when we switch to the real flare auth
113113
const authInterval = setInterval(async () => {
114114
try {

0 commit comments

Comments
 (0)