Commit 7902e03
authored
fix(amazonq): block completion before active edit is accepted/rejected (#8141)
## Problem
Both completion suggestions (ghost text) and edit suggestions (diff
view) could appear simultaneously due to a race condition. The
EditSuggestionState flag was set too late in the edit display flow,
allowing completion requests to check the state, see it as false, and
proceed even while an edit was being displayed.
## Solution
Fixed the race condition by setting the edit state immediately at the
start of displaySvgDecoration() before any async operations:
* Set EditSuggestionState to true at the beginning of the edit flow
* Add state cleanup when edit cannot be shown (completion already active
or invalid patch)
* Avoid calling clearDecorations() in displayEditSuggestion() to prevent
premature state reset
* Check EditSuggestionState before making completion requests in
recommendationService.ts.
This ensures only one suggestion type is displayed at a time with proper
mutual exclusion.
---
- Treat all work as PUBLIC. Private `feature/x` branches will not be
squash-merged at release time.
- Your code changes must meet the guidelines in
[CONTRIBUTING.md](https://github.com/aws/aws-toolkit-vscode/blob/master/CONTRIBUTING.md#guidelines).
- License: I confirm that my contribution is made under the terms of the
Apache 2.0 license.1 parent 593815a commit 7902e03
File tree
3 files changed
+23
-8
lines changed- packages/amazonq
- src/app/inline
- EditRendering
- test/unit/amazonq/apps/inline
3 files changed
+23
-8
lines changedLines changed: 17 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
136 | 136 | | |
137 | 137 | | |
138 | 138 | | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
143 | 144 | | |
144 | 145 | | |
145 | 146 | | |
| |||
313 | 314 | | |
314 | 315 | | |
315 | 316 | | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
316 | 321 | | |
317 | 322 | | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
318 | 327 | | |
319 | 328 | | |
320 | 329 | | |
| |||
326 | 335 | | |
327 | 336 | | |
328 | 337 | | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
329 | 342 | | |
330 | 343 | | |
331 | 344 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
138 | 138 | | |
139 | 139 | | |
140 | 140 | | |
141 | | - | |
| 141 | + | |
142 | 142 | | |
143 | 143 | | |
144 | 144 | | |
| |||
Lines changed: 5 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
333 | 333 | | |
334 | 334 | | |
335 | 335 | | |
336 | | - | |
| 336 | + | |
337 | 337 | | |
338 | 338 | | |
339 | 339 | | |
| |||
360 | 360 | | |
361 | 361 | | |
362 | 362 | | |
363 | | - | |
364 | | - | |
| 363 | + | |
| 364 | + | |
365 | 365 | | |
366 | 366 | | |
367 | 367 | | |
368 | 368 | | |
369 | 369 | | |
| 370 | + | |
| 371 | + | |
370 | 372 | | |
371 | 373 | | |
372 | 374 | | |
| |||
0 commit comments