hololake-system-architecture/product-source/hololake-native-desktop/src-tauri/src/home_status.rs

44 lines
1.8 KiB
Rust
Raw Normal View History

// SPDX-License-Identifier: AGPL-3.0-or-later
use crate::direct_local_broker::DirectLocalBrokerHandle;
use crate::direct_local_session::{active_session_count_at, direct_session_root};
use crate::pncc_receipt_projection::{pncc_projection_root, projection_event_count_at};
use crate::pncc_repository_binding::{mounted_repository_count_at, pncc_repository_mount_root};
use crate::release_trust::release_trust_state;
use serde::Serialize;
use tauri::{AppHandle, State};
#[derive(Debug, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct HoloLakeHomeStatus {
pub schema: &'static str,
pub direct_local_broker_state: &'static str,
pub direct_connection_count: usize,
pub resumable_session_count: usize,
pub code_repository_mount_count: usize,
pub pncc_receipt_count: usize,
pub update_state: &'static str,
pub automatic_upstream_updates: bool,
pub mcp_role: &'static str,
}
#[tauri::command]
pub fn get_hololake_home_status(
app: AppHandle,
broker: State<'_, DirectLocalBrokerHandle>,
) -> Result<HoloLakeHomeStatus, String> {
let session_root = direct_session_root(&app)?;
let mount_root = pncc_repository_mount_root(&app)?;
let projection_root = pncc_projection_root(&app)?;
Ok(HoloLakeHomeStatus {
schema: "hololake.home-status/v1",
direct_local_broker_state: "READY",
direct_connection_count: broker.active_connection_count(),
resumable_session_count: active_session_count_at(&session_root)?,
code_repository_mount_count: mounted_repository_count_at(&mount_root)?,
pncc_receipt_count: projection_event_count_at(&projection_root)?,
update_state: release_trust_state()?,
automatic_upstream_updates: false,
mcp_role: "DISCOVERY_RECOVERY_COMPATIBILITY_ONLY",
})
}