2023-06-11 19:18:58 +05:00
|
|
|
<script lang="ts">
|
2026-01-04 22:50:34 +05:00
|
|
|
import { onMount, onDestroy } from "svelte"
|
2026-01-06 23:32:58 +05:00
|
|
|
import { invoke } from "@tauri-apps/api/core"
|
2026-01-04 22:50:34 +05:00
|
|
|
|
2026-01-07 05:04:04 +05:00
|
|
|
import SearchBar from "@/components/elements/SearchBar.svelte"
|
2023-06-11 19:18:58 +05:00
|
|
|
import ArcReactor from "@/components/elements/ArcReactor.svelte"
|
|
|
|
|
import HDivider from "@/components/elements/HDivider.svelte"
|
|
|
|
|
import Stats from "@/components/elements/Stats.svelte"
|
|
|
|
|
import Footer from "@/components/Footer.svelte"
|
2026-01-07 05:04:04 +05:00
|
|
|
|
2026-01-07 00:15:36 +05:00
|
|
|
import {
|
|
|
|
|
isJarvisRunning,
|
|
|
|
|
updateJarvisStats,
|
|
|
|
|
enableIpc,
|
2026-01-07 05:04:04 +05:00
|
|
|
disableIpc,
|
|
|
|
|
translate,
|
|
|
|
|
translations
|
2026-01-07 00:15:36 +05:00
|
|
|
} from "@/stores"
|
2023-06-11 19:18:58 +05:00
|
|
|
|
2026-01-07 05:04:04 +05:00
|
|
|
$: t = (key: string) => translate($translations, key)
|
|
|
|
|
|
2026-01-07 00:15:36 +05:00
|
|
|
let processRunning = false
|
2026-01-06 23:32:58 +05:00
|
|
|
let launching = false
|
2026-01-07 23:29:46 +05:00
|
|
|
let wasRunning = false // track previous state
|
2026-01-06 23:32:58 +05:00
|
|
|
|
2026-01-07 00:15:36 +05:00
|
|
|
isJarvisRunning.subscribe((value) => {
|
|
|
|
|
processRunning = value
|
|
|
|
|
if (value) {
|
|
|
|
|
enableIpc()
|
2026-01-07 23:29:46 +05:00
|
|
|
wasRunning = true
|
|
|
|
|
} else if (wasRunning) {
|
|
|
|
|
// only disable if it was running before
|
2026-01-07 00:15:36 +05:00
|
|
|
disableIpc()
|
2026-01-07 23:29:46 +05:00
|
|
|
wasRunning = false
|
2026-01-07 00:15:36 +05:00
|
|
|
}
|
2026-01-04 22:50:34 +05:00
|
|
|
})
|
2023-06-11 19:18:58 +05:00
|
|
|
|
2026-01-04 22:50:34 +05:00
|
|
|
onMount(() => {
|
2026-01-07 00:15:36 +05:00
|
|
|
updateJarvisStats()
|
2026-01-04 22:50:34 +05:00
|
|
|
})
|
2023-06-11 19:18:58 +05:00
|
|
|
|
2026-01-04 22:50:34 +05:00
|
|
|
onDestroy(() => {
|
2026-01-07 00:15:36 +05:00
|
|
|
disableIpc()
|
2026-01-04 22:50:34 +05:00
|
|
|
})
|
2026-01-06 23:32:58 +05:00
|
|
|
|
|
|
|
|
async function runAssistant() {
|
|
|
|
|
launching = true
|
|
|
|
|
try {
|
|
|
|
|
await invoke("run_jarvis_app")
|
2026-01-07 00:15:36 +05:00
|
|
|
setTimeout(async () => {
|
|
|
|
|
await updateJarvisStats()
|
2026-01-06 23:32:58 +05:00
|
|
|
launching = false
|
2026-01-07 00:15:36 +05:00
|
|
|
}, 2500)
|
2026-01-06 23:32:58 +05:00
|
|
|
} catch (err) {
|
|
|
|
|
console.error("Failed to run jarvis-app:", err)
|
|
|
|
|
launching = false
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-06-11 19:18:58 +05:00
|
|
|
</script>
|
|
|
|
|
|
2026-01-07 05:04:04 +05:00
|
|
|
<div class="app-container assist-page">
|
2026-01-06 23:32:58 +05:00
|
|
|
|
2026-01-07 05:04:04 +05:00
|
|
|
<div class="search search-section">
|
|
|
|
|
<HDivider />
|
|
|
|
|
<SearchBar />
|
|
|
|
|
</div>
|
2026-01-07 00:15:36 +05:00
|
|
|
|
2026-01-07 05:04:04 +05:00
|
|
|
<div class="reactor-section">
|
|
|
|
|
<div class="reactor-wrapper" class:dimmed={!processRunning}>
|
|
|
|
|
<ArcReactor />
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{#if !processRunning}
|
|
|
|
|
<div class="offline-badge">
|
|
|
|
|
<span class="offline-icon">⚠</span>
|
|
|
|
|
<span class="offline-text">{t('assistant-not-running')}</span>
|
|
|
|
|
<small>{t('assistant-offline-hint')}</small>
|
|
|
|
|
</div>
|
|
|
|
|
<button
|
|
|
|
|
class="start-button"
|
|
|
|
|
on:click={runAssistant}
|
|
|
|
|
disabled={launching}
|
|
|
|
|
>
|
|
|
|
|
{launching ? t('btn-starting') : t('btn-start')}
|
|
|
|
|
</button>
|
|
|
|
|
{/if}
|
|
|
|
|
</div>
|
2026-01-04 22:50:34 +05:00
|
|
|
|
2026-01-07 05:04:04 +05:00
|
|
|
<HDivider noMargin />
|
|
|
|
|
<Stats />
|
|
|
|
|
<Footer />
|
|
|
|
|
</div>
|