Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
import { useState } from "react";
import type { LocaleKey } from "@/locales";
import { t } from "@/lib/i18n";
import { useFeature, type Feature } from "@/lib/use-feature";
import { api, type ConfigStatus } from "@/state/store";
import { useStoreDispatch, useStoreSelector } from "@/state/store-select";
import { SettingRow, SettingsGroup, SettingsRows, Switch } from "../../SettingsPrimitives";
import { useSettingsShell } from "../settings-shell";
const COPY: Record<Feature, { title: LocaleKey; line: LocaleKey }> = {
skillBurger: { title: "settings.features.skillBurger", line: "settings.features.skillBurgerLine" },
threadTabs: { title: "settings.features.threadTabs", line: "settings.features.threadTabsLine" },
suggestedReplies: { title: "settings.features.suggestedReplies", line: "settings.features.suggestedRepliesLine" },
skillsLibrary: { title: "settings.features.skillsLibrary", line: "settings.features.skillsLibraryLine" },
promotions: { title: "settings.features.promotions", line: "settings.features.promotionsLine" },
};
/** One switch kept in this place's config.json; shown once its server says it knows the switch. */
function FeatureRow({ name }: { name: Feature }) {
const on = useFeature(name);
const known = useStoreSelector((state) => typeof state.config?.features?.[name] === "boolean");
const dispatch = useStoreDispatch();
const [saving, setSaving] = useState(false);
const [error, setError] = useState("");
if (!known) return null;
const save = async (next: boolean) => {
if (saving) return;
setSaving(true);
setError("");
try {
const config: ConfigStatus = await api("/api/config", { method: "PATCH", body: JSON.stringify({ features: { [name]: next } }) });
dispatch({ type: "configStatus", config });
} catch {
setError(t("settings.features.error"));
} finally {
setSaving(false);
}
};
const copy = COPY[name];
return (
<SettingRow title={t(copy.title)} subtitle={t(copy.line)} message={error ? <p role="alert" className="text-danger">{error}</p> : null}>
<Switch data-feature-switch={name} checked={on} aria-label={t(copy.title)} disabled={saving} onClick={() => void save(!on)}
className="disabled:cursor-wait disabled:opacity-50" />
</SettingRow>
);
}
export function FeaturesPage() {
// The Skills section the library switch reveals is on the Bots page, which only Advanced lists.
const { ctx } = useSettingsShell();
return (
<SettingsGroup block="features">
<SettingsRows>
<FeatureRow name="skillBurger" />
<FeatureRow name="threadTabs" />
<FeatureRow name="suggestedReplies" />
{ctx.advanced && <FeatureRow name="skillsLibrary" />}
<FeatureRow name="promotions" />
</SettingsRows>
</SettingsGroup>
);
}