-
Notifications
You must be signed in to change notification settings - Fork 2.6k
fix: race in short-running command output capture #2624
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
Conversation
Previously, handlers for terminal output were registered after starting the process, which could cause output to be missed for fast-executing commands that complete before handlers are set up. - Adds CommandCallbacks interface to register handlers upfront - Moves handler registration before process start to ensure no output is missed - Provides process instance in callbacks for direct control - Adds debug logging to help diagnose timing issues Signed-off-by: Eric Wheeler <[email protected]>
|
|
|
||
| // keep in case we need it to troubleshoot user issues, but this should be removed in the future | ||
| // if everything looks good: | ||
| console.debug( |
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.
Debug logging is quite detailed (using JSON.stringify with indentation) and logs several internal state fields. Consider gating this under a debug flag or proper logging level check to avoid performance overhead or inadvertent leakage of sensitive/internal information in production.
|
please test this but I think it is worth expediting. |
mrubens
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.
Thanks!
Previously, handlers for terminal output were registered after starting the process, which could cause output to be missed for fast-executing commands that complete before handlers are set up. - Adds CommandCallbacks interface to register handlers upfront - Moves handler registration before process start to ensure no output is missed - Provides process instance in callbacks for direct control - Adds debug logging to help diagnose timing issues Signed-off-by: Eric Wheeler <[email protected]> Co-authored-by: Eric Wheeler <[email protected]>
Context
There was a race condition in terminal command handling where fast-executing commands would incorrectly signal to the AI that they were running in background mode. This occurred because:
The issue specifically manifests when the terminal delay is set to zero, typically appearing after 3-5 command iterations.
Implementation
Before
After
How to Test
Set terminal delay to zero and give the AI this exact instruction:
Verify that:
Get in Touch
Discord: KJ7LNW
Important
Fixes race condition in terminal command handling by registering event handlers before process start and introducing
CommandCallbacksfor accurate command state detection.Cline.tsandTerminal.ts.CommandCallbacksinterface inTerminal.tsfor handling terminal events likeonLine,onCompleted, etc.runCommandmethod inTerminal.tsto acceptCommandCallbacksfor accurate command state detection.Cline.tsto diagnose command completion vs background mode confusion.This description was created by
for 688da6d. It will automatically update as commits are pushed.