Skip to content

fix(conversation): send fewer carriage returns after a user message #11

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

Merged
merged 3 commits into from
May 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 4 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode"
"editor.defaultFormatter": "esbenp.prettier-vscode",
"[go]": {
"editor.defaultFormatter": "golang.go"
}
}
12 changes: 10 additions & 2 deletions lib/screentracker/conversation.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,15 +289,23 @@ func (c *Conversation) writeMessageWithConfirmation(ctx context.Context, message

// wait for the screen to change after the carriage return is written
screenBeforeCarriageReturn := c.cfg.AgentIO.ReadScreen()
lastCarriageReturnTime := time.Time{}
if err := util.WaitFor(ctx, util.WaitTimeout{
Timeout: 15 * time.Second,
MinInterval: 25 * time.Millisecond,
}, func() (bool, error) {
if _, err := c.cfg.AgentIO.Write([]byte("\r")); err != nil {
return false, xerrors.Errorf("failed to write carriage return: %w", err)
// we don't want to spam additional carriage returns because the agent may process them
// (aider does this), but we do want to retry sending one if nothing's
// happening for a while
if time.Since(lastCarriageReturnTime) >= 3*time.Second {
lastCarriageReturnTime = time.Now()
if _, err := c.cfg.AgentIO.Write([]byte("\r")); err != nil {
return false, xerrors.Errorf("failed to write carriage return: %w", err)
}
}
time.Sleep(25 * time.Millisecond)
screen := c.cfg.AgentIO.ReadScreen()

return screen != screenBeforeCarriageReturn, nil
}); err != nil {
return xerrors.Errorf("failed to wait for processing to start: %w", err)
Expand Down