From ca29e7b2152260059417c142641cd19ddbb512c4 Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Wed, 24 Dec 2025 16:12:46 +0800 Subject: Add local output channel for CLI feedback in track actions Add `try_get_local_output` helper to retrieve output channel from context and `local_println!` macro for sending formatted strings. Use these in track actions to send progress messages to CLI instead of stdout. Also reduce log level for connection events from info to debug. --- crates/vcs_actions/src/actions.rs | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'crates/vcs_actions/src/actions.rs') diff --git a/crates/vcs_actions/src/actions.rs b/crates/vcs_actions/src/actions.rs index d3c0dd6..260a6be 100644 --- a/crates/vcs_actions/src/actions.rs +++ b/crates/vcs_actions/src/actions.rs @@ -3,7 +3,7 @@ use std::sync::Arc; use action_system::action::ActionContext; use cfg_file::config::ConfigFile; use tcp_connection::{error::TcpTargetError, instance::ConnectionInstance}; -use tokio::sync::Mutex; +use tokio::sync::{Mutex, mpsc::Sender}; use vcs_data::{ constants::SERVER_PATH_MEMBER_PUB, data::{ @@ -64,6 +64,16 @@ pub fn try_get_user_directory(ctx: &ActionContext) -> Result, Ok(user_directory) } +/// Try to get the LocalWorkspace instance from the context. +pub fn try_get_local_output(ctx: &ActionContext) -> Result>, TcpTargetError> { + let Some(output) = ctx.get_arc::>() else { + return Err(TcpTargetError::NotFound( + "Client sender not found".to_string(), + )); + }; + Ok(output) +} + /// Authenticate member based on context and return MemberId pub async fn auth_member( ctx: &ActionContext, @@ -196,3 +206,13 @@ macro_rules! write_and_return { return Ok($result); }}; } + +/// The macro to send formatted string to output channel. +/// Usage: local_println!(output, "format string", arg1, arg2, ...) +#[macro_export] +macro_rules! local_println { + ($output:expr, $($arg:tt)*) => {{ + let formatted = format!($($arg)*); + let _ = $output.send(formatted).await; + }}; +} -- cgit