Skip to content

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

fix(rooms): name other people's lines on shared self-hosted servers

Brunoabc9f703497c
diff --git a/src/components/ChatView.team.test.ts b/src/components/ChatView.team.test.ts
index 74e3c17822..c420cfaf45 100644
--- a/src/components/ChatView.team.test.ts
+++ b/src/components/ChatView.team.test.ts
@@ -43,8 +43,8 @@ const luna = (messages: Message[], extra: Partial<Bot> = {}): Bot => ({
tasks: [{ threadId: "main", title: "Main", createdAt: 1, busy: false, activity: "idle", modelSelection: { instanceId: "test", model: "m" }, approvalMode: "ask" }],
...extra,
});
-const draw = (bot: Bot) => {
- const state: AppState = { ...initialState, connected: true, selectedId: bot.id, bots: [bot], instances, config: { team } as AppState["config"] };
+const draw = (bot: Bot, config: Partial<NonNullable<AppState["config"]>> = { team }) => {
+ const state: AppState = { ...initialState, connected: true, selectedId: bot.id, bots: [bot], instances, config: config as AppState["config"] };
const value = { state, dispatch: () => {}, flushBotPatches: async () => null, refreshInstances: async () => {}, refreshModels: async () => {} };
flushSync(() => root.render(createElement(BotEditorStore, { value, children: createElement(ChatView, { bot }) })));
};
@@ -61,6 +61,12 @@ it("shows a teammate's line in a shared chat as theirs, with their name, and onl
expect(own.querySelector("[data-chat-bubble]")!.className).toContain("user-bubble-colored");
});
+it("names a teammate's line on a shared server without a team, and not the viewer's own", () => {
+ draw(luna([line("o1", { name: "Olive", id: "p_olive" }, "plant is memory-Fernando"), line("a1", { name: "Ada", id: "p_ada" }, "noted")]), {});
+ expect(row("plant is memory-Fernando").textContent).toContain("Olive");
+ expect(row("noted").textContent).not.toContain("Ada");
+});
+
it("says a member's own MausBot is theirs, not everyone's", () => {
draw(luna([], { defaultBot: { person: "[email protected]" } } as Partial<Bot>));
expect(container.textContent).not.toContain(t("team.sharedHeader", { team: "Acme" }));
diff --git a/src/components/ChatView.tsx b/src/components/ChatView.tsx
index 77627809a1..860df10712 100644
--- a/src/components/ChatView.tsx
+++ b/src/components/ChatView.tsx
@@ -145,7 +145,6 @@ interface ChatRows {
tts: ConfigStatus["tts"]; localVoice: boolean;
hasMore: boolean; bots: readonly Bot[];
mentionPeers: readonly MentionPeer[]; mentionPerson: { profileName?: string };
- /** On a Team Cloud, the viewer's person key: another person's line carries their name. */
speakerViewer?: string | null;
focus: AppState["focusMessage"];
showToolCalls: boolean;
@@ -885,7 +884,7 @@ export const ChatView = memo(function ChatView({ bot: profile, inForkPanel = fal
const bubbleStyle = useMemo(() => (colorMine ? userBubbleStyle(bot.color, { flat: !advanced }) : undefined), [colorMine, bot.color, advanced]);
const hasMore = Boolean(bot.hasMore);
const reactor = useReactor();
- const speakerViewer = state.config?.team && reactor !== "user" ? reactor : null;
+ const speakerViewer = reactor !== "user" ? reactor : null;
const rows = useMemo<ChatRows>(
() => ({ botId: bot.id, threadId: bot.threadId, botName: bot.name, botColor: bot.color, voiceId: bot.voice, tts, localVoice, hasMore, bots, mentionPeers, mentionPerson: { profileName: state.config?.profile?.name }, focus, showToolCalls, locale, dispatch, onBranch, bubbleStyle, conversational: isConversational(bot.replyStyle), simple: !advanced, canReact: canWrite !== false, openedAt, speakerViewer, phone }),
[bot.id, bot.threadId, bot.name, bot.color, bot.voice, tts, localVoice, hasMore, bots, mentionPeers, state.config?.profile?.name, focus, showToolCalls, locale, dispatch, onBranch, bubbleStyle, bot.replyStyle, advanced, canWrite, openedAt, speakerViewer, phone],
diff --git a/src/components/GroupView.speaker.test.ts b/src/components/GroupView.speaker.test.ts
index 851ab6a89b..b27aaceb33 100644
--- a/src/components/GroupView.speaker.test.ts
+++ b/src/components/GroupView.speaker.test.ts
@@ -3,6 +3,7 @@ import { renderToStaticMarkup } from "react-dom/server";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import type { Bot, Group, Message } from "@/state/store";
+const viewer = vi.hoisted(() => ({ reactor: "user" }));
vi.mock("@/state/store", async (importOriginal) => {
const original = await importOriginal<typeof import("@/state/store")>();
return { ...original, useStore: () => ({ state: original.initialState, dispatch: vi.fn() }) };
@@ -12,6 +13,7 @@ vi.mock("./DesktopCapabilities", () => ({
useCaptionChrome: () => ({}),
}));
vi.mock("@/lib/analytics", () => ({ track: vi.fn() }));
+vi.mock("@/lib/cloud-guest", async (importOriginal) => ({ ...await importOriginal<typeof import("@/lib/cloud-guest")>(), useReactor: () => viewer.reactor }));
const { Transcript } = await import("./GroupView");
@@ -43,6 +45,7 @@ beforeEach(() => {
});
afterEach(() => {
+ viewer.reactor = "user";
vi.unstubAllGlobals();
});
@@ -90,4 +93,17 @@ describe("room speaker names", () => {
expect(html).toMatch(/>Ada<\/span><span[^>]*>→<\/span><span class="text-\[13px\] font-semibold bot-identity" data-bot-color="orange">Kai</);
expect(html.match(/→/g)).toHaveLength(1);
});
+
+ it("names another person's line on a shared server without a team, and never the viewer's own", () => {
+ const said = (sender: { name: string; id: string }, text: string): Message => ({ ...line(text, "user", text), sender });
+ const messages = [said({ name: "Olive", id: "p_olive" }, "can you check the draft"), said({ name: "Ada", id: "p_ada" }, "on my side too")];
+ viewer.reactor = "p_ada";
+ const shared = markup(messages);
+ expect(shared).toContain(">Olive<");
+ expect(shared).not.toContain(">Ada<");
+ viewer.reactor = "user";
+ const solo = markup(messages);
+ expect(solo).not.toContain(">Olive<");
+ expect(solo).not.toContain(">Ada<");
+ });
});
diff --git a/src/components/GroupView.tsx b/src/components/GroupView.tsx
index 0e29e4412a..83db693785 100644
--- a/src/components/GroupView.tsx
+++ b/src/components/GroupView.tsx
@@ -158,7 +158,7 @@ function RoomTextMessage({
const { state, dispatch } = useStore();
const user = m.role === "user";
const reactor = useReactor();
- const speaker = otherSpeaker(m, state.config?.team && reactor !== "user" ? reactor : null);
+ const speaker = otherSpeaker(m, reactor !== "user" ? reactor : null);
const rawText = user ? (m.text ?? "") : stripLeakedSystemHarnessMessages(m.text ?? "");
const cited = user && m.text ? splitTranscriptCitations(m.text) : null;
const attachments = user && m.text ? splitTranscriptAttachments(cited?.display ?? m.text) : null;