feat: first cut at dev brain
This commit is contained in:
@@ -10,6 +10,8 @@ pub(super) struct PreferenceDraft {
|
||||
pub(super) endpoint_port: String,
|
||||
pub(super) endpoint_enabled: bool,
|
||||
pub(super) endpoint_cors: bool,
|
||||
pub(super) dev_brain_enabled: bool,
|
||||
pub(super) dev_brain_vault_path: String,
|
||||
pub(super) context_tokens: String,
|
||||
pub(super) max_generated_tokens: String,
|
||||
pub(super) system_prompt: text_editor::Content,
|
||||
@@ -60,6 +62,8 @@ impl PreferenceDraft {
|
||||
endpoint_port: config.endpoint.port.to_string(),
|
||||
endpoint_enabled: config.endpoint.enabled,
|
||||
endpoint_cors: config.endpoint.cors,
|
||||
dev_brain_enabled: config.dev_brain.enabled,
|
||||
dev_brain_vault_path: config.dev_brain.vault_path.clone().unwrap_or_default(),
|
||||
context_tokens: generation.context_tokens.to_string(),
|
||||
max_generated_tokens: generation.max_generated_tokens.to_string(),
|
||||
system_prompt: text_editor::Content::with_text(&generation.system_prompt),
|
||||
@@ -368,6 +372,10 @@ impl App {
|
||||
enabled: self.preference_draft.endpoint_enabled,
|
||||
cors: self.preference_draft.endpoint_cors,
|
||||
},
|
||||
dev_brain: DevBrainConfig {
|
||||
enabled: self.preference_draft.dev_brain_enabled,
|
||||
vault_path: optional_text(&self.preference_draft.dev_brain_vault_path),
|
||||
},
|
||||
generation,
|
||||
runtime,
|
||||
interface: self.config.interface.clone(),
|
||||
@@ -376,6 +384,18 @@ impl App {
|
||||
self.preference_error = Some(error);
|
||||
return;
|
||||
}
|
||||
if config.dev_brain.enabled {
|
||||
let projects = self
|
||||
.projects
|
||||
.iter()
|
||||
.map(|project| project.project.clone())
|
||||
.collect::<Vec<_>>();
|
||||
if let Err(error) = crate::dev_brain::DevBrain::open(&config.dev_brain, &projects) {
|
||||
self.preference_error = Some(error);
|
||||
return;
|
||||
}
|
||||
}
|
||||
let dev_brain_changed = self.config.dev_brain != config.dev_brain;
|
||||
#[cfg(target_os = "macos")]
|
||||
let endpoint_changed = self.config.endpoint != config.endpoint;
|
||||
#[cfg(target_os = "macos")]
|
||||
@@ -415,6 +435,10 @@ impl App {
|
||||
}
|
||||
self.config = config;
|
||||
#[cfg(target_os = "macos")]
|
||||
if dev_brain_changed {
|
||||
self.invalidate_dev_brain_context();
|
||||
}
|
||||
#[cfg(target_os = "macos")]
|
||||
update_runtime_config(&self.runtime_config, &self.config);
|
||||
#[cfg(target_os = "macos")]
|
||||
if endpoint_changed {
|
||||
|
||||
Reference in New Issue
Block a user