Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

Disable the isolation choice while the desktop status loads or saves

aivsomkar4d5b2bac6e08
diff --git a/src/components/LocalComputerSection.test.ts b/src/components/LocalComputerSection.test.ts
index 4d45aefbed..46031d9052 100644
--- a/src/components/LocalComputerSection.test.ts
+++ b/src/components/LocalComputerSection.test.ts
@@ -576,6 +576,12 @@ describe("Settings → Computers on an OMB Cloud home", () => {
expect(titles).not.toContain("Private desktops");
expect(titles).not.toContain("Setup");
});
+
+ it("disables the isolation choice until the computer's status has loaded", () => {
+ const markup = renderToStaticMarkup(createElement(LocalComputerSection));
+ const isolation = markup.match(/<div role="radiogroup" aria-label="Isolation"[^>]*>(.*?)<\/div>/)?.[1] ?? "";
+ expect([...isolation.matchAll(/<button[^>]*>/g)].map(([button]) => button.includes('disabled=""'))).toEqual([true, true]);
+ });
});
describe("Local VM idle timeout setting", () => {
diff --git a/src/components/LocalComputerSection.tsx b/src/components/LocalComputerSection.tsx
index 5d36cda2e7..8ee6aeee51 100644
--- a/src/components/LocalComputerSection.tsx
+++ b/src/components/LocalComputerSection.tsx
@@ -1267,8 +1267,8 @@ export function LocalComputerSection() {
subtitle={t("vm.isolation.subtitle")}
>
<div className="flex justify-end">
- <Segmented label={t("vm.isolation.title")} value={status?.mode === "per-bot" ? "per-bot" : "shared"}
- onChange={(mode) => { if (status && !policyPending) void savePolicy(mode, status.max_instances ?? 2); }}
+ <Segmented label={t("vm.isolation.title")} value={status?.mode === "per-bot" ? "per-bot" : "shared"} disabled={!status || policyPending}
+ onChange={(mode) => { if (status) void savePolicy(mode, status.max_instances ?? 2); }}
options={[{ value: "shared" as const, label: t("vm.isolation.shared") }, { value: "per-bot" as const, label: t("vm.isolation.perBot") }]} />
</div>
{perBot && (
diff --git a/src/components/SettingsPrimitives.tsx b/src/components/SettingsPrimitives.tsx
index a8e25d63a0..be85424337 100644
--- a/src/components/SettingsPrimitives.tsx
+++ b/src/components/SettingsPrimitives.tsx
@@ -325,14 +325,14 @@ export const SETTINGS_INPUT = `h-8 w-full rounded-lg ${FIELD_EDGE} bg-app px-2 t
export const SETTINGS_INLINE_INPUT = `h-7 w-20 rounded-lg ${FIELD_EDGE} bg-app px-2 text-right text-[13px] leading-5 tabular-nums text-ink outline-none focus-visible:outline-2 focus-visible:outline-offset-0 focus-visible:outline-focus disabled:opacity-40`;
/** The one segmented control: a 28 px pill track; the chosen part is a card-coloured pill with an edge. */
-export function Segmented<T extends string>({ value, options, onChange, label }: {
- value: T; options: Array<{ value: T; label: string }>; onChange: (value: T) => void; label: string;
+export function Segmented<T extends string>({ value, options, onChange, label, disabled = false }: {
+ value: T; options: Array<{ value: T; label: string }>; onChange: (value: T) => void; label: string; disabled?: boolean;
}) {
return (
- <div role="radiogroup" aria-label={label} data-settings-segmented="" className="inline-flex h-7 items-center rounded-full bg-ink/[0.05] p-0.5">
+ <div role="radiogroup" aria-label={label} aria-disabled={disabled || undefined} data-settings-segmented="" className={cn("inline-flex h-7 items-center rounded-full bg-ink/[0.05] p-0.5", disabled && "opacity-40")}>
{options.map((option) => (
- <button key={option.value} type="button" role="radio" aria-checked={value === option.value} onClick={() => onChange(option.value)}
- className={cn("h-6 cursor-pointer rounded-full px-3 text-[13px] leading-5 transition-colors focus-visible:outline-2 focus-visible:outline-focus",
+ <button key={option.value} type="button" role="radio" aria-checked={value === option.value} disabled={disabled} onClick={() => onChange(option.value)}
+ className={cn("h-6 cursor-pointer rounded-full disabled:cursor-default px-3 text-[13px] leading-5 transition-colors focus-visible:outline-2 focus-visible:outline-focus",
value === option.value ? "bg-menu font-medium text-ink shadow-[inset_0_0_0_0.5px_var(--settings-edge)]" : "text-ink-secondary hover:text-ink")}>
{option.label}
</button>