Skip to content

Commit 4003e39

Browse files
authored
Merge branch 'master' into jl
2 parents ce0af16 + f084467 commit 4003e39

File tree

5 files changed

+303
-25
lines changed

5 files changed

+303
-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_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: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
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+
env:
47+
CUSTOM_VERSION: ${{ inputs.customVersion }}
48+
VERSION_INCREMENT: ${{ inputs.versionIncrement }}
49+
run: |
50+
customVersion="$CUSTOM_VERSION"
51+
versionIncrement="$VERSION_INCREMENT"
52+
53+
increment_version() {
54+
local currentVersion=$1
55+
if [[ "$versionIncrement" == "Custom" && -n "$customVersion" ]]; then
56+
echo "$customVersion"
57+
else
58+
IFS='.' read -r major minor patch <<< "$currentVersion"
59+
case "$versionIncrement" in
60+
"Major")
61+
major=$((major + 1))
62+
minor=0
63+
patch=0
64+
;;
65+
"Minor")
66+
minor=$((minor + 1))
67+
patch=0
68+
;;
69+
"Patch")
70+
patch=$((patch + 1))
71+
;;
72+
esac
73+
echo "$major.$minor.$patch"
74+
fi
75+
}
76+
77+
# Read and increment toolkit version
78+
toolkitCurrentVersion=$(node -e "console.log(require('./packages/toolkit/package.json').version)" | sed 's/-SNAPSHOT//')
79+
toolkitNewVersion=$(increment_version "$toolkitCurrentVersion")
80+
81+
# Read and increment amazonq version
82+
amazonqCurrentVersion=$(node -e "console.log(require('./packages/amazonq/package.json').version)" | sed 's/-SNAPSHOT//')
83+
amazonqNewVersion=$(increment_version "$amazonqCurrentVersion")
84+
85+
echo "TOOLKIT_VERSION=$toolkitNewVersion" >> $GITHUB_OUTPUT
86+
echo "AMAZONQ_VERSION=$amazonqNewVersion" >> $GITHUB_OUTPUT
87+
# Use date-based branch naming instead of version-based because we release
88+
# both extensions (toolkit and amazonq) from the same branch, and they may
89+
# have different version numbers. We can change this in the future
90+
echo "BRANCH_NAME=release/rc-$(date +%Y%m%d)" >> $GITHUB_OUTPUT
91+
92+
- name: Create RC Branch and Update Versions
93+
env:
94+
TOOLKIT_VERSION: ${{ steps.release-version.outputs.TOOLKIT_VERSION }}
95+
AMAZONQ_VERSION: ${{ steps.release-version.outputs.AMAZONQ_VERSION }}
96+
BRANCH_NAME: ${{ steps.release-version.outputs.BRANCH_NAME }}
97+
run: |
98+
git config user.name "aws-toolkit-automation"
99+
git config user.email "<>"
100+
101+
# Create RC branch using date-based naming
102+
git checkout -b $BRANCH_NAME
103+
104+
# Update package versions individually
105+
npm version --no-git-tag-version $TOOLKIT_VERSION -w packages/toolkit
106+
npm version --no-git-tag-version $AMAZONQ_VERSION -w packages/amazonq
107+
108+
# Commit version changes
109+
git add packages/toolkit/package.json packages/amazonq/package.json package-lock.json
110+
git commit -m "chore: bump versions - toolkit=$TOOLKIT_VERSION, amazonq=$AMAZONQ_VERSION"
111+
112+
# Push RC branch
113+
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)