Skip to content
This repository was archived by the owner on Jan 2, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions apps/desktop/src-tauri/src/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Configuration>) -> Option<String> {
Expand Down Expand Up @@ -50,26 +52,37 @@ pub fn initialize<R: Runtime>(app: &mut tauri::App<R>) -> 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<R: Runtime>(configuration: Configuration, app: tauri::AppHandle<R>) {
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
{
Expand Down
28 changes: 28 additions & 0 deletions apps/desktop/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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);
Expand All @@ -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(),
Expand Down Expand Up @@ -208,11 +220,27 @@ function App() {
[homeDirectory, indexFolder, os, release, envConfig],
);

const bugReportContextValue = useMemo(
() => ({
isBugReportModalOpen,
setBugReportModalOpen,
activeTab: '',
}),
[isBugReportModalOpen],
);

return (
<LocaleContext.Provider value={localeContextValue}>
<AnimatePresence initial={false}>
{shouldShowSplashScreen && <SplashScreen />}
</AnimatePresence>
{shouldShowSplashScreen && (
<DeviceContextProvider deviceContextValue={deviceContextValue}>
<UIContext.BugReport.Provider value={bugReportContextValue}>
<ReportBugModal errorBoundaryMessage={serverCrashedMessage} />
</UIContext.BugReport.Provider>
</DeviceContextProvider>
)}
<TextSearch contentRoot={contentContainer.current} />
<div ref={contentContainer}>
<BrowserRouter>
Expand Down
2 changes: 1 addition & 1 deletion apps/desktop/src/SplashScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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"
>
<div className="w-99 rounded-xl border border-bg-border bg-bg-base px-12 py-20 relative animate-pulse-shadow-slow z-0">
<div
Expand Down