//! The Browser app's viewport (ยง7.1): the latest screenshot captured by //! browser.goto, straight from the blob store. use axum::extract::{Path, State}; use axum::http::{header, StatusCode}; use axum::response::IntoResponse; use cm_domain::AgentId; use crate::routes::claws::workspace_agent; use crate::{ApiError, AppState, Authed}; /// GET /api/claws/{clawId}/browser/viewport.png pub async fn viewport( State(state): State, Authed(user): Authed, Path(claw_id): Path, ) -> Result { let agent = workspace_agent(&state, &user, claw_id).await?; let key = format!("{}/browser/{}/viewport.png", user.workspace_id, agent.id); match state.runtime.blob().get(&key).await { Ok(png) => Ok(([(header::CONTENT_TYPE, "image/png")], png).into_response()), Err(_) => Ok(StatusCode::NOT_FOUND.into_response()), } }