diff --git a/server/packages/sandbox-agent/src/router.rs b/server/packages/sandbox-agent/src/router.rs index 7270336..59b89c3 100644 --- a/server/packages/sandbox-agent/src/router.rs +++ b/server/packages/sandbox-agent/src/router.rs @@ -235,9 +235,7 @@ pub fn build_router_with_state(shared: Arc) -> (Router, Arc) .nest("/opencode", opencode_router) .merge(opencode_root_router); - if ui::is_enabled() { - router = router.merge(ui::router()); - } + router = router.merge(ui::router()); let http_logging = match std::env::var("SANDBOX_AGENT_LOG_HTTP") { Ok(value) if value == "0" || value.eq_ignore_ascii_case("false") => false, diff --git a/server/packages/sandbox-agent/src/ui.rs b/server/packages/sandbox-agent/src/ui.rs index 3bb475f..c2c27ef 100644 --- a/server/packages/sandbox-agent/src/ui.rs +++ b/server/packages/sandbox-agent/src/ui.rs @@ -15,7 +15,10 @@ pub fn is_enabled() -> bool { pub fn router() -> Router { if !INSPECTOR_ENABLED { - return Router::new(); + return Router::new() + .route("/ui", get(handle_not_built)) + .route("/ui/", get(handle_not_built)) + .route("/ui/*path", get(handle_not_built)); } Router::new() .route("/ui", get(handle_index)) @@ -23,6 +26,18 @@ pub fn router() -> Router { .route("/ui/*path", get(handle_path)) } +async fn handle_not_built() -> Response { + let body = "Inspector UI was not included in this build.\n\n\ + To enable it, build the frontend first:\n\n\ + cd frontend/packages/inspector && pnpm install && pnpm build\n\n\ + Then rebuild sandbox-agent without SANDBOX_AGENT_SKIP_INSPECTOR.\n"; + Response::builder() + .status(StatusCode::NOT_FOUND) + .header(header::CONTENT_TYPE, "text/plain; charset=utf-8") + .body(Body::from(body)) + .unwrap() +} + async fn handle_index() -> Response { serve_path("") }