MCPcopy Create free account
hub / github.com/ScriptedAlchemy/tracedecay / run_hook_event_plan

Method run_hook_event_plan

src/mcp/server.rs:1996–2071  ·  view source on GitHub ↗
(&self, cg: Arc<TraceDecay>, root: &Path, plan: HookEventPlan)

Source from the content-addressed store, hash-verified

1994 }
1995
1996 async fn run_hook_event_plan(&self, cg: Arc<TraceDecay>, root: &Path, plan: HookEventPlan) {
1997 match plan {
1998 HookEventPlan::SyncFiles(rel_paths) => {
1999 match cg.sync_if_stale_silent(&rel_paths).await {
2000 Ok(()) | Err(TraceDecayError::SyncLock { .. }) => {
2001 self.refresh_file_token_map().await;
2002 }
2003 Err(e) => eprintln!("[tracedecay] hook file sync failed: {e}"),
2004 }
2005 }
2006 HookEventPlan::AddBranch(branch) => {
2007 match self.add_hook_branch_tracking(root, &branch, &cg).await {
2008 Ok(crate::branch::BranchAddOutcome::Added) => {
2009 self.reopen_after_branch_tracking_added().await;
2010 }
2011 Ok(crate::branch::BranchAddOutcome::AlreadyTracked) => {
2012 self.refresh_file_token_map().await;
2013 }
2014 Ok(
2015 crate::branch::BranchAddOutcome::Deferred
2016 | crate::branch::BranchAddOutcome::NotIndexed,
2017 ) => {}
2018 Err(e) => eprintln!("[tracedecay] hook branch tracking failed: {e}"),
2019 }
2020 }
2021 HookEventPlan::AddBranchAt {
2022 root,
2023 branch,
2024 agent,
2025 } => {
2026 // The routed worktree root is not this server's checkout, so
2027 // reopen/token-map refresh only applies after opening that root.
2028 match self.add_hook_branch_tracking(&root, &branch, &cg).await {
2029 Ok(crate::branch::BranchAddOutcome::AlreadyTracked) => {
2030 match TraceDecay::open_with_options(&root, cg.open_options()).await {
2031 Ok(worktree_cg) => {
2032 self.run_hook_incremental_sync(Arc::new(worktree_cg), agent)
2033 .await;
2034 }
2035 Err(e) => {
2036 eprintln!(
2037 "[tracedecay] hook worktree branch sync open failed: {e}"
2038 );
2039 }
2040 }
2041 }
2042 Ok(
2043 crate::branch::BranchAddOutcome::Added
2044 | crate::branch::BranchAddOutcome::Deferred
2045 | crate::branch::BranchAddOutcome::NotIndexed,
2046 ) => {}
2047 Err(e) => eprintln!("[tracedecay] hook worktree branch tracking failed: {e}"),
2048 }
2049 }
2050 HookEventPlan::SyncCurrentBranch { branch, agent } => {
2051 match self.add_hook_branch_tracking(root, &branch, &cg).await {
2052 Ok(crate::branch::BranchAddOutcome::Added) => {
2053 self.reopen_after_branch_tracking_added().await;

Callers 1

Tested by

no test coverage detected