Skip to content

Commit

Permalink
Merge main into feature/notifications: resolve settings.ts conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
openhands-agent committed Jan 30, 2025
2 parents ad4c818 + 5dd4810 commit 95a102e
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 7 deletions.
4 changes: 4 additions & 0 deletions docs/modules/usage/installation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@
- General: `Use the WSL 2 based engine` is enabled.
- Resources > WSL Integration: `Enable integration with my default WSL distro` is enabled.

:::note
The docker command below to start the app must be run inside the WSL terminal.
:::

</details>

## Start the App
Expand Down
6 changes: 6 additions & 0 deletions frontend/__tests__/routes/_oh.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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
Expand Down
11 changes: 8 additions & 3 deletions frontend/src/routes/_oh/route.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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({
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/services/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const DEFAULT_SETTINGS: Settings = {
GITHUB_TOKEN_IS_SET: false,
ENABLE_DEFAULT_CONDENSER: false,
ENABLE_SOUND_NOTIFICATIONS: false,
USER_CONSENTS_TO_ANALYTICS: null,
USER_CONSENTS_TO_ANALYTICS: false,
};

/**
Expand Down
5 changes: 4 additions & 1 deletion openhands/runtime/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ def setup_initial_env(self) -> None:
self.add_env_vars(self.config.sandbox.runtime_startup_env_vars)

def close(self) -> None:
"""
This should only be called by conversation manager or closing the session.
If called for instance by error handling, it could prevent recovery.
"""
pass

@classmethod
Expand Down Expand Up @@ -209,7 +213,6 @@ async def _handle_action(self, event: Action) -> None:
self.log('error', f'Unexpected error while running action: {error_message}')
self.log('error', f'Problematic action: {str(event)}')
self.send_error_message(err_id, error_message)
self.close()
return

observation._cause = event.id # type: ignore[attr-defined]
Expand Down
2 changes: 0 additions & 2 deletions openhands/runtime/impl/remote/remote_runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,8 +341,6 @@ def _wait_until_alive_impl(self):
f'Runtime (ID={self.runtime_id}) is not yet ready. Status: {pod_status}'
)
elif pod_status in ('failed', 'unknown', 'crashloopbackoff'):
# clean up the runtime
self.close()
if pod_status == 'crashloopbackoff':
raise AgentRuntimeUnavailableError(
'Runtime crashed and is being restarted, potentially due to memory usage. Please try again.'
Expand Down

0 comments on commit 95a102e

Please sign in to comment.