Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
Room feed: show your profile photo on your own lines and among the repliers
Bugfixer 25e5b016bb39e
diff --git a/src/components/room-feed/RoomFeedRow.dom.test.ts b/src/components/room-feed/RoomFeedRow.dom.test.tsindex 723ca77cc9..4e775afaac 100644--- a/src/components/room-feed/RoomFeedRow.dom.test.ts+++ b/src/components/room-feed/RoomFeedRow.dom.test.ts@@ -17,9 +17,9 @@ const row = (extra: Partial<FeedRowData> = {}): FeedRowData => ({});let root: Root | null = null;-const render = (data: FeedRowData, onOpen = vi.fn(), open = false, actions?: FeedRowActions) => {+const render = (data: FeedRowData, onOpen = vi.fn(), open = false, actions?: FeedRowActions, yourPicture?: string) => {root = createRoot(document.body.appendChild(document.createElement("ol")));- act(() => root!.render(createElement(RoomFeedRow, { row: data, groupId: "room", bots: BOTS, you: "Sam", now: NOW, open, onOpen, actions })));+ act(() => root!.render(createElement(RoomFeedRow, { row: data, groupId: "room", bots: BOTS, you: "Sam", yourPicture, now: NOW, open, onOpen, actions })));return onOpen;};const roomActions = (deletable = true): FeedRowActions => ({ onRename: vi.fn(), onDelete: vi.fn(), onPin: vi.fn(), onArchive: vi.fn(), onSetClosed: vi.fn(), deletable });@@ -60,6 +60,18 @@ describe("a room feed row", () => {expect(item().textContent).toContain("Sam");});+ it("draws your profile photo on your own lines and among the repliers, and initials for other people", () => {+ const photo = "/api/attachments/5f0c2b1e-8a43-4c1d-9e7a-2b6f1d3c4e5a.webp";+ render(row({ speaker: { person: {} }, replies: 3, lastReplyAt: NOW, repliers: [{ person: { id: "[email protected]", name: "Ana" } }, { person: { name: "Lee" } }, { person: {} }] }), vi.fn(), false, undefined, photo);+ const [speaker, ...repliers] = [...item().querySelectorAll<HTMLElement>("[data-avatar-kind=person]")];+ expect(speaker.getAttribute("data-avatar")).toBe("picture");+ expect(speaker.getAttribute("src")).toBe(photo);+ expect(repliers.map((face) => [face.getAttribute("data-avatar"), face.getAttribute("src")])).toEqual([["initials", null], ["initials", null], ["picture", photo]]);+ act(() => root!.unmount());+ render(row({ speaker: { person: {} } }));+ expect(item().querySelector("[data-avatar-kind=person]")?.getAttribute("data-avatar")).toBe("initials");+ });+it("marks a thread waiting on the person over unread, and says a bot is answering", () => {render(row({ mark: "waiting" }));expect(item().querySelector("[data-feed-mark]")?.getAttribute("data-feed-mark")).toBe("waiting");diff --git a/src/components/room-feed/RoomFeedRow.tsx b/src/components/room-feed/RoomFeedRow.tsxindex e23fcac591..15cae2f78b 100644--- a/src/components/room-feed/RoomFeedRow.tsx+++ b/src/components/room-feed/RoomFeedRow.tsx@@ -57,22 +57,23 @@ const FACES = 3;const LONG_CHARS = 280;const LONG_LINES = 4;-interface Who { key: string; name: string; bot?: Bot; personId?: string }+interface Who { key: string; name: string; bot?: Bot; personId?: string; picture?: string }-function who(speaker: RoomThreadSpeaker, bots: readonly Bot[], you: string): Who {+function who(speaker: RoomThreadSpeaker, bots: readonly Bot[], you: string, yourPicture?: string): Who {if ("botId" in speaker) {const bot = bots.find((candidate) => candidate.id === speaker.botId);return { key: `bot:${speaker.botId}`, name: bot?.name ?? t("room.aBot"), bot };}- const name = speaker.person.name?.trim() || you;- return { key: `person:${speaker.person.id ?? name}`, name, personId: speaker.person.id };+ const { id } = speaker.person, named = speaker.person.name?.trim();+ const name = named || you;+ return { key: `person:${id ?? name}`, name, personId: id, picture: id || named ? undefined : yourPicture };}function Face({ who: speaker, size }: { who: Who; size: number }) {if (speaker.key.startsWith("bot:")) {return <BotAvatar bot={speaker.bot ?? { name: speaker.name, color: "blue" }} state="happy" size={size} motion="none" motionKey={0} animated={false} />;}- return <PersonFace person={{ email: speaker.personId ?? speaker.name, name: speaker.name, role: "member" }} size={size} />;+ return <PersonFace person={{ email: speaker.personId ?? speaker.name, name: speaker.name, role: "member", pictureUrl: speaker.picture }} size={size} />;}function Name({ who: speaker }: { who: Who }) {@@ -92,19 +93,21 @@ function previewText(row: FeedRowData, bot: boolean): string {/** One thread in a room's feed: its first line and who said it, then how many replies it has, who wrote them and when* the last came. The whole row opens the thread beside the feed. */-export const RoomFeedRow = memo(function RoomFeedRow({ row, groupId, bots, you, now, open, onOpen, actions }: {+export const RoomFeedRow = memo(function RoomFeedRow({ row, groupId, bots, you, yourPicture, now, open, onOpen, actions }: {row: FeedRowData;/** The room, which the menu's thread link names. */groupId: string;bots: readonly Bot[];/** What a person whose lines carry no name is called: the profile's name. */you: string;+ /** The profile's photo, drawn for the same person. */+ yourPicture?: string;now: number;open: boolean;onOpen: (threadId: string) => void;actions?: FeedRowActions;}) {- const speaker = who(row.speaker, bots, you);+ const speaker = who(row.speaker, bots, you, yourPicture);const [menu, setMenu] = useState<ThreadMenuAt | null>(null);const [renaming, setRenaming] = useState(false);const moreRef = useRef<HTMLButtonElement>(null);@@ -119,8 +122,8 @@ export const RoomFeedRow = memo(function RoomFeedRow({ row, groupId, bots, you,const long = text.length > LONG_CHARS || text.split("\n").length > LONG_LINES;const repliers = useMemo(() => {const seen = new Set<string>();- return row.repliers.map((one) => who(one, bots, you)).filter((one) => !seen.has(one.key) && Boolean(seen.add(one.key))).slice(0, FACES);- }, [row.repliers, bots, you]);+ return row.repliers.map((one) => who(one, bots, you, yourPicture)).filter((one) => !seen.has(one.key) && Boolean(seen.add(one.key))).slice(0, FACES);+ }, [row.repliers, bots, you, yourPicture]);const workingBot = row.workingBotId ? bots.find((bot) => bot.id === row.workingBotId) : undefined;const replies = row.replies === 1 ? t("room.feed.replyOne") : t("room.feed.replyMany", { count: row.replies });const markLabel = row.mark === "waiting" ? t("sidebar.preview.waiting") : row.mark === "unread" ? t("task.unread") : null;diff --git a/src/components/room-feed/RoomFeedView.tsx b/src/components/room-feed/RoomFeedView.tsxindex a46a3a6ca2..ef06cc167a 100644--- a/src/components/room-feed/RoomFeedView.tsx+++ b/src/components/room-feed/RoomFeedView.tsx@@ -68,6 +68,7 @@ export function RoomFeedView({ group }: { group: Group }) {const store = useStoreRef();const bots = useStoreSelector((state) => state.bots, sameDrawnBots);const you = useStoreSelector((state) => state.config?.profile?.name?.trim()) || t("room.feed.you");+ const yourPicture = useStoreSelector((state) => state.config?.profile?.avatarUrl) || undefined;const error = useStoreSelector((state) => state.error);const notice = useStoreSelector((state) => state.notice);const openThread = useStoreSelector((state) => (state.forkPanel?.kind === "group" && state.forkPanel.ownerId === group.id ? state.forkPanel.threadId : null));@@ -197,7 +198,7 @@ export function RoomFeedView({ group }: { group: Group }) {</button></li>) : (- <RoomFeedRow key={item.row.threadId || "pending"} row={item.row} groupId={group.id} bots={bots} you={you} now={now} open={item.row.threadId !== "" && item.row.threadId === openThread}+ <RoomFeedRow key={item.row.threadId || "pending"} row={item.row} groupId={group.id} bots={bots} you={you} yourPicture={yourPicture} now={now} open={item.row.threadId !== "" && item.row.threadId === openThread}onOpen={open} actions={actions} />))}</ol>