feat: add static previews to the room pane

The preview tool could only name a port, so a static build needed a
server the terminal had to keep alive. `preview` now accepts a path:
the app reads the file or folder over the room's ssh sandbox and serves
it from a signed host, with `..` and dotfiles refused and a 16 MiB cap.

The target is stored with the room and replayed as a durable event. The
pane shows a static path with a reload control and keeps the port field
as a local fallback.
This commit is contained in:
vhaudiquet committed 2026-11-28 11:24:57 +01:00
1 parent 5be17cf4ef
commit 36de0aace7
20 files changed
+1046 -145

No files matched your search

+6 -2
View File
@@ -8,7 +8,7 @@ use std::sync::Arc;
use base64::Engine;
use rhema_bash::{AllowAll, ShellTools};
use rhema_core::request::ThinkingEffort;
use rhema_core::{Session, ToolResolver};
use rhema_core::{Overlay, Session, ToolResolver};
use rhema_host_agent::{HostAgent, HostAgentConfig};
use rhema_sandbox::WorkspaceSeed;
use rhema_sandbox::{Sandbox, ShellSandbox};
@@ -18,6 +18,7 @@ use crate::error::{AppError, AppResult};
use crate::state::Shared;
use super::message_tool::MessageTool;
use super::preview_tool::PreviewTool;
/// The room and its configuration, read fresh for every turn.
pub struct TurnConfig {
@@ -310,6 +311,9 @@ pub fn build_agent(state: &Shared, config: &TurnConfig, session: Session) -> App
.map_err(|err| AppError::bad_request(format!("provider: {err}")))?;
let message_tool: Arc<dyn ToolResolver> =
Arc::new(MessageTool::new(state.clone(), config.room_id.clone()));
let preview_tool: Arc<dyn ToolResolver> =
Arc::new(PreviewTool::new(state.clone(), config.room_id.clone()));
let extra_tools: Arc<dyn ToolResolver> = Arc::new(Overlay::new(message_tool, preview_tool));
let max_turn_steps =
NonZeroU32::new(config.max_turn_steps).unwrap_or(NonZeroU32::new(48).unwrap());
let mut sections = BTreeMap::new();
@@ -330,7 +334,7 @@ pub fn build_agent(state: &Shared, config: &TurnConfig, session: Session) -> App
max_turn_steps,
thinking: ThinkingEffort::Default,
tools: Some(shell),
extra_resolver: Some(message_tool),
extra_resolver: Some(extra_tools),
shell_env: Default::default(),
transcript: Some(Default::default()),
summary_worker: None,