diff --git a/ui/app/(prowler)/lighthouse/_components/chat/lighthouse-v2-chat-page.test.tsx b/ui/app/(prowler)/lighthouse/_components/chat/lighthouse-v2-chat-page.test.tsx index 5e2bb0cfed..2fc0b96c3b 100644 --- a/ui/app/(prowler)/lighthouse/_components/chat/lighthouse-v2-chat-page.test.tsx +++ b/ui/app/(prowler)/lighthouse/_components/chat/lighthouse-v2-chat-page.test.tsx @@ -219,6 +219,25 @@ describe("LighthouseV2ChatPage", () => { expect(within(currentModel).getByText("GPT-5.1")).toBeInTheDocument(); }); + it("defaults to gpt-5.5 when OpenAI has no remembered model", () => { + // Given / When + renderPage({ + configurations: [ + { ...configurations[0], defaultModel: null, connected: true }, + { ...configurations[1], connected: false }, + ], + modelsByProvider: { + openai: [model("gpt-4.1", "GPT-4.1"), model("gpt-5.5", "GPT-5.5")], + bedrock: [model("anthropic.claude-4")], + "openai-compatible": [model("llama-3.3")], + }, + }); + + // Then + const currentModel = screen.getByLabelText("Current model: OpenAI GPT-5.5"); + expect(within(currentModel).getByText("GPT-5.5")).toBeInTheDocument(); + }); + it("uses the AWS onboarding quick prompt instead of the docs prompt", async () => { // Given const user = userEvent.setup(); diff --git a/ui/app/(prowler)/lighthouse/_components/chat/lighthouse-v2-chat-page.tsx b/ui/app/(prowler)/lighthouse/_components/chat/lighthouse-v2-chat-page.tsx index 4f5baf6de7..82697ce506 100644 --- a/ui/app/(prowler)/lighthouse/_components/chat/lighthouse-v2-chat-page.tsx +++ b/ui/app/(prowler)/lighthouse/_components/chat/lighthouse-v2-chat-page.tsx @@ -516,6 +516,13 @@ const LIGHTHOUSE_V2_PROVIDER_PRIORITY = [ LIGHTHOUSE_V2_PROVIDER_TYPE.OPENAI_COMPATIBLE, ] as const; +// Fallback model per provider when the configuration has no remembered model. +const LIGHTHOUSE_V2_PREFERRED_DEFAULT_MODEL: Partial< + Record +> = { + [LIGHTHOUSE_V2_PROVIDER_TYPE.OPENAI]: "gpt-5.5", +}; + function resolveInitialModelSelection( connectedConfigurations: LighthouseV2Configuration[], modelsByProvider: Record< @@ -535,14 +542,19 @@ function resolveInitialModelSelection( for (const configuration of orderedConfigurations) { const providerModels = modelsByProvider[configuration.providerType] ?? []; if (providerModels.length === 0) continue; - // Prefer the provider's remembered model when it is still supported; - // otherwise fall back to the first supported model. + // Prefer the provider's remembered model when it is still supported, then + // the provider's preferred default, then the first supported model. const rememberedModel = providerModels.find( (model) => model.id === configuration.defaultModel, ); + const preferredModel = providerModels.find( + (model) => + model.id === + LIGHTHOUSE_V2_PREFERRED_DEFAULT_MODEL[configuration.providerType], + ); return { providerType: configuration.providerType, - modelId: (rememberedModel ?? providerModels[0]).id, + modelId: (rememberedModel ?? preferredModel ?? providerModels[0]).id, }; }