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

+2 -15
View File
@@ -18,6 +18,7 @@ use crate::error::{AppError, AppResult};
use crate::models::FileEntry;
use crate::room::agent;
use crate::state::Shared;
use crate::util::safe_rel_path;
use super::rooms::member_of;
@@ -35,21 +36,7 @@ fn room_workspace(state: &Shared, room: &str) -> AppResult<(String, agent::Targe
/// Validates a workspace-relative path.
fn safe_rel(path: &str) -> AppResult<String> {
let trimmed = path.trim();
if trimmed.starts_with('/') {
return Err(AppError::bad_request(
"path must be relative to the workspace",
));
}
let normalized = trimmed.trim_matches('/');
if normalized.split('/').any(|part| part == "..") {
return Err(AppError::bad_request("path escapes the workspace"));
}
Ok(if normalized.is_empty() {
".".to_owned()
} else {
normalized.to_owned()
})
safe_rel_path(path).map_err(AppError::bad_request)
}
async fn run(