Improve chat rendering and generation summaries

This commit is contained in:
Georg Bauer
2026-07-27 14:04:14 +02:00
parent 6a541b51f9
commit 8a08cd7b52
10 changed files with 152 additions and 13 deletions

View File

@@ -19,6 +19,7 @@ pub(crate) struct GenerationService {
pub(crate) struct ActiveGeneration {
pub(crate) events: Receiver<GenerationEvent>,
pub(crate) cancel: Arc<AtomicBool>,
pub(crate) started_at: Instant,
}
impl Drop for ActiveGeneration {
@@ -107,6 +108,7 @@ impl GenerationService {
checkpoint: CheckpointTarget,
idle_timeout: Duration,
) -> Result<ActiveGeneration, String> {
let started_at = Instant::now();
let source = checkpoint.source();
let cancel = Arc::new(AtomicBool::new(false));
let (events, receiver) = mpsc::channel();
@@ -131,6 +133,7 @@ impl GenerationService {
Ok(ActiveGeneration {
events: receiver,
cancel,
started_at,
})
}
@@ -145,6 +148,7 @@ impl GenerationService {
checkpoint: PathBuf,
idle_timeout: Duration,
) -> Result<ActiveGeneration, String> {
let started_at = Instant::now();
let cancel = Arc::new(AtomicBool::new(false));
let (events, receiver) = mpsc::channel();
self.commands
@@ -165,6 +169,7 @@ impl GenerationService {
Ok(ActiveGeneration {
events: receiver,
cancel,
started_at,
})
}
@@ -175,6 +180,7 @@ impl GenerationService {
messages: Vec<ChatTurn>,
idle_timeout: Duration,
) -> Result<ActiveGeneration, String> {
let started_at = Instant::now();
let cancel = Arc::new(AtomicBool::new(false));
let (events, receiver) = mpsc::channel();
self.metrics.request_queued(WorkSource::LocalChat);
@@ -193,6 +199,7 @@ impl GenerationService {
Ok(ActiveGeneration {
events: receiver,
cancel,
started_at,
})
}
}
@@ -430,6 +437,7 @@ mod tests {
drop(ActiveGeneration {
events,
cancel: Arc::clone(&cancel),
started_at: Instant::now(),
});
assert!(cancel.load(Ordering::Relaxed));