Skip to content

armgit / alook

Public Imported from GitHub
0

Multi-Agent Collaboration for Team and Friends

feat(web): show participating text threads in channel sidebar (#1096)

Gustavo Ye1afd2f5b88cf
diff --git a/src/web/src/app/api/community/servers/[id]/channels/route.human.test.ts b/src/web/src/app/api/community/servers/[id]/channels/route.human.test.ts
index fa9225e5c..e718009a5 100644
--- a/src/web/src/app/api/community/servers/[id]/channels/route.human.test.ts
+++ b/src/web/src/app/api/community/servers/[id]/channels/route.human.test.ts
@@ -62,6 +62,21 @@ describe("GET /api/community/servers/[id]/channels — human resource", () => {
expect(mockListServerChannelsForViewer).toHaveBeenCalledWith(expect.anything(), "server_1", "user_1")
})
+ it("reuses the scoped participant query for visible text and forum parents", async () => {
+ mockGetMember.mockResolvedValue({ id: "member_1", role: "member" })
+ mockListServerChannelsForViewer.mockResolvedValue([
+ { id: "forum_visible", type: "forum" }, { id: "text_visible", type: "text" }, { id: "child", type: "thread" },
+ ])
+ const thread = { id: "text_child", parentChannelId: "text_visible", parentMessageId: "opener", type: "thread", activityAt: "2026-08-08T11:00:00.000Z" }
+ mockListParticipatingForumThreads.mockResolvedValue({ canonical: [thread], retained: null, retainedDisposition: null })
+ mockGetMessagesByIds.mockResolvedValue([{ id: "opener", channelId: "text_visible", content: "Text opener" }])
+ const response = await GET(new NextRequest("http://localhost/api/community/servers/server_1/channels?type=thread&parentType=forum,text&participating=true&activeWithin=72h&limitPerParent=5&include=parentMessage"), { params: { id: "server_1" } } as never)
+ expect(response.status).toBe(200)
+ expect(mockListParticipatingForumThreads).toHaveBeenCalledWith(expect.anything(), expect.objectContaining({ parentChannelIds: ["forum_visible", "text_visible"], userId: "user_1", limitPerParent: 5 }))
+ expect(mockGetMessagesByIds).toHaveBeenCalledWith(expect.anything(), ["opener"], ["forum_visible", "text_visible"])
+ expect(await response.json()).toMatchObject({ channels: [expect.objectContaining({ id: "text_child" })], included: { parentMessages: [{ id: "opener", channelId: "text_visible", content: "Text opener" }] } })
+ })
+
it("returns recent participating forum threads with opener messages and server-relative expiry", async () => {
vi.useFakeTimers()
vi.setSystemTime(new Date("2026-08-08T12:00:00.000Z"))
diff --git a/src/web/src/app/api/community/servers/[id]/channels/route.ts b/src/web/src/app/api/community/servers/[id]/channels/route.ts
index 762275d1b..49c926316 100644
--- a/src/web/src/app/api/community/servers/[id]/channels/route.ts
+++ b/src/web/src/app/api/community/servers/[id]/channels/route.ts
@@ -1,6 +1,7 @@
import { NextResponse, NextRequest } from "next/server"
+import { supportsSidebarThreads } from "@/lib/community/forum-sidebar"
import { getDb } from "@/lib/db"
-import { compareAsciiSqliteBinary, isForum, parseNameAndTag, queries } from "@alook/shared"
+import { compareAsciiSqliteBinary, parseNameAndTag, queries } from "@alook/shared"
import { withCommunityActor } from "@/lib/middleware/community-actor"
import { buildServerChannelGroups } from "@/lib/community/list-channels"
import { requireServerMember } from "@/lib/community/permissions"
@@ -37,12 +38,12 @@ export const GET = withCommunityActor(async (req: NextRequest, ctx) => {
if (
search.get("type") !== "thread" ||
- search.get("parentType") !== "forum" ||
+ !["forum", "forum,text"].includes(search.get("parentType") ?? "") ||
search.get("participating") !== "true" ||
search.get("activeWithin") !== "72h" ||
search.get("include") !== "parentMessage"
) {
- return NextResponse.json({ error: "invalid forum sidebar query" }, { status: 400 })
+ return NextResponse.json({ error: "invalid thread sidebar query" }, { status: 400 })
}
const rawLimit = search.get("limitPerParent")
const limitPerParent = rawLimit && /^\d+$/.test(rawLimit) ? Number(rawLimit) : NaN
@@ -54,12 +55,14 @@ export const GET = withCommunityActor(async (req: NextRequest, ctx) => {
return NextResponse.json({ error: "retainId is required" }, { status: 400 })
}
- const forumIds = visibleChannels.filter((channel) => isForum(channel.type)).map((channel) => channel.id)
+ const parentIds = visibleChannels.filter((channel) =>
+ supportsSidebarThreads(channel.type) && (search.get("parentType") !== "forum" || channel.type === "forum")
+ ).map((channel) => channel.id)
const serverNow = new Date().toISOString()
const windowMs = 72 * 60 * 60 * 1000
const activeAfter = new Date(Date.parse(serverNow) - windowMs).toISOString()
const projection = await queries.communityThread.listParticipatingForumThreads(db, {
- parentChannelIds: forumIds,
+ parentChannelIds: parentIds,
userId: ctx.actor.userId,
activeAfter,
limitPerParent,
@@ -75,7 +78,7 @@ export const GET = withCommunityActor(async (req: NextRequest, ctx) => {
.map((channel) => channel.parentMessageId)
.filter((id): id is string => !!id)
const [parentMessages, unreadRows] = await Promise.all([
- queries.communityMessage.getMessagesByIdsInChannels(db, parentMessageIds, forumIds),
+ queries.communityMessage.getMessagesByIdsInChannels(db, parentMessageIds, parentIds),
queries.communityInbox.listEligibleUnreadChannels(db, ctx.actor.userId, rows.map((channel) => channel.id)),
])
const unreadIds = new Set(unreadRows.map((row) => row.channelId))
diff --git a/src/web/src/components/community/channels/thread-channel-surface.tsx b/src/web/src/components/community/channels/thread-channel-surface.tsx
index 92114f7c2..1d420c164 100644
--- a/src/web/src/components/community/channels/thread-channel-surface.tsx
+++ b/src/web/src/components/community/channels/thread-channel-surface.tsx
@@ -182,7 +182,7 @@ export function ThreadChannelSurface({
serverId={serverId}
serverParam={serverParam}
channelName={displayName}
- forumParentChannelId={parentIsForum ? parentChannelId ?? undefined : undefined}
+ forumParentChannelId={parentChannelId ?? undefined}
viewer={viewer}
anchorMessageId={anchorMessageId}
feed={feed}
diff --git a/src/web/src/components/community/members/channel-member-view-model.dom.test.ts b/src/web/src/components/community/members/channel-member-view-model.dom.test.ts
index f36513e6b..c145eb14a 100644
--- a/src/web/src/components/community/members/channel-member-view-model.dom.test.ts
+++ b/src/web/src/components/community/members/channel-member-view-model.dom.test.ts
@@ -234,7 +234,7 @@ describe("useChannelMemberViewModel", () => {
mocks.kickMember.mockResolvedValue({})
})
- it("scopes forum sidebar participant mutations only to children of a forum", () => {
+ it("scopes sidebar participant mutations to children of text and forum channels", () => {
const child = (parentType: string) => props({
channelId: "thread_1",
currentServer: {
@@ -252,8 +252,8 @@ describe("useChannelMemberViewModel", () => {
act(() => {
renderer = rtlRender(renderHarness(child("text")))
})
- expect(mocks.addThreadHookArgs.at(-1)).toEqual(["thread_1", undefined, "viewer_1"])
- expect(mocks.removeThreadHookArgs.at(-1)).toEqual(["thread_1", "server_1", "viewer_1", false])
+ expect(mocks.addThreadHookArgs.at(-1)).toEqual(["thread_1", "server_1", "viewer_1"])
+ expect(mocks.removeThreadHookArgs.at(-1)).toEqual(["thread_1", "server_1", "viewer_1", true])
act(() => {
renderer!.rerender(renderHarness(child("forum")))
diff --git a/src/web/src/components/community/members/channel-member-view-model.tsx b/src/web/src/components/community/members/channel-member-view-model.tsx
index 79d4132da..ccb7c62cc 100644
--- a/src/web/src/components/community/members/channel-member-view-model.tsx
+++ b/src/web/src/components/community/members/channel-member-view-model.tsx
@@ -4,7 +4,8 @@ import { useAtom, useCreateAtom } from "@tanstack/react-store";
import { useCallback, useEffect, useMemo, type ComponentProps, type ReactNode } from "react"
import { toast } from "sonner"
-import { isForum, type CommunityRole as Role, type CommunityChannelIdentity } from "@alook/shared"
+import { supportsSidebarThreads } from "@/lib/community/forum-sidebar"
+import { type CommunityRole as Role, type CommunityChannelIdentity } from "@alook/shared"
import type { Category, Channel } from "@/lib/community/models/navigation"
import { AddMembersDialog } from "@/components/community/members/add-members-dialog"
import type { CommunityPanel } from "@/components/community/shell/community-panel"
@@ -180,7 +181,7 @@ export function useChannelMemberViewModel({
?.flatMap((category) => category.channels)
.find((channel) => channel.id === currentChannelMeta.parentChannelId)
: null
- const forumSidebarServerId = isChildChannel && isForum(parentChannel?.type)
+ const forumSidebarServerId = isChildChannel && supportsSidebarThreads(parentChannel?.type)
? serverId
: undefined
const addThreadParticipantMut = useAddThreadParticipant(
diff --git a/src/web/src/components/community/shell/server-sidebar-slot.identity.dom.test.tsx b/src/web/src/components/community/shell/server-sidebar-slot.identity.dom.test.tsx
index c9df27c26..faf047e4d 100644
--- a/src/web/src/components/community/shell/server-sidebar-slot.identity.dom.test.tsx
+++ b/src/web/src/components/community/shell/server-sidebar-slot.identity.dom.test.tsx
@@ -35,7 +35,7 @@ it.each([false, true])("keeps real same-server list, row and category nodes thro
mocks.load.mockClear()
publishCommunityLiveSnapshot(client, { snapshot: { kind: "server-detail", data: { ...server, categories: [{ id: "category", name: grouped ? "Group" : "", private: 0, channels: [{ id: "channel", name: "Target channel", active: false, unread: true, muted: false, type: "text" }] }] } }, proof })
client.setQueryData(communityKeys.server(server.id), server.id)
- client.setQueryData(communityKeys.forumSidebarThreads(server.id), { threads: [], verifiedEpoch: 0, serverNow: new Date().toISOString(), serverClockOffsetMs: 0 })
+ client.setQueryData(communityKeys.forumSidebarThreads(server.id), { threads: [], verifiedEpoch: 0, serverNow: new Date().toISOString(), serverClockOffsetMs: 0, window: { version: 1, accountId: registry.accountId, serverId: server.id, parents: ["channel"], base: [], retained: null } })
const token = createOwnerServerDeleteRouteToken(client)
function Harness({ frame }: { frame: CommunityCommittedFrame }) {
const navigation = useCommunityNavigationController(frame)
diff --git a/src/web/src/components/community/shell/server-sidebar-slot.target.dom.test.tsx b/src/web/src/components/community/shell/server-sidebar-slot.target.dom.test.tsx
index 19c0fb99d..82dd12e5e 100644
--- a/src/web/src/components/community/shell/server-sidebar-slot.target.dom.test.tsx
+++ b/src/web/src/components/community/shell/server-sidebar-slot.target.dom.test.tsx
@@ -91,7 +91,7 @@ it.each(["primary", "forum"])("ends a failed cold %s read with retry", async kin
</CommunityRouteContext>
</CurrentUserProvider>
</CommunityTestProvider>)
- expect(await view.findByRole("alert")).toHaveTextContent(kind === "primary" ? "Couldn't load server channels." : "Couldn't load forum posts.")
+ expect(await view.findByRole("alert")).toHaveTextContent(kind === "primary" ? "Couldn't load server channels." : "Couldn't load threads.")
expect(view.queryByText("Target server")).toBeNull()
expect(view.getByRole("button", { name: "Retry" })).toBeEnabled()
fail = false
diff --git a/src/web/src/components/community/shell/server-sidebar-slot.tsx b/src/web/src/components/community/shell/server-sidebar-slot.tsx
index f04ed2b1e..da3f971bd 100644
--- a/src/web/src/components/community/shell/server-sidebar-slot.tsx
+++ b/src/web/src/components/community/shell/server-sidebar-slot.tsx
@@ -26,7 +26,8 @@ import { ServerSettings } from "@/components/community/settings/server-settings"
import { ImageCropDialog } from "@/components/community/image-crop-dialog"
import { validateIconSourceFile } from "@/lib/community/image-crop"
import type { SettingsSection } from "@/components/community/settings/settings-types"
-import { canManageServer, isForum, notifLevelDisplay, type ChannelType } from "@alook/shared"
+import { supportsSidebarThreads } from "@/lib/community/forum-sidebar"
+import { canManageServer, notifLevelDisplay, type ChannelType } from "@alook/shared"
import { readCommunityProfile } from "@/lib/community/profile-read"
import { useCurrentUser } from "@/contexts/community/current-user"
import {
@@ -159,7 +160,7 @@ function ServerSidebar({ serverId, href, routeCommitted }: { serverId: string; h
const parent = sidebarCategories
.flatMap((category) => category.channels)
.find((channel) => channel.id === currentChannelMeta.parentChannelId)
- return isForum(parent?.type) ? currentChannelId : null
+ return supportsSidebarThreads(parent?.type) ? currentChannelId : null
}, [currentChannelId, currentChannelMeta?.parentChannelId, sidebarCategories])
const sidebarRouteCandidate = useMemo(() => {
const topLevelChannels = sidebarCategories.length > 0
@@ -171,7 +172,7 @@ function ServerSidebar({ serverId, href, routeCommitted }: { serverId: string; h
return resolveForumSidebarRouteCandidate(
routeChannelId,
topLevelChannels?.map((channel) => channel.id) ?? null,
- isForum(parent?.type),
+ supportsSidebarThreads(parent?.type),
)
}, [currentChannelId, currentChannelMeta?.parentChannelId, routeChannelId, sidebarCategories])
const forumSidebar = useForumSidebarThreads(
@@ -606,7 +607,7 @@ function ServerSidebar({ serverId, href, routeCommitted }: { serverId: string; h
return <>{serverReadFailed && !currentServer || forumSidebar.sidebar.status === "error" ? (
<aside className="flex min-h-0 min-w-0 flex-1 flex-col">
<div role="alert" className="flex flex-col gap-2 p-4 text-sm text-muted-foreground">
- <span>{serverReadFailed && !currentServer ? "Couldn't load server channels." : "Couldn't load forum posts."}</span>
+ <span>{serverReadFailed && !currentServer ? "Couldn't load server channels." : "Couldn't load threads."}</span>
<button
type="button"
disabled={!routeCommitted || serverReadPending || forumSidebar.isFetching}
diff --git a/src/web/src/hooks/community/community-ws/membership-events.dom.test.ts b/src/web/src/hooks/community/community-ws/membership-events.dom.test.ts
index 828124aab..06e44ccd5 100644
--- a/src/web/src/hooks/community/community-ws/membership-events.dom.test.ts
+++ b/src/web/src/hooks/community/community-ws/membership-events.dom.test.ts
@@ -518,11 +518,12 @@ describe("useCommunityWs — channel.member_add/remove → invalidate rosters",
expect(hasCanonicalChannel("ch_1")).toBe(false)
})
- it("adds/removes the viewer's participating child in the forum sidebar", async () => {
+ it.each(["forum", "text"] as const)("adds/removes the viewer's participating child below a %s parent", async (parentType) => {
await mountHook({ viewerUserId: "u_me" })
const { useCommunityStore } = await import("@/stores/community")
const key = communityKeys.forumSidebarThreads("srv_1")
await act(async () => { seedCanonicalForumSidebar("srv_1", ["post_1", "post_2"]) })
+ await act(async () => { patchCanonicalCommunityChannel(capturedQueryClient, "forum_1", row => ({ ...row, type: parentType })) })
await act(async () => { patchCanonicalCommunityChannel(capturedQueryClient, "post_1", (row) => ({
...row,
unread: true,
diff --git a/src/web/src/hooks/community/community-ws/structure-tree-events.dom.test.ts b/src/web/src/hooks/community/community-ws/structure-tree-events.dom.test.ts
index 6896c618a..577b60bf4 100644
--- a/src/web/src/hooks/community/community-ws/structure-tree-events.dom.test.ts
+++ b/src/web/src/hooks/community/community-ws/structure-tree-events.dom.test.ts
@@ -591,6 +591,31 @@ describe("useCommunityWs — child_create patches parent thread badge with count
})
})
+ it.each([
+ ["Archive", [], ["archived"]],
+ ["Unarchive", ["archived"], []],
+ ] as const)("replaces a pending first vocabulary read after remote %s", async (_action, staleTags, tags) => {
+ await mountHook()
+ const key = communityKeys.forumTags("forum_1")
+ let release!: (value: { tags: string[] }) => void
+ const oldRead = new Promise<{ tags: string[] }>(resolve => { release = resolve })
+ const read = vi.fn().mockImplementationOnce(() => oldRead).mockResolvedValue({ tags: [...tags] })
+ const observer = new QueryObserver(capturedQueryClient, { queryKey: key, queryFn: read, staleTime: Infinity })
+ const unsubscribe = observer.subscribe(() => {})
+ try {
+ await vi.waitFor(() => expect(read).toHaveBeenCalledTimes(1))
+ await act(async () => { capturedOnMessage!({
+ type: "community:channel.child_update",
+ parentChannelId: "forum_1",
+ channelId: "post_1",
+ changes: { tags: [...tags] },
+ } satisfies CommunityChildChannelUpdate) })
+ await vi.waitFor(() => expect(read).toHaveBeenCalledTimes(2))
+ await act(async () => { release({ tags: [...staleTags] }); await oldRead })
+ await vi.waitFor(() => expect(capturedQueryClient.getQueryData(key)).toEqual({ tags: [...tags] }))
+ } finally { unsubscribe() }
+ })
+
it("projects remote Archive out of warm All and ordinary feeds synchronously", async () => {
await mountHook()
seedForumFeed([{ id: "post_1", opener: "opener_1", tags: ["bug"] }])
@@ -935,9 +960,9 @@ describe("useCommunityWs — child_create patches parent thread badge with count
})
describe("useCommunityWs — channel.delete refreshes the parent forum feed", () => {
- it("invalidates the parent's message feed + threads list when parentChannelId is present", async () => {
+ it.each(["forum", "text"])("invalidates the %s parent feed while preserving ordinary thread openers", async parentType => {
await mountHook()
- seedCanonicalServer({ id: "srv_1", categories: [{ id: "cat1", name: "Forum", channels: [{ id: "forum_1", name: "Forum", type: "forum", active: false, unread: false }] }] })
+ seedCanonicalServer({ id: "srv_1", categories: [{ id: "cat1", name: "Forum", channels: [{ id: "forum_1", name: "Forum", type: parentType, active: false, unread: false }] }] })
seedCanonicalMessages("forum_1", [{ id: "opener_1", content: "Post", thread: { id: "post_1", name: "Post", messageCount: 0 } }])
const invalidateSpy = vi.spyOn(capturedQueryClient, "invalidateQueries")
const allKey = communityKeys.channelMessages("forum_1")
@@ -960,8 +985,8 @@ describe("useCommunityWs — channel.delete refreshes the parent forum feed", ()
const invalidatedKeys = invalidateSpy.mock.calls.map((c) => JSON.stringify(c[0]?.queryKey))
expect(invalidatedKeys).toContain(JSON.stringify(communityKeys.channelMessages("forum_1")))
expect(invalidatedKeys).toContain(JSON.stringify(communityKeys.threads("forum_1")))
- expect(capturedQueryClient.getQueryData<{ pages: { messages: unknown[] }[] }>(allKey)?.pages[0].messages).toHaveLength(0)
- expect(capturedQueryClient.getQueryData<{ pages: { messages: unknown[] }[] }>(bugKey)?.pages[0].messages).toHaveLength(0)
+ expect(capturedQueryClient.getQueryData<{ pages: { messages: unknown[] }[] }>(allKey)?.pages[0].messages).toHaveLength(parentType === "forum" ? 0 : 1)
+ expect(capturedQueryClient.getQueryData<{ pages: { messages: unknown[] }[] }>(bugKey)?.pages[0].messages).toHaveLength(parentType === "forum" ? 0 : 1)
})
it("does not throw and still evicts own caches when parentChannelId is absent (legacy event)", async () => {
diff --git a/src/web/src/hooks/community/community-ws/structure-tree-events.ts b/src/web/src/hooks/community/community-ws/structure-tree-events.ts
index c635b5427..7e579b8db 100644
--- a/src/web/src/hooks/community/community-ws/structure-tree-events.ts
+++ b/src/web/src/hooks/community/community-ws/structure-tree-events.ts
@@ -14,6 +14,7 @@ import type {
CommunityServerDelete,
CommunityServerUpdate,
} from "@alook/shared"
+import { supportsSidebarThreads } from "@/lib/community/forum-sidebar"
import { FORUM_ARCHIVE_TAG } from "@alook/shared"
import { communityKeys } from "@/lib/query-keys"
import { getCommunityDbRegistry } from "@/lib/community-db/collections"
@@ -44,7 +45,7 @@ import {
export function handleChildChannelCreate(event: CommunityChildChannelCreate, { queryClient, projection }: StructureTreeEventContext) {
invalidateChannelRefTargets(projection)
- const parent = getCanonicalCommunityChannels(queryClient).find(row => row.id === event.parentChannelId && row.type === "forum")
+ const parent = getCanonicalCommunityChannels(queryClient).find(row => row.id === event.parentChannelId && supportsSidebarThreads(row.type))
if (parent?.serverId) invalidateForumSidebar(projection, parent.serverId)
projection.fence("threads", { queryKey: communityKeys.threads(event.parentChannelId) })
if (event.parentMessageId) invalidateChannelMessages(projection, event.parentChannelId)
@@ -62,11 +63,11 @@ export function handleChildChannelUpdate(
queryKey: communityKeys.threads(event.parentChannelId),
})
invalidateChannelMessages(projection, event.parentChannelId)
- projection.invalidate("forum-post-tags", {
+ projection.fence("forum-post-tags", {
queryKey: communityKeys.forumTags(event.parentChannelId),
})
}
- const sidebarServerId = getCanonicalCommunityChannels(queryClient).find(row => row.id === event.parentChannelId && row.type === "forum")?.serverId
+ const sidebarServerId = getCanonicalCommunityChannels(queryClient).find(row => row.id === event.parentChannelId && supportsSidebarThreads(row.type))?.serverId
if (
sidebarServerId &&
isForumSidebarParent(queryClient, sidebarServerId, event.parentChannelId)
diff --git a/src/web/src/hooks/community/mutations/messages.dom.test.ts b/src/web/src/hooks/community/mutations/messages.dom.test.ts
index ebfc17b9f..efff5d71b 100644
--- a/src/web/src/hooks/community/mutations/messages.dom.test.ts
+++ b/src/web/src/hooks/community/mutations/messages.dom.test.ts
@@ -325,7 +325,7 @@ describe("useSendMessage — happy path", () => {
})
})
- it("does not touch forum resources when sending in an ordinary text thread", async () => {
+ it("refreshes the shared sidebar when sending in an ordinary text thread", async () => {
await seedParent("text", "text_parent")
const baseKey = communityKeys.forumSidebarThreads("s1")
const retainedKey = communityKeys.forumSidebarRetained("s1", "forum_post")
@@ -353,7 +353,7 @@ describe("useSendMessage — happy path", () => {
author: { id: "u_me", name: "me", avatar: "M" },
})
- expect(capturedQc.getQueryState(baseKey)?.isInvalidated).toBe(false)
+ expect(capturedQc.getQueryState(baseKey)?.isInvalidated).toBe(true)
expect([
capturedQc.getQueryData(baseKey),
capturedQc.getQueryData(retainedKey),
diff --git a/src/web/src/hooks/community/use-forum-sidebar-threads.dom.test.ts b/src/web/src/hooks/community/use-forum-sidebar-threads.dom.test.ts
index 0843ac015..d0ba2a05e 100644
--- a/src/web/src/hooks/community/use-forum-sidebar-threads.dom.test.ts
+++ b/src/web/src/hooks/community/use-forum-sidebar-threads.dom.test.ts
@@ -13,6 +13,7 @@ import { CommunityDbProvider, useForumSidebarProjection, useServerTreeProjection
import { ChannelSidebarRevealBoundary } from "@/components/community/channels/channel-sidebar-tree-owner"
import { tid } from "@/lib/community/testids"
import {
+ patchCanonicalCommunityChannel,
captureCommunityLiveSnapshotToken,
ingestAttentionSnapshot,
ingestMessages,
@@ -415,7 +416,7 @@ describe("forum sidebar canonical projection", () => {
rendered.unmount()
})
- it("keeps a notified text reply outside the forum sidebar after its message read", async () => {
+ it("includes a notified text reply in the shared sidebar after its message read", async () => {
const { queryClient, registry, wrapper } = await setup()
act(() => ingestServerDetail(registry, {
id: "server-1", name: "Server", discriminator: "0001", description: "", icon: null, ownerId: "viewer",
@@ -434,8 +435,8 @@ describe("forum sidebar canonical projection", () => {
})
await waitFor(() => expect(getCanonicalCommunityChannels(queryClient).some((row) => row.id === "text-child")).toBe(true))
expect(getCanonicalCommunityMessages(queryClient).find((row) => row.id === "text-opener")?.content).toBe("Text reply opener")
- expect(rendered.result.current.threads.map((row) => row.id)).toEqual(["post-1"])
- expect(getForumSidebarBase(queryClient, "server-1").threads.map((row) => row.id)).toEqual(["post-1"])
+ expect(rendered.result.current.threads.map((row) => row.id)).toEqual(["post-1", "text-child"])
+ expect(getForumSidebarBase(queryClient, "server-1").threads.map((row) => row.id)).toEqual(["post-1", "text-child"])
expect(registry.collections.channelMemberships.get("text-child:viewer:notify")).toBeDefined()
rendered.unmount()
})
@@ -536,8 +537,9 @@ describe("forum sidebar canonical projection", () => {
rendered.unmount()
})
- it.each([null, "0", "expired"] as const)("shares ASCII candidates and one expiry/top-five/retain=$0 view selector", async (retainId) => {
+ it.each((["forum", "text"] as const).flatMap(parentType => [null, "0", "expired"].map(retainId => ({ parentType, retainId }))))("shares $parentType candidates and expiry/top-five/retain=$retainId selector", async ({ parentType, retainId }) => {
const { queryClient, registry, wrapper } = await setup()
+ patchCanonicalCommunityChannel(queryClient, "forum-1", row => ({ ...row, type: parentType }))
const data = envelopeFor(["0", "9", "A", "Z", "a", "z", "expired"])
const expired = data.channels.find((row) => row.id === "expired")!
expired.lastMessageAt = expired.activityAt = new Date(Date.now() - 73 * 60 * 60 * 1000).toISOString()
diff --git a/src/web/src/hooks/community/use-forum-sidebar-threads.ts b/src/web/src/hooks/community/use-forum-sidebar-threads.ts
index 73a46c0be..b70e526c8 100644
--- a/src/web/src/hooks/community/use-forum-sidebar-threads.ts
+++ b/src/web/src/hooks/community/use-forum-sidebar-threads.ts
@@ -31,7 +31,7 @@ type CommunityFreshQueryProof,
type CommunityForumSidebarChannel,
type CommunityForumSidebarOpener,
} from "@/lib/community-db/sync"
-import { forumSidebarCandidates, viewerNotifyChannelIds, compareForumSidebarThreads as compareThreads,
+import { supportsSidebarThreads, forumSidebarCandidates, viewerNotifyChannelIds, compareForumSidebarThreads as compareThreads,
FORUM_SIDEBAR_ACTIVITY_WINDOW_MS as SIDEBAR_ACTIVITY_WINDOW_MS, type ForumSidebarThread } from "@/lib/community/forum-sidebar"
export type { ForumSidebarThread } from "@/lib/community/forum-sidebar"
@@ -74,9 +74,9 @@ export type NormalizedForumSidebarEnvelope = {
export function resolveForumSidebarRouteCandidate(
channelId: string | null,
topLevelChannelIds: Iterable<string> | null,
- parentIsForum: boolean | null | undefined,
+ parentSupportsThreads: boolean | null | undefined,
) {
- if (!channelId || !topLevelChannelIds || !parentIsForum) return null
+ if (!channelId || !topLevelChannelIds || !parentSupportsThreads) return null
return new Set(topLevelChannelIds).has(channelId) ? null : channelId
}
@@ -160,7 +160,7 @@ export function normalizeForumSidebarEnvelope(
function sidebarUrl(serverId: string, retainId: string | null) {
const params = new URLSearchParams({
type: "thread",
- parentType: "forum",
+ parentType: "forum,text",
participating: "true",
activeWithin: "72h",
limitPerParent: "5",
@@ -216,7 +216,7 @@ function publishNormalizedForumSidebar(
...normalized.base, threads: [], verifiedEpoch: token.accessEpoch,
window: {
version: 1 as const, accountId: token.viewerId!, serverId,
- parents: [...new Set([...getCanonicalCommunityChannels(queryClient).filter(row => row.serverId === serverId && row.type === "forum").map(row => row.id), ...normalized.channels.flatMap(row => row.parentChannelId ? [row.parentChannelId] : [])])],
+ parents: [...new Set([...getCanonicalCommunityChannels(queryClient).filter(row => row.serverId === serverId && supportsSidebarThreads(row.type)).map(row => row.id), ...normalized.channels.flatMap(row => row.parentChannelId ? [row.parentChannelId] : [])])],
base: normalized.base.threads.map(reference),
retained: retainId ? normalized.retainedDisposition === "eligible" && normalized.retained
? { id: retainId, disposition: "eligible" as const, reference: reference(normalized.retained) }
@@ -256,9 +256,9 @@ export function isKnownNonForumSidebarChannel(
const channel = channels.find((candidate) => candidate.id === channelId)
if (!channel) return false
if (channel.serverId !== serverId) return true
- if (channel.type !== "thread") return channel.type !== "forum"
+ if (channel.type !== "thread") return !supportsSidebarThreads(channel.type)
const parent = channels.find((candidate) => candidate.id === channel.parentChannelId)
- return !!parent && parent.type !== "forum"
+ return !!parent && !supportsSidebarThreads(parent.type)
}
export function isForumSidebarParent(
@@ -269,7 +269,7 @@ export function isForumSidebarParent(
return getCanonicalCommunityChannels(queryClient).some((channel) => (
channel.id === parentChannelId
&& channel.serverId === serverId
- && channel.type === "forum"
+ && supportsSidebarThreads(channel.type)
))
}
@@ -401,7 +401,7 @@ function reconcileForumSidebarNotifyMembershipsFromBase(
&& channel.type === "thread"
&& notifyIds.has(channel.id)
&& !!channel.parentChannelId
- && channelById.get(channel.parentChannelId)?.type === "forum"
+ && supportsSidebarThreads(channelById.get(channel.parentChannelId)?.type)
))
const baseIds = new Set(base.threads.map((thread) => thread.id))
diff --git a/src/web/src/hooks/community/use-thread-participants.dom.test.ts b/src/web/src/hooks/community/use-thread-participants.dom.test.ts
index d0a00c8de..89df0f9b0 100644
--- a/src/web/src/hooks/community/use-thread-participants.dom.test.ts
+++ b/src/web/src/hooks/community/use-thread-participants.dom.test.ts
@@ -27,8 +27,8 @@ afterEach(async () => {
function Owner({ children }: PropsWithChildren) {
return createElement(QueryClientProvider, { client }, createElement(CommunityDbProvider, { registry }, children))
}
-function seedSidebar() {
- ingestServerDetail(registry, { id: "server_1", name: "Server", discriminator: "0001", description: "", icon: null, ownerId: "viewer_1", categories: [{ id: "category", name: "Channels", channels: [{ id: "forum_1", name: "Forum", type: "forum", active: false, unread: false }] }] })
+function seedSidebar(parentType: "forum" | "text" = "forum") {
+ ingestServerDetail(registry, { id: "server_1", name: "Server", discriminator: "0001", description: "", icon: null, ownerId: "viewer_1", categories: [{ id: "category", name: "Channels", channels: [{ id: "forum_1", name: "Forum", type: parentType, active: false, unread: false }] }] })
const key = communityKeys.forumSidebarThreads("server_1")
client.setQueryData(key, { ids: ["post_1"], serverNow: "2026-08-08T00:00:00.000Z", serverClockOffsetMs: 0 })
publishCommunityForumSidebar(client, {
@@ -45,8 +45,8 @@ async function command<T>(run: () => Promise<T>) {
return value
}
describe("useRemoveThreadParticipant", () => {
- it("removes the child from every sidebar view when the viewer leaves", async () => {
- seedSidebar()
+ it.each(["forum", "text"] as const)("removes the %s child from every sidebar view when the viewer leaves", async (parentType) => {
+ seedSidebar(parentType)
const metaKey = communityKeys.channelMeta("server_1", "post_1")
client.setQueryData(metaKey, { id: "post_1", parentChannelId: "forum_1" })
diff --git a/src/web/src/lib/community-db/projections.ts b/src/web/src/lib/community-db/projections.ts
index be7b9ccb4..6c51dd5c1 100644
--- a/src/web/src/lib/community-db/projections.ts
+++ b/src/web/src/lib/community-db/projections.ts
@@ -8,7 +8,7 @@ import { DbProvider, and, eq, inArray, useLiveQuery as useNativeLiveQuery, type
import { createStore, useSelector } from "@tanstack/react-store"
import { CommunityRuntimeProvider } from "@/stores/community/runtime"
import { serverRailTopOrder, sortServerRailRows, notifLevelDisplay } from "@alook/shared"
-import { projectForumSidebar } from "@/lib/community/forum-sidebar"
+import { projectForumSidebar, supportsSidebarThreads } from "@/lib/community/forum-sidebar"
import { avatarInitial } from "@/lib/community/avatar"
import { readCommunityProfile } from "@/lib/community/profile-read"
import type { DM } from "@/lib/community/models/people"
@@ -513,7 +513,7 @@ export function useServerSidebarProjection(
if (serverNowMs === null || !ready || !registry || !servers || !channels || !channelMemberships || !messages) {
return { server, projection: undefined, status: failed ? "error" as const : "pending" as const, needsRead: false }
}
- const complete = !!server && (!channels.some(row => row.type === "forum")
+ const complete = !!server && (!channels.some(row => supportsSidebarThreads(row.type))
|| !!window && forumSidebarWindowComplete(window, { servers, channels, channelMemberships, messages }, registry.accountId, serverId, retainId, serverNowMs))
const projection = projectForumSidebar(channels, channelMemberships, messages, registry.accountId, serverId, retainId, serverNowMs, attention)
return { server, projection, status: complete ? "ready" as const : failed ? "error" as const : "pending" as const,
diff --git a/src/web/src/lib/community/forum-sidebar-window.ts b/src/web/src/lib/community/forum-sidebar-window.ts
index d63298e36..bdfedb167 100644
--- a/src/web/src/lib/community/forum-sidebar-window.ts
+++ b/src/web/src/lib/community/forum-sidebar-window.ts
@@ -1,5 +1,5 @@
import { z } from "zod"
-import { projectForumSidebar } from "./forum-sidebar"
+import { projectForumSidebar, supportsSidebarThreads } from "./forum-sidebar"
import type { CommunityCollectionRows } from "@/lib/community-db/schema"
const referenceSchema = z.object({ id: z.string().min(1), parentChannelId: z.string().min(1), parentMessageId: z.string().min(1) })
@@ -41,8 +41,8 @@ export function forumSidebarWindowComplete(
) {
if (window.accountId !== accountId || window.serverId !== serverId
|| !rows.servers.some(row => row.id === serverId && row.detailComplete)) return false
- const parents = rows.channels.filter(row => row.serverId === serverId && row.type === "forum")
- if (window.parents.some(id => !parents.some(row => row.id === id))) return false
+ const parents = rows.channels.filter(row => row.serverId === serverId && supportsSidebarThreads(row.type))
+ if (window.parents.some(id => !parents.some(row => row.id === id)) || parents.some(row => !window.parents.includes(row.id))) return false
const visible = projectForumSidebar(rows.channels, rows.channelMemberships, rows.messages, accountId, serverId,
retainId ?? (window.retained?.disposition === "eligible" ? window.retained.id : null), serverNowMs).threads
const references = [...window.base, ...(window.retained?.disposition === "eligible" ? [window.retained.reference] : []), ...visible]
diff --git a/src/web/src/lib/community/forum-sidebar.ts b/src/web/src/lib/community/forum-sidebar.ts
index 8f554e892..8f6009e0a 100644
--- a/src/web/src/lib/community/forum-sidebar.ts
+++ b/src/web/src/lib/community/forum-sidebar.ts
@@ -9,6 +9,10 @@ export type ForumSidebarThread = Pick<ChannelRow, "id"> & { unread: boolean } &
expiresAt: string
}
+export function supportsSidebarThreads(type: string | null | undefined) {
+ return type === "forum" || type === "text"
+}
+
export const FORUM_SIDEBAR_ACTIVITY_WINDOW_MS = 72 * 60 * 60 * 1000
export function viewerNotifyChannelIds(memberships: readonly ChannelMembershipRow[], viewerId: string | null) {
@@ -27,7 +31,7 @@ export function forumSidebarCandidates(
) {
const participating = viewerNotifyChannelIds(memberships, viewerId)
const messageById = new Map(messages.map((message) => [message.id, message]))
- const parents = channels.filter((channel) => channel.serverId === serverId && channel.type === "forum")
+ const parents = channels.filter((channel) => channel.serverId === serverId && supportsSidebarThreads(channel.type))
const parentIds = new Set(parents.map((channel) => channel.id))
return channels.flatMap((channel) => {
if (channel.serverId !== serverId || channel.type !== "thread" || channel.archived
diff --git a/src/web/src/lib/query-persister.forum-window.test.ts b/src/web/src/lib/query-persister.forum-window.test.ts
index 88ebb193f..db4689d76 100644
--- a/src/web/src/lib/query-persister.forum-window.test.ts
+++ b/src/web/src/lib/query-persister.forum-window.test.ts
@@ -35,6 +35,13 @@ function setup(empty = false) {
}
describe("scoped forum window persistence", () => {
+ it("refreshes a restored forum-only window when visible text parents are missing", () => {
+ const owner = setup()
+ const rows = { ...owner.rows, channels: [...owner.rows.channels, canonicalChannelRow({ id: "text", serverId, type: "text" })] }
+ expect(forumSidebarWindowComplete(owner.result.window, rows, accountId, serverId)).toBe(false)
+ expect(forumSidebarWindowComplete({ ...owner.result.window, parents: ["forum", "text"] }, rows, accountId, serverId)).toBe(true)
+ })
+
it.each([false, true])("restores only a complete minimal %s window without entity copies or access proof", async empty => {
const owner = setup(empty)
const persister = createIdbPersister(accountId)
diff --git a/src/web/src/test/e2e-ui/17-forum-sidebar-stage-b.spec.ts b/src/web/src/test/e2e-ui/17-forum-sidebar-stage-b.spec.ts
index e3120f9e7..6739ad616 100644
--- a/src/web/src/test/e2e-ui/17-forum-sidebar-stage-b.spec.ts
+++ b/src/web/src/test/e2e-ui/17-forum-sidebar-stage-b.spec.ts
@@ -318,7 +318,7 @@ test.describe("forum sidebar Stage B request shape", () => {
expect(await participantUserIds(page, threadId)).not.toContain(userId("carol"))
})
- test("a grouped ordinary thread never asks the forum sidebar to retain it", async ({ caseActors }) => {
+ test("an ordinary thread checks sidebar retention without enrolling a nonparticipant", async ({ caseActors }) => {
const actors = await caseActors(["alice", "bob", "carol"])
const { asUser, userId } = actors
const { participantUserIds, serverId, ordinaryThreadId } = await prepareCase1(actors)
@@ -344,10 +344,11 @@ test.describe("forum sidebar Stage B request shape", () => {
expect(successfulResponses.filter((url) => isConversationEntryRequest(url, ordinaryThreadId)))
.toHaveLength(1)
- expect(requests.filter((url) =>
+ await expect.poll(() => requests.filter((url) =>
isSidebarRequest(url, serverId)
&& new URL(url).searchParams.get("retainId") === ordinaryThreadId
- )).toHaveLength(0)
+ ).length).toBe(1)
+ await expect(page.getByTestId(tid.forumSidebarThread(ordinaryThreadId))).toHaveCount(0)
expect(await routeStability(page)).toEqual({ mounts: 1, losses: 0, present: true })
expect(await participantUserIds(page, ordinaryThreadId)).not.toContain(userId("bob"))
})
diff --git a/src/web/src/test/e2e-ui/51-mobile-forum-tag-editor.spec.ts b/src/web/src/test/e2e-ui/51-mobile-forum-tag-editor.spec.ts
index 4f6437f60..3682cd950 100644
--- a/src/web/src/test/e2e-ui/51-mobile-forum-tag-editor.spec.ts
+++ b/src/web/src/test/e2e-ui/51-mobile-forum-tag-editor.spec.ts
@@ -75,6 +75,32 @@ async function gateNextForumFeedResponse(page: Page, caseResources: CaseResource
return { release, captured, delivered }
}
+async function gateInitialForumTags(page: Page, forumId: string, caseResources: CaseResources) {
+ let release!: () => void
+ let sawResponse!: () => void
+ let finished!: () => void
+ const gate = new Promise<void>((resolve) => { release = resolve })
+ const captured = new Promise<void>((resolve) => { sawResponse = resolve })
+ const delivered = new Promise<void>((resolve) => { finished = resolve })
+ caseResources.own(release, async (captured) => { captured() })
+ caseResources.own(sawResponse, async (captured) => { captured() })
+ caseResources.own(finished, async (captured) => { captured() })
+ await page.route(`**/api/community/channels/${forumId}/messages/tags`, async (routeRequest) => {
+ const response = await routeRequest.fetch()
+ const body = await response.json() as { tags: string[] }
+ if (body.tags.length > 0) {
+ await routeRequest.fulfill({ response })
+ return
+ }
+ expect(body).toEqual({ tags: [] })
+ sawResponse()
+ await gate
+ await routeRequest.fulfill({ response }).catch(() => undefined)
+ finished()
+ })
+ return { release, captured, delivered }
+}
+
async function openEditor(page: Page, threadId: string) {
await page.getByTestId(tid.forumThreadCard(threadId)).hover()
const trigger = page.getByTestId(tid.forumThreadTagBtn(threadId))
@@ -242,7 +268,7 @@ test.describe("forum tag editor", () => {
await expect(card).toHaveCount(0)
})
- test("converges Archive and Unarchive across two tabs", async ({ caseActors }) => {
+ test("converges Archive and Unarchive across two tabs", async ({ caseActors, caseResources }) => {
const actors = await caseActors(["alice"])
const { asUser } = actors
const { seedForum } = await prepareCase1(actors)
@@ -250,10 +276,12 @@ test.describe("forum tag editor", () => {
const { route, forumId, threadId } = await seedForum("Archive cross tab")
const tabA = await asUser("alice")
const tabB = await asUser("alice")
+ const staleTags = await gateInitialForumTags(tabB.page, forumId, caseResources)
await Promise.all([
gotoAfterUserWsAuth(tabA.page, route),
gotoAfterUserWsAuth(tabB.page, route),
])
+ await staleTags.captured
const cardA = tabA.page.getByTestId(tid.forumThreadCard(threadId))
const cardB = tabB.page.getByTestId(tid.forumThreadCard(threadId))
await expect(cardA).toBeVisible()
@@ -267,6 +295,8 @@ test.describe("forum tag editor", () => {
await tabA.page.getByTestId(tid.forumThreadArchiveBtn(threadId)).click()
expect((await archived).status()).toBe(200)
await expect(cardB).toHaveCount(0)
+ staleTags.release()
+ await staleTags.delivered
await expect(tabA.page.getByTestId(tid.forumTagChip("archived"))).toBeVisible()
await expect(tabB.page.getByTestId(tid.forumTagChip("archived"))).toBeVisible()
diff --git a/src/web/src/test/e2e-ui/67-text-sidebar-threads.spec.ts b/src/web/src/test/e2e-ui/67-text-sidebar-threads.spec.ts
new file mode 100644
index 000000000..97d095c75
--- /dev/null
+++ b/src/web/src/test/e2e-ui/67-text-sidebar-threads.spec.ts
@@ -0,0 +1,105 @@
+import { test, expect } from "./_fixtures/case-fixture"
+import { gotoAfterUserWsAuth } from "./_fixtures/actions"
+import { tid } from "./_fixtures/testids"
+
+test("participating text threads share sidebar limits, retention and live membership with forums", async ({ caseActors }, testInfo) => {
+ test.setTimeout(180_000)
+ const actors = await caseActors(["alice", "bob"])
+ const seed = actors.seed
+ const serverId = await seed.seedServer("alice", `Thread sidebar ${Date.now()}`)
+ const textId = await seed.seedChannel("alice", serverId, "engineering")
+ const forumId = await seed.seedChannel("alice", serverId, "discussions", "forum")
+ const restricted = await seed.seedCategory("alice", serverId, "Restricted QA", { private: true })
+ const privateId = await seed.seedChannel("alice", serverId, "restricted", "text", restricted)
+ await seed.seedJoinServer("alice", "bob", serverId)
+ const owner = await actors.asUser("alice")
+ const viewer = await actors.asUser("bob", { viewport: { width: 1440, height: 1000 }, reducedMotion: "reduce" })
+ const bobId = actors.userId("bob")
+ const add = async (id: string) => {
+ const response = await owner.page.request.post(`/api/community/channels/${id}/participants`, { data: { userId: bobId } })
+ expect(response.status()).toBe(201)
+ }
+ const threads: string[] = []
+ const openers: string[] = []
+ for (let index = 0; index < 7; index++) {
+ const opener = await seed.seedMessage("alice", textId, `Engineering topic ${index + 1}`)
+ openers.push(opener)
+ const id = await seed.seedThread("alice", opener, `fallback-${index}`)
+ await seed.seedMessage("alice", id, `Reply for topic ${index + 1}`)
+ await add(id)
+ threads.push(id)
+ }
+ const excludedId = await seed.seedThread("alice", await seed.seedMessage("alice", textId, "Not participating"), "excluded")
+ const privateThread = await seed.seedThread("alice", await seed.seedMessage("alice", privateId, "Private opener"), "private")
+ const forumThread = await seed.seedForumThread("alice", forumId, "Forum topic remains", "Forum body")
+ await add(forumThread)
+ const { page } = viewer
+ const events: unknown[] = []
+ page.on("websocket", (socket) => socket.on("framereceived", ({ payload }) => {
+ try { const value = JSON.parse(String(payload)); if (String(value.type).startsWith("community:")) events.push(value) } catch {}
+ }))
+ const query = new URLSearchParams({ type: "thread", parentType: "forum,text", participating: "true", activeWithin: "72h", limitPerParent: "5", include: "parentMessage" })
+ const endpoint = `/api/community/servers/${serverId}/channels?${query}`
+ const canonicalResponse = await page.request.get(endpoint)
+ expect(canonicalResponse.status()).toBe(200)
+ const canonical = await canonicalResponse.json() as { canonicalChannels: Array<{ id: string; parentChannelId: string }> }
+ expect(canonical.canonicalChannels.filter((row) => row.parentChannelId === textId)).toHaveLength(5)
+ expect(canonical.canonicalChannels.map((row) => row.id)).not.toContain(excludedId)
+ expect(canonical.canonicalChannels.map((row) => row.id)).not.toContain(privateThread)
+ const legacyResponse = await page.request.get(endpoint.replace("forum%2Ctext", "forum"))
+ expect(legacyResponse.status()).toBe(200)
+ const legacy = await legacyResponse.json() as { canonicalChannels: Array<{ id: string }> }
+ expect(legacy.canonicalChannels.map((row) => row.id)).toEqual([forumThread])
+ await gotoAfterUserWsAuth(page, `/c/channels/${serverId}/${textId}`)
+ const sidebarRow = (id: string) => page.getByTestId(tid.forumSidebarThread(id))
+ await expect(sidebarRow(threads[6])).toBeVisible()
+ await expect(sidebarRow(threads[6])).toContainText("Engineering topic 7")
+ await expect(sidebarRow(threads[0])).toHaveCount(0)
+ await expect(sidebarRow(excludedId)).toHaveCount(0)
+ await expect(page.getByTestId(tid.channelRow(privateId))).toHaveCount(0)
+ await expect(sidebarRow(forumThread)).toBeVisible()
+ await sidebarRow(threads[6]).click()
+ await expect.poll(() => new URL(page.url()).pathname).toBe(`/c/channels/${serverId}/${threads[6]}`)
+ await expect(sidebarRow(threads[6])).toHaveAttribute("aria-current", "page")
+ await page.reload({ waitUntil: "commit" })
+ await expect(sidebarRow(threads[6])).toHaveAttribute("aria-current", "page")
+ await page.goto(`/c/channels/${serverId}/${threads[0]}`, { waitUntil: "commit" })
+ await expect(sidebarRow(threads[0])).toBeVisible()
+ await expect(sidebarRow(threads[0])).toHaveAttribute("aria-current", "page")
+ const retainedResponse = await page.request.get(`${endpoint}&retainId=${threads[0]}`)
+ expect(retainedResponse.status()).toBe(200)
+ const retained = await retainedResponse.json() as { retainedChannel: { id: string } }
+ expect(retained.retainedChannel.id).toBe(threads[0])
+
+ await page.goto(`/c/channels/${serverId}/${textId}`, { waitUntil: "commit" })
+ await expect(sidebarRow(threads[6])).toBeVisible()
+ await add(excludedId)
+ await expect(sidebarRow(excludedId)).toBeVisible()
+ const remove = await page.request.delete(`/api/community/channels/${excludedId}/participants/${bobId}`)
+ expect(remove.status()).toBe(204)
+ await expect(sidebarRow(excludedId)).toHaveCount(0)
+ await seed.seedMessage("alice", threads[0], "Live activity lifts the oldest thread")
+ await expect(sidebarRow(threads[0])).toBeVisible()
+ const ordered = await page.locator('[data-testid^="community-forum-sidebar-thread-"]').evaluateAll((rows) => rows.map((row) => row.getAttribute("data-testid")))
+ expect(ordered.indexOf(tid.forumSidebarThread(threads[0]))).toBeLessThan(ordered.indexOf(tid.forumSidebarThread(threads[6])))
+ await expect.poll(() => events.some((event) => JSON.stringify(event).includes(excludedId))).toBe(true)
+ const membershipResponse = await page.request.get(`/api/community/channels/${threads[0]}/members`)
+ expect(membershipResponse.status()).toBe(200)
+ const membership = await membershipResponse.json() as { members: Array<{ userId: string }> }
+ expect(membership.members.map((member) => member.userId)).toContain(bobId)
+
+ for (const theme of ["light", "dark"]) {
+ await page.evaluate((value) => localStorage.setItem("theme", value), theme)
+ await page.reload({ waitUntil: "commit" })
+ await expect(sidebarRow(threads[0])).toBeVisible()
+ await expect(sidebarRow(forumThread)).toBeVisible()
+ await expect(page.getByTestId(tid.message(openers[0]))).toBeVisible()
+ await testInfo.attach(`text-sidebar-${theme}`, { body: await page.screenshot(), contentType: "image/png" })
+ }
+ const mobile = await actors.asUser("bob", { viewport: { width: 390, height: 844 }, isMobile: true, hasTouch: true, reducedMotion: "reduce" })
+ await mobile.page.goto(`/c/channels/${serverId}`, { waitUntil: "commit" })
+ await expect(mobile.page.getByTestId(tid.forumSidebarThread(threads[0]))).toBeVisible()
+ await expect(mobile.page.getByTestId(tid.forumSidebarThread(forumThread))).toBeVisible()
+ await testInfo.attach("text-sidebar-mobile", { body: await mobile.page.screenshot(), contentType: "image/png" })
+ await testInfo.attach("text-sidebar-api-ws", { body: JSON.stringify({ serverId, textId, forumId, threads, excludedId, privateThread, canonical, legacy, retained, membership, events }), contentType: "application/json" })
+})