2026-04-26 12:39:06 -06:00
|
|
|
//! Placeholder client-side TUI surface for the remote shell leaf.
|
|
|
|
|
//!
|
|
|
|
|
//! The first application-layer consumer will be a CLI and later a full GUI. This
|
|
|
|
|
//! stub keeps the leaf-specific interpretation point in place without forcing a
|
|
|
|
|
//! rendering-library decision yet.
|
|
|
|
|
|
|
|
|
|
use std::string::String;
|
|
|
|
|
use std::vec::Vec;
|
|
|
|
|
|
|
|
|
|
use unshell::protocol::DataMessage;
|
2026-04-26 15:19:33 -06:00
|
|
|
use unshell_macros::Procedure;
|
2026-04-26 12:39:06 -06:00
|
|
|
|
|
|
|
|
use crate::{LeafTui, TuiError};
|
|
|
|
|
|
|
|
|
|
/// Stub TUI surface for the remote shell leaf.
|
2026-04-26 13:54:44 -06:00
|
|
|
#[derive(Default)]
|
2026-04-26 15:19:33 -06:00
|
|
|
pub struct RemoteShell {
|
2026-04-26 12:39:06 -06:00
|
|
|
transcript: Vec<u8>,
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-26 15:19:33 -06:00
|
|
|
impl RemoteShell {
|
2026-04-26 12:39:06 -06:00
|
|
|
/// Returns a short explanation of the current stub status.
|
|
|
|
|
pub fn status_line(&self) -> &'static str {
|
|
|
|
|
"remote shell TUI stub: rendering is placeholder-only for now"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-26 15:19:33 -06:00
|
|
|
impl LeafTui for RemoteShell {
|
2026-04-26 12:39:06 -06:00
|
|
|
fn leaf_name(&self) -> String {
|
|
|
|
|
Self::protocol_leaf_name()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn handle_data(&mut self, message: &DataMessage) -> Result<(), TuiError> {
|
|
|
|
|
self.transcript.extend_from_slice(&message.data);
|
|
|
|
|
Ok(())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn render(&self) -> String {
|
|
|
|
|
let body = String::from_utf8_lossy(&self.transcript);
|
|
|
|
|
format!("{}\n\n{}", self.status_line(), body)
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-04-26 15:19:33 -06:00
|
|
|
|
|
|
|
|
/// TUI-side placeholder procedure symbol for the shared `remote_shell` leaf
|
|
|
|
|
/// declaration.
|
|
|
|
|
#[derive(Procedure)]
|
|
|
|
|
#[procedure(leaf = RemoteShell, name = "open")]
|
|
|
|
|
pub struct Open {}
|