Add persistent local agent tools
This commit is contained in:
26
src/app.rs
26
src/app.rs
@@ -32,7 +32,7 @@ use std::fs;
|
||||
use std::path::PathBuf;
|
||||
use std::sync::atomic::{AtomicBool, AtomicU64, Ordering};
|
||||
use std::sync::mpsc::{self, TryRecvError};
|
||||
use std::sync::{Arc, RwLock};
|
||||
use std::sync::{Arc, Mutex, RwLock};
|
||||
use std::thread;
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
@@ -84,6 +84,10 @@ pub(crate) struct App {
|
||||
#[cfg(target_os = "macos")]
|
||||
active_generation: Option<ActiveGeneration>,
|
||||
#[cfg(target_os = "macos")]
|
||||
agent_tools: Option<(i32, Arc<Mutex<crate::agent::Tools>>)>,
|
||||
#[cfg(target_os = "macos")]
|
||||
active_tools: Option<crate::agent::ActiveTools>,
|
||||
#[cfg(target_os = "macos")]
|
||||
active_titling: Option<generation::TitleRequest>,
|
||||
#[cfg(target_os = "macos")]
|
||||
runtime_preferences: Arc<RwLock<AppPreferences>>,
|
||||
@@ -249,6 +253,10 @@ impl App {
|
||||
#[cfg(target_os = "macos")]
|
||||
active_generation: None,
|
||||
#[cfg(target_os = "macos")]
|
||||
agent_tools: None,
|
||||
#[cfg(target_os = "macos")]
|
||||
active_tools: None,
|
||||
#[cfg(target_os = "macos")]
|
||||
active_titling: None,
|
||||
#[cfg(target_os = "macos")]
|
||||
runtime_preferences,
|
||||
@@ -326,6 +334,10 @@ impl App {
|
||||
#[cfg(target_os = "macos")]
|
||||
active_generation: None,
|
||||
#[cfg(target_os = "macos")]
|
||||
agent_tools: None,
|
||||
#[cfg(target_os = "macos")]
|
||||
active_tools: None,
|
||||
#[cfg(target_os = "macos")]
|
||||
active_titling: None,
|
||||
#[cfg(target_os = "macos")]
|
||||
runtime_preferences,
|
||||
@@ -643,12 +655,15 @@ impl App {
|
||||
self.start_generation();
|
||||
return scroll_chat_to_end();
|
||||
}
|
||||
Message::StopGeneration =>
|
||||
{
|
||||
Message::StopGeneration => {
|
||||
#[cfg(target_os = "macos")]
|
||||
if let Some(active) = &self.active_generation {
|
||||
active.cancel.store(true, Ordering::Relaxed);
|
||||
}
|
||||
#[cfg(target_os = "macos")]
|
||||
if let Some(active) = &self.active_tools {
|
||||
active.cancel.store(true, Ordering::Relaxed);
|
||||
}
|
||||
}
|
||||
Message::GenerationTick => {
|
||||
#[cfg(target_os = "macos")]
|
||||
@@ -1007,6 +1022,10 @@ impl Drop for App {
|
||||
if let Some(active) = &self.active_generation {
|
||||
active.cancel.store(true, Ordering::Relaxed);
|
||||
}
|
||||
#[cfg(target_os = "macos")]
|
||||
if let Some(active) = &self.active_tools {
|
||||
active.cancel.store(true, Ordering::Relaxed);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1130,6 +1149,7 @@ mod tests {
|
||||
let mut message = ChatMessage {
|
||||
id: 1,
|
||||
user: false,
|
||||
tool: false,
|
||||
reasoning: Some(String::new()),
|
||||
reasoning_complete: false,
|
||||
reasoning_open: true,
|
||||
|
||||
Reference in New Issue
Block a user