Skip to content

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

Merge remote-tracking branch 'gh/main' into train/nov30-u4b

milind-soni04757f6777a7
diff --cc server/app-settings/host.test.ts
index 756f3b24dc,404ea759fd..4b9b3b652a
--- a/server/app-settings/host.test.ts
+++ b/server/app-settings/host.test.ts
@@@ -493,37 -493,35 +493,50 @@@ describe("Simple mode: a bot changes se
expect(fx.windowValues.get("appearance.advanced")).toBe(true);
});
- it.each([
- ["appearance.showThreads", "true"], ["appearance.toolsLayout", "toolbar"], ["appearance.pinnedCircles", "true"],
- ["appearance.pinnedPages", JSON.stringify([{ name: "Docs", url: "https://example.com" }])],
- ])("refuses %s, which Simple does not show, rather than claim a change nobody sees", async (id, value) => {
+ it("lists threads in Simple when asked, with no word of Advanced, and Undo puts Simple back as it was", async () => {
const fx = simple();
- const refused = await fx.set(id, value);
- expect(refused.status).toBe(409);
- expect(refused.body.error).toMatch(/shows only in Advanced mode and this app is on Simple, so nothing changed\. Don't switch modes for it.*the switch at the bottom of Settings, then ask again\.$/);
- expect(fx.windowValues.has(id)).toBe(false);
+ fx.windowValues.set("appearance.showThreads", false);
+ const applied = await fx.set("appearance.showThreads", "true");
+ expect(applied).toMatchObject({ status: 200, body: { text: expect.stringMatching(/^Done: List each bot's threads in the sidebar\. /) } });
+ expect(fx.windowValues.get("appearance.showThreads")).toBe(true);
expect(fx.windowValues.get("appearance.advanced")).toBe(false);
- expect(fx.cards()).toEqual([]);
- fx.windowValues.set("appearance.advanced", true);
- expect((await fx.set(id, value)).status).toBe(200);
+ expect(fx.cards().at(-1)!.card.subtitle).toBe("List each bot's threads in the sidebar");
+ expect(await fx.undo()).toEqual({ claimed: true, state: "undone" });
+ expect(fx.windowValues.get("appearance.showThreads")).toBe(false);
});
+ it.each([
+ ["appearance.usageIndicator", "ring", "ring"], ["appearance.composerOrder", JSON.stringify(["mic", "send"]), ["mic", "send"]],
+ ])("changes %s in Simple too, since both modes draw it, without switching modes", async (id, value, stored) => {
+ const fx = simple();
+ expect((await fx.set(id, value)).status).toBe(200);
+ expect(fx.windowValues.get(id)).toEqual(stored);
+ expect(fx.windowValues.get("appearance.advanced")).toBe(false);
+ });
+
+ it("refuses a composer order that names a button twice or one that is not there", async () => {
+ const fx = simple();
+ for (const value of [JSON.stringify(["send", "send"]), JSON.stringify(["keyboard"])]) expect((await fx.set("appearance.composerOrder", value)).status).toBe(400);
+ expect(fx.windowValues.has("appearance.composerOrder")).toBe(false);
+ });
+
- it("pins pages in Simple while the window frame's bar shows them", async () => {
+ it.each([
+ ["appearance.toolsLayout", "toolbar", "toolbar", "Show the sidebar's tools as a toolbar of icons"],
+ ["appearance.pinnedCircles", "true", true, "Show pinned bots as circles"],
+ ["appearance.pinnedPages", JSON.stringify([{ name: "Docs", url: "https://example.com" }]), [{ name: "Docs", url: "https://example.com" }], "Pin these pages beside the chat: Docs (https://example.com)"],
+ ])("saves %s in Simple, which keeps its own layout for it, and the card says it shows in Advanced mode", async (id, value, saved, line) => {
+ const fx = simple();
+ const applied = await fx.set(id, value);
+ expect(applied.status).toBe(200);
+ expect(applied.body.text).toContain(`Done: ${line} (shows in Advanced mode).`);
+ expect(fx.windowValues.get(id)).toEqual(saved);
+ expect(fx.windowValues.get("appearance.advanced")).toBe(false);
+ expect(fx.cards().map((card) => card.card.subtitle)).toEqual([`${line} (shows in Advanced mode)`]);
+ fx.windowValues.set("appearance.advanced", true);
+ expect((await fx.set(id, value)).body.text).toContain(`Done: ${line}.`);
+ });
+
+ it("pins pages in Simple with no word of Advanced while the window frame's bar shows them", async () => {
const fx = simple();
fx.windowValues.set("appearance.windowFrame", true);
expect((await fx.set("appearance.pinnedPages", JSON.stringify([{ name: "Docs", url: "https://example.com" }]))).status).toBe(200);
diff --cc src/components/Composer.tsx
index fe377a9ee6,edb4171bef..f9fd53eb3d
--- a/src/components/Composer.tsx
+++ b/src/components/Composer.tsx
@@@ -1,8 -1,8 +1,8 @@@
import { directMessageSent, roomMessageSent } from "@/lib/product-events";
import { TeamAudienceLabel } from "./TeamSideSwitch";
-import { useComposerDictation } from "@/lib/use-composer-dictation"; import { isPlaceId } from "@/lib/place-chat";
+import { useComposerDictation } from "@/lib/use-composer-dictation"; import { DismissWarning } from "./DismissWarning"; import { composerOrderStyle, useComposerLayout } from "@/lib/composer-layout"; import { isPlaceId } from "@/lib/place-chat";
import { ComposerForkError, useComposerFork } from "./ComposerFork";
- import { isNewChatThread } from "@/state/new-chat";
+ import { isNewChatThread, newChatThreadId } from "@/state/new-chat";
import { useCallback, useEffect, useMemo, useRef, useState, type SetStateAction } from "react";
import { Mic, Square } from "lucide-react";
import { sameFields, useStoreDispatch, useStoreSelector } from "@/state/store-select"; import { useStoreRef } from "@/state/store-ref"; import { sameDrawnBots } from "@/lib/drawn-bots";
diff --cc src/lib/window-prefs.ts
index c25280f050,aa84b38a26..bf853109a1
--- a/src/lib/window-prefs.ts
+++ b/src/lib/window-prefs.ts
@@@ -45,11 -44,9 +45,11 @@@ const PREFS: { [I in WindowPrefId]: Pre
"general.sendKey": { read: () => readSendKey(), write: (key) => setSendKey(key) },
"general.notificationSounds": { read: () => notificationSoundsEnabled(), write: (on) => setNotificationSounds(on) },
"appearance.userBubbles": { read: () => readColorUserBubbles(), write: (on) => setColorUserBubbles(on) },
- "appearance.showThreads": { read: () => showThreads(), write: (on) => setShowThreads(on) },
+ "appearance.showThreads": { read: () => (readAdvancedMode() ? showThreads() : threadsChosenOn()), write: (on) => setShowThreads(on) },
"appearance.toolsLayout": { read: () => loadSidebarToolsLayout(), write: (layout) => setSidebarToolsLayout(layout) },
"appearance.pinnedCircles": { read: () => loadPinnedCircles(), write: (on) => setPinnedCircles(on) },
+ "appearance.usageIndicator": { read: () => readUsageIndicator(), write: (choice) => setUsageIndicator(choice) },
+ "appearance.composerOrder": { read: () => readComposerOrder(), write: (order) => setComposerOrder(order) },
"appearance.universalPins": { read: () => loadUniversalPins(), write: (on) => setUniversalPins(on) },
"appearance.pinnedPages": {
read: () => latestWebPanels().flatMap((panel) => (panel.url === undefined ? [] : [{ name: panel.name, url: panel.url }])),