OpenHands icon indicating copy to clipboard operation
OpenHands copied to clipboard

[Bug]: Initial LLM settings UI resets when switching window/tab during initial setup (Alt+Tab / Ctrl+Tab)

Open llamantino opened this issue 6 months ago • 1 comments

Is there an existing issue for the same bug? (If one exists, thumbs up or comment on the issue instead).

  • [x] I have checked the existing issues.

Describe the bug and reproduction steps

During the initial onboarding flow, the application prompts the user to configure an AI Provider.
By clicking on the "see advanced settings" link, the user is redirected to the full LLM Settings page (/settings, under the LLM tab).

Now, if the user does the following:

  • Toggles Advanced mode
  • Fills in values like Custom Model, Base URL, or API Key
  • Then presses Alt+Tab or Ctrl+Tab to switch apps or browser tabs

Upon returning to the window/tab, the entire settings UI resets:

  • "Advanced" mode is toggled off
  • All fields (Custom Model, Base URL, API Key, etc.) are cleared
  • User input is lost, and configuration must be re-entered from scratch

This behavior occurs only during the initial setup, before the LLM configuration has been saved.

I observed this issue on both Chrome (version 137) and Firefox (version 138).

OpenHands Installation

Docker command in README

OpenHands Version

0.39

Operating System

WSL on Windows

Logs, Errors, Screenshots, and Additional Context

No response

llamantino avatar May 27 '25 23:05 llamantino

From what I understand, this issue occurs because the settings value returned by the use-settings hook is initially empty (because user hasn't saved the initial LLM setup yet), so switching tabs will prompt a refetch by react-query which then triggers the Skeleton to be rendered in the page: if (!settings || isFetching) return <LlmSettingsInputsSkeleton />; Since the inputs in the page are uncontrolled, the value of the inputs aren't saved in the browser after the re-render of skeleton and won't be displayed anymore.

I have a few suggestions for fixing this issue:

Option 1: (easy) Disable react-query refetch on window focus in the use-settings hook refetchOnWindowFocus: false,

Option 2: (Very Time Consuming) Change the inputs in the settings page from uncontrolled to controlled so that the values are saved after re-render

Option 3: Change the Skeleton Rendering condition so that it only renders when the page is initially loaded

Feel free to provide more suggestions for this issue since I am new to this project.

KianoshArian avatar May 28 '25 16:05 KianoshArian