Skip to main content

routa_server/api/
a2ui.rs

1//! A2UI Dashboard API - /api/a2ui/dashboard
2//!
3//! Mock implementation for desktop backend.
4//! The A2UI protocol is primarily used in the web interface for dashboard rendering.
5//! Desktop mode returns minimal mock responses for API compatibility.
6//!
7//! GET  /api/a2ui/dashboard - Returns A2UI v0.10 messages (mock)
8//! POST /api/a2ui/dashboard - Accepts custom A2UI messages (mock)
9
10use axum::{extract::Query, routing::get, Json, Router};
11use serde::Deserialize;
12
13use crate::state::AppState;
14
15pub fn router() -> Router<AppState> {
16    Router::new().route("/dashboard", get(get_dashboard).post(post_dashboard))
17}
18
19#[derive(Debug, Deserialize)]
20#[serde(rename_all = "camelCase")]
21#[allow(dead_code)]
22struct DashboardQuery {
23    workspace_id: Option<String>,
24}
25
26/// GET /api/a2ui/dashboard — Mock A2UI dashboard data
27async fn get_dashboard(Query(_q): Query<DashboardQuery>) -> Json<serde_json::Value> {
28    // Desktop mode: return minimal A2UI response
29    Json(serde_json::json!({
30        "data": [],
31        "kind": "data",
32        "metadata": {
33            "mimeType": "application/json+a2ui",
34            "note": "A2UI protocol is not fully implemented in desktop mode"
35        }
36    }))
37}
38
39/// POST /api/a2ui/dashboard — Mock A2UI custom surface handler
40async fn post_dashboard(Json(_body): Json<serde_json::Value>) -> Json<serde_json::Value> {
41    // Desktop mode: acknowledge but don't process
42    Json(serde_json::json!({
43        "success": true,
44        "surfaceCount": 0,
45        "totalMessages": 0,
46        "note": "A2UI protocol is not fully implemented in desktop mode"
47    }))
48}