Skip to content

The agent that grows with you

fix(desktop): pin the cross-provider onboarding pick test to the confirm card's picker wiring

teknium1be81cf7d4d2e
diff --git a/apps/desktop/src/components/onboarding/flow.test.tsx b/apps/desktop/src/components/onboarding/flow.test.tsx
new file mode 100644
index 00000000000..7768b3cb691
--- /dev/null
+++ b/apps/desktop/src/components/onboarding/flow.test.tsx
@@ -0,0 +1,127 @@
+import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
+import { cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react'
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
+
+import type * as HermesApi from '@/hermes'
+import { $desktopOnboarding, type DesktopOnboardingState, type OnboardingContext } from '@/store/onboarding'
+
+import { FlowPanel } from './flow'
+
+// Only the catalog fetch is replaced; the model assignment keeps its real path
+// down to window.hermesDesktop.api so the test observes the wire body.
+vi.mock('@/hermes', async importOriginal => ({
+ ...(await importOriginal<typeof HermesApi>()),
+ getGlobalModelOptions: async () => ({
+ providers: [
+ { free_tier: false, models: ['gpt-5.6-terra'], name: 'OpenAI OAuth (ChatGPT)', slug: 'openai' },
+ { models: ['deepseek/deepseek-v4-flash-0731'], name: 'Nous Portal', slug: 'nous' }
+ ]
+ })
+}))
+
+// The real picker is a cmdk/Radix dialog; stand in a button that reports the
+// same {provider, model} selection shape the real one emits.
+vi.mock('@/components/model-picker', () => ({
+ ModelPickerDialog: ({
+ onSelect,
+ open
+ }: {
+ onSelect: (selection: { model: string; provider: string }) => void
+ open: boolean
+ }) =>
+ open ? (
+ <button onClick={() => onSelect({ model: 'deepseek/deepseek-v4-flash-0731', provider: 'nous' })} type="button">
+ pick-nous-model
+ </button>
+ ) : null
+}))
+
+const ctx: OnboardingContext = { requestGateway: async () => undefined as never }
+
+function confirmingModelState(): DesktopOnboardingState {
+ return {
+ configured: false,
+ flow: {
+ status: 'confirming_model',
+ currentModel: 'gpt-5.6-terra',
+ label: 'OpenAI OAuth (ChatGPT)',
+ providerSlug: 'openai',
+ saving: false
+ },
+ mode: 'oauth',
+ providers: null,
+ reason: null,
+ requested: false,
+ firstRunSkipped: false,
+ manual: false,
+ localEndpoint: false,
+ freeTierReady: false
+ }
+}
+
+function Harness() {
+ const state = $desktopOnboarding.get()
+
+ return (
+ <QueryClientProvider client={new QueryClient({ defaultOptions: { queries: { retry: false } } })}>
+ <FlowPanel ctx={ctx} flow={state.flow} leaving={false} onBegin={() => undefined} />
+ </QueryClientProvider>
+ )
+}
+
+beforeEach(() => {
+ $desktopOnboarding.set(confirmingModelState())
+})
+
+afterEach(() => {
+ cleanup()
+ $desktopOnboarding.set({ ...confirmingModelState(), configured: null, flow: { status: 'idle' } })
+})
+
+describe('ConfirmingModelPanel model pick', () => {
+ it('persists a cross-provider pick against the picked model provider, not the sign-in provider', async () => {
+ const calls: { body?: unknown; path: string }[] = []
+
+ Object.defineProperty(window, 'hermesDesktop', {
+ configurable: true,
+ value: {
+ api: async ({ body, path }: { body?: unknown; path: string }) => {
+ calls.push({ body, path })
+
+ if (path === '/api/model/set') {
+ return { ok: true, provider: 'nous', model: 'deepseek/deepseek-v4-flash-0731' }
+ }
+
+ throw new Error(`unexpected api path: ${path}`)
+ }
+ }
+ })
+
+ render(<Harness />)
+
+ // The Pro badge only renders once the catalog query has resolved — the
+ // relabel below reads the picked provider's name from that catalog.
+ await screen.findByText('Pro')
+
+ // The user signed in with OpenAI OAuth; the picker offers a deepseek
+ // model that only Nous Portal serves.
+ fireEvent.click(screen.getByRole('button', { name: 'Change' }))
+ fireEvent.click(await screen.findByRole('button', { name: 'pick-nous-model' }))
+
+ await waitFor(() => expect(calls.some(c => c.path === '/api/model/set')).toBe(true))
+
+ expect(calls.find(c => c.path === '/api/model/set')?.body).toMatchObject({
+ scope: 'main',
+ provider: 'nous',
+ model: 'deepseek/deepseek-v4-flash-0731'
+ })
+
+ const flow = $desktopOnboarding.get().flow
+ expect(flow.status).toBe('confirming_model')
+
+ if (flow.status === 'confirming_model') {
+ expect(flow.providerSlug).toBe('nous')
+ expect(flow.label).toBe('Nous Portal')
+ }
+ })
+})
diff --git a/apps/desktop/src/store/onboarding.test.ts b/apps/desktop/src/store/onboarding.test.ts
index d3984efe65b..02691a73730 100644
--- a/apps/desktop/src/store/onboarding.test.ts
+++ b/apps/desktop/src/store/onboarding.test.ts
@@ -866,6 +866,9 @@ describe('device-code poll expiry', () => {
})
})
+// The happy path (cross-provider pick reaches /api/model/set with the picked
+// model's provider) is covered from the ConfirmingModelPanel in
+// components/onboarding/flow.test.tsx so it exercises the onSelect wiring.
describe('setOnboardingModel', () => {
beforeEach(() => {
window.localStorage.clear()
@@ -891,44 +894,6 @@ describe('setOnboardingModel', () => {
})
}
- it('persists a cross-provider pick against the picked model provider, not the sign-in provider', async () => {
- const calls: { body?: unknown; path: string }[] = []
-
- const api = vi.fn(async ({ body, path }: { body?: unknown; path: string }) => {
- calls.push({ body, path })
-
- if (path === '/api/model/set') {
- return { ok: true, provider: 'nous', model: 'deepseek/deepseek-v4-flash-0731' }
- }
-
- throw new Error(`unexpected api path: ${path}`)
- })
-
- installApiMock(api)
- $desktopOnboarding.set(confirmingModelState())
-
- // The user signed in with OpenAI OAuth but picked a deepseek model that
- // Nous Portal serves. The assignment must target `nous`, never `openai`.
- await setOnboardingModel('deepseek/deepseek-v4-flash-0731', 'nous', 'Nous Portal')
-
- const assign = calls.find(c => c.path === '/api/model/set')
- expect(assign?.body).toMatchObject({
- scope: 'main',
- provider: 'nous',
- model: 'deepseek/deepseek-v4-flash-0731'
- })
-
- const flow = $desktopOnboarding.get().flow
- expect(flow.status).toBe('confirming_model')
-
- if (flow.status === 'confirming_model') {
- expect(flow.currentModel).toBe('deepseek/deepseek-v4-flash-0731')
- expect(flow.providerSlug).toBe('nous')
- expect(flow.label).toBe('Nous Portal')
- expect(flow.saving).toBe(false)
- }
- })
-
it('reverts the model, provider and label when persistence fails', async () => {
installApiMock(async () => {
throw new Error('backend down')