use dioxus::prelude::*; use crate::app::Route; use crate::components::help_chat::HelpChat; use crate::components::notification_bell::NotificationBell; use crate::components::sidebar::Sidebar; use crate::components::toast::{ToastContainer, Toasts}; use crate::infrastructure::auth_check::check_auth; use crate::infrastructure::platform::fetch_platform_info; #[component] pub fn AppShell() -> Element { use_context_provider(Toasts::new); crate::i18n::provide_lang(); // Agent contract handshake (features such as `source_only`), provided // app-wide so pages can hide runtime-only surfaces. Read on the server // before the first render, so a page never shows a feature first and // then takes it away; an unreachable agent reads as the full set. let platform = use_server_future(fetch_platform_info)?; let auth = use_server_future(check_auth)?; let platform_now = platform().and_then(Result::ok).unwrap_or_default(); use_context_provider(|| Signal::new(platform_now)); match auth() { Some(Ok(info)) if info.authenticated => { use_context_provider(|| Signal::new(info.clone())); rsx! { div { class: "app-shell", Sidebar {} main { class: "main-content", Outlet:: {} } NotificationBell {} ToastContainer {} HelpChat {} } } } Some(Ok(_)) | Some(Err(_)) => { // Not authenticated — redirect to Keycloak login rsx! { document::Script { "window.location.href = '/auth';" } } } None => { rsx! { div { class: "flex items-center justify-center h-screen bg-gray-950", p { class: "text-gray-400", "Loading..." } } } } } }