refactor: clean up cortex (#6003)
* refactor: clean up cortex * chore: clean up * refactor: clean up
This commit is contained in:
parent
9573329d06
commit
9c0d09c487
@ -1,3 +1,2 @@
|
||||
declare const NODE: string
|
||||
declare const VERSION: string
|
||||
declare const CORTEX_API_URL: string
|
||||
|
||||
@ -7,7 +7,5 @@ export default defineConfig({
|
||||
file: 'dist/index.js',
|
||||
},
|
||||
platform: 'browser',
|
||||
define: {
|
||||
API_URL: JSON.stringify(`http://127.0.0.1:${process.env.CORTEX_API_PORT ?? "39291"}`),
|
||||
},
|
||||
define: {},
|
||||
})
|
||||
|
||||
@ -1,5 +1,3 @@
|
||||
declare const API_URL: string
|
||||
|
||||
interface Core {
|
||||
api: APIFunctions
|
||||
events: EventEmitter
|
||||
|
||||
@ -260,7 +260,7 @@ async fn monitor_mcp_server_handle(
|
||||
}
|
||||
}
|
||||
|
||||
/// Starts an MCP server with restart monitoring (similar to cortex restart)
|
||||
/// Starts an MCP server with restart monitoring
|
||||
/// Returns the result of the first start attempt, then continues with restart monitoring
|
||||
async fn start_mcp_server_with_restart<R: Runtime>(
|
||||
app: AppHandle<R>,
|
||||
|
||||
@ -6,7 +6,6 @@ use core::{
|
||||
state::{generate_app_token, AppState},
|
||||
utils::download::DownloadManagerState,
|
||||
};
|
||||
use reqwest::Client;
|
||||
use std::{collections::HashMap, sync::Arc};
|
||||
use tauri::{Emitter, Manager, RunEvent};
|
||||
use tokio::sync::Mutex;
|
||||
@ -143,10 +142,6 @@ pub fn run() {
|
||||
cleanup_processes(state).await;
|
||||
});
|
||||
}
|
||||
|
||||
let client = Client::new();
|
||||
let url = "http://127.0.0.1:39291/processManager/destroy";
|
||||
let _ = client.delete(url).send();
|
||||
}
|
||||
_ => {}
|
||||
})
|
||||
@ -171,15 +166,6 @@ pub fn run() {
|
||||
|
||||
// Quick cleanup with shorter timeout
|
||||
cleanup_processes(state).await;
|
||||
|
||||
// Stop HTTP server with shorter timeout
|
||||
let client = Client::new();
|
||||
let url = "http://127.0.0.1:39291/processManager/destroy";
|
||||
let _ = tokio::time::timeout(
|
||||
tokio::time::Duration::from_secs(2),
|
||||
client.delete(url).send(),
|
||||
)
|
||||
.await;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@ -1,88 +0,0 @@
|
||||
import { useEffect, useState } from 'react'
|
||||
import { listen } from '@tauri-apps/api/event'
|
||||
import { invoke } from '@tauri-apps/api/core'
|
||||
|
||||
import {
|
||||
Dialog,
|
||||
DialogContent,
|
||||
DialogDescription,
|
||||
DialogFooter,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
} from '@/components/ui/dialog'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { useTranslation } from '@/i18n'
|
||||
|
||||
export function CortexFailureDialog() {
|
||||
const { t } = useTranslation()
|
||||
const [showDialog, setShowDialog] = useState(false)
|
||||
|
||||
useEffect(() => {
|
||||
let unlisten: (() => void) | undefined
|
||||
const setupListener = async () => {
|
||||
unlisten = await listen<null>('cortex_max_restarts_reached', (event) => {
|
||||
console.log('Cortex max restarts reached event received:', event)
|
||||
setShowDialog(true)
|
||||
})
|
||||
}
|
||||
|
||||
setupListener()
|
||||
|
||||
return () => {
|
||||
if (unlisten) {
|
||||
unlisten()
|
||||
}
|
||||
}
|
||||
}, [])
|
||||
|
||||
const handleRestartJan = async () => {
|
||||
try {
|
||||
await invoke('relaunch')
|
||||
} catch (error) {
|
||||
console.error('Failed to relaunch app:', error)
|
||||
alert(
|
||||
'Failed to automatically restart. Please close and reopen Jan manually.'
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
if (!showDialog) {
|
||||
return null
|
||||
}
|
||||
|
||||
return (
|
||||
<Dialog open={showDialog} onOpenChange={setShowDialog}>
|
||||
<DialogContent>
|
||||
<DialogHeader>
|
||||
<DialogTitle>{t('cortexFailureDialog.title')}</DialogTitle>
|
||||
</DialogHeader>
|
||||
<DialogDescription>
|
||||
{t('cortexFailureDialog.description')}
|
||||
</DialogDescription>
|
||||
<DialogFooter className="flex gap-2">
|
||||
<Button
|
||||
asChild
|
||||
variant="link"
|
||||
className="bg-transparent border border-main-view-fg/20 hover:bg-main-view-fg/4"
|
||||
onClick={() => {
|
||||
setShowDialog(false)
|
||||
}}
|
||||
>
|
||||
<a
|
||||
href="https://jan.ai/support"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
<span className="text-main-view-fg/70">
|
||||
{t('cortexFailureDialog.contactSupport')}
|
||||
</span>
|
||||
</a>
|
||||
</Button>
|
||||
<Button onClick={handleRestartJan}>
|
||||
{t('cortexFailureDialog.restartJan')}
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
)
|
||||
}
|
||||
@ -257,11 +257,5 @@
|
||||
"title": "Download abgebrochen",
|
||||
"description": "Der Download-Prozess wurde abgebrochen"
|
||||
}
|
||||
},
|
||||
"cortexFailureDialog": {
|
||||
"title": "Problem mit der lokalen KI-Engine",
|
||||
"description": "Die Lokale KI-Engine (Cortex) konnte nach mehreren Versuchen nicht gestartet werden. Dies verhindert möglicherweise die korrekte Ausführung diverser Funktionalitäten.",
|
||||
"contactSupport": "Support kontaktieren",
|
||||
"restartJan": "Jan neu starten"
|
||||
}
|
||||
}
|
||||
|
||||
@ -258,11 +258,5 @@
|
||||
"title": "Download Cancelled",
|
||||
"description": "The download process was cancelled"
|
||||
}
|
||||
},
|
||||
"cortexFailureDialog": {
|
||||
"title": "Local AI Engine Issue",
|
||||
"description": "The local AI engine (Cortex) failed to start after multiple attempts. This might prevent some features from working correctly.",
|
||||
"contactSupport": "Contact Support",
|
||||
"restartJan": "Restart Jan"
|
||||
}
|
||||
}
|
||||
|
||||
@ -250,11 +250,5 @@
|
||||
"title": "Unduhan Dibatalkan",
|
||||
"description": "Proses unduhan telah dibatalkan"
|
||||
}
|
||||
},
|
||||
"cortexFailureDialog": {
|
||||
"title": "Cortex gagal dimulai",
|
||||
"description": "Cortex gagal dimulai. Silakan periksa log untuk detail lebih lanjut.",
|
||||
"contactSupport": "Hubungi Dukungan",
|
||||
"restartJan": "Restart Jan"
|
||||
}
|
||||
}
|
||||
|
||||
@ -250,11 +250,5 @@
|
||||
"title": "Đã hủy tải xuống",
|
||||
"description": "Quá trình tải xuống đã bị hủy"
|
||||
}
|
||||
},
|
||||
"cortexFailureDialog": {
|
||||
"title": "Cortex không khởi động được",
|
||||
"description": "Cortex không khởi động được. Vui lòng kiểm tra log để biết thêm chi tiết.",
|
||||
"contactSupport": "Liên hệ Hỗ trợ",
|
||||
"restartJan": "Khởi động lại Jan"
|
||||
}
|
||||
}
|
||||
|
||||
@ -250,11 +250,5 @@
|
||||
"title": "下载已取消",
|
||||
"description": "下载过程已取消"
|
||||
}
|
||||
},
|
||||
"cortexFailureDialog": {
|
||||
"title": "Cortex 启动失败",
|
||||
"description": "Cortex 启动失败。请检查日志以获取更多详细信息。",
|
||||
"contactSupport": "联系支持",
|
||||
"restartJan": "重启 Jan"
|
||||
}
|
||||
}
|
||||
|
||||
@ -250,11 +250,5 @@
|
||||
"title": "下載已取消",
|
||||
"description": "下載過程已取消"
|
||||
}
|
||||
},
|
||||
"cortexFailureDialog": {
|
||||
"title": "Cortex 啟動失敗",
|
||||
"description": "Cortex 啟動失敗。請檢查日誌以獲取更多詳細信息。",
|
||||
"contactSupport": "聯繫支援",
|
||||
"restartJan": "重啟 Jan"
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,7 +3,6 @@ import { createRootRoute, Outlet, useRouterState } from '@tanstack/react-router'
|
||||
|
||||
import LeftPanel from '@/containers/LeftPanel'
|
||||
import DialogAppUpdater from '@/containers/dialogs/AppUpdater'
|
||||
import { CortexFailureDialog } from '@/containers/dialogs/CortexFailureDialog' // Added import
|
||||
import { Fragment } from 'react/jsx-runtime'
|
||||
import { AppearanceProvider } from '@/providers/AppearanceProvider'
|
||||
import { ThemeProvider } from '@/providers/ThemeProvider'
|
||||
@ -167,7 +166,6 @@ function RootLayout() {
|
||||
</ExtensionProvider>
|
||||
{isLocalAPIServerLogsRoute ? <LogsLayout /> : <AppLayout />}
|
||||
{/* <TanStackRouterDevtools position="bottom-right" /> */}
|
||||
<CortexFailureDialog />
|
||||
<ToolApproval />
|
||||
<LoadModelErrorDialog />
|
||||
<OutOfContextPromiseModal />
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user