Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
fix(shortcuts): cycle bots with Ctrl+Shift+] / [ on Windows and Linux
Anil Kumarc54ce2b3ffba
diff --git a/src/App.tsx b/src/App.tsxindex 8d2027286b..ff771a63ac 100644--- a/src/App.tsx+++ b/src/App.tsx@@ -54,7 +54,7 @@ import { cloudFirstRun, cloudWelcomeVisible, useCloudWelcome } from "@/lib/cloudimport { engineReady } from "@/components/EngineLibrary";import { CommandPalette } from "@/components/CommandPalette";import { t } from "@/lib/i18n";-import { shouldOpenKeyboardShortcuts } from "@/lib/keyboard-shortcuts";+import { botCycleStep, shouldOpenKeyboardShortcuts } from "@/lib/keyboard-shortcuts";import { effectiveLanguage, useLanguageChoice, usePageLanguage } from "@/lib/language-preference";import { botUnreadCount, showBrowserUnread } from "@/lib/bot-unread";import { phonePairingSettingsAction, takePhonePairingRequest } from "@/lib/phone-pairing"; import { takeConnectRequest } from "@/lib/connect-link";@@ -177,6 +177,7 @@ function Shell({ viewer }: { viewer: WelcomeViewer | null }) {const mod = e.metaKey || e.ctrlKey;if (!mod) return;const bots = state.bots.filter((b) => !b.hidden);+ const step = e.shiftKey ? botCycleStep(e) : null;if (e.key === "n" && !e.shiftKey) {e.preventDefault();dispatch({ type: "newBot" });@@ -186,9 +187,9 @@ function Shell({ viewer }: { viewer: WelcomeViewer | null }) {e.preventDefault();openBot(dispatch, target, showThreads);}- } else if (e.shiftKey && (e.key === "[" || e.key === "]")) {+ } else if (step !== null) {const idx = bots.findIndex((b) => b.id === state.selectedId);- const next = bots[(idx + (e.key === "]" ? 1 : -1) + bots.length) % bots.length];+ const next = bots[(idx + step + bots.length) % bots.length];if (next) {e.preventDefault();openBot(dispatch, next, showThreads);diff --git a/src/lib/keyboard-shortcuts.test.ts b/src/lib/keyboard-shortcuts.test.tsindex d858abec90..68a6210c92 100644--- a/src/lib/keyboard-shortcuts.test.ts+++ b/src/lib/keyboard-shortcuts.test.ts@@ -1,6 +1,7 @@import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";import {+ botCycleStep,filterShortcutGroups,isSidebarToggle,SHORTCUT_GROUPS,@@ -143,3 +144,20 @@ describe("keyboard shortcut opening guard", () => {expect(shouldOpenKeyboardShortcuts(event("/", { metaKey: true, shiftKey: true }))).toBe(false);});});++describe("botCycleStep", () => {+ it("steps forward on ] and back on [, as macOS reports them with ⌘⇧", () => {+ expect(botCycleStep({ key: "]" })).toBe(1);+ expect(botCycleStep({ key: "[" })).toBe(-1);+ });++ it("also steps on } and {, which Ctrl+Shift reports on Windows and Linux", () => {+ expect(botCycleStep({ key: "}" })).toBe(1);+ expect(botCycleStep({ key: "{" })).toBe(-1);+ });++ it("ignores other keys", () => {+ expect(botCycleStep({ key: "+" })).toBeNull();+ expect(botCycleStep({ key: "1" })).toBeNull();+ });+});diff --git a/src/lib/keyboard-shortcuts.ts b/src/lib/keyboard-shortcuts.tsindex 96a0d19d05..860ad76c4a 100644--- a/src/lib/keyboard-shortcuts.ts+++ b/src/lib/keyboard-shortcuts.ts@@ -157,6 +157,17 @@ export function isSidebarToggle(event: Pick<KeyboardEvent, "key" | "metaKey" | "return !event.defaultPrevented && event.key === "\\" && (event.metaKey || event.ctrlKey) && !event.shiftKey && !event.altKey;}+/**+ * The step of ⌘⇧] / ⌘⇧[ (Ctrl+Shift outside macOS) through the bots: 1, -1, or null for any other key. Outside+ * macOS, Shift turns the key into "}" / "{", so those count too. The physical key (`code`) is not used: on many+ * layouts BracketRight types another character.+ */+export function botCycleStep(event: Pick<KeyboardEvent, "key">): 1 | -1 | null {+ if (event.key === "]" || event.key === "}") return 1;+ if (event.key === "[" || event.key === "{") return -1;+ return null;+}+export function shouldOpenKeyboardShortcuts(event: KeyboardEvent): boolean {if (event.defaultPrevented || event.isComposing || event.altKey) return false;const helpKey = event.key === "?" && !event.metaKey && !event.ctrlKey;