Skip to content

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

1.4 KB
Raw Blame
import { useId } from "react";
import { ROUTINE_COMPUTERS, type RoutineComputer } from "../../../shared/routines";
import { t } from "@/lib/i18n";
import { routineComputerLabel } from "@/lib/routine-display";
import { Select } from "../Select";

/** Where each run of a bot routine works: the bot's own Works on setting, or a computer the routine keeps, by default
 * the one its chat was set to when it was made. Choosing the first clears the routine's own computer. */
export function RoutineComputerChoice({ value, cloudHome, onChange }: {
  value: RoutineComputer | null;
  cloudHome: boolean;
  onChange: (computer: RoutineComputer | null) => void;
}) {
  const id = useId();
  return <div className="mt-3 min-w-0 space-y-1.5">
    <label htmlFor={id} className="block text-[12px] font-medium text-ink">{t("routines.computer.label")}</label>
    <Select className="w-full" id={id} aria-describedby={`${id}-help`} value={value ?? ""}
      onChange={(event) => onChange(ROUTINE_COMPUTERS.find((computer) => computer === event.target.value) ?? null)}>
      <option value="">{t("routines.computer.worksOn")}</option>
      {ROUTINE_COMPUTERS.filter((computer) => computer !== "vm" || !cloudHome || value === "vm").map((computer) => <option key={computer} value={computer}>{routineComputerLabel(computer, cloudHome)}</option>)}
    </Select>
    <p id={`${id}-help`} className="text-[11px] leading-relaxed text-ink-secondary">{t("routines.computer.help")}</p>
  </div>;
}