Skip to content

Commit 439e281

Browse files
Merge master into feature/ui-e2e-tests
2 parents 1f25f3c + 9a88c41 commit 439e281

File tree

5 files changed

+300
-25
lines changed

5 files changed

+300
-25
lines changed

.github/workflows/release.yml

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ on:
1212
required: false
1313
default: prerelease
1414
push:
15-
branches: [master, feature/*]
15+
branches: [master, feature/*, release/*]
1616
# tags:
1717
# - v[0-9]+.[0-9]+.[0-9]+
1818

@@ -40,12 +40,16 @@ jobs:
4040
# run: echo 'TAG_NAME=prerelease' >> $GITHUB_ENV
4141
- if: github.event_name == 'workflow_dispatch'
4242
run: echo "TAG_NAME=${{ github.event.inputs.tag_name }}" >> $GITHUB_ENV
43-
- if: github.ref_name != 'master'
43+
- if: startsWith(github.ref_name, 'feature/')
4444
run: |
45-
TAG_NAME=${{ github.ref_name }}
46-
FEAT_NAME=$(echo $TAG_NAME | sed 's/feature\///')
45+
FEAT_NAME=$(echo ${{ github.ref_name }} | sed 's/feature\///')
4746
echo "FEAT_NAME=$FEAT_NAME" >> $GITHUB_ENV
4847
echo "TAG_NAME=pre-$FEAT_NAME" >> $GITHUB_ENV
48+
- if: startsWith(github.ref_name, 'release/')
49+
run: |
50+
RC_NAME=$(echo ${{ github.ref_name }} | sed 's/release\///')
51+
echo "FEAT_NAME=" >> $GITHUB_ENV
52+
echo "TAG_NAME=rc-$RC_NAME" >> $GITHUB_ENV
4953
- if: github.ref_name == 'master'
5054
run: |
5155
echo "FEAT_NAME=" >> $GITHUB_ENV
@@ -105,10 +109,14 @@ jobs:
105109
- uses: actions/checkout@v4
106110
- uses: actions/download-artifact@v4
107111
- name: Delete existing prerelease
108-
# "prerelease" (main branch) or "pre-<feature>"
109-
if: "env.TAG_NAME == 'prerelease' || startsWith(env.TAG_NAME, 'pre-')"
112+
# "prerelease" (main branch), "pre-<feature>", or "rc-<date>"
113+
if: env.TAG_NAME == 'prerelease' || startsWith(env.TAG_NAME, 'pre-') || startsWith(env.TAG_NAME, 'rc-')
110114
run: |
111-
echo "SUBJECT=AWS IDE Extensions: ${FEAT_NAME:-${TAG_NAME}}" >> $GITHUB_ENV
115+
if [[ "$TAG_NAME" == rc-* ]]; then
116+
echo "SUBJECT=AWS IDE Extensions Release Candidate: ${TAG_NAME#rc-}" >> $GITHUB_ENV
117+
else
118+
echo "SUBJECT=AWS IDE Extensions: ${FEAT_NAME:-${TAG_NAME}}" >> $GITHUB_ENV
119+
fi
112120
gh release delete "$TAG_NAME" --cleanup-tag --yes || true
113121
# git push origin :"$TAG_NAME" || true
114122
- name: Publish Prerelease
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
name: Setup Release Candidate
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
versionIncrement:
7+
description: 'Release Version Increment'
8+
default: 'Minor'
9+
required: true
10+
type: choice
11+
options:
12+
- Major
13+
- Minor
14+
- Patch
15+
- Custom
16+
customVersion:
17+
description: "Custom Release Version (only used if release increment is 'Custom') - Format: 3.15.0"
18+
default: ''
19+
required: false
20+
type: string
21+
commitId:
22+
description: 'Commit ID to create RC from'
23+
required: true
24+
type: string
25+
26+
jobs:
27+
setup-rc:
28+
runs-on: ubuntu-latest
29+
permissions:
30+
contents: write
31+
steps:
32+
- uses: actions/checkout@v4
33+
with:
34+
ref: ${{ inputs.commitId }}
35+
token: ${{ secrets.GITHUB_TOKEN }}
36+
persist-credentials: true
37+
38+
- name: Setup Node.js
39+
uses: actions/setup-node@v4
40+
with:
41+
node-version: '18'
42+
cache: 'npm'
43+
44+
- name: Calculate Release Versions
45+
id: release-version
46+
run: |
47+
customVersion="${{ inputs.customVersion }}"
48+
versionIncrement="${{ inputs.versionIncrement }}"
49+
50+
increment_version() {
51+
local currentVersion=$1
52+
if [[ "$versionIncrement" == "Custom" && -n "$customVersion" ]]; then
53+
echo "$customVersion"
54+
else
55+
IFS='.' read -r major minor patch <<< "$currentVersion"
56+
case "$versionIncrement" in
57+
"Major")
58+
major=$((major + 1))
59+
minor=0
60+
patch=0
61+
;;
62+
"Minor")
63+
minor=$((minor + 1))
64+
patch=0
65+
;;
66+
"Patch")
67+
patch=$((patch + 1))
68+
;;
69+
esac
70+
echo "$major.$minor.$patch"
71+
fi
72+
}
73+
74+
# Read and increment toolkit version
75+
toolkitCurrentVersion=$(node -e "console.log(require('./packages/toolkit/package.json').version)" | sed 's/-SNAPSHOT//')
76+
toolkitNewVersion=$(increment_version "$toolkitCurrentVersion")
77+
78+
# Read and increment amazonq version
79+
amazonqCurrentVersion=$(node -e "console.log(require('./packages/amazonq/package.json').version)" | sed 's/-SNAPSHOT//')
80+
amazonqNewVersion=$(increment_version "$amazonqCurrentVersion")
81+
82+
echo "TOOLKIT_VERSION=$toolkitNewVersion" >> $GITHUB_OUTPUT
83+
echo "AMAZONQ_VERSION=$amazonqNewVersion" >> $GITHUB_OUTPUT
84+
# Use date-based branch naming instead of version-based because we release
85+
# both extensions (toolkit and amazonq) from the same branch, and they may
86+
# have different version numbers. We can change this in the future
87+
echo "BRANCH_NAME=rc-$(date +%Y%m%d)" >> $GITHUB_OUTPUT
88+
89+
- name: Create RC Branch and Update Versions
90+
env:
91+
TOOLKIT_VERSION: ${{ steps.release-version.outputs.TOOLKIT_VERSION }}
92+
AMAZONQ_VERSION: ${{ steps.release-version.outputs.AMAZONQ_VERSION }}
93+
BRANCH_NAME: ${{ steps.release-version.outputs.BRANCH_NAME }}
94+
run: |
95+
git config user.name "aws-toolkit-automation"
96+
git config user.email "<>"
97+
98+
# Create RC branch using date-based naming
99+
git checkout -b $BRANCH_NAME
100+
101+
# Update package versions individually
102+
npm version --no-git-tag-version $TOOLKIT_VERSION -w packages/toolkit
103+
npm version --no-git-tag-version $AMAZONQ_VERSION -w packages/amazonq
104+
105+
# Commit version changes
106+
git add packages/toolkit/package.json packages/amazonq/package.json package-lock.json
107+
git commit -m "chore: bump versions - toolkit=$TOOLKIT_VERSION, amazonq=$AMAZONQ_VERSION"
108+
109+
# Push RC branch
110+
git push origin $BRANCH_NAME

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ import { EditSuggestionState } from '../editSuggestionState'
1616
import type { AmazonQInlineCompletionItemProvider } from '../completion'
1717
import { vsCodeState } from 'aws-core-vscode/codewhisperer'
1818

19+
const autoRejectEditCursorDistance = 25
20+
1921
export class EditDecorationManager {
2022
private imageDecorationType: vscode.TextEditorDecorationType
2123
private removedCodeDecorationType: vscode.TextEditorDecorationType
@@ -346,6 +348,19 @@ export async function displaySvgDecoration(
346348
void vscode.commands.executeCommand('aws.amazonq.inline.rejectEdit')
347349
}
348350
})
351+
const cursorChangeListener = vscode.window.onDidChangeTextEditorSelection((e) => {
352+
if (!EditSuggestionState.isEditSuggestionActive()) {
353+
return
354+
}
355+
if (e.textEditor !== editor) {
356+
return
357+
}
358+
const currentPosition = e.selections[0].active
359+
const distance = Math.abs(currentPosition.line - startLine)
360+
if (distance > autoRejectEditCursorDistance) {
361+
void vscode.commands.executeCommand('aws.amazonq.inline.rejectEdit')
362+
}
363+
})
349364
await decorationManager.displayEditSuggestion(
350365
editor,
351366
svgImage,
@@ -371,6 +386,7 @@ export async function displaySvgDecoration(
371386

372387
await decorationManager.clearDecorations(editor)
373388
documentChangeListener.dispose()
389+
cursorChangeListener.dispose()
374390
const params: LogInlineCompletionSessionResultsParams = {
375391
sessionId: session.sessionId,
376392
completionSessionResult: {
@@ -405,6 +421,7 @@ export async function displaySvgDecoration(
405421
getLogger().info('Edit suggestion rejected')
406422
await decorationManager.clearDecorations(editor)
407423
documentChangeListener.dispose()
424+
cursorChangeListener.dispose()
408425
const params: LogInlineCompletionSessionResultsParams = {
409426
sessionId: session.sessionId,
410427
completionSessionResult: {

packages/amazonq/test/unit/amazonq/apps/inline/recommendationService.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,9 @@ describe('RecommendationService', () => {
129129

130130
describe('getAllRecommendations', () => {
131131
it('should handle single request with no partial result token', async () => {
132+
// Mock EditSuggestionState to return false (no edit suggestion active)
133+
sandbox.stub(EditSuggestionState, 'isEditSuggestionActive').returns(false)
134+
132135
const mockFirstResult = {
133136
sessionId: 'test-session',
134137
items: [mockInlineCompletionItemOne],
@@ -172,6 +175,9 @@ describe('RecommendationService', () => {
172175
})
173176

174177
it('should handle multiple request with partial result token', async () => {
178+
// Mock EditSuggestionState to return false (no edit suggestion active)
179+
sandbox.stub(EditSuggestionState, 'isEditSuggestionActive').returns(false)
180+
175181
const mockFirstResult = {
176182
sessionId: 'test-session',
177183
items: [mockInlineCompletionItemOne],

0 commit comments

Comments
 (0)