Skip to content

Conversation

LiGaCu
Copy link
Contributor

@LiGaCu LiGaCu commented Jul 10, 2025

Problem

In order to open workspace context server to all users, we need to support both client-side opt-out (controlled by individual users in IDE) and server-side opt-out (controlled by users' administrator in AWS console).

Solution

Add the support for both client-side opt-out and server-side opt-out and react properly to status flips between opted-in and opted-out.

There are corresponding Amazon Q extension changes:

Testing

Tested locally that workspace context server is having the expected behaviors under the following scenarios, with:

  • An Amazon internal user identity and a Pro Tier user identity
  • An Amazon Q extension on VSCode and an Amazon Q extension on JetBrains

Client-side Opt-in Tests

Scenario Behavior
On Extension without Checkbox
Amazon Internal User / BuilderID User Treated the same as client-side opted-in
Pro Tier User Treated the same as client-side opted-out
On Extension with Checkbox (All users)
IDE window open without previous opt-in settings Default as client-side opted-in
IDE window open with opt-in checkbox checked Workspace context server creates a remote workspace and reacts to events
IDE window open with opt-in checkbox unchecked Workspace context server neither creates a remote workspace nor reacts to events
IDE opt-in checkbox switch from opted-in to opted-out After the switch, workspace context server stops reacting to events and calls DeleteWorkspace API to delete the remote workspace
IDE opt-in checkbox switch from opted-out to opted-in After the switch, workspace context server creates a remote workspace and starts reacting to events

Server-side Opt-in Tests (with client-side opted-in)

Scenario Behavior
User's administrator opted-in Workspace context server creates a remote workspace and reacts to events, probing server-side opt-in status every 30 minutes
User's administrator opted-out Workspace context server neither creates a remote workspace nor reacts to events, probing server-side opt-in status every 30 minutes
User's administrator switch from opted-in to opted-out After the switch, workspace context server stops reacting to events
User's administrator switch from opted-out to opted-in After the switch, workspace context server creates a remote workspace and starts reacting to events

License

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@@ -137,6 +137,7 @@ export class DependencyDiscoverer {
async reSyncDependenciesToS3(folders: WorkspaceFolder[]) {
Atomics.store(this.dependencyUploadedSizeSum, 0, 0)
for (const dependencyHandler of this.dependencyHandlerRegistry) {
dependencyHandler.markAllDependenciesAsUnZipped()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was your intention to call this on L139? Why do it inside this for loop

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nuh, this is intended. these are individual dependencyHandlers and we need to reset the states in dependency maps for all of them.

return waitedWorkspaceId
private setRemoteWorkspaceId(workspaceId: string) {
this.workspaceState.workspaceId = workspaceId
this.remoteWorkspaceIdResolver(true)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is such workspace id promise needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since where to get the remote workspace ID and where it is needed is asynchronous, and we want to make sure the places need it will wait for this information properly.

private remoteWorkspaceIdPromise: Promise<string>
private remoteWorkspaceIdResolver!: (id: string) => void
// Promise that resolves to whether remote workspace operations should proceed
private remoteWorkspaceIdPromise: Promise<boolean>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add more comments on why these variables are needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, can add more comments separately.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added more comments.

@@ -203,10 +210,13 @@ export class WorkspaceFolderManager {

async clearAllWorkspaceResources() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This clearAllWorkspaceResources is in fact a sync function, but it is marked as async

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch! Got it updated.

@LiGaCu LiGaCu merged commit 72b6d76 into aws:main Jul 14, 2025
6 checks passed
laileni-aws added a commit that referenced this pull request Jul 14, 2025
* fix(amazonq): allow taking .jpg file as image context, add image cont… (#1814)

* fix(amazonq): allow taking .jpg file as image context, add image context used to transparency list

* fix(amazonq): fix comments

* feat(flags): change flag name to enablewebformtransform(#1804)

* feat(netTransform): rename EnableWebFormsToBlazorTransform to EnableWebFormsTransform

* Revert "feat(netTransform): rename EnableWebFormsToBlazorTransform to EnableWebFormsTransform"

This reverts commit 80b4c97.

* Reapply "feat(netTransform): rename EnableWebFormsToBlazorTransform to EnableWebFormsTransform"

This reverts commit e274513.

* feat: produce agentic chat bundle from repo (#1827)

* chore: configure .gitattributes to store files under app/aws-lsp-codewhisperer-runtimes/_bundle-assets with LFS

* chore: add ripgrep assets to repo for bundling

* chore: add qserver assets to repo for bundling

* feat: produce agentic chat bundle

* fix: imagecontext image name bug, mutliple images in pinned context (#1834)

On windows, when we add an image using the options @image or @image: options, full file name is shown, we should only show file name.
I was able to add only one image when I used @image context menu option, when I add another image, it does not show up in pinned context.

This PR fixes these issues.

* fix(amazonq): fix typo in image context list (#1836)

* fix: adding files on VSC windows properly triggers reindexing (#1820)

* fix: image context drag and drop fix on windows (#1837)

* feat(amazonq): add transformation preferences functionality to input gen (#1792)

* fix(amazonq): change the image filter used in open file dialog (#1838)

* feat: passing partialResultToken to onInlineCompletionHandler result for EDITS (#1840)

* fix: remove redundent thinking... for file operations (#1839)

* feat(chat-client): add stringOverrides to createChat config (#1847)

* refactor(amazonq): captilize constant variables, incremental code quality PR (#1843)

* chore: create GitHub releases for agentic chat alpha, feature, and rc builds (#1832)

* chore: set up lsp-codewhisperer-runtimes so that version can be queried

* chore: create GitHub releases for agentic chat alpha, feature, and rc builds

* fix: use correct commit, and support release candidate branches

* feat: adding streakLength back for UserTriggerDecisionEvent (#1841)

* fix: adding agenticcoding field to amazonqaddMessage metric(#1849)

* refactor(amazonq): futher constant handling and creation of a helper (#1850)

* chore: upgrade mynah-ui to 4.35.8 (#1853)

* fix(amazonq): use config to render the overlay (#1851)

* fix(amazonq): use config to render the overlay

* fix(amazonq): fix typo

* chore(release): release packages from branch main (#1823)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* chore: bump runtime version (#1856)

* revert: create GitHub releases for agentic chat alpha, feature, and rc

This reverts commit 10e04ba.

* revert: produce agentic chat bundle from repo (#1827) (#1858)

This reverts commit 0f71dd3.

* revert: adding files on VSC windows properly triggers reindexing (#1820)" (#1860)

This reverts commit 0c2d8eb.

* revert: revert: adding files on VSC windows properly triggers reindexing (#18…" (#1862)

This reverts commit 423cdbc.

* chore: bump runtimes to 0.2.105 (#1863)

* chore: add unit tests for codeWhispererServer.ts with editsEnabled (#1864)

* fix(amazonq): add files created by fsWrite tool to @Files list (#1784)

* fix(amazonq): remove the deep copy logic in updateRequestInputWithToolResults (#1870)

* fix(amazonq): use structuredClone for deep copy of requestInput

* fix(amazonq): remove the deep copy logic

* Revert "fix(amazonq): remove the deep copy logic"

This reverts commit 19c2993.

* fix: use absolute file path for shell (#1871)

* chore(release): release packages from branch main (#1861)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* feat(amazonq): added full system information to the logs (#1875)

* revert: adding streakLength back for UserTriggerDecisionEvent (#1877)

This reverts commit 7052132.

* feat: update UserTriggerDecisionEventStreakLengthInteger min value (#1878)

* fix(amazonq): catch mcp initialization errors (#1873)

On server startup, tool initialization failure can crash the entire LSP process

* fix(amazonq): additional checks for binary and credential files (#1866)

* fix: validate Create Prompt & Create Rule prompts input onChange (#1854)

* fix: Forward slash shown in rules list in multi-root workspaces on windows (#1855)

* fix: forward slash shown in rules list windows muti root workspace

* fix: switch map to some

* test: add unit tests

* fix: send "thinking" in assistant response for pinned context

* feat(amazonq): Adding QCodeReview tool to amazonQ (#1882)

* feat: add QCodeReviewTool and QCodeAnalysisServer

* feat: update QCodeReviewTool to support both file and folder level scans

* fix: remove QFindingCritic references

* feat: add support to scan code diff

* feat: enhance code review tool with agentic scan capabilities

- Remove codeSearch case from agenticChatController tool handling
- Update QCodeReview to use AGENTIC_CODE_REVIEW upload intent
- Change scan scope to AGENTIC for improved code review analysis
- Add codeDiffMetadata support for code diff scanning

* fix: replace timestamp-based scan names with UUID in code review tool

- Use randomUUID() from crypto module instead of Date.now().toString()
- Change scan name prefix from 'q-agentic-code-review-' to 'Standard-'
- Improves uniqueness and follows standard naming conventions

* fix: improve Q Code Review tool logging and schema handling

- Update scan logging message for better clarity
- Remove unused determineLanguageFromFolderContent method
- Simplify zip file structure to use absolute paths
- Add detailed logging for zip contents debugging
- Make recommendation URL nullable in schema
- Add optional findingContext field to finding schema

* refactor(amazonq): extract utilities and improve Q Code Review organization

- Extract git diff operations to QCodeReviewUtils for better reusability
- Break down large prepareFilesForUpload method into focused smaller methods
- Add centralized error handling with withErrorHandling wrapper
- Improve code organization with proper imports and constants
- Add zip utility methods for better maintainability
- Add saveZipToDownloads functionality for debugging support
- Enhance separation of concerns between main logic and utilities

* feat: send message containing findings

* feat(amazonq): add filePath to finding

* feat: group findings by file

* feat(amazonq): store constant for findings suffix

* fix: refactor publish finding to code issues panel

* fix: resolve absolute file path of llm findings when performing a folder scan

* fix: add qCodeReview tool in standard tool list

* fix: enhance Q Code Review tool with pagination and improved structure

- Rename constants and schemas for better clarity and consistency
- Add pagination support for findings retrieval using nextToken
- Change response structure: jobId -> codeReviewId, findings -> findingsByFile
- Improve error handling and logging throughout the tool
- Enhance findings processing and aggregation logic
- Add warning logs for unresolved file paths
- Refactor type definitions and improve code organization

* fix: show only code diff findings when customer asks for a code diff scan

* fix: perform code review of code diff by default

* fix: update code review tool implementation

- Enhanced qCodeReview tool functionality
- Updated toolServer configuration

* fix: do not download zip artifact

* fix: refactor qCodeAnalysis tool

* fix: add scope-based reviews and improve architecture

- Refactor monolithic execute() method into focused, testable functions
- Add FULL_REVIEW vs PARTIAL_REVIEW scope detection based on user intent
- Implement centralized error handling with consistent messaging
- Add comprehensive telemetry for monitoring tool performance
- Enhance tool description to position as primary code analysis tool
- Improve timeout handling with configurable polling intervals
- Add intelligent findings filtering based on review scope
- Strengthen input validation and schema definitions

This refactoring improves maintainability, adds intelligent scope detection,
and provides better user experience through clearer tool positioning.

* fix: increase range of prompts for q code review tool

* fix: emit metrics

* fix: remove unwanted changes

* fix: restore missing formatting changes in test files

* fix: remove unwanted changes

* fix: remove unwanted changes

* fix: add q code analysis server

* fix: add q code analysis server as built in tool

* fix: normalize finding and fileartifact path

* Fix package failures

* feat(amazonq): include rules in the file upload zip for QCodeReview

* fix: add logs for custom guidelines and telemetry

* fix: tool output prompt

* fix: update tool output prompt to not show any summary

* fix: increase scan timeout to 5 mins, remove unused variables and imports

* feat: enhance Q Code Review tool with cancellation support and improved error handling

- Add cancellation token support to allow users to cancel long-running code reviews
- Implement structured InvokeOutput with success/failure indicators
- Update schema to default to FULL_REVIEW for ambiguous scope requests
- Improve error handling with consistent output formatting
- Add cancellation checks at key processing points
- Update controller to handle new output structure for findings display

* fix: update chat with code review status

* fix: update writer name

* fix: update cancellation token handling

* fix: update prompts to include limited findings, handle failures

* fix: update qCodeReview tool description

* fix: update qCodeReview tool description

* fix: update qCodeReview tool description

* fix: add logs for fetching findings

* fix: revert changes

* fix: update zip files and structure logging

* fix: update qCodeReview supported extensions, do not need language in input

* feat(amazonq): custom guidelines

* fix(amazonq): do not use all context files, only the active rules in custom guidelines

* fix(amazonq): ensuring the customer code base path is always the folder name

* fix: update tool prompt

* fix: update partial review to code diff review

* fix: update tool prompt

* fix: update scopeOfReview prompt

* feat(amazonq): add agentic reviewer feature flag

* fix: update uploaded file path to unix format always

* fix: version update

* fix: refactor tool, use file path in unix format always

* fix: validate if there are files to scan other than rule artifacts

* fix: add unit tests for qCodeReviewUtils, remove unused fields from qCodeReview tool initiation

* fix: add qCodeReview tool test

* fix: update qCodeReview tool enable flag to

* fix(amazonq): refactor qcodereview tool with improved error handling and type safety

- Add dedicated error classes (QCodeReviewError, QCodeReviewValidationError,
  QCodeReviewTimeoutError, QCodeReviewInternalError)
- Create comprehensive type definitions in qCodeReviewTypes.ts for better type safety
- Simplify error handling by using exceptions instead of error objects
- Remove programmingLanguage field from file artifacts (now handled at tool level)
- Improve result processing and aggregation logic
- Add better path resolution with common suffix matching
- Update tests to reflect new structure and error handling
- Fix typo in schema description (abosolute -> absolute)
- Enhance logging and error messages with more context
- Streamline code review result structure and processing flow

* fix: update block type when displaying tool updates

* fix: fix unit tests for windows and mac

* fix: fix unit tests for windows and mac

---------

Co-authored-by: Nitish Kumar Singh <[email protected]>
Co-authored-by: Blake Lazarine <[email protected]>
Co-authored-by: Nitish <[email protected]>

* feat(amazonq): allow opt-out for workspace context server (#1867)

* feat(amazonq): allow opt-out for workspace context server

* feat(amazonq): add overriding value for workspace context server opt-in

* fix(amazonq): fix WCS behavior when administrator switch from opt-out to opt-in

* fix(amazonq): fix WCS reSyncDependenciesToS3 method not working

* chore(amazonq): add unit tests for WCS updateConfiguration

* docs(amazonq): add comments for WCS remoteWorkspaceIdPromise variables

* fix(amazonq): make WCS react correctly during close opt-in / opt-out flips

---------

Co-authored-by: Jiatong Li <[email protected]>

---------

Co-authored-by: yzhangok <[email protected]>
Co-authored-by: Rajanna-Karthik <[email protected]>
Co-authored-by: Christopher Christou <[email protected]>
Co-authored-by: Lokesh <[email protected]>
Co-authored-by: chungjac <[email protected]>
Co-authored-by: jabouayash <[email protected]>
Co-authored-by: atontb <[email protected]>
Co-authored-by: Boyu <[email protected]>
Co-authored-by: Avi Alpert <[email protected]>
Co-authored-by: abhraina-aws <[email protected]>
Co-authored-by: Laxman Reddy <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Jason Guo <[email protected]>
Co-authored-by: tsmithsz <[email protected]>
Co-authored-by: Richard Li <[email protected]>
Co-authored-by: invictus <[email protected]>
Co-authored-by: Nitish Singh <[email protected]>
Co-authored-by: Nitish Kumar Singh <[email protected]>
Co-authored-by: Blake Lazarine <[email protected]>
Co-authored-by: Nitish <[email protected]>
Co-authored-by: Jiatong Li <[email protected]>
Co-authored-by: Jiatong Li <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants