Use ActivityGuard for context overflow retry progress

Instead of two separate notifications piling up on the status bar,
use a single ActivityGuard that updates in place during overflow
retries and auto-completes when the turn finishes.

Co-Authored-By: Proof of Concept <poc@bcachefs.org>
This commit is contained in:
ProofOfConcept 2026-04-09 22:25:16 -04:00 committed by Kent Overstreet
parent 121b46e1d2
commit 5fe22a5f23

View file

@ -318,6 +318,7 @@ impl Agent {
} }
let mut overflow_retries: u32 = 0; let mut overflow_retries: u32 = 0;
let mut overflow_activity: Option<ActivityGuard> = None;
let mut empty_retries: u32 = 0; let mut empty_retries: u32 = 0;
let mut ds = DispatchState::new(); let mut ds = DispatchState::new();
@ -382,8 +383,12 @@ impl Agent {
} }
if overflow_retries < 2 { if overflow_retries < 2 {
overflow_retries += 1; overflow_retries += 1;
agent.state.lock().await.notify( let msg = format!("context overflow — compacting ({}/2)", overflow_retries);
format!("context overflow — retrying ({}/2)", overflow_retries)); match &overflow_activity {
Some(a) => a.update(&msg).await,
None => overflow_activity = Some(
start_activity(&agent, &msg).await),
}
agent.compact().await; agent.compact().await;
continue; continue;
} }