Skip to content

Commit e9370c6

Browse files
Merge branch 'main' into dev
2 parents 22097b1 + 0ae89b9 commit e9370c6

File tree

3 files changed

+131
-65
lines changed

3 files changed

+131
-65
lines changed

.github/workflows/deploy.yml

Lines changed: 111 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,27 @@ jobs:
123123
embeddingDeploymentCapacity="30" \
124124
imageTag="latest"
125125
126+
- name: Extract AI Services and Key Vault Names
127+
if: always()
128+
run: |
129+
echo "Fetching AI Services and Key Vault names before deletion..."
130+
131+
# Get Key Vault name
132+
KEYVAULT_NAME=$(az resource list --resource-group "${{ env.RESOURCE_GROUP_NAME }}" --resource-type "Microsoft.KeyVault/vaults" --query "[].name" -o tsv)
133+
echo "Detected Key Vault: $KEYVAULT_NAME"
134+
echo "KEYVAULT_NAME=$KEYVAULT_NAME" >> $GITHUB_ENV
135+
136+
137+
# Extract AI Services names
138+
echo "Fetching AI Services..."
139+
AI_SERVICES=$(az resource list --resource-group '${{ env.RESOURCE_GROUP_NAME }}' --resource-type "Microsoft.CognitiveServices/accounts" --query "[].name" -o tsv)
140+
141+
# Flatten newline-separated values to space-separated
142+
AI_SERVICES=$(echo "$AI_SERVICES" | paste -sd ' ' -)
143+
144+
echo "Detected AI Services: $AI_SERVICES"
145+
echo "AI_SERVICES=$AI_SERVICES" >> $GITHUB_ENV
146+
126147
- name: Delete Bicep Deployment
127148
if: success()
128149
run: |
@@ -142,82 +163,124 @@ jobs:
142163
143164
- name: Wait for Resource Deletion to Complete
144165
run: |
145-
# List of resources to check based on SOLUTION_PREFIX
146-
resources_to_check=(
147-
"aoai-${{ env.SOLUTION_PREFIX }}"
148-
"appins-${{ env.SOLUTION_PREFIX }}"
149-
"db-cosmos-${{ env.SOLUTION_PREFIX }}"
150-
"${{ env.SOLUTION_PREFIX }}-plan"
151-
"search-${{ env.SOLUTION_PREFIX }}"
152-
"webapp-${{ env.SOLUTION_PREFIX }}"
153-
"worksp-${{ env.SOLUTION_PREFIX }}"
154-
)
155-
156-
# Get the list of resources in YAML format
157-
resource_list=$(az resource list --subscription ${{ secrets.AZURE_SUBSCRIPTION_ID }} --output yaml)
158-
159-
# Maximum number of retries and retry intervals
166+
echo "Waiting for all deployed resources (including AI Services) to be deleted..."
167+
168+
# Convert AI_SERVICES space-separated string into an array
169+
IFS=' ' read -r -a resources_to_check <<< "${{ env.AI_SERVICES }}"
170+
171+
echo "Resources to check for deletion:"
172+
printf '%s\n' "${resources_to_check[@]}"
173+
174+
# Get the current resource list in YAML
175+
resource_list=$(az resource list --subscription "${{ secrets.AZURE_SUBSCRIPTION_ID }}" --output yaml)
176+
177+
# Set up retry logic
160178
max_retries=3
161179
retry_intervals=(30 60 120)
162180
retries=0
163-
181+
164182
while true; do
165183
resource_found=false
166-
# Iterate through the resources to check
167184
for resource in "${resources_to_check[@]}"; do
168-
echo "Checking resource: $resource"
185+
echo "Checking if resource '$resource' still exists..."
169186
if echo "$resource_list" | grep -q "name: $resource"; then
170-
echo "Resource '$resource' exists in the subscription."
187+
echo "Resource '$resource' still exists."
171188
resource_found=true
172189
else
173-
echo "Resource '$resource' does not exist in the subscription."
190+
echo "Resource '$resource' has been deleted."
174191
fi
175192
done
176-
177-
# If any resource exists, retry
193+
178194
if [ "$resource_found" = true ]; then
179195
retries=$((retries + 1))
180196
if [ "$retries" -ge "$max_retries" ]; then
181-
echo "Maximum retry attempts reached. Exiting."
197+
echo "Reached max retry attempts. Exiting wait loop."
182198
break
183199
else
184-
echo "Waiting for ${retry_intervals[$retries-1]} seconds before retrying..."
185-
sleep ${retry_intervals[$retries-1]}
200+
echo "Some resources still exist. Waiting for ${retry_intervals[$((retries-1))]} seconds..."
201+
sleep "${retry_intervals[$((retries-1))]}"
202+
resource_list=$(az resource list --subscription "${{ secrets.AZURE_SUBSCRIPTION_ID }}" --output yaml)
186203
fi
187204
else
188-
echo "No resources found. Exiting."
205+
echo "All resources have been deleted."
189206
break
190207
fi
191208
done
209+
192210

