fix: better handling of dev brain
This commit is contained in:
@@ -380,6 +380,19 @@ fn title_context(messages: impl IntoIterator<Item = ChatTurn>) -> Vec<ChatTurn>
|
||||
.collect()
|
||||
}
|
||||
|
||||
#[cfg(any(target_os = "macos", test))]
|
||||
fn agents_prompt_for_turn(
|
||||
opening_turn: bool,
|
||||
opening_prompt: Option<String>,
|
||||
stored_prompt: Option<&str>,
|
||||
) -> Option<String> {
|
||||
if opening_turn {
|
||||
opening_prompt
|
||||
} else {
|
||||
stored_prompt.map(str::to_owned)
|
||||
}
|
||||
}
|
||||
|
||||
impl App {
|
||||
fn chat_system_prompt(&self, model: ModelChoice, prompt: &str, agents: Option<&str>) -> String {
|
||||
let mut prompt = crate::agent::system_prompt(model, prompt, self.config.dev_brain.enabled);
|
||||
@@ -445,7 +458,7 @@ impl App {
|
||||
#[cfg(target_os = "macos")]
|
||||
let opening_turn = self.selected_session.is_none();
|
||||
#[cfg(target_os = "macos")]
|
||||
let agents = if opening_turn {
|
||||
let opening_agents = if opening_turn {
|
||||
let Some(project) = self
|
||||
.projects
|
||||
.iter()
|
||||
@@ -464,6 +477,9 @@ impl App {
|
||||
} else {
|
||||
None
|
||||
};
|
||||
#[cfg(target_os = "macos")]
|
||||
let agents =
|
||||
agents_prompt_for_turn(opening_turn, opening_agents, self.session_agents_prompt());
|
||||
self.a2ui_auto_switch_pending = true;
|
||||
self.context_notice = None;
|
||||
#[cfg(target_os = "macos")]
|
||||
@@ -1860,10 +1876,10 @@ pub(super) fn session_title(reply: &str) -> Option<String> {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::{
|
||||
ChatMessage, TOOL_PROTOCOL_CORRECTION, TurnSummary, chat_turn, compacted_context_start,
|
||||
correction_already_sent, has_chat_after_last_compaction, has_misplaced_tool_call,
|
||||
is_empty_response, project_agents, promote_legacy_turn_summaries, queued_prompt,
|
||||
sync_a2ui_message, title_context,
|
||||
ChatMessage, TOOL_PROTOCOL_CORRECTION, TurnSummary, agents_prompt_for_turn, chat_turn,
|
||||
compacted_context_start, correction_already_sent, has_chat_after_last_compaction,
|
||||
has_misplaced_tool_call, is_empty_response, project_agents, promote_legacy_turn_summaries,
|
||||
queued_prompt, sync_a2ui_message, title_context,
|
||||
};
|
||||
use crate::engine::ChatTurn;
|
||||
use crate::model::ModelChoice;
|
||||
@@ -1919,6 +1935,19 @@ mod tests {
|
||||
std::fs::remove_dir_all(directory).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn user_continuations_reuse_the_stored_agents_prompt() {
|
||||
let stored = "Project AGENTS.md instructions:\nkeep this exact";
|
||||
assert_eq!(
|
||||
agents_prompt_for_turn(false, None, Some(stored)).as_deref(),
|
||||
Some(stored)
|
||||
);
|
||||
assert_eq!(
|
||||
agents_prompt_for_turn(true, Some("opening".into()), Some(stored)).as_deref(),
|
||||
Some("opening")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn turn_summary_accumulates_model_continuations() {
|
||||
let mut summary = TurnSummary::new();
|
||||
|
||||
@@ -164,7 +164,7 @@ impl App {
|
||||
checkbox(self.preference_draft.dev_brain_enabled)
|
||||
.label("Enable project-backed LLM wiki")
|
||||
.on_toggle(Message::PreferenceDevBrainEnabledChanged),
|
||||
"Adds validated search, read, and batch-publication tools for a dedicated Obsidian vault. Disabled means no Dev Brain tools or prompt instructions.",
|
||||
"Lets the agent use its normal file tools on managed pages in a dedicated Obsidian vault, with indexed search and validation. Disabled means no Dev Brain access or prompt instructions.",
|
||||
),
|
||||
row![
|
||||
text_input(
|
||||
|
||||
Reference in New Issue
Block a user