diff --git a/apps/desktop/src-tauri/src/backend.rs b/apps/desktop/src-tauri/src/backend.rs index 78943de995..edfbcee01b 100644 --- a/apps/desktop/src-tauri/src/backend.rs +++ b/apps/desktop/src-tauri/src/backend.rs @@ -2,6 +2,8 @@ use bleep::{analytics, Application, Configuration, Environment}; use tracing::error; use super::{config::get_device_id, Manager, Payload, Runtime}; +use std::thread; +use std::time::Duration; #[tauri::command] pub fn get_last_log_file(config: tauri::State) -> Option { @@ -50,26 +52,37 @@ pub fn initialize(app: &mut tauri::App) -> tauri::plugin::Result< Ok(()) } -async fn wait_for_qdrant() { +async fn wait_for_qdrant() -> anyhow::Result<()> { use qdrant_client::prelude::*; let qdrant = QdrantClient::new(Some(QdrantClientConfig::from_url("http://127.0.0.1:6334"))).unwrap(); - for _ in 0..60 { + for _ in 0..35 { if qdrant.health_check().await.is_ok() { - return; + return Ok(()); } tokio::time::sleep(std::time::Duration::from_secs(1)).await; } - panic!("qdrant cannot be started"); + anyhow::bail!("qdrant cannot be started"); } async fn start_backend(configuration: Configuration, app: tauri::AppHandle) { tracing::info!("booting bleep back-end"); - wait_for_qdrant().await; + if let Err(err) = wait_for_qdrant().await { + error!(?err, "qdrant failed to come up"); + sentry_anyhow::capture_anyhow(&err); + thread::sleep(Duration::from_secs(4)); + app.emit_all( + "server-crashed", + Payload { + message: "Failed to start qdrant".into(), + }, + ) + .unwrap(); + }; let configuration = if let Ok(remote) = configuration.clone().with_remote_cognito_config().await { diff --git a/apps/desktop/src/App.tsx b/apps/desktop/src/App.tsx index 4a84a84ddc..81855e69ac 100644 --- a/apps/desktop/src/App.tsx +++ b/apps/desktop/src/App.tsx @@ -28,6 +28,9 @@ import { } from '../../../client/src/services/storage'; import { LocaleType } from '../../../client/src/types/general'; import { polling } from '../../../client/src/utils/requestUtils'; +import ReportBugModal from '../../../client/src/components/ReportBugModal'; +import { UIContext } from '../../../client/src/context/uiContext'; +import { DeviceContextProvider } from '../../../client/src/context/providers/DeviceContextProvider'; import TextSearch from './TextSearch'; import SplashScreen from './SplashScreen'; @@ -106,6 +109,8 @@ function App() { (getPlainFromStorage(LANGUAGE_KEY) as LocaleType | null) || 'en', ); const [shouldShowSplashScreen, setShouldShowSplashScreen] = useState(true); + const [isBugReportModalOpen, setBugReportModalOpen] = useState(false); + const [serverCrashedMessage, setServerCrashedMessage] = useState(''); useEffect(() => { i18n.changeLanguage(locale); @@ -121,6 +126,13 @@ function App() { ); useEffect(() => { + listen('server-crashed', (event) => { + console.log(event); + setBugReportModalOpen(true); + // @ts-ignore + setServerCrashedMessage(event.payload.message); + }); + homeDir().then(setHomeDir); Promise.all([ tauriOs.arch(), @@ -208,11 +220,27 @@ function App() { [homeDirectory, indexFolder, os, release, envConfig], ); + const bugReportContextValue = useMemo( + () => ({ + isBugReportModalOpen, + setBugReportModalOpen, + activeTab: '', + }), + [isBugReportModalOpen], + ); + return ( {shouldShowSplashScreen && } + {shouldShowSplashScreen && ( + + + + + + )}
diff --git a/apps/desktop/src/SplashScreen.tsx b/apps/desktop/src/SplashScreen.tsx index 3ae16bc1da..4ba612fd6d 100644 --- a/apps/desktop/src/SplashScreen.tsx +++ b/apps/desktop/src/SplashScreen.tsx @@ -12,7 +12,7 @@ const SplashScreen = ({}: Props) => { animate={{ opacity: 1 }} exit={{ opacity: 0 }} key="splash" - className="w-screen h-screen flex items-center justify-center bg-bg-sub fixed top-0 left-0 z-[1000]" + className="w-screen h-screen flex items-center justify-center bg-bg-sub fixed top-0 left-0 z-10" >