Personal AI, On Personal Devices
Python
fix: clean stale desktop release artifacts and fix frontend port mismatch (#52)
Jon Saad-Falconbca60b5706e8
diff --git a/.github/workflows/desktop.yml b/.github/workflows/desktop.ymlindex f1162c13..d726597d 100644--- a/.github/workflows/desktop.yml+++ b/.github/workflows/desktop.yml@@ -74,9 +74,30 @@ jobs:working-directory: desktop/src-taurirun: cargo check- build-and-release:+ # Remove stale artifacts from the desktop-latest pre-release so that+ # only the current build's files are available for download.+ clean-release:needs: [validate]if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'+ runs-on: ubuntu-latest+ steps:+ - name: Delete old assets from desktop-latest+ if: "!startsWith(github.ref, 'refs/tags/')"+ env:+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}+ run: |+ TAG="desktop-latest"+ # List all asset IDs on the release and delete them+ ASSET_IDS=$(gh api "repos/${{ github.repository }}/releases/tags/${TAG}" \+ --jq '.assets[].id' 2>/dev/null || true)+ for id in $ASSET_IDS; do+ echo "Deleting asset $id"+ gh api -X DELETE "repos/${{ github.repository }}/releases/assets/$id" || true+ done++ build-and-release:+ needs: [validate, clean-release]+ if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'strategy:fail-fast: falsediff --git a/desktop/src-tauri/src/lib.rs b/desktop/src-tauri/src/lib.rsindex 10429c38..d1f26918 100644--- a/desktop/src-tauri/src/lib.rs+++ b/desktop/src-tauri/src/lib.rs@@ -385,6 +385,11 @@ async fn get_setup_status(Ok(state.lock().await.clone())}+#[tauri::command]+fn get_api_base() -> String {+ api_base()+}+#[tauri::command]async fn start_backend(backend: tauri::State<'_, SharedBackend>,@@ -684,6 +689,7 @@ pub fn run() {}).invoke_handler(tauri::generate_handler![get_setup_status,+ get_api_base,start_backend,stop_backend,check_health,diff --git a/frontend/package.json b/frontend/package.jsonindex 99abc3d4..ab96be62 100644--- a/frontend/package.json+++ b/frontend/package.json@@ -1,7 +1,7 @@{"name": "openjarvis-chat","private": true,- "version": "1.0.0",+ "version": "0.1.0","type": "module","scripts": {"dev": "vite",diff --git a/frontend/src/lib/api.ts b/frontend/src/lib/api.tsindex a00031dc..c3f3dc3d 100644--- a/frontend/src/lib/api.ts+++ b/frontend/src/lib/api.ts@@ -15,7 +15,23 @@ declare global {export const isTauri = () => typeof window !== 'undefined' && !!window.__TAURI_INTERNALS__;-const DESKTOP_API = 'http://127.0.0.1:8000';+// Cached API base URL fetched from the Tauri backend at startup.+// This avoids hardcoding the port — the Rust backend is the single+// source of truth for JARVIS_PORT.+let _tauriApiBase: string | null = null;++/** Pre-fetch the API base URL from the Tauri backend (call once at init). */+export async function initApiBase(): Promise<void> {+ if (!isTauri()) return;+ try {+ const { invoke } = await import('@tauri-apps/api/core');+ _tauriApiBase = await invoke<string>('get_api_base');+ } catch {+ // Command may not exist on older builds; fall through to default.+ }+}++const DESKTOP_API_FALLBACK = 'http://127.0.0.1:8222';const getSettingsApiUrl = (): string => {try {@@ -32,7 +48,7 @@ export const getBase = (): string => {const settingsUrl = getSettingsApiUrl();if (settingsUrl) return settingsUrl;if (import.meta.env.VITE_API_URL) return import.meta.env.VITE_API_URL;- if (isTauri()) return DESKTOP_API;+ if (isTauri()) return _tauriApiBase || DESKTOP_API_FALLBACK;return '';};diff --git a/frontend/src/main.tsx b/frontend/src/main.tsxindex 2126e656..0295548a 100644--- a/frontend/src/main.tsx+++ b/frontend/src/main.tsx@@ -3,6 +3,7 @@ import { createRoot } from 'react-dom/client';import { BrowserRouter } from 'react-router';import { ErrorBoundary } from './components/ErrorBoundary';import App from './App';+import { initApiBase } from './lib/api';import './index.css';function applyTheme() {@@ -22,12 +23,17 @@ function applyTheme() {applyTheme();-createRoot(document.getElementById('root')!).render(- <StrictMode>- <ErrorBoundary>- <BrowserRouter>- <App />- </BrowserRouter>- </ErrorBoundary>- </StrictMode>,-);+// Fetch the API base URL from the Tauri backend before rendering.+// This ensures JARVIS_PORT is defined in one place (the Rust backend).+// In non-Tauri environments this is a no-op.+initApiBase().finally(() => {+ createRoot(document.getElementById('root')!).render(+ <StrictMode>+ <ErrorBoundary>+ <BrowserRouter>+ <App />+ </BrowserRouter>+ </ErrorBoundary>+ </StrictMode>,+ );+});