agent2: Port retry logic (#36421)

Release Notes:

- N/A
This commit is contained in:
Bennet Bo Fenner 2025-08-19 11:41:55 +02:00 committed by GitHub
parent 47e1d4511c
commit 0ea0d466d2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 514 additions and 52 deletions

View file

@ -24,6 +24,7 @@ use std::fmt::{Formatter, Write};
use std::ops::Range;
use std::process::ExitStatus;
use std::rc::Rc;
use std::time::{Duration, Instant};
use std::{fmt::Display, mem, path::PathBuf, sync::Arc};
use ui::App;
use util::ResultExt;
@ -658,6 +659,15 @@ impl PlanEntry {
}
}
#[derive(Debug, Clone)]
pub struct RetryStatus {
pub last_error: SharedString,
pub attempt: usize,
pub max_attempts: usize,
pub started_at: Instant,
pub duration: Duration,
}
pub struct AcpThread {
title: SharedString,
entries: Vec<AgentThreadEntry>,
@ -676,6 +686,7 @@ pub enum AcpThreadEvent {
EntryUpdated(usize),
EntriesRemoved(Range<usize>),
ToolAuthorizationRequired,
Retry(RetryStatus),
Stopped,
Error,
ServerExited(ExitStatus),
@ -916,6 +927,10 @@ impl AcpThread {
cx.emit(AcpThreadEvent::NewEntry);
}
pub fn update_retry_status(&mut self, status: RetryStatus, cx: &mut Context<Self>) {
cx.emit(AcpThreadEvent::Retry(status));
}
pub fn update_tool_call(
&mut self,
update: impl Into<ToolCallUpdate>,