193-
- name: Purging the Resources
194-
if: success()
211+
- name: Wait for Soft Deletion of Key Vault and AI Services
212+
if: always()
195213
run: |
196-
set -e
197-
# Purging resources based on solution prefix
198-
echo "Purging resources..."
199-
200-
# List of resources to purge
201-
resources_to_purge=(
202-
"aoai-${{ env.SOLUTION_PREFIX }}"
203-
"appins-${{ env.SOLUTION_PREFIX }}"
204-
"db-cosmos-${{ env.SOLUTION_PREFIX }}"
205-
"${{ env.SOLUTION_PREFIX }}-plan"
206-
"search-${{ env.SOLUTION_PREFIX }}"
207-
"webapp-${{ env.SOLUTION_PREFIX }}"
208-
"worksp-${{ env.SOLUTION_PREFIX }}"
209-
)
214+
echo "Waiting for resources to be soft deleted..."
215+
216+
# Wait for Key Vault to be soft deleted
217+
if [ -n "${{ env.KEYVAULT_NAME }}" ]; then
218+
while true; do
219+
DELETED_VAULT=$(az keyvault show-deleted --name ${{ env.KEYVAULT_NAME }} --query "id" -o tsv 2>/dev/null || echo "")
220+
if [ -n "$DELETED_VAULT" ]; then
221+
echo "Key Vault soft deleted!"
222+
break
223+
fi
224+
echo "Key Vault not yet soft deleted. Retrying in 15s..."
225+
sleep 15
226+
done
227+
fi
228+
229+
230+
# Wait for AI Services to be soft deleted
231+
for AI_SERVICE in ${{ env.AI_SERVICES }}; do
232+
while true; do
233+
DELETED_AI_SERVICE=$(az cognitiveservices account list-deleted --query "[?name=='$AI_SERVICE'].id" -o tsv 2>/dev/null || echo "")
234+
if [ -n "$DELETED_AI_SERVICE" ]; then
235+
echo "AI Service $AI_SERVICE is soft deleted!"
236+
break
237+
fi
238+
echo "AI Service $AI_SERVICE not yet soft deleted. Retrying in 15s..."
239+
sleep 15
240+
done
241+
done
242+
243+
244+
- name: Purge Key Vault and AI Services
245+
if: always()
246+
run: |
247+
echo "Purging soft deleted resources..."
210248
211-
for resource in "${resources_to_purge[@]}"; do
212-
echo "Purging resource: $resource"
213-
if ! az resource delete --ids /subscriptions/${{ secrets.AZURE_SUBSCRIPTION_ID }}/providers/Microsoft.CognitiveServices/locations/uksouth/deletedAccounts/$resource --verbose; then
214-
echo "Failed to purge resource: $resource"
249+
# Ensure AI_SERVICES is properly split into individual services
250+
IFS=' ' read -r -a SERVICES <<< "${{ env.AI_SERVICES }}"
251+
252+
for AI_SERVICE in "${SERVICES[@]}"; do
253+
echo "Checking location for AI Service: $AI_SERVICE"
254+
255+
# Fetch AI Service location
256+
SERVICE_LOCATION=$(az cognitiveservices account list-deleted --query "[?name=='$AI_SERVICE'].location" -o tsv 2>/dev/null || echo "")
257+
258+
if [ -n "$SERVICE_LOCATION" ]; then
259+
echo "Purging AI Service $AI_SERVICE in $SERVICE_LOCATION"
260+
az cognitiveservices account purge --location "$SERVICE_LOCATION" --resource-group "${{ env.RESOURCE_GROUP_NAME }}" --name "$AI_SERVICE"
261+
else
262+
echo "Could not determine location for AI Service: $AI_SERVICE. Skipping purge."
263+
fi
264+
done
265+
266+
# --- Purge Key Vaults ---
267+
echo "Starting purge for Key Vaults..."
268+
IFS=' ' read -r -a VAULTS <<< "${{ env.KEYVAULT_NAME }}"
269+
270+
for VAULT in "${VAULTS[@]}"; do
271+
echo "Checking location for Key Vault: $VAULT"
272+
273+
# Fetch Key Vault location
274+
VAULT_LOCATION=$(az keyvault list-deleted --query "[?name=='$VAULT'].properties.location" -o tsv 2>/dev/null || echo "")
275+
276+
if [ -n "$VAULT_LOCATION" ]; then
277+
echo "Purging Key Vault $VAULT in $VAULT_LOCATION"
278+
az keyvault purge --name "$VAULT" --location "$VAULT_LOCATION"
215279
else
216-
echo "Purged the resource: $resource"
280+
echo "Could not determine location for Key Vault: $VAULT. Skipping purge."
217281
fi
218282
done
219283
220-
echo "Resource purging completed successfully"
221284
222285
- name: Send Notification on Failure
223286
if: failure()

