Skip to content

Commit 96ced1d

Browse files
authored
Merge branch 'feature/code-diff' into feature/StreamingDiffAnimation
2 parents 88bde6f + 7c3e39b commit 96ced1d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+2561
-79
lines changed

package-lock.json

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "Feature",
3+
"description": "/transform: Show transformation history in Transformation Hub and allow users to resume jobs"
4+
}

packages/amazonq/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -746,7 +746,7 @@
746746
},
747747
{
748748
"command": "aws.amazonq.showHistoryInHub",
749-
"title": "%AWS.command.q.transform.viewJobStatus%"
749+
"title": "%AWS.command.q.transform.viewJobHistory%"
750750
},
751751
{
752752
"command": "aws.amazonq.selectCustomization",

packages/amazonq/src/app/inline/EditRendering/displayImage.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,8 @@ export async function displaySvgDecoration(
352352
discarded: false,
353353
},
354354
},
355+
totalSessionDisplayTime: Date.now() - session.requestStartTime,
356+
firstCompletionDisplayLatency: session.firstCompletionDisplayLatency,
355357
isInlineEdit: true,
356358
}
357359
languageClient.sendNotification('aws/logInlineCompletionSessionResults', params)

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

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,11 @@ export class InlineCompletionManager implements Disposable {
170170
const onInlineRejection = async () => {
171171
try {
172172
vsCodeState.isCodeWhispererEditing = true
173-
if (this.sessionManager.getActiveSession() === undefined) {
173+
const session = this.sessionManager.getActiveSession()
174+
if (session === undefined) {
174175
return
175176
}
176-
const requestStartTime = this.sessionManager.getActiveSession()!.requestStartTime
177+
const requestStartTime = session.requestStartTime
177178
const totalSessionDisplayTime = performance.now() - requestStartTime
178179
await commands.executeCommand('editor.action.inlineSuggest.hide')
179180
// TODO: also log the seen state for other suggestions in session
@@ -182,9 +183,9 @@ export class InlineCompletionManager implements Disposable {
182183
CodeWhispererConstants.platformLanguageIds,
183184
this.inlineCompletionProvider
184185
)
185-
const sessionId = this.sessionManager.getActiveSession()?.sessionId
186+
const sessionId = session.sessionId
186187
const itemId = this.sessionManager.getActiveRecommendation()[0]?.itemId
187-
if (!sessionId || !itemId) {
188+
if (!itemId) {
188189
return
189190
}
190191
const params: LogInlineCompletionSessionResultsParams = {
@@ -196,6 +197,7 @@ export class InlineCompletionManager implements Disposable {
196197
discarded: false,
197198
},
198199
},
200+
firstCompletionDisplayLatency: session.firstCompletionDisplayLatency,
199201
totalSessionDisplayTime: totalSessionDisplayTime,
200202
}
201203
this.languageClient.sendNotification(this.logSessionResultMessageName, params)
@@ -290,14 +292,16 @@ export class AmazonQInlineCompletionItemProvider implements InlineCompletionItem
290292
const prevSessionId = prevSession?.sessionId
291293
const prevItemId = this.sessionManager.getActiveRecommendation()?.[0]?.itemId
292294
const prevStartPosition = prevSession?.startPosition
293-
if (prevSession?.triggerOnAcceptance) {
295+
const editsTriggerOnAcceptance = prevSession?.triggerOnAcceptance
296+
if (editsTriggerOnAcceptance) {
294297
getAllRecommendationsOptions = {
295298
...getAllRecommendationsOptions,
296299
editsStreakToken: prevSession?.editsStreakPartialResultToken,
297300
}
298301
}
299302
const editor = window.activeTextEditor
300-
if (prevSession && prevSessionId && prevItemId && prevStartPosition) {
303+
// Skip prefix matching for Edits suggestions that trigger on acceptance.
304+
if (prevSession && prevSessionId && prevItemId && prevStartPosition && !editsTriggerOnAcceptance) {
301305
const prefix = document.getText(new Range(prevStartPosition, position))
302306
const prevItemMatchingPrefix = []
303307
for (const item of this.sessionManager.getActiveRecommendation()) {
@@ -341,6 +345,7 @@ export class AmazonQInlineCompletionItemProvider implements InlineCompletionItem
341345
discarded: !prevSession.displayed,
342346
},
343347
},
348+
firstCompletionDisplayLatency: prevSession.firstCompletionDisplayLatency,
344349
totalSessionDisplayTime: performance.now() - prevSession.requestStartTime,
345350
}
346351
this.languageClient.sendNotification(this.logSessionResultMessageName, params)

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
import { TelemetryHelper } from './telemetryHelper'
2222
import { ICursorUpdateRecorder } from './cursorUpdateManager'
2323
import { getLogger } from 'aws-core-vscode/shared'
24+
import { getOpenFilesInWindow } from 'aws-core-vscode/utils'
2425
import { asyncCallWithTimeout } from '../../util/timeoutUtil'
2526

2627
export interface GetAllRecommendationsOptions {
@@ -79,14 +80,15 @@ export class RecommendationService {
7980
contentChanges: documentChangeEvent.contentChanges.map((x) => x as TextDocumentContentChangeEvent),
8081
}
8182
: undefined
82-
83+
const openTabs = await getOpenFilesInWindow()
8384
let request: InlineCompletionWithReferencesParams = {
8485
textDocument: {
8586
uri: document.uri.toString(),
8687
},
8788
position,
8889
context,
8990
documentChangeParams: documentChangeParams,
91+
openTabFilepaths: openTabs,
9092
}
9193
if (options.editsStreakToken) {
9294
request = { ...request, partialResultToken: options.editsStreakToken }

packages/amazonq/src/extension.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ import { registerCommands } from './commands'
4545
import { focusAmazonQPanel } from 'aws-core-vscode/codewhispererChat'
4646
import { activate as activateAmazonqLsp } from './lsp/activation'
4747
import { hasGlibcPatch } from './lsp/client'
48+
import { activateAutoDebug } from './lsp/chat/autoDebug/activation'
4849

4950
export const amazonQContextPrefix = 'amazonq'
5051

@@ -131,6 +132,14 @@ export async function activateAmazonQCommon(context: vscode.ExtensionContext, is
131132
await activateAmazonqLsp(context)
132133
}
133134

135+
// Activate AutoDebug feature at extension level
136+
try {
137+
const autoDebugFeature = await activateAutoDebug(context)
138+
context.subscriptions.push(autoDebugFeature)
139+
} catch (error) {
140+
getLogger().error('Failed to activate AutoDebug feature at extension level: %s', error)
141+
}
142+
134143
// Generic extension commands
135144
registerGenericCommands(context, amazonQContextPrefix)
136145

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,16 @@ import { activate as registerLegacyChatListeners } from '../../app/chat/activati
1717
import { DefaultAmazonQAppInitContext } from 'aws-core-vscode/amazonq'
1818
import { AuthUtil, getSelectedCustomization } from 'aws-core-vscode/codewhisperer'
1919
import { pushConfigUpdate } from '../config'
20+
import { AutoDebugLspClient } from './autoDebug/lsp/autoDebugLspClient'
2021

2122
export async function activate(languageClient: LanguageClient, encryptionKey: Buffer, mynahUIPath: string) {
2223
const disposables = globals.context.subscriptions
2324

2425
const provider = new AmazonQChatViewProvider(mynahUIPath, languageClient)
2526

27+
// Set the chat view provider for AutoDebug to use
28+
AutoDebugLspClient.setChatViewProvider(provider)
29+
2630
disposables.push(
2731
window.registerWebviewViewProvider(AmazonQChatViewProvider.viewType, provider, {
2832
webviewOptions: {
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
/*!
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
import * as vscode from 'vscode'
7+
import { getLogger } from 'aws-core-vscode/shared'
8+
import { AutoDebugCommands } from './commands'
9+
import { AutoDebugCodeActionsProvider } from './codeActionsProvider'
10+
import { AutoDebugController } from './controller'
11+
12+
/**
13+
* Auto Debug feature activation for Amazon Q
14+
* This handles the complete lifecycle of the auto debug feature
15+
*/
16+
export class AutoDebugFeature implements vscode.Disposable {
17+
private readonly logger = getLogger()
18+
private readonly disposables: vscode.Disposable[] = []
19+
20+
private autoDebugCommands?: AutoDebugCommands
21+
private codeActionsProvider?: AutoDebugCodeActionsProvider
22+
private controller?: AutoDebugController
23+
24+
constructor(private readonly context: vscode.ExtensionContext) {}
25+
26+
/**
27+
* Activate the auto debug feature
28+
*/
29+
async activate(): Promise<void> {
30+
try {
31+
// Initialize the controller first
32+
this.controller = new AutoDebugController()
33+
34+
// Initialize commands and register them with the controller
35+
this.autoDebugCommands = new AutoDebugCommands()
36+
this.autoDebugCommands.registerCommands(this.context, this.controller)
37+
38+
// Initialize code actions provider
39+
this.codeActionsProvider = new AutoDebugCodeActionsProvider()
40+
this.context.subscriptions.push(this.codeActionsProvider)
41+
42+
// Add all to disposables
43+
this.disposables.push(this.controller, this.autoDebugCommands, this.codeActionsProvider)
44+
} catch (error) {
45+
this.logger.error('AutoDebugFeature: Failed to activate auto debug feature: %s', error)
46+
throw error
47+
}
48+
}
49+
50+
/**
51+
* Get the auto debug controller instance
52+
*/
53+
getController(): AutoDebugController | undefined {
54+
return this.controller
55+
}
56+
57+
/**
58+
* Dispose of all resources
59+
*/
60+
dispose(): void {
61+
vscode.Disposable.from(...this.disposables).dispose()
62+
}
63+
}
64+
65+
/**
66+
* Factory function to activate auto debug feature with LSP client
67+
* This is the main entry point for activating auto debug
68+
*/
69+
export async function activateAutoDebug(
70+
context: vscode.ExtensionContext,
71+
client?: any,
72+
encryptionKey?: Buffer
73+
): Promise<AutoDebugFeature> {
74+
const feature = new AutoDebugFeature(context)
75+
await feature.activate()
76+
77+
return feature
78+
}
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
/*!
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
import * as vscode from 'vscode'
7+
8+
/**
9+
* Provides code actions for Amazon Q Auto Debug features.
10+
* Integrates with VS Code's quick fix system to offer debugging assistance.
11+
*/
12+
export class AutoDebugCodeActionsProvider implements vscode.CodeActionProvider, vscode.Disposable {
13+
private readonly disposables: vscode.Disposable[] = []
14+
15+
public static readonly providedCodeActionKinds = [vscode.CodeActionKind.QuickFix, vscode.CodeActionKind.Refactor]
16+
17+
constructor() {
18+
this.registerProvider()
19+
}
20+
21+
private registerProvider(): void {
22+
// Register for all file types
23+
const selector: vscode.DocumentSelector = [{ scheme: 'file' }]
24+
25+
this.disposables.push(
26+
vscode.languages.registerCodeActionsProvider(selector, this, {
27+
providedCodeActionKinds: AutoDebugCodeActionsProvider.providedCodeActionKinds,
28+
})
29+
)
30+
}
31+
32+
/**
33+
* Provides code actions for the given document and range
34+
*/
35+
public provideCodeActions(
36+
document: vscode.TextDocument,
37+
range: vscode.Range | vscode.Selection,
38+
context: vscode.CodeActionContext,
39+
token: vscode.CancellationToken
40+
): vscode.ProviderResult<(vscode.CodeAction | vscode.Command)[]> {
41+
if (token.isCancellationRequested) {
42+
return []
43+
}
44+
45+
const actions: vscode.CodeAction[] = []
46+
47+
// Get diagnostics for the current range
48+
const diagnostics = context.diagnostics.filter(
49+
(diagnostic) => diagnostic.range.intersection(range) !== undefined
50+
)
51+
52+
if (diagnostics.length > 0) {
53+
// Add "Fix with Amazon Q" action
54+
actions.push(this.createFixWithQAction(document, range, diagnostics))
55+
56+
// Add "Fix All with Amazon Q" action
57+
actions.push(this.createFixAllWithQAction(document))
58+
59+
// Add "Explain Problem" action
60+
actions.push(this.createExplainProblemAction(document, range, diagnostics))
61+
}
62+
return actions
63+
}
64+
65+
private createFixWithQAction(
66+
document: vscode.TextDocument,
67+
range: vscode.Range,
68+
diagnostics: vscode.Diagnostic[]
69+
): vscode.CodeAction {
70+
const action = new vscode.CodeAction(
71+
`Amazon Q: Fix Problem (${diagnostics.length} issue${diagnostics.length !== 1 ? 's' : ''})`,
72+
vscode.CodeActionKind.QuickFix
73+
)
74+
75+
action.command = {
76+
command: 'amazonq.01.fixWithQ',
77+
title: 'Amazon Q: Fix Problem',
78+
arguments: [range, diagnostics],
79+
}
80+
81+
action.diagnostics = diagnostics
82+
action.isPreferred = true // Make this the preferred quick fix
83+
84+
return action
85+
}
86+
87+
private createFixAllWithQAction(document: vscode.TextDocument): vscode.CodeAction {
88+
const action = new vscode.CodeAction('Amazon Q: Fix All Errors', vscode.CodeActionKind.QuickFix)
89+
90+
action.command = {
91+
command: 'amazonq.02.fixAllWithQ',
92+
title: 'Amazon Q: Fix All Errors',
93+
}
94+
95+
return action
96+
}
97+
98+
private createExplainProblemAction(
99+
document: vscode.TextDocument,
100+
range: vscode.Range,
101+
diagnostics: vscode.Diagnostic[]
102+
): vscode.CodeAction {
103+
const action = new vscode.CodeAction('Amazon Q: Explain Problem', vscode.CodeActionKind.QuickFix)
104+
105+
action.command = {
106+
command: 'amazonq.03.explainProblem',
107+
title: 'Amazon Q: Explain Problem',
108+
arguments: [range, diagnostics],
109+
}
110+
111+
action.diagnostics = diagnostics
112+
113+
return action
114+
}
115+
116+
public dispose(): void {
117+
vscode.Disposable.from(...this.disposables).dispose()
118+
}
119+
}

0 commit comments

Comments
 (0)