embed dashboard (#1169)

* embed dashboard

* docs

* fmt
This commit is contained in:
Chris Tate
2026-04-06 10:45:08 -05:00
committed by GitHub
parent 3896ed0d9d
commit 1f8757b215
15 changed files with 116 additions and 272 deletions
-22
View File
@@ -9,7 +9,6 @@ pub use cdp_loop::{ack_screencast_frame, start_screencast, stop_screencast};
pub use dashboard::run_dashboard_server;
use serde_json::{json, Value};
use std::path::PathBuf;
use std::sync::Arc;
use tokio::net::TcpListener;
@@ -55,7 +54,6 @@ pub struct StreamServer {
screencasting: Arc<Mutex<bool>>,
viewport_width: Arc<Mutex<u32>>,
viewport_height: Arc<Mutex<u32>>,
dashboard_dir: Option<PathBuf>,
last_tabs: Arc<RwLock<Vec<Value>>>,
last_engine: Arc<RwLock<String>>,
last_frame: Arc<RwLock<Option<String>>>,
@@ -91,16 +89,6 @@ impl StreamServer {
Self::start_inner(preferred_port, client_slot, session_id, allow_port_fallback).await
}
/// Resolve the dashboard directory if it exists.
fn resolve_dashboard_dir() -> Option<PathBuf> {
let dir = dirs::home_dir()?.join(".agent-browser").join("dashboard");
if dir.join("index.html").exists() {
Some(dir)
} else {
None
}
}
/// Notify the background CDP listener that the client has changed (browser launched/closed).
pub fn notify_client_changed(&self) {
self.client_notify.notify_one();
@@ -181,8 +169,6 @@ impl StreamServer {
.map_err(|e| format!("Failed to get stream address: {}", e))?;
let port = actual_addr.port();
let dashboard_dir = Self::resolve_dashboard_dir();
let (frame_tx, _) = broadcast::channel::<String>(64);
let client_count = Arc::new(Mutex::new(0usize));
let client_notify = Arc::new(Notify::new());
@@ -205,7 +191,6 @@ impl StreamServer {
let vw_clone = viewport_width.clone();
let vh_clone = viewport_height.clone();
let dashboard_dir_clone = dashboard_dir.clone();
let last_tabs_clone = last_tabs.clone();
let last_engine_clone = last_engine.clone();
let last_frame_clone = last_frame.clone();
@@ -223,7 +208,6 @@ impl StreamServer {
cdp_session_clone,
vw_clone,
vh_clone,
dashboard_dir_clone,
last_tabs_clone,
last_engine_clone,
last_frame_clone,
@@ -277,7 +261,6 @@ impl StreamServer {
screencasting,
viewport_width,
viewport_height,
dashboard_dir,
last_tabs,
last_engine,
last_frame,
@@ -435,11 +418,6 @@ impl StreamServer {
});
let _ = self.frame_tx.send(msg.to_string());
}
/// Whether the dashboard directory is available.
pub fn has_dashboard(&self) -> bool {
self.dashboard_dir.is_some()
}
}
pub(crate) fn timestamp_ms() -> u64 {