-
Notifications
You must be signed in to change notification settings - Fork 80
refactor: trigger code path & non-blocking edits trigger #1990
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
base: main
Are you sure you want to change the base?
Conversation
readonly editsSessionManager: SessionManager | ||
) {} | ||
|
||
async init( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you move this init to the constructor so that inlineCompletionHandler
does not need to be undefined?
@@ -181,6 +270,8 @@ export class CodeWhispererServiceToken extends CodeWhispererServiceBase { | |||
/** If user clicks "Upgrade" multiple times, cancel the previous wait-promise. */ | |||
#waitUntilSubscriptionCancelSource?: CancellationTokenSource | |||
|
|||
private cache: Map<string, GenerateSuggestionsResponse> = new Map() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is not used
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This refactor removes the amazonQServiceManager
parameter from supplemental context utility functions, simplifying the API and centralizing service management responsibility. The change appears to be part of consolidating how code path triggering is handled.
- Remove optional
amazonQServiceManager
parameter from supplemental context functions - Update all function calls to match the simplified signature
- Maintain existing functionality while improving separation of concerns
Reviewed Changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 6 comments.
Show a summary per file
File | Description |
---|---|
supplementalContextUtil.ts | Remove amazonQServiceManager parameter from fetchSupplementalContext function signature |
supplementalContextUtil.test.ts | Update test calls to match simplified function signature |
crossFileContextUtil.ts | Remove amazonQServiceManager parameter from fetchProjectContext function |
codeWhispererService.ts | Add comprehensive refactoring including new file context method, abstract supplemental context construction, and service-specific implementations |
codeWhispererService.test.ts | Add mock implementation for new abstract constructSupplementalContext method |
trigger.ts | New file implementing trigger logic for completions and edits |
sessionManager.ts | Add support for separate completion and edit session managers |
logInlineCompletionSessionResultsHandler.ts | New handler for logging inline completion session results |
inlineCompletionHandler.ts | New dedicated handler for inline completions |
editCompletionHandler.ts | New dedicated handler for edit completions |
documentChangedListener.ts | New listener for tracking document changes |
codewhispererController.ts | New controller orchestrating completion handlers |
codeWhispererServer.ts | Major refactor replacing inline implementation with controller-based architecture |
codeDiffTracker.ts | Add AcceptedInlineSuggestionEntry interface |
autoTrigger.ts | Update previousDecision parameter to allow undefined |
// add cancellation check | ||
// add error check | ||
this.logging.info(request.editorState?.document?.text ?? '') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Logging the entire document text could expose sensitive information in logs. Consider logging only metadata like document length or a sanitized summary instead.
this.logging.info(request.editorState?.document?.text ?? '') | |
const docTextLength = request.editorState?.document?.text?.length ?? 0 | |
const filename = request.fileContext?.filename ?? 'unknown' | |
this.logging.info(`Document length: ${docTextLength}, Filename: ${filename}`) |
Copilot uses AI. Check for mistakes.
private cache: Map<string, GenerateSuggestionsResponse> = new Map() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The cache is declared but never used in the visible code. Consider implementing cache logic or removing this unused field to avoid confusion.
private cache: Map<string, GenerateSuggestionsResponse> = new Map() |
Copilot uses AI. Check for mistakes.
token: CancellationToken | ||
): Promise<InlineCompletionListWithReferences> { | ||
if (!this.inlineCompletionHandler) { | ||
throw new Error('') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Empty error message provides no useful information for debugging. Consider adding a descriptive message like 'InlineCompletionHandler not initialized'.
throw new Error('') | |
throw new Error('InlineCompletionHandler not initialized') |
Copilot uses AI. Check for mistakes.
token: CancellationToken | ||
): Promise<InlineCompletionListWithReferences> { | ||
if (!this.editCompletionHandler) { | ||
throw new Error('') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Empty error message provides no useful information for debugging. Consider adding a descriptive message like 'EditCompletionHandler not initialized'.
throw new Error('') | |
throw new Error('EditCompletionHandler not initialized') |
Copilot uses AI. Check for mistakes.
|
||
async onLogInlineCompletionSessionResultsHandler(params: LogInlineCompletionSessionResultsParams) { | ||
if (!this.logInlineCompletionSessionResultsHandler) { | ||
throw new Error('') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Empty error message provides no useful information for debugging. Consider adding a descriptive message like 'LogInlineCompletionSessionResultsHandler not initialized'.
throw new Error('') | |
throw new Error('LogInlineCompletionSessionResultsHandler not initialized') |
Copilot uses AI. Check for mistakes.
if (this.customizationArn) request.customizationArn = this.customizationArn | ||
const response = await this.client.generateCompletions(this.withProfileArn(request)).promise() | ||
this.logging.info( | ||
`GenerateCompletion response: | ||
"version": "debounced gc", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hard-coded string 'debounced gc' in logging appears to be debug code that should be removed or made configurable.
"version": "debounced gc", |
Copilot uses AI. Check for mistakes.
This reverts commit 06e5a62.
Problem
Solution
License
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.