src/frontend/src/components/ChatHistory/ChatHistoryListItem.tsx

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,14 @@ export const ChatHistoryListItemCell: React.FC<ChatHistoryListItemCellProps> = (
225225
tabIndex={0}
226226
aria-label="chat history item"
227227
className={styles.itemCell}
228-
onClick={() => handleSelectItem()}
229-
onKeyDown={e => (e.key === 'Enter' || e.key === ' ' ? handleSelectItem() : null)}
228+
onClick={() => {if (!edit) handleSelectItem()}}
229+
onKeyDown={e => {
230+
if (!edit && (e.key === 'Enter' || e.key === ' ')) {
231+
handleSelectItem();
232+
} else {
233+
e.stopPropagation(); // stop from reaching here when editing
234+
}
235+
}}
230236
verticalAlign="center"
231237
// horizontal
232238
onMouseEnter={() => setIsHovered(true)}
@@ -258,7 +264,7 @@ export const ChatHistoryListItemCell: React.FC<ChatHistoryListItemCellProps> = (
258264
<Stack aria-label="action button group" horizontal verticalAlign={'center'}>
259265
<IconButton
260266
role="button"
261-
disabled={errorRename !== undefined}
267+
disabled={errorRename !== undefined || editTitle == item.title}
262268
onKeyDown={e => (e.key === ' ' || e.key === 'Enter' ? handleSaveEdit(e) : null)}
263269
onClick={e => handleSaveEdit(e)}
264270
aria-label="confirm new title"
@@ -311,13 +317,21 @@ export const ChatHistoryListItemCell: React.FC<ChatHistoryListItemCellProps> = (
311317
disabled={isButtonDisabled}
312318
onKeyDown={e => (e.key === ' ' ? toggleDeleteDialog() : null)}
313319
/>
314-
<IconButton
320+
<IconButton
315321
className={styles.itemButton}
316322
iconProps={{ iconName: 'Edit' }}
317323
title="Edit"
318-
onClick={onEdit}
324+
onClick={(e) => {
325+
e.stopPropagation(); // Prevent triggering parent click
326+
onEdit();
327+
}}
319328
disabled={isButtonDisabled}
320-
onKeyDown={e => (e.key === ' ' ? onEdit() : null)}
329+
onKeyDown={(e) => {
330+
if (e.key === ' ') {
331+
e.stopPropagation(); // Prevent triggering parent keydown
332+
onEdit();
333+
}
334+
}}
321335
/>
322336
</Stack>
323337
)}

src/frontend/src/components/ChatHistory/chatHistoryListItem.test.tsx

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -487,10 +487,6 @@ describe('ChatHistoryListItemCell', () => {
487487
// Simulate clicking the confirm button
488488
userEvent.click(screen.getByRole('button', { name: 'confirm new title' }))
489489

490-
// Wait for the error message to appear
491-
await waitFor(() => {
492-
expect(screen.getByText(/Error: Enter a new title to proceed./i)).toBeInTheDocument()
493-
})
494490

495491
// Wait for the error message to disappear after 5 seconds
496492
await waitFor(() => expect(screen.queryByText('Error: Enter a new title to proceed.')).not.toBeInTheDocument(), {
@@ -550,18 +546,11 @@ describe('ChatHistoryListItemCell', () => {
550546
await userEvent.type(inputItem, 'update Chat')
551547
})
552548

553-
userEvent.click(screen.getByRole('button', { name: 'confirm new title' }))
554-
555-
await waitFor(() => {
556-
expect(screen.getByText(/Error: Enter a new title to proceed./i)).toBeInTheDocument()
557-
})
558549

559550
// Wait for the error to be hidden after 5 seconds
560551
await waitFor(() => expect(screen.queryByText('Error: could not rename item')).not.toBeInTheDocument(), {
561552
timeout: 6000
562553
})
563-
const input = screen.getByLabelText('chat history item')
564-
expect(input).toHaveFocus()
565554
}, 10000)
566555

567556
test('shows error when trying to rename to an existing title', async () => {

0 commit comments

Comments
 (0)