fix(webui): preserve custom shell runtime editing

This commit is contained in:
chengyongru authored and chengyongru committed 2026-10-16 14:09:55 +08:00
1 parent 3ccc181d29
commit 6f04038d21
2 files changed
+24

No files matched your search

@@ -67,6 +67,7 @@ export function ShellRuntimeControl({
: t("settings.runtimeConfig.commandRuntime.rangeError", { max: maximum.toLocaleString(i18n.language) }));
return;
}
setCustomSelected(true);
onChange(next);
}} />
<span aria-hidden className="pointer-events-none absolute inset-y-0 right-3 flex items-center text-[12px] text-muted-foreground">{unit}</span>
@@ -1,4 +1,5 @@
import { fireEvent, render, screen, waitFor, within } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { describe, expect, it, vi } from "vitest";
import { RuntimeSettings } from "@/components/settings/system/RuntimeSettings";
import { TimezonePicker } from "@/components/settings/shared/TimezonePicker";
@@ -150,6 +151,28 @@ describe("Runtime configuration settings", () => {
expect(await screen.findByText("Saved. Restart to apply changes.")).toBeInTheDocument();
});
it("keeps a loaded custom runtime editable when typing through a preset", async () => {
const payload = runtimeSettings();
requestMutationMock.mockResolvedValue({ ...payload, runtime_config: {
...payload.runtime_config, "tools.exec.timeout": 9000,
} });
const user = userEvent.setup();
renderSettingsView({ initialSection: "advanced", initialSettings: payload });
const field = screen.getByRole("spinbutton", { name: "Custom runtime (seconds)" });
await user.clear(field);
await user.type(field, "900");
expect(field).toHaveFocus();
expect(field).toHaveValue(900);
await user.type(field, "0");
expect(field).toHaveFocus();
expect(field).toHaveValue(9000);
await waitFor(() => expect(requestMutationMock).toHaveBeenCalledWith(
"settings.runtime_config.update", { values: { "tools.exec.timeout": 9000 } }, 20_000,
));
});
it("validates numbers and keeps a failed draft editable", async () => {
requestMutationMock.mockRejectedValue(new Error("Could not save settings"));
renderSettingsView({ initialSection: "advanced", initialSettings: runtimeSettings() });