Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:
required: false
default: prerelease
push:
branches: [master, feature/*]
branches: [master, feature/*, release/*]
# tags:
# - v[0-9]+.[0-9]+.[0-9]+

Expand Down Expand Up @@ -40,12 +40,16 @@ jobs:
# run: echo 'TAG_NAME=prerelease' >> $GITHUB_ENV
- if: github.event_name == 'workflow_dispatch'
run: echo "TAG_NAME=${{ github.event.inputs.tag_name }}" >> $GITHUB_ENV
- if: github.ref_name != 'master'
- if: startsWith(github.ref_name, 'feature/')
run: |
TAG_NAME=${{ github.ref_name }}
FEAT_NAME=$(echo $TAG_NAME | sed 's/feature\///')
FEAT_NAME=$(echo ${{ github.ref_name }} | sed 's/feature\///')
echo "FEAT_NAME=$FEAT_NAME" >> $GITHUB_ENV
echo "TAG_NAME=pre-$FEAT_NAME" >> $GITHUB_ENV
- if: startsWith(github.ref_name, 'release/')
run: |
RC_NAME=$(echo ${{ github.ref_name }} | sed 's/release\///')
echo "FEAT_NAME=" >> $GITHUB_ENV
echo "TAG_NAME=rc-$RC_NAME" >> $GITHUB_ENV
- if: github.ref_name == 'master'
run: |
echo "FEAT_NAME=" >> $GITHUB_ENV
Expand Down Expand Up @@ -105,10 +109,14 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
- name: Delete existing prerelease
# "prerelease" (main branch) or "pre-<feature>"
if: "env.TAG_NAME == 'prerelease' || startsWith(env.TAG_NAME, 'pre-')"
# "prerelease" (main branch), "pre-<feature>", or "rc-<date>"
if: env.TAG_NAME == 'prerelease' || startsWith(env.TAG_NAME, 'pre-') || startsWith(env.TAG_NAME, 'rc-')
run: |
echo "SUBJECT=AWS IDE Extensions: ${FEAT_NAME:-${TAG_NAME}}" >> $GITHUB_ENV
if [[ "$TAG_NAME" == rc-* ]]; then
echo "SUBJECT=AWS IDE Extensions Release Candidate: ${TAG_NAME#rc-}" >> $GITHUB_ENV
else
echo "SUBJECT=AWS IDE Extensions: ${FEAT_NAME:-${TAG_NAME}}" >> $GITHUB_ENV
fi
gh release delete "$TAG_NAME" --cleanup-tag --yes || true
# git push origin :"$TAG_NAME" || true
- name: Publish Prerelease
Expand Down
108 changes: 108 additions & 0 deletions .github/workflows/setup-release-candidate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
name: Setup Release Candidate

on:
workflow_dispatch:
inputs:
versionIncrement:
description: 'Release Version Increment'
default: 'Minor'
required: true
type: choice
options:
- Major
- Minor
- Patch
- Custom
customVersion:
description: "Custom Release Version (only used if release increment is 'Custom') - Format: 3.15.0"
default: ''
required: false
type: string
commitId:
description: 'Commit ID to create RC from'
required: true
type: string

jobs:
setup-rc:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.commitId }}
token: ${{ secrets.RELEASE_CANDIDATE_BRANCH_CREATION_PAT }}
persist-credentials: true

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'npm'

- name: Calculate Release Versions
id: release-version
run: |
customVersion="${{ inputs.customVersion }}"
versionIncrement="${{ inputs.versionIncrement }}"

increment_version() {
local currentVersion=$1
if [[ "$versionIncrement" == "Custom" && -n "$customVersion" ]]; then
echo "$customVersion"
else
IFS='.' read -r major minor patch <<< "$currentVersion"
case "$versionIncrement" in
"Major")
major=$((major + 1))
minor=0
patch=0
;;
"Minor")
minor=$((minor + 1))
patch=0
;;
"Patch")
patch=$((patch + 1))
;;
esac
echo "$major.$minor.$patch"
fi
}

# Read and increment toolkit version
toolkitCurrentVersion=$(node -e "console.log(require('./packages/toolkit/package.json').version)" | sed 's/-SNAPSHOT//')
toolkitNewVersion=$(increment_version "$toolkitCurrentVersion")

# Read and increment amazonq version
amazonqCurrentVersion=$(node -e "console.log(require('./packages/amazonq/package.json').version)" | sed 's/-SNAPSHOT//')
amazonqNewVersion=$(increment_version "$amazonqCurrentVersion")

echo "TOOLKIT_VERSION=$toolkitNewVersion" >> $GITHUB_OUTPUT
echo "AMAZONQ_VERSION=$amazonqNewVersion" >> $GITHUB_OUTPUT
# Use date-based branch naming instead of version-based because we release
# both extensions (toolkit and amazonq) from the same branch, and they may
# have different version numbers. We can change this in the future
echo "BRANCH_NAME=rc-$(date +%Y%m%d)" >> $GITHUB_OUTPUT

- name: Create RC Branch and Update Versions
env:
TOOLKIT_VERSION: ${{ steps.release-version.outputs.TOOLKIT_VERSION }}
AMAZONQ_VERSION: ${{ steps.release-version.outputs.AMAZONQ_VERSION }}
BRANCH_NAME: ${{ steps.release-version.outputs.BRANCH_NAME }}
run: |
git config user.name "aws-toolkit-automation"
git config user.email "<>"

# Create RC branch using date-based naming
git checkout -b $BRANCH_NAME

# Update package versions individually
npm version --no-git-tag-version $TOOLKIT_VERSION -w packages/toolkit
npm version --no-git-tag-version $AMAZONQ_VERSION -w packages/amazonq

# Commit version changes
git add packages/toolkit/package.json packages/amazonq/package.json package-lock.json
git commit -m "chore: bump versions - toolkit=$TOOLKIT_VERSION, amazonq=$AMAZONQ_VERSION"

# Push RC branch
git push origin $BRANCH_NAME

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}
17 changes: 17 additions & 0 deletions packages/amazonq/src/app/inline/EditRendering/displayImage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import { EditSuggestionState } from '../editSuggestionState'
import type { AmazonQInlineCompletionItemProvider } from '../completion'
import { vsCodeState } from 'aws-core-vscode/codewhisperer'

const autoRejectEditCursorDistance = 25

export class EditDecorationManager {
private imageDecorationType: vscode.TextEditorDecorationType
private removedCodeDecorationType: vscode.TextEditorDecorationType
Expand Down Expand Up @@ -346,6 +348,19 @@ export async function displaySvgDecoration(
void vscode.commands.executeCommand('aws.amazonq.inline.rejectEdit')
}
})
const cursorChangeListener = vscode.window.onDidChangeTextEditorSelection((e) => {
if (!EditSuggestionState.isEditSuggestionActive()) {
return
}
if (e.textEditor !== editor) {
return
}
const currentPosition = e.selections[0].active
const distance = Math.abs(currentPosition.line - startLine)
if (distance > autoRejectEditCursorDistance) {
void vscode.commands.executeCommand('aws.amazonq.inline.rejectEdit')
}
})
await decorationManager.displayEditSuggestion(
editor,
svgImage,
Expand All @@ -371,6 +386,7 @@ export async function displaySvgDecoration(

await decorationManager.clearDecorations(editor)
documentChangeListener.dispose()
cursorChangeListener.dispose()
const params: LogInlineCompletionSessionResultsParams = {
sessionId: session.sessionId,
completionSessionResult: {
Expand Down Expand Up @@ -405,6 +421,7 @@ export async function displaySvgDecoration(
getLogger().info('Edit suggestion rejected')
await decorationManager.clearDecorations(editor)
documentChangeListener.dispose()
cursorChangeListener.dispose()
const params: LogInlineCompletionSessionResultsParams = {
sessionId: session.sessionId,
completionSessionResult: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ describe('RecommendationService', () => {

describe('getAllRecommendations', () => {
it('should handle single request with no partial result token', async () => {
// Mock EditSuggestionState to return false (no edit suggestion active)
sandbox.stub(EditSuggestionState, 'isEditSuggestionActive').returns(false)

const mockFirstResult = {
sessionId: 'test-session',
items: [mockInlineCompletionItemOne],
Expand Down Expand Up @@ -172,6 +175,9 @@ describe('RecommendationService', () => {
})

it('should handle multiple request with partial result token', async () => {
// Mock EditSuggestionState to return false (no edit suggestion active)
sandbox.stub(EditSuggestionState, 'isEditSuggestionActive').returns(false)

const mockFirstResult = {
sessionId: 'test-session',
items: [mockInlineCompletionItemOne],
Expand Down
Loading
Loading