Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
// Each source file's calls to useStore(), the whole-store read: a component that calls it draws again on every store
// change, another bot's message included, whatever it shows. Read what a component draws with useStoreSelector
// (src/state/store-select.ts) instead. A count may only go down: a PR that adds a call fails here. One that removes calls
// passes and is told which numbers to lower; scripts/tighten-ratchets.mjs lowers any left at each release.
import { execFileSync } from "node:child_process";
import { readFileSync } from "node:fs";
import { describe, expect, it } from "vitest";
import { storeReadsIn } from "../tighten-ratchets.mjs";
const ROOT = new URL("../../", import.meta.url);
const READS: Record<string, number> = {
"src/App.tsx": 1,
"src/components/ActivityPanel.tsx": 1,
"src/components/AppGrantPrompt.tsx": 1,
"src/components/AppNotices.tsx": 1,
"src/components/ArchivedBotsPanel.tsx": 1,
"src/components/AwakeBotsPicker.tsx": 2,
"src/components/BotLimitPopup.tsx": 2,
"src/components/BotMenuDelete.tsx": 1,
"src/components/BotProjects.tsx": 2,
"src/components/BrowserPanel.tsx": 2,
"src/components/BrowserProfilesManager.tsx": 1,
"src/components/BurstCard.tsx": 1,
"src/components/CallView.tsx": 4,
"src/components/CanvasComputers.tsx": 1,
"src/components/CardHint.tsx": 1,
"src/components/ChatEmptyState.tsx": 1,
"src/components/ChatFindBar.tsx": 1,
"src/components/ClaudeCodeSwitches.tsx": 2,
"src/components/ClaudeSignIn.tsx": 1,
"src/components/ClaudeUpdatePrompt.tsx": 1,
"src/components/CloudAddDialog.tsx": 1,
"src/components/CloudEngineSignIn.tsx": 2,
"src/components/CloudHowTo.tsx": 1,
"src/components/CloudIntent.tsx": 1,
"src/components/CloudRoomCard.tsx": 2,
"src/components/CloudSetup.tsx": 2,
"src/components/CloudTimeZone.tsx": 1,
"src/components/CloudUsageMeter.tsx": 2,
"src/components/CommandAllowlistDialog.tsx": 1,
"src/components/CompanyModels.tsx": 1,
"src/components/ComposerPlusMenu.tsx": 1,
"src/components/ComputerFilesPane.tsx": 1,
"src/components/ComputerPanel.tsx": 1,
"src/components/ComputerSharingSettings.tsx": 1,
"src/components/ConnectedWorkspacesSettings.tsx": 1,
"src/components/ConversationTurnLimit.tsx": 1,
"src/components/DataResultChip.tsx": 1,
"src/components/DeviceSignIn.tsx": 1,
"src/components/EngineAccounts.tsx": 3,
"src/components/EngineAppCopy.tsx": 1,
"src/components/EngineBrowserSignIn.tsx": 1,
"src/components/EngineSetup.tsx": 5,
"src/components/EngineUsage.tsx": 3,
"src/components/FilePreviewPanel.tsx": 1,
"src/components/FilesView.tsx": 2,
"src/components/FirstReplyRescueRow.tsx": 1,
"src/components/ForkPanel.tsx": 1,
"src/components/FrameBarPinnedPages.tsx": 1,
"src/components/GoalRunCard.tsx": 1,
"src/components/GrokMoveDialog.tsx": 1,
"src/components/GroupCallView.tsx": 1,
"src/components/GroupView.tsx": 2,
"src/components/HelperIntro.tsx": 1,
"src/components/HelperKeySuggestion.tsx": 1,
"src/components/HelperSetup.tsx": 3,
"src/components/HomeLine.tsx": 1,
"src/components/ImportDialog.tsx": 1,
"src/components/ImportSettings.tsx": 1,
"src/components/InboxLine.tsx": 3,
"src/components/InspectorPanel.tsx": 1,
"src/components/LiveCallBar.tsx": 1,
"src/components/LiveCallHost.tsx": 1,
"src/components/LiveCallPill.tsx": 1,
"src/components/LiveCallSettings.tsx": 1,
"src/components/LiveKeyNeeded.tsx": 1,
"src/components/LiveKeySetup.tsx": 1,
"src/components/LiveProviderSettings.tsx": 1,
"src/components/LocalComputerSection.tsx": 1,
"src/components/LocalVmWorkspace.tsx": 1,
"src/components/ManageMembersPanel.tsx": 1,
"src/components/MapComposer.tsx": 1,
"src/components/MausBotWelcome.tsx": 3,
"src/components/McpServersPanel.tsx": 1,
"src/components/MemberApps.tsx": 1,
"src/components/NewBotDialog.tsx": 2,
"src/components/NewTaskFolderDialog.tsx": 1,
"src/components/NoEngines.tsx": 1,
"src/components/NotificationsPanel.tsx": 3,
"src/components/OllamaServer.tsx": 1,
"src/components/OpenAiCompatServers.tsx": 5,
"src/components/OpenFilesButton.tsx": 1,
"src/components/OptionCard.tsx": 1,
"src/components/PendingApproval.tsx": 1,
"src/components/PlaceTint.tsx": 1,
"src/components/PostizCard.tsx": 1,
"src/components/ProIntroduction.tsx": 3,
"src/components/PublishedPageCard.tsx": 1,
"src/components/QuestionCard.tsx": 2,
"src/components/ReadyBotGallery.tsx": 1,
"src/components/RemoteAgentSettingsPanel.tsx": 1,
"src/components/RoomBulletin.tsx": 1,
"src/components/RoomChiefAbsent.tsx": 1,
"src/components/RoomHeader.tsx": 2,
"src/components/RoomHoldsBanner.tsx": 1,
"src/components/RoomMoreMenu.tsx": 1,
"src/components/RoomQueueList.tsx": 1,
"src/components/RoutineCalendarPage.tsx": 3,
"src/components/RoutineRunCard.tsx": 2,
"src/components/RoutineScheduleNote.tsx": 1,
"src/components/SavedStepsRow.tsx": 1,
"src/components/SearchResults.tsx": 1,
"src/components/SecretRequestCard.tsx": 1,
"src/components/SetupOffer.tsx": 1,
"src/components/SidebarBotMenu.tsx": 1,
"src/components/SidebarConnectApps.tsx": 2,
"src/components/SidebarFooter.tsx": 3,
"src/components/SidebarFooterNav.tsx": 3,
"src/components/SidebarGroupThreadList.tsx": 1,
"src/components/SidebarInboxRow.tsx": 1,
"src/components/SidebarNewChatPanel.tsx": 1,
"src/components/SidebarNewRoomPanel.tsx": 1,
"src/components/SidebarPeople.tsx": 1,
"src/components/SidebarPhoneBar.tsx": 1,
"src/components/SidebarProfileMenu.tsx": 1,
"src/components/SidebarSectionPicker.tsx": 1,
"src/components/SidebarTeamMenu.tsx": 2,
"src/components/SidebarTiles.tsx": 1,
"src/components/SignInRequestCard.tsx": 1,
"src/components/SimpleHelperIntro.tsx": 1,
"src/components/SkillsSection.tsx": 1,
"src/components/SoulField.tsx": 1,
"src/components/StatusActivityRow.tsx": 1,
"src/components/TailnetComputers.tsx": 2,
"src/components/TaskPicker.tsx": 3,
"src/components/TeamCanvas.tsx": 2,
"src/components/TeamDialog.tsx": 1,
"src/components/TeamLibraryPanel.tsx": 1,
"src/components/TeamMapPage.tsx": 2,
"src/components/TeamOwner.tsx": 3,
"src/components/TeamSettingsDialog.tsx": 1,
"src/components/TeamSideSwitch.tsx": 2,
"src/components/TeamWelcome.tsx": 1,
"src/components/TemplateCard.tsx": 2,
"src/components/ThreadChip.tsx": 1,
"src/components/ThreadRefs.tsx": 1,
"src/components/TrialCreditNotice.tsx": 1,
"src/components/TriggerCard.tsx": 1,
"src/components/UsageCaps.tsx": 1,
"src/components/UsageSection.tsx": 4,
"src/components/VoiceEveryReplySetting.tsx": 1,
"src/components/VoiceHearingSetting.tsx": 1,
"src/components/VoiceSettings.tsx": 1,
"src/components/VoiceSetupDialog.tsx": 1,
"src/components/WatchScreenButton.tsx": 1,
"src/components/WebPanelPage.tsx": 2,
"src/components/WebhookTrigger.tsx": 1,
"src/components/WindowFrameBar.tsx": 1,
"src/components/WindowPlaceTitle.tsx": 1,
"src/components/WorkspacesSection.tsx": 1,
"src/components/XCard.tsx": 1,
"src/components/announcements/AnnouncementsPage.tsx": 2,
"src/components/announcements/use-announcements.ts": 1,
"src/components/app/AppFrame.tsx": 1,
"src/components/app/AppMessage.tsx": 2,
"src/components/app/PageTools.tsx": 1,
"src/components/bot-panel/use-memory-doc.ts": 1,
"src/components/browser/PasskeyNotice.tsx": 1,
"src/components/cloud-welcome/CloudWelcome.tsx": 1,
"src/components/cloud-welcome/WelcomeKeeper.tsx": 1,
"src/components/cloud-welcome/WelcomeSteps.tsx": 1,
"src/components/cloud-welcome/parts.tsx": 1,
"src/components/conversation-share/ConversationShareDialogs.tsx": 1,
"src/components/data/DataPanel.tsx": 1,
"src/components/data/InlineDataChart.tsx": 1,
"src/components/keys/KeyPanels.tsx": 3,
"src/components/keys/KeyRow.tsx": 2,
"src/components/keys/KeysLink.tsx": 1,
"src/components/onboarding/ChiefIntro.tsx": 1,
"src/components/onboarding/ConnectAi.tsx": 1,
"src/components/onboarding/FirstConversationTour.tsx": 1,
"src/components/onboarding/GuidedTour.tsx": 1,
"src/components/onboarding/MeetScreen.tsx": 1,
"src/components/onboarding/SignInPill.tsx": 1,
"src/components/onboarding/WelcomeFlow.tsx": 1,
"src/components/onboarding/WelcomeGate.tsx": 1,
"src/components/published-apps/AppPreviewPanel.tsx": 1,
"src/components/published-apps/PublishedAppsPage.tsx": 1,
"src/components/remote-desktop-panel.tsx": 1,
"src/components/room-panel/ResponderPage.tsx": 1,
"src/components/room-panel/RoomPanel.tsx": 1,
"src/components/team-files/TeamFilesPage.tsx": 1,
"src/components/usage/TraceWaterfall.tsx": 2,
"src/components/usage/UsageInsights.tsx": 1,
"src/components/widget/WidgetMessage.tsx": 1,
"src/hooks/use-read-shown-chat.ts": 1,
"src/hooks/use-usage-snapshot.ts": 1,
"src/lib/app-load.ts": 1,
"src/lib/connect-ai-events.ts": 1,
"src/state/store-ref.ts": 1,
"src/state/store-select.ts": 1,
};
function sourceFiles(): string[] {
const out = execFileSync("git", ["ls-files", "src"], { cwd: ROOT, encoding: "utf8" });
return out.split("\n").filter((file) => /\.(ts|tsx)$/.test(file) && !file.includes(".test.") && !file.includes("/testing/"));
}
describe("whole-store reads", () => {
it("no file calls useStore() more often than written here", () => {
const grown: string[] = [], shrunk: string[] = [];
for (const file of sourceFiles()) {
const calls = storeReadsIn(readFileSync(new URL(file, ROOT), "utf8"));
const written = READS[file] ?? 0;
if (calls > written) grown.push(`${file} calls useStore() ${calls} times, ${written ? `more than ${written}` : "and is not listed"}: select what it draws with useStoreSelector`);
else if (calls < written) shrunk.push(`${file}: ${written} → ${calls}`);
}
if (shrunk.length) console.info(`Fewer useStore() calls than written in scripts/testing/store-read-ratchet.test.ts; lower these numbers (or run node scripts/tighten-ratchets.mjs):\n${shrunk.join("\n")}`);
expect(grown, "See src/state/store-select.ts").toEqual([]);
});
});