pub struct ShellController {
controller_type: String,
tab_id: String,
block_id: String,
run_lock: Arc<AtomicBool>,
inner: Arc<Mutex<ShellControllerInner>>,
conn_factory: Mutex<Option<Box<dyn Fn(&str, &HashMap<String, Value>) -> Result<Box<dyn ConnInterface>, String> + Send + Sync>>>,
broker: Option<Arc<Broker>>,
event_bus: Option<Arc<EventBus>>,
wstore: Option<Arc<WaveStore>>,
}Expand description
ShellController manages one shell or command block.
Fields§
§controller_type: StringController type: “shell” or “cmd”.
tab_id: StringParent tab UUID.
block_id: StringBlock UUID.
run_lock: Arc<AtomicBool>Prevents concurrent run() calls.
inner: Arc<Mutex<ShellControllerInner>>Protected inner state.
conn_factory: Mutex<Option<Box<dyn Fn(&str, &HashMap<String, Value>) -> Result<Box<dyn ConnInterface>, String> + Send + Sync>>>Optional factory for creating ConnInterface (for testing).
broker: Option<Arc<Broker>>WPS broker for publishing events (blockfile, controllerstatus).
event_bus: Option<Arc<EventBus>>Event bus (unused for now, reserved for future event routing).
wstore: Option<Arc<WaveStore>>Wave object store — used to seed cmd:cwd on shell spawn.
Implementations§
Source§impl ShellController
impl ShellController
Sourcepub fn new(
controller_type: String,
tab_id: String,
block_id: String,
broker: Option<Arc<Broker>>,
event_bus: Option<Arc<EventBus>>,
wstore: Option<Arc<WaveStore>>,
) -> Self
pub fn new( controller_type: String, tab_id: String, block_id: String, broker: Option<Arc<Broker>>, event_bus: Option<Arc<EventBus>>, wstore: Option<Arc<WaveStore>>, ) -> Self
Create a new ShellController.
Sourcepub fn set_conn_factory(
&self,
factory: Box<dyn Fn(&str, &HashMap<String, Value>) -> Result<Box<dyn ConnInterface>, String> + Send + Sync>,
)
pub fn set_conn_factory( &self, factory: Box<dyn Fn(&str, &HashMap<String, Value>) -> Result<Box<dyn ConnInterface>, String> + Send + Sync>, )
Set a custom ConnInterface factory (for testing).
Sourcefn try_lock_run(&self) -> bool
fn try_lock_run(&self) -> bool
Try to acquire the run lock. Returns false if already running.
Sourcefn unlock_run(&self)
fn unlock_run(&self)
Release the run lock.
Sourcefn set_status(inner: &mut ShellControllerInner, status: &str)
fn set_status(inner: &mut ShellControllerInner, status: &str)
Update process status and increment version (must hold inner lock).
Sourcefn get_status_snapshot(&self) -> BlockControllerRuntimeStatus
fn get_status_snapshot(&self) -> BlockControllerRuntimeStatus
Get the runtime status (snapshot).
Sourcepub fn last_output_secs_ago(&self) -> Option<u64>
pub fn last_output_secs_ago(&self) -> Option<u64>
Seconds since last PTY output, or None if no output yet.
Sourcepub fn is_agent_pane(&self) -> bool
pub fn is_agent_pane(&self) -> bool
True if this pane is running an agent CLI.
Sourcefn should_run_on_start(meta: &HashMap<String, Value>) -> bool
fn should_run_on_start(meta: &HashMap<String, Value>) -> bool
Check block meta for whether to run on start.
Sourcefn should_run_once(meta: &HashMap<String, Value>) -> bool
fn should_run_once(meta: &HashMap<String, Value>) -> bool
Check block meta for run-once mode (used in full lifecycle integration).
Sourcefn should_clear_on_start(meta: &HashMap<String, Value>) -> bool
fn should_clear_on_start(meta: &HashMap<String, Value>) -> bool
Check block meta for clear-on-start (used in full lifecycle integration).
Sourcefn should_close_on_exit(meta: &HashMap<String, Value>) -> bool
fn should_close_on_exit(meta: &HashMap<String, Value>) -> bool
Check block meta for close-on-exit (used in full lifecycle integration).
Sourcefn should_close_on_exit_force(meta: &HashMap<String, Value>) -> bool
fn should_close_on_exit_force(meta: &HashMap<String, Value>) -> bool
Check block meta for force close-on-exit (used in full lifecycle integration).
Sourcefn close_on_exit_delay_ms(meta: &HashMap<String, Value>) -> u64
fn close_on_exit_delay_ms(meta: &HashMap<String, Value>) -> u64
Get the close-on-exit delay in ms (defaults to 2000, used in full lifecycle integration).
Sourcefn get_conn_name(meta: &HashMap<String, Value>) -> String
fn get_conn_name(meta: &HashMap<String, Value>) -> String
Get the connection name from block meta.
Sourcefn get_cmd_str(meta: &HashMap<String, Value>) -> String
fn get_cmd_str(meta: &HashMap<String, Value>) -> String
Get the command string from block meta.
Sourcefn get_cmd_args(meta: &HashMap<String, Value>) -> Vec<String>
fn get_cmd_args(meta: &HashMap<String, Value>) -> Vec<String>
Get cmd:args array from block meta.
Sourcefn is_interactive(meta: &HashMap<String, Value>) -> bool
fn is_interactive(meta: &HashMap<String, Value>) -> bool
Check if cmd:interactive is set in block meta.
Sourcefn publish_status(&self)
fn publish_status(&self)
Publish current controller status via the WPS broker.
Trait Implementations§
Source§impl Controller for ShellController
impl Controller for ShellController
Source§fn start(
&self,
block_meta: HashMap<String, Value>,
_rt_opts: Option<Value>,
force: bool,
) -> Result<(), String>
fn start( &self, block_meta: HashMap<String, Value>, _rt_opts: Option<Value>, force: bool, ) -> Result<(), String>
force restarts even if already running.Source§fn stop(&self, _graceful: bool, new_status: &str) -> Result<(), String>
fn stop(&self, _graceful: bool, new_status: &str) -> Result<(), String>
graceful waits for process to exit; new_status is the target state.Source§fn get_runtime_status(&self) -> BlockControllerRuntimeStatus
fn get_runtime_status(&self) -> BlockControllerRuntimeStatus
Source§fn send_input(
&self,
input: BlockInputUnion,
seq: Option<u64>,
) -> Result<(), String>
fn send_input( &self, input: BlockInputUnion, seq: Option<u64>, ) -> Result<(), String>
seq is the per-TermViewModel monotonic counter; None means fire-and-forget (no ordering).Source§fn controller_type(&self) -> &str
fn controller_type(&self) -> &str
Auto Trait Implementations§
impl !Freeze for ShellController
impl RefUnwindSafe for ShellController
impl Send for ShellController
impl Sync for ShellController
impl Unpin for ShellController
impl UnwindSafe for ShellController
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.