Skip to content

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

Blocked Works on choices say why, and draft picks are tested

Kevinffbd6426c790
diff --git a/src/components/bot-settings/AccessSection.test.ts b/src/components/bot-settings/AccessSection.test.ts
index b787bd884b..4bce631128 100644
--- a/src/components/bot-settings/AccessSection.test.ts
+++ b/src/components/bot-settings/AccessSection.test.ts
@@ -226,8 +226,23 @@ describe("AccessSection Works on", () => {
fixture.config = { box: { configured: true } } as Partial<ConfigStatus>;
const chosen = draft(makeBot({ computer: "cloud" }));
- expect(chosen.html).toMatch(/aria-pressed="true"[^>]*>.*?Cloud desktop/);
+ expect(chosen.html).toMatch(/<button[^>]*aria-pressed="true"[^>]*>(?:(?!<\/button>).)*?Cloud desktop/);
expect(chosen.html).toContain("Cloud backend");
+
+ const picker = nodes(chosen.tree).find((node) => (node.type as { name?: string }).name === "DraftWorksOn")!;
+ let rendered: ReactNode = null;
+ function Picker() { rendered = (picker.type as (props: unknown) => ReactNode)(picker.props); return rendered; }
+ renderToStaticMarkup(createElement(StoreProvider, null, createElement(Picker)));
+ const grid = nodes(rendered).find((node) => (node.type as { name?: string }).name === "WorksOnGrid")!;
+ const options = grid.props.options as Array<{ mode: string | null; disabled: boolean; unavailableTitle?: string }>;
+ const local = options.find((option) => option.mode === "local")!;
+ expect(local.disabled).toBe(true);
+ expect(local.unavailableTitle).toBeTruthy();
+
+ const select = grid.props.onSelect as (mode: string | null) => void;
+ select("browser");
+ select(null);
+ expect(vi.mocked(derived.patch).mock.calls).toEqual([[{ computer: "browser", browser: true }], [{ computer: null }]]);
});
it("hides the Boat or VPS choice on My Cloud, whose cloud computers are the plan's", () => {
diff --git a/src/components/bot-settings/AccessSection.tsx b/src/components/bot-settings/AccessSection.tsx
index 1e0610777f..f3a232b91f 100644
--- a/src/components/bot-settings/AccessSection.tsx
+++ b/src/components/bot-settings/AccessSection.tsx
@@ -636,7 +636,6 @@ export function CloudPreference({ bot, patch }: { bot: Bot; patch: ReturnType<ty
);
}
-/** A bot not made yet has no Screen panel to open, so its place is chosen here. */
function DraftWorksOn({ bot, patch, seat }: { bot: Bot; patch: ReturnType<typeof useBotSettingsDerived>["patch"]; seat: PlaceSeat }) {
const { state } = useStore();
const { capabilities } = useDesktopCapabilities();
@@ -655,6 +654,7 @@ function DraftWorksOn({ bot, patch, seat }: { bot: Bot; patch: ReturnType<typeof
selected: mode === null ? !bot.computer : bot.computer === mode,
disabled: Boolean(managedBy) || placeBlocked(view),
issue: !managedBy && placeHasIssue(view),
+ unavailableTitle: managedBy ?? (placeBlocked(view) ? view.line : undefined),
};
});
const choose = (mode: WorksOnMode) => patch(mode === "browser" ? { computer: mode, browser: true } : { computer: mode });