Skip to content

The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.

fix(onboarding): ask Tauri directly whether the wizard has its own window

purple97b5c0b39c7c
diff --git a/src/lib/__tests__/a-re-run-of-the-onboarding-can-be-left.test.ts b/src/lib/__tests__/a-re-run-of-the-onboarding-can-be-left.test.ts
index f07c9003..3b0c0c6a 100644
--- a/src/lib/__tests__/a-re-run-of-the-onboarding-can-be-left.test.ts
+++ b/src/lib/__tests__/a-re-run-of-the-onboarding-can-be-left.test.ts
@@ -22,6 +22,7 @@ vi.mock('../../api/backend', async () => {
const actual = await vi.importActual<typeof import('../../api/backend')>('../../api/backend')
return { ...actual, backendCall: backend.backendCall }
})
+vi.mock('@tauri-apps/api/core', () => ({ invoke: (cmd: string) => backend.backendCall(cmd) }))
import { rerunOnboarding } from '../onboarding-rerun'
import { useSettingsStore } from '../../stores/settingsStore'
@@ -50,7 +51,7 @@ describe('Re-run onboarding', () => {
const reload = vi.fn()
await rerunOnboarding(reload)
expect(calls).toEqual(['set_onboarding_done', 'onboarding_window_open'])
- expect(backend.backendCall).toHaveBeenCalledWith('set_onboarding_done', { done: false })
+ expect(backend.backendCall).toHaveBeenNthCalledWith(1, 'set_onboarding_done', { done: false })
expect(useSettingsStore.getState().settings.onboardingDone).toBe(true)
expect(reload).toHaveBeenCalledTimes(1)
})
diff --git a/src/lib/onboarding-rerun.ts b/src/lib/onboarding-rerun.ts
index 352f1225..c9b250f4 100644
--- a/src/lib/onboarding-rerun.ts
+++ b/src/lib/onboarding-rerun.ts
@@ -24,7 +24,11 @@ import { useSettingsStore } from '../stores/settingsStore'
export async function rerunOnboarding(reload: () => void = () => window.location.reload()): Promise<void> {
try { await backendCall('set_onboarding_done', { done: false }) } catch { /* see above */ }
- const ownWindow = await backendCall<boolean>('onboarding_window_open').catch(() => false)
+ // Straight to Tauri like `awaitOnboardingHandover` (host-window.ts): the
+ // question has no dev-server route, and outside Tauri the answer is no.
+ const ownWindow = await import('@tauri-apps/api/core')
+ .then(({ invoke }) => invoke<boolean>('onboarding_window_open'))
+ .catch(() => false)
if (ownWindow !== true) useSettingsStore.getState().updateSettings({ onboardingDone: false })
reload()
}