Compare commits

...

1 Commits

Author SHA1 Message Date
Rohit Malhotra
69470b0a27 [Bug]: Settings modal opens on every refresh (#5670)
Co-authored-by: openhands <openhands@all-hands.dev>
2024-12-18 13:07:35 -05:00
2 changed files with 9 additions and 12 deletions

View File

@@ -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 />);

View File

@@ -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 (
<div
data-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>
);