Skip to content

Commit 6a544cf

Browse files
Merge master into feature/ui-e2e-tests
2 parents ebc2dd8 + 89a455c commit 6a544cf

File tree

8 files changed

+115
-14
lines changed

8 files changed

+115
-14
lines changed

docs/lsp.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ sequenceDiagram
2525
```
2626

2727
## Language Server Debugging
28+
If you want to connect a local version of language-servers to aws-toolkit-vscode, follow these steps:
2829

2930
1. Clone https://github.com/aws/language-servers.git and set it up in the same workspace as this project by cmd+shift+p and "add folder to workspace" and selecting the language-servers folder that you just cloned. Your VS code folder structure should look like below.
3031

@@ -55,6 +56,43 @@ sequenceDiagram
5556
5. Use the `Launch LSP with Debugging` configuration and set breakpoints in VSCode or the language server, Once you run "Launch LSP with Debugging" a new window should start, wait for the plugin to show up there. Then go to the run menu again and run "Attach to Language Server (amazonq)" after this you should be able to add breakpoints in the LSP code.
5657
6. (Optional): Enable `"amazonq.trace.server": "on"` or `"amazonq.trace.server": "verbose"` in your VSCode settings to view detailed log messages sent to/from the language server. These log messages will show up in the "Amazon Q Language Server" output channel
5758
59+
### Breakpoints Work-Around
60+
If the breakpoints in your language-servers project remain greyed out and do not trigger when you run `Launch LSP with Debugging`, your debugger may be attaching to the language server before it has launched. You can follow the work-around below to avoid this problem. If anyone fixes this issue, please remove this section.
61+
1. Set your breakpoints and click `Launch LSP with Debugging`
62+
2. Once the debugging session has started, click `Launch LSP with Debugging` again, then `Cancel` on any pop-ups that appear
63+
3. On the debug panel, click `Attach to Language Server (amazonq)` next to the red stop button
64+
4. Click `Launch LSP with Debugging` again, then `Cancel` on any pop-ups that appear
65+
66+
## Language Server Runtimes Debugging
67+
If you want to connect a local version of language-server-runtimes to aws-toolkit-vscode, follow these steps:
68+
69+
1. Clone https://github.com/aws/language-server-runtimes.git and set it up in the same workspace as this project by cmd+shift+p and "add folder to workspace" and selecting the language-server-runtimes folder that you just cloned. Your VS code folder structure should look like below.
70+
71+
```
72+
/aws-toolkit-vscode
73+
/toolkit
74+
/core
75+
/amazonq
76+
/language-server-runtimes
77+
```
78+
2. Inside of the language-server-runtimes project run:
79+
```
80+
npm install
81+
npm run compile
82+
cd runtimes
83+
npm run prepub
84+
cd out
85+
npm link
86+
cd ../../types
87+
npm link
88+
```
89+
If you get an error running `npm run prepub`, you can instead run `npm run prepub:copyFiles` to skip cleaning and testing.
90+
3. Inside of aws-toolkit-vscode run:
91+
```
92+
npm install
93+
npm link @aws/language-server-runtimes @aws/language-server-runtimes-types
94+
```
95+
5896
## Amazon Q Inline Activation
5997
6098
- In order to get inline completion working you must open a supported file type defined in CodewhispererInlineCompletionLanguages in `packages/amazonq/src/app/inline/completion.ts`

package-lock.json

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/amazonq/src/app/inline/completion.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ import {
3535
inlineCompletionsDebounceDelay,
3636
noInlineSuggestionsMsg,
3737
ReferenceInlineProvider,
38+
getDiagnosticsDifferences,
39+
getDiagnosticsOfCurrentFile,
40+
toIdeDiagnostics,
3841
} from 'aws-core-vscode/codewhisperer'
3942
import { LineTracker } from './stateTracker/lineTracker'
4043
import { InlineTutorialAnnotation } from './tutorials/inlineTutorialAnnotation'
@@ -116,6 +119,13 @@ export class InlineCompletionManager implements Disposable {
116119
firstCompletionDisplayLatency?: number
117120
) => {
118121
// TODO: also log the seen state for other suggestions in session
122+
// Calculate timing metrics before diagnostic delay
123+
const totalSessionDisplayTime = performance.now() - requestStartTime
124+
await sleep(1000)
125+
const diagnosticDiff = getDiagnosticsDifferences(
126+
this.sessionManager.getActiveSession()?.diagnosticsBeforeAccept,
127+
getDiagnosticsOfCurrentFile()
128+
)
119129
const params: LogInlineCompletionSessionResultsParams = {
120130
sessionId: sessionId,
121131
completionSessionResult: {
@@ -125,8 +135,10 @@ export class InlineCompletionManager implements Disposable {
125135
discarded: false,
126136
},
127137
},
128-
totalSessionDisplayTime: Date.now() - requestStartTime,
138+
totalSessionDisplayTime: totalSessionDisplayTime,
129139
firstCompletionDisplayLatency: firstCompletionDisplayLatency,
140+
addedDiagnostics: diagnosticDiff.added.map((it) => toIdeDiagnostics(it)),
141+
removedDiagnostics: diagnosticDiff.removed.map((it) => toIdeDiagnostics(it)),
130142
}
131143
this.languageClient.sendNotification(this.logSessionResultMessageName, params)
132144
this.disposable.dispose()

packages/amazonq/src/app/inline/sessionManager.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*/
55
import * as vscode from 'vscode'
66
import { InlineCompletionItemWithReferences } from '@aws/language-server-runtimes-types'
7+
import { FileDiagnostic, getDiagnosticsOfCurrentFile } from 'aws-core-vscode/codewhisperer'
78

89
// TODO: add more needed data to the session interface
910
export interface CodeWhispererSession {
@@ -14,6 +15,7 @@ export interface CodeWhispererSession {
1415
requestStartTime: number
1516
firstCompletionDisplayLatency?: number
1617
startPosition: vscode.Position
18+
diagnosticsBeforeAccept: FileDiagnostic | undefined
1719
// partialResultToken for the next trigger if user accepts an EDITS suggestion
1820
editsStreakPartialResultToken?: number | string
1921
}
@@ -31,13 +33,15 @@ export class SessionManager {
3133
startPosition: vscode.Position,
3234
firstCompletionDisplayLatency?: number
3335
) {
36+
const diagnosticsBeforeAccept = getDiagnosticsOfCurrentFile()
3437
this.activeSession = {
3538
sessionId,
3639
suggestions,
3740
isRequestInProgress: true,
3841
requestStartTime,
3942
startPosition,
4043
firstCompletionDisplayLatency,
44+
diagnosticsBeforeAccept,
4145
}
4246
}
4347

packages/core/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -471,8 +471,8 @@
471471
"@aws-sdk/types": "^3.13.1",
472472
"@aws/chat-client": "^0.1.4",
473473
"@aws/chat-client-ui-types": "^0.1.47",
474-
"@aws/language-server-runtimes": "^0.2.99",
475-
"@aws/language-server-runtimes-types": "^0.1.41",
474+
"@aws/language-server-runtimes": "^0.2.101",
475+
"@aws/language-server-runtimes-types": "^0.1.42",
476476
"@cspotcode/source-map-support": "^0.8.1",
477477
"@sinonjs/fake-timers": "^10.0.2",
478478
"@types/adm-zip": "^0.4.34",

packages/core/src/feedback/vue/submitFeedback.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ export class FeedbackWebview extends VueWebview {
4141
return 'Choose a reaction (smile/frown)'
4242
}
4343

44+
if (message.comment.length < 188) {
45+
return 'Please add atleast 100 characters in the template describing your issue.'
46+
}
47+
4448
if (this.commentData) {
4549
message.comment = `${message.comment}\n\n${this.commentData}`
4650
}

packages/core/src/feedback/vue/submitFeedback.vue

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,26 @@
3434
>.</em
3535
>
3636
</div>
37+
<div style="margin-top: 10px">
38+
<em>For helpful feedback, please include:</em>
39+
<ul style="margin-top: 5px; margin-bottom: 5px">
40+
<li>
41+
<em><strong>Issue:</strong> A brief summary of the issue or suggestion</em>
42+
</li>
43+
<li>
44+
<em
45+
><strong>Reproduction Steps:</strong> Clear steps to reproduce the issue (if
46+
applicable)</em
47+
>
48+
</li>
49+
<li>
50+
<em
51+
><strong>Expected vs. Actual:</strong> What you expected and what actually
52+
happened</em
53+
>
54+
</li>
55+
</ul>
56+
</div>
3757
<br />
3858
<div>
3959
<em>
@@ -66,7 +86,16 @@ const client = WebviewClientFactory.create<FeedbackWebview>()
6686
export default defineComponent({
6787
data() {
6888
return {
69-
comment: '',
89+
comment: `Issue:
90+
91+
Reproduction Steps:
92+
1.
93+
2.
94+
3.
95+
96+
Expected Behavior:
97+
98+
Actual Behavior: `,
7099
sentiment: '',
71100
isSubmitting: false,
72101
error: '',

packages/core/src/test/feedback/commands/submitFeedbackListener.test.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,14 @@ import { FeedbackWebview } from '../../../feedback/vue/submitFeedback'
1010
import sinon from 'sinon'
1111
import { waitUntil } from '../../../shared'
1212

13-
const comment = 'comment'
13+
const comment =
14+
'This is a detailed feedback comment that meets the minimum length requirement. ' +
15+
'It includes specific information about the issue, steps to reproduce, expected behavior, and actual behavior. ' +
16+
'This comment is long enough to pass the 188 character validation rule.'
1417
const sentiment = 'Positive'
1518
const message = { command: 'submitFeedback', comment: comment, sentiment: sentiment }
19+
const shortComment = 'This is a short comment'
20+
const shortMessage = { command: 'submitFeedback', comment: shortComment, sentiment: sentiment }
1621

1722
describe('submitFeedbackListener', function () {
1823
let mockTelemetry: TelemetryService
@@ -47,5 +52,14 @@ describe('submitFeedbackListener', function () {
4752
const result = await webview.submit(message)
4853
assert.strictEqual(result, expectedError)
4954
})
55+
56+
it(`validates ${productName} feedback comment length is at least 188 characters`, async function () {
57+
const postStub = sinon.stub()
58+
mockTelemetry.postFeedback = postStub
59+
const webview = new FeedbackWebview(mockTelemetry, productName)
60+
const result = await webview.submit(shortMessage)
61+
assert.strictEqual(result, 'Please add atleast 100 characters in the template describing your issue.')
62+
assert.strictEqual(postStub.called, false, 'postFeedback should not be called for short comments')
63+
})
5064
}
5165
})

0 commit comments

Comments
 (0)