Skip to content

πŸ™Œ OpenHands: AI-Driven Development

hotfix(frontend): Input set/unset state and disable runtime input (#6788)

sp.wackfdffca18e0bd
diff --git a/frontend/__tests__/routes/settings.test.tsx b/frontend/__tests__/routes/settings.test.tsx
index 2052d6eb9c..4578fbe58e 100644
--- a/frontend/__tests__/routes/settings.test.tsx
+++ b/frontend/__tests__/routes/settings.test.tsx
@@ -76,7 +76,8 @@ describe("Settings Screen", () => {
});
});
- it("should render an indicator if the GitHub token is not set", async () => {
+ // TODO: Set a better unset indicator
+ it.skip("should render an indicator if the GitHub token is not set", async () => {
getSettingsSpy.mockResolvedValue({
...MOCK_DEFAULT_USER_SETTINGS,
github_token_is_set: false,
@@ -97,6 +98,20 @@ describe("Settings Screen", () => {
});
});
+ it("should set asterik placeholder if the GitHub token is set", async () => {
+ getSettingsSpy.mockResolvedValue({
+ ...MOCK_DEFAULT_USER_SETTINGS,
+ github_token_is_set: true,
+ });
+
+ renderSettingsScreen();
+
+ await waitFor(() => {
+ const input = screen.getByTestId("github-token-input");
+ expect(input).toHaveProperty("placeholder", "**********");
+ });
+ });
+
it("should render an indicator if the GitHub token is set", async () => {
getSettingsSpy.mockResolvedValue({
...MOCK_DEFAULT_USER_SETTINGS,
@@ -314,7 +329,8 @@ describe("Settings Screen", () => {
// screen.getByTestId("security-analyzer-input");
});
- it("should render an indicator if the LLM API key is not set", async () => {
+ // TODO: Set a better unset indicator
+ it.skip("should render an indicator if the LLM API key is not set", async () => {
getSettingsSpy.mockResolvedValueOnce({
...MOCK_DEFAULT_USER_SETTINGS,
llm_api_key: null,
@@ -443,7 +459,22 @@ describe("Settings Screen", () => {
expect(input).toHaveValue("1x (2 core, 8G)");
});
- it("should save the runtime settings when the 'Save Changes' button is clicked", async () => {
+ it("should always have the runtime input disabled", async () => {
+ getConfigSpy.mockResolvedValue({
+ APP_MODE: "saas",
+ GITHUB_CLIENT_ID: "123",
+ POSTHOG_CLIENT_KEY: "456",
+ });
+
+ renderSettingsScreen();
+
+ await toggleAdvancedSettings(userEvent.setup());
+
+ const input = await screen.findByTestId("runtime-settings-input");
+ expect(input).toBeDisabled();
+ });
+
+ it.skip("should save the runtime settings when the 'Save Changes' button is clicked", async () => {
const user = userEvent.setup();
getConfigSpy.mockResolvedValue({
APP_MODE: "saas",
diff --git a/frontend/src/components/shared/modals/settings/settings-form.tsx b/frontend/src/components/shared/modals/settings/settings-form.tsx
index 0c7ef45079..dcd0f2f99e 100644
--- a/frontend/src/components/shared/modals/settings/settings-form.tsx
+++ b/frontend/src/components/shared/modals/settings/settings-form.tsx
@@ -75,7 +75,7 @@ export function SettingsForm({ settings, models, onClose }: SettingsFormProps) {
}
};
- const isLLMKeySet = settings.LLM_API_KEY !== "**********";
+ const isLLMKeySet = settings.LLM_API_KEY === "**********";
return (
<div>
@@ -97,7 +97,7 @@ export function SettingsForm({ settings, models, onClose }: SettingsFormProps) {
label="API Key"
type="password"
className="w-[680px]"
- startContent={<KeyStatusIcon isSet={isLLMKeySet} />}
+ startContent={isLLMKeySet && <KeyStatusIcon isSet={isLLMKeySet} />}
/>
<HelpLink
diff --git a/frontend/src/routes/settings.tsx b/frontend/src/routes/settings.tsx
index 34c8d572e4..0e12c38e52 100644
--- a/frontend/src/routes/settings.tsx
+++ b/frontend/src/routes/settings.tsx
@@ -257,7 +257,9 @@ function SettingsScreen() {
label="API Key"
type="password"
className="w-[680px]"
- startContent={<KeyStatusIcon isSet={isLLMKeySet} />}
+ startContent={
+ isLLMKeySet && <KeyStatusIcon isSet={isLLMKeySet} />
+ }
placeholder={isLLMKeySet ? "**********" : ""}
/>
@@ -291,6 +293,7 @@ function SettingsScreen() {
label="Runtime Settings"
items={REMOTE_RUNTIME_OPTIONS}
defaultSelectedKey={settings.REMOTE_RUNTIME_RESOURCE_FACTOR?.toString()}
+ isDisabled
isClearable={false}
/>
)}
@@ -348,7 +351,12 @@ function SettingsScreen() {
label="GitHub Token"
type="password"
className="w-[680px]"
- startContent={<KeyStatusIcon isSet={!!isGitHubTokenSet} />}
+ startContent={
+ isGitHubTokenSet && (
+ <KeyStatusIcon isSet={!!isGitHubTokenSet} />
+ )
+ }
+ placeholder={isGitHubTokenSet ? "**********" : ""}
/>
<HelpLink