-
Notifications
You must be signed in to change notification settings - Fork 4.1k
fix: prevent race conditions when applying multiple diffs in parallel #9490
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Learn moreAll Green is an AI agent that automatically: ✅ Addresses code review comments ✅ Fixes failing CI checks ✅ Resolves merge conflicts |
1 similar comment
Learn moreAll Green is an AI agent that automatically: ✅ Addresses code review comments ✅ Fixes failing CI checks ✅ Resolves merge conflicts |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 issue found across 2 files
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="gui/src/redux/thunks/handleApplyStateUpdate.ts">
<violation number="1" location="gui/src/redux/thunks/handleApplyStateUpdate.ts:172">
P1: Concurrent apply thunks can deadlock: the wait loop counts the current not-started apply state, so two simultaneous calls both wait forever and never call applyToFile.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
RomneyDa
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a more deterministic approach we could take to queuing these diffs?
My concern is that 1000 ms is kind of long so in the case a diff stopped streaming just after it checks (1000 ms till next check) and then someone starts clicking around it would suddenly start streaming and feel glitchy?
True. It need not be 1000 ms. I added that as an approximate - but most diffs resolve faster. Will put 100 ms instead. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@uinstinct I think we should consider more predictable routes to applying the diffs in order, there are other issues with this approach e.g. selectApplyStatesInProgress could potentially detect some stale apply states which were ignored in a previous session etc and then it would never apply the diff
Let's avoid polling if possible and implement some kind of predictable queue.
- for both reading and writing to the file when applying to it
implemented a new method to rely on getting the filepath's editor without opening activeTextEditor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 issue found across 5 files (changes from recent commits).
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="extensions/vscode/src/diff/vertical/manager.ts">
<violation number="1" location="extensions/vscode/src/diff/vertical/manager.ts:308">
P2: instantApplyDiff now assumes `filepath` is already a URI string; passing a filesystem path breaks handler creation and map lookups because `Uri.parse` and `fileUriToCodeLens` keys won’t match the editor’s file:// URI.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Description
Wait for the previous edit tool to create its diff in the IDE before the next edit tool.
This caused race conditions because the code required the text editor to be active for the diff to be streamed into the proper file.
resolves CON-5048
AI Code Review
@continue-reviewChecklist
Screen recording or screenshot
before.mp4
after.mp4
Tests
[ What tests were added or updated to ensure the changes work as expected? ]
Continue Tasks
Powered by Continue
Summary by cubic
Prevent race conditions when multiple edit tools apply diffs at the same time by targeting the correct file editor. Each diff now streams to the right file without relying on the active editor.
Written for commit 4d4211f. Summary will update on new commits.