Skip to content

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

942 B
Raw Blame
import { promotionsEnabled, skillBurgerEnabled, skillsLibraryEnabled, suggestedRepliesEnabled, threadTabsEnabled } from "@/lib/feature-flags";
import type { ConfigStatus } from "@/state/store";
import { useStoreSelector } from "@/state/store-select";

/** Switches on Settings → Features, kept in the place's config.json (`features.<name>`), so its server reads them too. */
export type Feature = "skillBurger" | "threadTabs" | "suggestedReplies" | "skillsLibrary" | "promotions";

const FEATURES: Record<Feature, (config: ConfigStatus | null | undefined) => boolean> = {
  skillBurger: skillBurgerEnabled,
  threadTabs: threadTabsEnabled,
  suggestedReplies: suggestedRepliesEnabled,
  skillsLibrary: skillsLibraryEnabled,
  promotions: promotionsEnabled,
};

/** Whether a switch on Settings → Features is on. */
export function useFeature(name: Feature): boolean {
  return useStoreSelector((state) => FEATURES[name](state.config));
}