Skip to content

The agent that grows with you

feat(desktop): quickstart lands on a new chat when it finishes

emozilla24a5d9b7d374
diff --git a/apps/desktop/src/app/settings/local-models-settings.test.tsx b/apps/desktop/src/app/settings/local-models-settings.test.tsx
index a118a21a511..a8df4c3ff3d 100644
--- a/apps/desktop/src/app/settings/local-models-settings.test.tsx
+++ b/apps/desktop/src/app/settings/local-models-settings.test.tsx
@@ -1,4 +1,5 @@
import { act, cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react'
+import { MemoryRouter, useLocation } from 'react-router'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import { I18nProvider } from '@/i18n'
@@ -102,9 +103,11 @@ const REFUSED_MODEL: LocalCatalogModel = {
function renderPane() {
return render(
- <I18nProvider>
- <LocalModelsSettings />
- </I18nProvider>
+ <MemoryRouter>
+ <I18nProvider>
+ <LocalModelsSettings />
+ </I18nProvider>
+ </MemoryRouter>
)
}
@@ -357,6 +360,7 @@ describe('quickstart', () => {
describe('BrowseSection', () => {
it('searches HF after a pause and shows fit-priced files on demand', async () => {
vi.useFakeTimers()
+
try {
vi.mocked(hermes.searchHFModels).mockResolvedValue({
hits: [{ downloads: 872724, gated: false, likes: 47, repo: 'unsloth/Qwen3.8-27B-GGUF', updated: '2026-08-18' }]
@@ -369,9 +373,11 @@ describe('BrowseSection', () => {
})
render(
- <I18nProvider>
- <LocalModelsSettings />
- </I18nProvider>
+ <MemoryRouter>
+ <I18nProvider>
+ <LocalModelsSettings />
+ </I18nProvider>
+ </MemoryRouter>
)
await act(async () => {
await vi.runOnlyPendingTimersAsync()
@@ -442,3 +448,54 @@ describe('added-by-you rows', () => {
expect(buttons.length).toBeGreaterThanOrEqual(3)
})
})
+
+describe('quickstart completion navigation', () => {
+ it('lands on a new chat when a quickstart it watched finishes; stale done jobs on mount never navigate', async () => {
+ const routeProbe = vi.fn()
+
+ function Probe() {
+ const loc = useLocation()
+ routeProbe(loc.pathname)
+
+ return null
+ }
+
+ const doneJob: LocalRuntimeJob = {
+ done_bytes: 0,
+ detail: '',
+ error: null,
+ job_id: 'stale-done',
+ kind: 'quickstart',
+ model_id: 'qwen3.8-27b',
+ phase: 'done',
+ status: 'done',
+ target: 'Qwen3.8 27B',
+ total_bytes: null
+ }
+
+ // A finished quickstart already in history when the pane mounts —
+ // must NOT trigger navigation.
+ $localRuntimeJobs.set([doneJob])
+
+ render(
+ <MemoryRouter initialEntries={['/settings']}>
+ <I18nProvider>
+ <LocalModelsSettings />
+ </I18nProvider>
+ <Probe />
+ </MemoryRouter>
+ )
+ await act(async () => {})
+ expect(routeProbe).not.toHaveBeenCalledWith('/')
+
+ // A quickstart the pane SAW running that then completes -> navigate.
+ const running: LocalRuntimeJob = { ...doneJob, job_id: 'live-run', phase: 'downloading', status: 'running' }
+ await act(async () => {
+ $localRuntimeJobs.set([doneJob, running])
+ })
+ await act(async () => {
+ $localRuntimeJobs.set([doneJob, { ...running, phase: 'done', status: 'done' }])
+ })
+ expect(routeProbe).toHaveBeenCalledWith('/')
+ })
+})
diff --git a/apps/desktop/src/app/settings/local-models-settings.tsx b/apps/desktop/src/app/settings/local-models-settings.tsx
index 13176857c46..16a1bdc84e8 100644
--- a/apps/desktop/src/app/settings/local-models-settings.tsx
+++ b/apps/desktop/src/app/settings/local-models-settings.tsx
@@ -1,6 +1,8 @@
import { useStore } from '@nanostores/react'
import { useCallback, useEffect, useRef, useState } from 'react'
+import { useNavigate } from 'react-router'
+import { NEW_CHAT_ROUTE } from '@/app/routes'
import { Button } from '@/components/ui/button'
import { Tip } from '@/components/ui/tooltip'
import {
@@ -226,6 +228,38 @@ export function LocalModelsSettings() {
}
}
+ // Setup flows end at the action, not the settings pane: when quickstart
+ // finishes while the user is still HERE watching it, land them on a new
+ // chat with the model ready to try. Unmount cancels the intent — a user
+ // who navigated away mid-download keeps their place (no focus theft).
+ // (Lives above the loading return: hooks run unconditionally.)
+ const navigate = useNavigate()
+ const seenQuickstarts = useRef(new Set<string>())
+
+ const runningQuickstart = jobs.find(
+ j => j.kind === 'quickstart' && j.status === 'running'
+ )
+
+ useEffect(() => {
+ // Event detection, not value mirroring: the ref only remembers which
+ // job ids THIS mount saw running, so a 'done' already in the list on
+ // mount (stale history) never triggers a navigation.
+ const seen = seenQuickstarts.current
+
+ for (const j of jobs) {
+ if (j.kind !== 'quickstart') {
+ continue
+ }
+
+ if (j.status === 'running') {
+ seen.add(j.job_id)
+ } else if (j.status === 'done' && seen.has(j.job_id)) {
+ seen.delete(j.job_id)
+ navigate(NEW_CHAT_ROUTE)
+ }
+ }
+ }, [jobs, navigate])
+
if (!status || catalog === null) {
return <SettingsSkeleton sections={[{ rows: 2 }, { rows: 4 }]} />
}
@@ -238,19 +272,23 @@ export function LocalModelsSettings() {
// leads with a hero that does everything in one click; the full pane
// stays one 'Configure…' click away. A running quickstart pins this
// view so its progress has a home even after a remount.
- const qJob = jobs.find(j => j.kind === 'quickstart' && j.status === 'running') ?? null
+ const qJob = runningQuickstart ?? null
+
const needsSetup = !status.runtime_installed || status.models.length === 0
const heroModel = catalog.find(c => c.recommended && c.fits) ?? catalog.find(c => c.fits) ?? null
if (qJob || (needsSetup && !configure && heroModel)) {
// Stage rail derived from the job phase: engine -> model -> finish.
const phase = qJob?.phase ?? ''
+
const stageIndex = ['starting-server', 'setting-default'].includes(phase)
? 2
: phase === 'downloading'
? 1
: 0
+
const stages = [copy.quickstartStageEngine, copy.quickstartStageModel, copy.quickstartStageFinish]
+
// The model-download leg blanks job.detail on purpose (pane rows
// render their own byte counter) — compose one here instead of
// falling back to runtime copy that would misname the stage.
@@ -691,9 +729,11 @@ export function LocalModelsSettings() {
const isLoaded = residency === 'loaded' || residency === 'ready'
const isLoadingNow = residency === 'loading'
const livePlacement = status.placement?.[m.id]
+
const aJob = jobs.find(
j => j.kind === 'model-activate' && j.status === 'running' && j.model_id === m.id
)
+
const anyActivateRunning = jobs.some(j => j.kind === 'model-activate' && j.status === 'running')
return (