π OpenHands: AI-Driven Development
refactor(frontend): remove certain security analyzer options for v1 conversations (#11988)
Hiep Le272a37d1b88c
diff --git a/frontend/__tests__/routes/llm-settings.test.tsx b/frontend/__tests__/routes/llm-settings.test.tsxindex adfca6b40a..8cb1239c0a 100644--- a/frontend/__tests__/routes/llm-settings.test.tsx+++ b/frontend/__tests__/routes/llm-settings.test.tsx@@ -253,6 +253,83 @@ describe("Content", () => {expect(securityAnalyzer).toHaveValue("SETTINGS$SECURITY_ANALYZER_NONE");});});++ it("should omit invariant and custom analyzers when V1 is enabled", async () => {+ const getSettingsSpy = vi.spyOn(SettingsService, "getSettings");+ getSettingsSpy.mockResolvedValue({+ ...MOCK_DEFAULT_USER_SETTINGS,+ confirmation_mode: true,+ security_analyzer: "llm",+ v1_enabled: true,+ });++ const getSecurityAnalyzersSpy = vi.spyOn(+ OptionService,+ "getSecurityAnalyzers",+ );+ getSecurityAnalyzersSpy.mockResolvedValue([+ "llm",+ "none",+ "invariant",+ "custom",+ ]);++ renderLlmSettingsScreen();+ await screen.findByTestId("llm-settings-screen");++ const advancedSwitch = screen.getByTestId("advanced-settings-switch");+ await userEvent.click(advancedSwitch);++ const securityAnalyzer = await screen.findByTestId(+ "security-analyzer-input",+ );+ await userEvent.click(securityAnalyzer);++ // Only llm + none should be available when V1 is enabled+ screen.getByText("SETTINGS$SECURITY_ANALYZER_LLM_DEFAULT");+ screen.getByText("SETTINGS$SECURITY_ANALYZER_NONE");+ expect(+ screen.queryByText("SETTINGS$SECURITY_ANALYZER_INVARIANT"),+ ).not.toBeInTheDocument();+ expect(screen.queryByText("custom")).not.toBeInTheDocument();+ });++ it("should include invariant analyzer option when V1 is disabled", async () => {+ const getSettingsSpy = vi.spyOn(SettingsService, "getSettings");+ getSettingsSpy.mockResolvedValue({+ ...MOCK_DEFAULT_USER_SETTINGS,+ confirmation_mode: true,+ security_analyzer: "llm",+ v1_enabled: false,+ });++ const getSecurityAnalyzersSpy = vi.spyOn(+ OptionService,+ "getSecurityAnalyzers",+ );+ getSecurityAnalyzersSpy.mockResolvedValue(["llm", "none", "invariant"]);++ renderLlmSettingsScreen();+ await screen.findByTestId("llm-settings-screen");++ const advancedSwitch = screen.getByTestId("advanced-settings-switch");+ await userEvent.click(advancedSwitch);++ const securityAnalyzer = await screen.findByTestId(+ "security-analyzer-input",+ );+ await userEvent.click(securityAnalyzer);++ expect(+ screen.getByText("SETTINGS$SECURITY_ANALYZER_LLM_DEFAULT"),+ ).toBeInTheDocument();+ expect(+ screen.getByText("SETTINGS$SECURITY_ANALYZER_NONE"),+ ).toBeInTheDocument();+ expect(+ screen.getByText("SETTINGS$SECURITY_ANALYZER_INVARIANT"),+ ).toBeInTheDocument();+ });});it.todo("should render an indicator if the llm api key is set");diff --git a/frontend/src/routes/llm-settings.tsx b/frontend/src/routes/llm-settings.tsxindex 056bf28c2c..00de428f26 100644--- a/frontend/src/routes/llm-settings.tsx+++ b/frontend/src/routes/llm-settings.tsx@@ -453,6 +453,10 @@ function LlmSettingsScreen() {label: t(I18nKey.SETTINGS$SECURITY_ANALYZER_NONE),});+ if (isV1Enabled) {+ return orderedItems;+ }+// Add Invariant analyzer thirdif (analyzers.includes("invariant")) {orderedItems.push({