The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): owner-routed model.options no longer sends the ambient profile
Tekniuma15a5aae4f4d
diff --git a/apps/desktop/src/lib/model-options.test.ts b/apps/desktop/src/lib/model-options.test.tsindex 846cf74cc75..4a2d7882909 100644--- a/apps/desktop/src/lib/model-options.test.ts+++ b/apps/desktop/src/lib/model-options.test.ts@@ -160,9 +160,11 @@ describe('requestModelOptions', () => {params?: Record<string, unknown>) => Promise<T>- await expect(requestModelOptions({ gateway: gateway as never, request, sessionId: 'tile-1' })).resolves.toBe(- routedPayload- )+ // The window's ambient profile must not ride along: the backend lets an+ // explicit profile override the session the owner already resolves.+ await expect(+ requestModelOptions({ gateway: gateway as never, profile: 'default', request, sessionId: 'tile-1' })+ ).resolves.toBe(routedPayload)expect(request).toHaveBeenCalledWith('model.options', { explicit_only: true, session_id: 'tile-1' })expect(gateway.request).not.toHaveBeenCalled()diff --git a/apps/desktop/src/lib/model-options.ts b/apps/desktop/src/lib/model-options.tsindex 2c8635c7f3d..97f9e765d56 100644--- a/apps/desktop/src/lib/model-options.ts+++ b/apps/desktop/src/lib/model-options.ts@@ -170,7 +170,11 @@ export async function requestModelOptions({const profileKey = (profile ?? '').trim()- if (profileKey) {+ // An owner-routed session read is scoped by its session_id. The backend lets+ // an explicit `profile` override that, and callers hand in the window's+ // ambient profile, so sending it built the launch profile's catalog; the+ // router adds the owner's own profile where its socket needs one.+ if (profileKey && !(request && sessionId)) {params.profile = profileKey}diff --git a/apps/desktop/src/lib/session-owner-routed-rpcs.test.tsx b/apps/desktop/src/lib/session-owner-routed-rpcs.test.tsxindex f26e6249c38..e312eeb9d69 100644--- a/apps/desktop/src/lib/session-owner-routed-rpcs.test.tsx+++ b/apps/desktop/src/lib/session-owner-routed-rpcs.test.tsx@@ -23,7 +23,7 @@ const mocks = vi.hoisted(() => {})}- return { ambient, requestGatewayForAgent: vi.fn(), requestModelOptions: vi.fn() }+ return { ambient, requestGatewayForAgent: vi.fn() }})vi.mock('@/store/gateway', async importOriginal => ({@@ -33,11 +33,6 @@ vi.mock('@/store/gateway', async importOriginal => ({requestGatewayForAgent: mocks.requestGatewayForAgent}))-vi.mock('@/lib/model-options', async importOriginal => ({- ...(await importOriginal<Record<string, unknown>>()),- requestModelOptions: mocks.requestModelOptions-}))-const { requestOneShot } = await import('./oneshot')const { setSessionYolo } = await import('./yolo-session')const { renameSessionPreferringRpc } = await import('@/app/chat/sidebar/session-actions-menu')@@ -59,7 +54,6 @@ beforeEach(() => {? { title: 'Renamed on owner' }: {})- mocks.requestModelOptions.mockResolvedValue({ providers: [] } satisfies ModelOptionsResult)$sessionStates.set({ [RUNTIME]: { storedSessionId: STORED } as never })setSessionOwnerHint(STORED, OWNER)})@@ -109,7 +103,10 @@ describe('session_id RPCs go to the session owner, not the ambient socket', () =})})- it('Edit Models reads model.options for a secondary-profile session from its owner', async () => {+ it('Edit Models reads model.options for a secondary-profile session from its owner, under its profile', async () => {+ const catalog: ModelOptionsResult = { providers: [{ models: ['m-research'], name: 'R', slug: 'r' }] }+ mocks.requestGatewayForAgent.mockResolvedValue(catalog)+render(<QueryClientProvider client={new QueryClient({ defaultOptions: { queries: { retry: false } } })}><I18nProvider>@@ -125,17 +122,16 @@ describe('session_id RPCs go to the session owner, not the ambient socket', () =</QueryClientProvider>)- await waitFor(() => expect(mocks.requestModelOptions).toHaveBeenCalled())+ await waitFor(() =>+ expect(mocks.requestGatewayForAgent).toHaveBeenCalledWith('local', 'research', 'model.options', expect.anything())+ )+ expect(mocks.ambient.request).not.toHaveBeenCalled()- const { request } = mocks.requestModelOptions.mock.calls[0][0] as {- request?: (method: string, params?: Record<string, unknown>) => Promise<unknown>- }+ // The backend lets an explicit profile override session_id: the window's+ // ambient 'default' would build the launch profile's catalog.+ const params = mocks.requestGatewayForAgent.mock.calls[0][3] as Record<string, unknown>- expect(request).toBeTypeOf('function')- await request!('model.options', { session_id: RUNTIME })- expect(mocks.ambient.request).not.toHaveBeenCalled()- expect(mocks.requestGatewayForAgent).toHaveBeenCalledWith('local', 'research', 'model.options', {- session_id: RUNTIME- })+ expect(params).toMatchObject({ explicit_only: true, session_id: RUNTIME })+ expect(params.profile ?? 'research').toBe('research')})})