fix(desktop): guard invoke calls with isTauriRuntime check
Some checks failed
CI / Lint & TypeCheck (push) Has been cancelled
CI / Unit Tests (push) Has been cancelled
CI / Build Frontend (push) Has been cancelled
CI / Rust Check (push) Has been cancelled
CI / Security Scan (push) Has been cancelled
CI / E2E Tests (push) Has been cancelled

Step 5 (embedding config) and Step 5b (summary driver) in App.tsx
bootstrap called invoke() without checking if Tauri IPC is available.
When accessing http://localhost:1420/ in a regular browser, this caused
"Cannot read properties of undefined (reading 'transformCallback')".

Also added __TAURI_INTERNALS__ guard in saasStore kernel config sync.
This commit is contained in:
iven
2026-04-03 12:46:14 +08:00
parent 65b73c547f
commit 564c7ca28f
2 changed files with 53 additions and 51 deletions

View File

@@ -261,7 +261,8 @@ function App() {
// Non-critical, continue without heartbeat // Non-critical, continue without heartbeat
} }
// Step 5: Restore embedding config to Rust backend // Step 5: Restore embedding config to Rust backend (Tauri-only)
if (isTauriRuntime()) {
try { try {
// Migrate plaintext embedding apiKey to secure storage if present // Migrate plaintext embedding apiKey to secure storage if present
try { try {
@@ -319,6 +320,7 @@ function App() {
log.warn('Failed to configure summary driver:', sumErr); log.warn('Failed to configure summary driver:', sumErr);
// Non-critical, summaries won't be auto-generated // Non-critical, summaries won't be auto-generated
} }
}
// Step 6: Bootstrap complete // Step 6: Bootstrap complete
setBootstrapping(false); setBootstrapping(false);

View File

@@ -542,7 +542,7 @@ export const useSaaSStore = create<SaaSStore>((set, get) => {
const kernelConfigs = result.configs.filter( const kernelConfigs = result.configs.filter(
(c) => kernelCategories.includes(c.category) && c.value !== null (c) => kernelCategories.includes(c.category) && c.value !== null
); );
if (kernelConfigs.length > 0) { if (kernelConfigs.length > 0 && typeof window !== 'undefined' && '__TAURI_INTERNALS__' in window) {
try { try {
const { invoke } = await import('@tauri-apps/api/core'); const { invoke } = await import('@tauri-apps/api/core');
await invoke('kernel_apply_saas_config', { await invoke('kernel_apply_saas_config', {