Skip to content

Commit

Permalink
[Bug]: Settings modal opens on every refresh (#5670)
Browse files Browse the repository at this point in the history
Co-authored-by: openhands <[email protected]>
  • Loading branch information
2 people authored and mamoodi committed Dec 18, 2024
1 parent f9d052c commit 69470b0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
6 changes: 0 additions & 6 deletions frontend/__tests__/routes/_oh.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 />);
Expand Down
15 changes: 9 additions & 6 deletions frontend/src/routes/_oh/route.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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 (
<div
data-testid="root-layout"
Expand All @@ -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>
);
Expand Down

0 comments on commit 69470b0

Please sign in to comment.