Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
Room feed: start a short feed's threads at the top
AdityaUmale89e5a1426915
diff --git a/src/components/room-feed/RoomFeedView.dom.test.ts b/src/components/room-feed/RoomFeedView.dom.test.tsnew file mode 100644index 0000000000..5ab6653a60--- /dev/null+++ b/src/components/room-feed/RoomFeedView.dom.test.ts@@ -0,0 +1,60 @@+// @vitest-environment happy-dom+import { act, createElement } from "react";+import { createRoot, type Root } from "react-dom/client";+import { afterEach, describe, expect, it, vi } from "vitest";+import type { Group, GroupTask } from "@/state/store";+import type { FeedThread } from "./use-room-threads";++(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true;+const fixture = vi.hoisted(() => ({ threads: null as FeedThread[] | null }));+const state = { bots: [], config: {}, groups: [], error: null, notice: null, forkPanel: null };+vi.mock("@/state/api", async (original) => ({ ...(await original<typeof import("@/state/api")>()), api: vi.fn(() => new Promise(() => {})) }));+vi.mock("@/state/store-select", () => ({ useStoreDispatch: () => vi.fn(), useStoreSelector: (select: (value: typeof state) => unknown) => select(state) }));+vi.mock("@/state/store-ref", () => ({ useStoreRef: () => ({ state: () => state }) }));+vi.mock("./use-room-threads", () => ({ useRoomThreads: () => ({ threads: fixture.threads, failed: false, retry: () => {} }) }));+vi.mock("./use-room-work", () => ({ useRoomWorkStatuses: () => new Map() }));+vi.mock("./FeedComposer", () => ({ FeedComposer: () => null }));+vi.mock("../RoomHeader", () => ({ RoomHeader: () => null }));+vi.mock("../RoomBulletin", () => ({ RoomBulletin: () => null }));+vi.mock("../RoomChiefAbsent", () => ({ RoomChiefAbsent: () => null }));+vi.mock("../RoomHoldsBanner", () => ({ RoomHoldsBanner: () => null }));++const { RoomFeedView } = await import("./RoomFeedView");++const NOW = Date.UTC(2026, 10, 27, 12, 0, 0);+const task = (threadId: string, extra: Partial<GroupTask> = {}) => ({ threadId, title: threadId, createdAt: NOW - 7_200_000, ...extra }) as GroupTask;+const thread = (threadId: string, extra: Partial<GroupTask> = {}): FeedThread => ({+ task: task(threadId, extra),+ summary: { threadId, first: { speaker: { person: { name: "Ana" } }, text: `Start ${threadId}`, at: NOW - 7_200_000 }, replies: 57, lastReplyAt: NOW - 600_000, repliers: [] },+} as FeedThread);+const group = (tasks: GroupTask[]) => ({ id: "room", name: "Project room", memberIds: [], threadId: "main", tasks }) as unknown as Group;++let root: Root | null = null;+const render = (threads: FeedThread[]) => {+ fixture.threads = threads;+ root = createRoot(document.body.appendChild(document.createElement("div")));+ act(() => root!.render(createElement(RoomFeedView, { group: group(threads.map((one) => one.task)) })));+};+const column = () => document.querySelector<HTMLElement>("[data-room-feed] .glass-scroller-content")!;+afterEach(() => { act(() => root?.unmount()); root = null; fixture.threads = null; document.body.innerHTML = ""; });++describe("a room's feed with few threads", () => {+ it("starts its threads at the top, under the header, instead of under an empty block", () => {+ render([thread("t1"), thread("t2")]);+ expect(document.querySelectorAll("[data-feed-thread]")).toHaveLength(2);+ expect(column().classList).toContain("flex-col");+ expect(column().classList).not.toContain("justify-end");+ });++ it("keeps a thread closed by a bot folded at the top too", () => {+ render([thread("t1", { closedAt: NOW - 600_000, closedBy: { id: "maus", name: "MausBot" } } as Partial<GroupTask>)]);+ expect(document.querySelector("[data-feed-fold]")?.textContent).toBe("1 closed thread");+ expect(column().classList).not.toContain("justify-end");+ });++ it("keeps the empty room's hint at the foot, next to the composer it points to", () => {+ render([]);+ const hint = [...column().children].find((child) => child.textContent?.includes("No threads yet"));+ expect(hint?.classList).toContain("mt-auto");+ });+});diff --git a/src/components/room-feed/RoomFeedView.tsx b/src/components/room-feed/RoomFeedView.tsxindex db179bcee5..a46a3a6ca2 100644--- a/src/components/room-feed/RoomFeedView.tsx+++ b/src/components/room-feed/RoomFeedView.tsx@@ -61,7 +61,7 @@ function toRow(group: Group, { task, summary }: FeedThread, bots: readonly Bot[]const folds = (row: FeedRowData, openThread: string | null) =>Boolean(row.closedBy) && row.mark === null && !row.working && !row.pinned && row.threadId !== openThread;-/** A room as one feed of its threads, oldest at the top and the newest just above the composer, where a line starts a+/** A room as one feed of its threads, oldest at the top and the newest last, nearest the composer, where a line starts a* new thread. A row opens its thread beside the feed; the room's current thread, which is everyone's, never moves. */export function RoomFeedView({ group }: { group: Group }) {const dispatch = useStoreDispatch();@@ -170,20 +170,20 @@ export function RoomFeedView({ group }: { group: Group }) {if (foot || Date.now() - scrolledAt.current < INTENT_MS) atFoot.current = foot;hidden.measure();}}>- <div ref={contentRef} className="glass-scroller-content chat-column flex min-h-full w-full flex-col justify-end" style={{ paddingBottom: composerDock.pad }}>+ <div ref={contentRef} className="glass-scroller-content chat-column flex min-h-full w-full flex-col" style={{ paddingBottom: composerDock.pad }}>{hasArchived && rows !== null && <button type="button" data-feed-archived-toggle="" aria-pressed={showArchived} onClick={() => setShowArchived((shown) => !shown)}className="mt-2 inline-flex h-7 items-center self-center rounded-md px-2 text-[13px] font-medium leading-4 text-ink-secondary hover:text-ink">{showArchived ? t("room.feed.hideArchived") : t("room.feed.showArchived")}</button>}{rows === null || items === null ? (failed && (- <p role="alert" className="flex items-center justify-center gap-2 py-6 text-[13px] text-ink-secondary">+ <p role="alert" className="mt-auto flex items-center justify-center gap-2 py-6 text-[13px] text-ink-secondary">{t("room.feed.loadFailed")}<button type="button" className="ui-button ui-button-sm" onClick={retry}>{t("chat.retry")}</button></p>)) : rows.length === 0 ? (- <div className="py-6 text-center text-[13px] leading-[18px]">+ <div className="mt-auto py-6 text-center text-[13px] leading-[18px]"><p className="text-ink-secondary">{t("room.feed.empty")}</p>{team && <p data-feed-split-hint="" className="mt-1 text-ink-tertiary">{t("room.feed.splitHint")}</p>}</div>