Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: prevent race condition by setting placeholder before processing …
…task

Co-authored-by: aider (gemini/gemini-2.5-pro) <aider@aider.chat>
  • Loading branch information
ErichBSchulz and aider-chat-bot committed Oct 29, 2025
commit c7757a7e5880beb9fbcf97c06ec0d9db2cfbcade
4 changes: 3 additions & 1 deletion aider/coders/base_coder.py
Original file line number Diff line number Diff line change
Expand Up @@ -1099,7 +1099,7 @@ async def _run_patched(self, with_message=None, preproc=True):
f"input_task is None={input_task is None}, "
f"user_message is None={user_message is None}, "
f"processing_task is None={processing_task is None}, "
f"placeholder='{self.io.placeholder}'"
f"placeholder={self.io.placeholder!r}"
)
self.logger.debug("Getting input from user")
if not self.suppress_announcements_for_next_prompt:
Expand Down Expand Up @@ -1156,6 +1156,8 @@ async def _run_patched(self, with_message=None, preproc=True):
self.io.stop_spinner()

if user_message and self.run_one_completed and self.compact_context_completed:
if self.commands.is_command(user_message):
self.io.placeholder = "Running command..."
processing_task = asyncio.create_task(
self._processing_logic(user_message, preproc)
)
Expand Down
2 changes: 1 addition & 1 deletion aider/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from dataclasses import fields
from pathlib import Path

DEBUG_COUNTER = 4
DEBUG_COUNTER = 5

try:
import git
Expand Down
14 changes: 13 additions & 1 deletion debug_plan.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,23 @@ tracking to ensure clarity and correctness.
message while a command is running. This will prevent the main loop from asking for new
input until the command is finished. I will also increment the debug counter to version 3.
*Status: This fix was not successful and led to the application hanging.*
* `[ ]` **Add more logging to diagnose race condition**
* `[✓]` **Add more logging to diagnose race condition**
The application still tries to get input while a command is running. To understand why the
control flow logic is failing, I will add more detailed logging to `aider/coders/base_coder.py`.
This will capture the state of key variables (`confirmation_in_progress`, `input_task`,
`user_message`, `processing_task`, and `self.io.placeholder`) just before the decision to
request new user input is made. This should reveal the nature of the race condition or logical
flaw. The debug counter will be incremented to version 4.
* `[✓]` **Analyze logs and identify race condition**
The logs from debug counter 4 confirm a race condition. The main loop in `_run_patched` checks
whether to ask for new user input immediately after creating a `processing_task` for the
command. However, the `io.placeholder` which should prevent this is only set *inside* the
`processing_task`. By the time the placeholder is set, the main loop has already incorrectly
decided to ask for new user input.
* `[ ]` **Propose and Test a Fix**
To fix the race condition, I will modify `aider/coders/base_coder.py` to set a generic
placeholder (`"Running command..."`) *before* the `processing_task` is created. This will
ensure the main loop sees the placeholder and waits for the command to complete. The more
specific placeholder and its cleanup will still be handled within `aider/commands.py`. The
debug counter will be incremented to version 5.