Skip to content

πŸ™Œ OpenHands: AI-Driven Development

hotfix(frontend): Only open consent form if user truly did not make a choice (#6551)

sp.wack6b243155f416
diff --git a/frontend/__tests__/routes/_oh.test.tsx b/frontend/__tests__/routes/_oh.test.tsx
index f4b2eaed1b..3ab4780de9 100644
--- a/frontend/__tests__/routes/_oh.test.tsx
+++ b/frontend/__tests__/routes/_oh.test.tsx
@@ -58,6 +58,7 @@ describe("frontend/routes/_oh", () => {
it("should render and capture the user's consent if oss mode", async () => {
const user = userEvent.setup();
const getConfigSpy = vi.spyOn(OpenHands, "getConfig");
+ const getSettingsSpy = vi.spyOn(OpenHands, "getSettings");
const handleCaptureConsentSpy = vi.spyOn(
CaptureConsent,
"handleCaptureConsent",
@@ -69,6 +70,11 @@ describe("frontend/routes/_oh", () => {
POSTHOG_CLIENT_KEY: "test-key",
});
+ // @ts-expect-error - We only care about the user_consents_to_analytics field
+ getSettingsSpy.mockResolvedValue({
+ user_consents_to_analytics: null,
+ });
+
renderWithProviders(<RouteStub />);
// The user has not consented to tracking
diff --git a/frontend/src/routes/_oh/route.tsx b/frontend/src/routes/_oh/route.tsx
index ce9911a0ea..6d62dbcf19 100644
--- a/frontend/src/routes/_oh/route.tsx
+++ b/frontend/src/routes/_oh/route.tsx
@@ -48,9 +48,7 @@ export default function MainApp() {
const { data: settings } = useSettings();
const { migrateUserConsent } = useMigrateUserConsent();
- const [consentFormIsOpen, setConsentFormIsOpen] = React.useState(
- settings.USER_CONSENTS_TO_ANALYTICS === null,
- );
+ const [consentFormIsOpen, setConsentFormIsOpen] = React.useState(false);
const config = useConfig();
const {
@@ -70,6 +68,13 @@ export default function MainApp() {
}
}, [settings?.LANGUAGE]);
+ React.useEffect(() => {
+ const consentFormModalIsOpen =
+ settings?.USER_CONSENTS_TO_ANALYTICS === null;
+
+ setConsentFormIsOpen(consentFormModalIsOpen);
+ }, [settings]);
+
React.useEffect(() => {
// Migrate user consent to the server if it was previously stored in localStorage
migrateUserConsent({
diff --git a/frontend/src/services/settings.ts b/frontend/src/services/settings.ts
index 152a662c4c..8b59bff043 100644
--- a/frontend/src/services/settings.ts
+++ b/frontend/src/services/settings.ts
@@ -13,7 +13,7 @@ export const DEFAULT_SETTINGS: Settings = {
REMOTE_RUNTIME_RESOURCE_FACTOR: 1,
GITHUB_TOKEN_IS_SET: false,
ENABLE_DEFAULT_CONDENSER: false,
- USER_CONSENTS_TO_ANALYTICS: null,
+ USER_CONSENTS_TO_ANALYTICS: false,
};
/**