@@ -289,15 +289,23 @@ func (c *Conversation) writeMessageWithConfirmation(ctx context.Context, message
289
289
290
290
// wait for the screen to change after the carriage return is written
291
291
screenBeforeCarriageReturn := c .cfg .AgentIO .ReadScreen ()
292
+ lastCarriageReturnTime := time.Time {}
292
293
if err := util .WaitFor (ctx , util.WaitTimeout {
293
294
Timeout : 15 * time .Second ,
294
295
MinInterval : 25 * time .Millisecond ,
295
296
}, func () (bool , error ) {
296
- if _ , err := c .cfg .AgentIO .Write ([]byte ("\r " )); err != nil {
297
- return false , xerrors .Errorf ("failed to write carriage return: %w" , err )
297
+ // we don't want to spam additional carriage returns because the agent may process them
298
+ // (aider does this), but we do want to retry sending one if nothing's
299
+ // happening for a while
300
+ if time .Since (lastCarriageReturnTime ) >= 3 * time .Second {
301
+ lastCarriageReturnTime = time .Now ()
302
+ if _ , err := c .cfg .AgentIO .Write ([]byte ("\r " )); err != nil {
303
+ return false , xerrors .Errorf ("failed to write carriage return: %w" , err )
304
+ }
298
305
}
299
306
time .Sleep (25 * time .Millisecond )
300
307
screen := c .cfg .AgentIO .ReadScreen ()
308
+
301
309
return screen != screenBeforeCarriageReturn , nil
302
310
}); err != nil {
303
311
return xerrors .Errorf ("failed to wait for processing to start: %w" , err )
0 commit comments