π OpenHands: AI-Driven Development
[Bug]: Settings modal opens on every refresh (#5670)
Rohit Malhotra2c47a1b33f31
diff --git a/frontend/__tests__/routes/_oh.test.tsx b/frontend/__tests__/routes/_oh.test.tsxindex 8897b5dd8b..e22d959446 100644--- a/frontend/__tests__/routes/_oh.test.tsx+++ b/frontend/__tests__/routes/_oh.test.tsx@@ -39,12 +39,6 @@ describe("frontend/routes/_oh", () => {await screen.findByTestId("root-layout");});- it("should render the AI config modal if the user is authed", async () => {- // Our mock return value is true by default- renderWithProviders(<RouteStub />);- await screen.findByTestId("ai-config-modal");- });-it("should render the AI config modal if settings are not up-to-date", async () => {settingsAreUpToDateMock.mockReturnValue(false);renderWithProviders(<RouteStub />);diff --git a/frontend/src/routes/_oh/route.tsx b/frontend/src/routes/_oh/route.tsxindex 5055e24d23..27058be55c 100644--- a/frontend/src/routes/_oh/route.tsx+++ b/frontend/src/routes/_oh/route.tsx@@ -45,12 +45,15 @@ export function ErrorBoundary() {export default function MainApp() {const { gitHubToken, clearToken } = useAuth();- const { settings } = useUserPrefs();+ const { settings, settingsAreUpToDate } = useUserPrefs();const [consentFormIsOpen, setConsentFormIsOpen] = React.useState(!localStorage.getItem("analytics-consent"),);+ const [aiConfigModalIsOpen, setAiConfigModalIsOpen] =+ React.useState(!settingsAreUpToDate);+const config = useConfig();const {data: isAuthed,@@ -77,9 +80,6 @@ export default function MainApp() {const isInWaitlist =!isFetchingAuth && !isAuthed && config.data?.APP_MODE === "saas";- const { settingsAreUpToDate } = useUserPrefs();- const [showAIConfig, setShowAIConfig] = React.useState(true);-return (<divdata-testid="root-layout"@@ -101,8 +101,11 @@ export default function MainApp() {/>)}- {(isAuthed || !settingsAreUpToDate) && showAIConfig && (- <SettingsModal onClose={() => setShowAIConfig(false)} />+ {aiConfigModalIsOpen && (+ <SettingsModal+ onClose={() => setAiConfigModalIsOpen(false)}+ data-testid="ai-config-modal"+ />)}</div>);