mirror of
https://github.com/fabro-sh/fabro.git
synced 2026-09-05 08:10:39 +00:00
Add boolean helper methods to FabroConfig and remove unnecessary clones
Add verbose_enabled(), prevent_idle_sleep_enabled(), and upgrade_check_enabled() helpers to FabroConfig to encapsulate default values. Update all call sites in fabro-cli to use the new helpers. Also eliminate an unnecessary clone in SubAgentManager::run_to_completion and use extend() instead of append()+clone() in config merging. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
85094a3a4e
commit
48ea05cfde
3 changed files with 27 additions and 14 deletions
|
|
@ -233,9 +233,12 @@ impl SubAgentManager {
|
|||
|
||||
// Phase 5: Store result in status and return clone
|
||||
let agent = self.agents.get_mut(agent_id).unwrap();
|
||||
agent.status = SubAgentStatus::Finished(task_result.clone());
|
||||
agent.status = SubAgentStatus::Finished(task_result);
|
||||
|
||||
task_result
|
||||
match &agent.status {
|
||||
SubAgentStatus::Finished(result) => result.clone(),
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn close(&mut self, agent_id: &str) -> Result<(), AgentError> {
|
||||
|
|
|
|||
|
|
@ -568,7 +568,7 @@ async fn main_inner() -> (String, Result<()>) {
|
|||
match fabro_config::cli::load_cli_config(None) {
|
||||
Ok(cli_config) => (
|
||||
cli_config.log.as_ref().and_then(|l| l.level.clone()),
|
||||
cli_config.upgrade_check.unwrap_or(true),
|
||||
cli_config.upgrade_check_enabled(),
|
||||
),
|
||||
Err(err) => return (command_name, Err(err)),
|
||||
}
|
||||
|
|
@ -579,7 +579,7 @@ async fn main_inner() -> (String, Result<()>) {
|
|||
match fabro_config::cli::load_cli_config(None) {
|
||||
Ok(cli_config) => (
|
||||
cli_config.log.as_ref().and_then(|l| l.level.clone()),
|
||||
cli_config.upgrade_check.unwrap_or(true),
|
||||
cli_config.upgrade_check_enabled(),
|
||||
),
|
||||
Err(err) => return (command_name, Err(err)),
|
||||
}
|
||||
|
|
@ -684,8 +684,7 @@ async fn main_inner() -> (String, Result<()>) {
|
|||
Command::Exec(mut args) => {
|
||||
let cli_config = cli_config::load_cli_config(None)?;
|
||||
#[cfg(feature = "sleep_inhibitor")]
|
||||
let _sleep_guard =
|
||||
fabro_beastie::guard(cli_config.prevent_idle_sleep.unwrap_or(false));
|
||||
let _sleep_guard = fabro_beastie::guard(cli_config.prevent_idle_sleep_enabled());
|
||||
let exec_defaults = cli_config.exec.as_ref();
|
||||
args.apply_cli_defaults(
|
||||
exec_defaults.and_then(|a| a.provider.as_deref()),
|
||||
|
|
@ -753,7 +752,7 @@ async fn main_inner() -> (String, Result<()>) {
|
|||
let styles: &'static fabro_util::terminal::Styles =
|
||||
Box::leak(Box::new(fabro_util::terminal::Styles::detect_stderr()));
|
||||
let cli_config = cli_config::load_cli_config(None)?;
|
||||
args.verbose = args.verbose || cli_config.verbose.unwrap_or(false);
|
||||
args.verbose = args.verbose || cli_config.verbose_enabled();
|
||||
|
||||
if args.preflight {
|
||||
// Preflight validates config without creating a run dir.
|
||||
|
|
@ -768,12 +767,12 @@ async fn main_inner() -> (String, Result<()>) {
|
|||
} else {
|
||||
// Unified path: create + start (+ attach for foreground)
|
||||
let quiet = args.detach;
|
||||
let _prevent_idle_sleep = cli_config.prevent_idle_sleep;
|
||||
let _prevent_idle_sleep = cli_config.prevent_idle_sleep_enabled();
|
||||
let (run_id, run_dir) =
|
||||
commands::create::create_run(&args, cli_config, styles, quiet).await?;
|
||||
|
||||
#[cfg(feature = "sleep_inhibitor")]
|
||||
let _sleep_guard = fabro_beastie::guard(_prevent_idle_sleep.unwrap_or(false));
|
||||
let _sleep_guard = fabro_beastie::guard(_prevent_idle_sleep);
|
||||
|
||||
let child = commands::start::start_run(&run_dir)?;
|
||||
|
||||
|
|
@ -895,7 +894,7 @@ async fn main_inner() -> (String, Result<()>) {
|
|||
}
|
||||
Command::Doctor { verbose, dry_run } => {
|
||||
let cli_config = cli_config::load_cli_config(None)?;
|
||||
let verbose = verbose || cli_config.verbose.unwrap_or(false);
|
||||
let verbose = verbose || cli_config.verbose_enabled();
|
||||
let exit_code = doctor::run_doctor(verbose, !dry_run).await;
|
||||
std::process::exit(exit_code);
|
||||
}
|
||||
|
|
@ -973,10 +972,9 @@ async fn main_inner() -> (String, Result<()>) {
|
|||
let styles: &'static fabro_util::terminal::Styles =
|
||||
Box::leak(Box::new(fabro_util::terminal::Styles::detect_stderr()));
|
||||
let cli_config = cli_config::load_cli_config(None)?;
|
||||
args.verbose = args.verbose || cli_config.verbose.unwrap_or(false);
|
||||
args.verbose = args.verbose || cli_config.verbose_enabled();
|
||||
#[cfg(feature = "sleep_inhibitor")]
|
||||
let _sleep_guard =
|
||||
fabro_beastie::guard(cli_config.prevent_idle_sleep.unwrap_or(false));
|
||||
let _sleep_guard = fabro_beastie::guard(cli_config.prevent_idle_sleep_enabled());
|
||||
let github_app = build_github_app_credentials(cli_config.app_id());
|
||||
let git_author = fabro_workflows::git::GitAuthor::from_options(
|
||||
cli_config.git_author().and_then(|a| a.name.clone()),
|
||||
|
|
|
|||
|
|
@ -134,6 +134,18 @@ impl FabroConfig {
|
|||
self.git.as_ref().map(|g| &g.author)
|
||||
}
|
||||
|
||||
pub fn verbose_enabled(&self) -> bool {
|
||||
self.verbose.unwrap_or(false)
|
||||
}
|
||||
|
||||
pub fn prevent_idle_sleep_enabled(&self) -> bool {
|
||||
self.prevent_idle_sleep.unwrap_or(false)
|
||||
}
|
||||
|
||||
pub fn upgrade_check_enabled(&self) -> bool {
|
||||
self.upgrade_check.unwrap_or(true)
|
||||
}
|
||||
|
||||
/// Merge an overlay on top of this base. The overlay takes precedence
|
||||
/// for simple fields; compound fields (vars, hooks, mcp_servers) are
|
||||
/// deep-merged with the overlay winning on collision.
|
||||
|
|
@ -246,7 +258,7 @@ impl FabroConfig {
|
|||
if !overlay.checkpoint.exclude_globs.is_empty() {
|
||||
self.checkpoint
|
||||
.exclude_globs
|
||||
.append(&mut overlay.checkpoint.exclude_globs.clone());
|
||||
.extend(overlay.checkpoint.exclude_globs);
|
||||
self.checkpoint.exclude_globs.sort();
|
||||
self.checkpoint.exclude_globs.dedup();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue