Multi-Agent Collaboration for Team and Friends
TypeScript agent-automationagent-orchestrationagent-workflowai-agentsai-collaborationai-memoryai-workforceautonomous-agentsclaude-codeclaude-code-skillscodexcoding-agentmulti-agentmultiple-agentone-person-businessone-person-companyone-person-teamopencodesolopreneur
feat: add desktop thread split view (#642)
Gustavo Ye31feae4d39c6
diff --git a/scripts/ci/e2e-shards.mjs b/scripts/ci/e2e-shards.mjsindex b7148d88a..6ba81474b 100644--- a/scripts/ci/e2e-shards.mjs+++ b/scripts/ci/e2e-shards.mjs@@ -58,6 +58,7 @@ export const SPEC_SECONDS = {"41-community-initial-load-module-skeletons.spec.ts": 30,"42-versioned-avatar-identity.spec.ts": 50,"44-mobile-reaction-details.spec.ts": 70,+ "45-desktop-thread-split-view.spec.ts": 60,"50-daemon-update-notice.spec.ts": 35,"51-share-image-assets.spec.ts": 20,}diff --git a/scripts/ci/e2e-shards.test.ts b/scripts/ci/e2e-shards.test.tsindex e30ec223e..bf716ec1e 100644--- a/scripts/ci/e2e-shards.test.ts+++ b/scripts/ci/e2e-shards.test.ts@@ -70,7 +70,7 @@ describe("planE2eShards", () => {expect(first).toHaveLength(E2E_SHARD_COUNT)expect([...assigned].sort()).toEqual(specs)expect(new Set(assigned).size).toBe(specs.length)- expect(totals.sort((left, right) => left - right)).toEqual([439, 440, 443, 444, 444])+ expect(totals.sort((left, right) => left - right)).toEqual([451, 454, 455, 455, 455])expect(Math.max(...totals) / Math.min(...totals)).toBeLessThanOrEqual(1.15)})diff --git a/src/web/src/components/community/channels/channel-header.navigation.test.ts b/src/web/src/components/community/channels/channel-header.navigation.test.tsindex e9be3b7cf..7aba5cb40 100644--- a/src/web/src/components/community/channels/channel-header.navigation.test.ts+++ b/src/web/src/components/community/channels/channel-header.navigation.test.ts@@ -113,4 +113,19 @@ describe("ChannelHeader hierarchy navigation", () => {expect(current.props.className).toContain("min-w-8")expect(current.props.className).toContain("sm:min-w-0")})++ it("renders only supplied panel actions in compact split mode", () => {+ const renderer = render({+ compactActions: true,+ tools: undefined,+ notifLevel: "all",+ onSetNotifLevel: vi.fn(),+ endActions: createElement("button", { "aria-label": "Open thread full screen" }),+ })++ expect(renderer.root.findAllByProps({ "aria-label": "Member list" })).toHaveLength(0)+ expect(renderer.root.findAllByProps({ "aria-label": "Channel notifications" })).toHaveLength(0)+ expect(renderer.root.findAllByProps({ "aria-label": "More channel options" })).toHaveLength(0)+ expect(renderer.root.findByProps({ "aria-label": "Open thread full screen" })).toBeTruthy()+ })})diff --git a/src/web/src/components/community/channels/channel-header.tsx b/src/web/src/components/community/channels/channel-header.tsxindex 6aa2e3873..6f28a2e29 100644--- a/src/web/src/components/community/channels/channel-header.tsx+++ b/src/web/src/components/community/channels/channel-header.tsx@@ -1,6 +1,6 @@"use client"-import { useEffect, useRef, useState } from "react"+import { useEffect, useRef, useState, type ReactNode } from "react"import type { LucideIcon } from "lucide-react"import { Bell, BellOff, Pin, Users, MessagesSquare, ChevronLeft, Check, Pencil, MoreHorizontal } from "lucide-react"import { NOTIF_LEVELS, USE_SERVER_DEFAULT, type NotifLevel } from "@alook/shared"@@ -54,6 +54,7 @@ export type ChannelNotifLevel = typeof USE_SERVER_DEFAULT | NotifLevelexport function ChannelHeader({channel, rightPanel, onToggle, notifLevel, onSetNotifLevel,breadcrumb, forum, server, mobileServer, onBack, tools,+ endActions, compactActions,}: {channel: stringrightPanel: RightPanel@@ -72,6 +73,8 @@ export function ChannelHeader({mobileServer?: { id: string; name: string; icon: string | null; onNavigate: () => void }onBack?: () => voidtools?: { threads?: boolean; pinned?: boolean; members?: boolean }+ endActions?: ReactNode+ compactActions?: boolean}) {// The parent-channel entity glyph (breadcrumb crumb + non-breadcrumb badge)@@ -141,17 +144,22 @@ export function ChannelHeader({</>)}<div className="ml-auto flex items-center text-muted-foreground">- {tools?.members !== false && tool("members", Users, "Member list")}- <span className="mx-1 h-5 w-px bg-border/60" aria-hidden />- <ChannelNotifDropdown level={notifLevel ?? USE_SERVER_DEFAULT} onSetLevel={onSetNotifLevel} />- {(tools?.threads !== false || tools?.pinned !== false) && (- <ChannelOverflowMenu- rightPanel={rightPanel}- onToggle={onToggle}- showThreads={tools?.threads !== false}- showPinned={tools?.pinned !== false}- />+ {!compactActions && (+ <>+ {tools?.members !== false && tool("members", Users, "Member list")}+ <span className="mx-1 h-5 w-px bg-border/60" aria-hidden />+ <ChannelNotifDropdown level={notifLevel ?? USE_SERVER_DEFAULT} onSetLevel={onSetNotifLevel} />+ {(tools?.threads !== false || tools?.pinned !== false) && (+ <ChannelOverflowMenu+ rightPanel={rightPanel}+ onToggle={onToggle}+ showThreads={tools?.threads !== false}+ showPinned={tools?.pinned !== false}+ />+ )}+ </>)}+ {endActions}</div></header>)diff --git a/src/web/src/components/community/channels/channel-route.text-scroll-target.test.ts b/src/web/src/components/community/channels/channel-route.text-scroll-target.test.tsindex ffbe7acf6..44982d33e 100644--- a/src/web/src/components/community/channels/channel-route.text-scroll-target.test.ts+++ b/src/web/src/components/community/channels/channel-route.text-scroll-target.test.ts@@ -17,6 +17,8 @@ const {mockHeaderParentNavigate,mockOpenerGate,mockSearchParams,+ mockSplitMode,+ mockSplitParentSurface,} = vi.hoisted(() => ({mockRouter: { push: vi.fn(), replace: vi.fn(), back: vi.fn() },mockUiHandlers: { replacePath: vi.fn(), goBackMobile: vi.fn() },@@ -25,6 +27,8 @@ const {mockHeaderParentNavigate: { current: undefined as undefined | (() => void) },mockOpenerGate: vi.fn(() => null),mockSearchParams: { value: "msg=m_target&keep=1" },+ mockSplitMode: { value: "full" as "split" | "full" },+ mockSplitParentSurface: vi.fn(() => null),mockRouteModel: {server: {id: "server_1",@@ -75,13 +79,15 @@ vi.mock("@/components/community/channels/channel-header", () => ({ChannelHeader: ({mobileServer,breadcrumb,+ endActions,}: {mobileServer?: { onNavigate: () => void }breadcrumb?: { onNavigate?: () => void }+ endActions?: React.ReactNode}) => {mockHeaderServerNavigate.current = mobileServer?.onNavigatemockHeaderParentNavigate.current = breadcrumb?.onNavigate- return null+ return React.createElement(React.Fragment, null, endActions)},ChannelHeaderSkeleton: () => null,}))@@ -107,6 +113,7 @@ vi.mock("@/components/community/messages/thread-opener", () => ({ ThreadOpener:vi.mock("@/components/community/members/add-members-dialog", () => ({ AddMembersDialog: () => null }))vi.mock("@alook/shared", () => ({canManageServer: () => false,+ devWsDoPort: () => 8789,isForum: () => false,deriveThreadName: () => "thread",USE_SERVER_DEFAULT: "default",@@ -136,6 +143,12 @@ vi.mock("@/contexts/community/current-user", () => ({vi.mock("@/hooks/community/use-channel-route-model", () => ({useChannelRouteModel: () => mockRouteModel,}))+vi.mock("@/hooks/community/use-thread-split-mode", () => ({+ useThreadSplitMode: () => ({ containerRef: vi.fn(), mode: mockSplitMode.value }),+}))+vi.mock("@/components/community/channels/thread-split-parent-surface", () => ({+ ThreadSplitParentSurface: mockSplitParentSurface,+}))vi.mock("@/hooks/community/use-forum-opener-hint", () => ({useForumOpenerHint: () => ({ data: null, isLoading: false }),}))@@ -194,6 +207,8 @@ vi.mock("@/hooks/community/mutations", () => ({vi.mock("@/hooks/community/use-community-ws", () => ({communityWsSendTyping: vi.fn(),communityWsResetTypingThrottle: vi.fn(),+ communityWsClaimSecondaryChannel: vi.fn(),+ communityWsReleaseSecondaryChannel: vi.fn(),}))const mockedMessageList = vi.mocked(MessageList)@@ -253,6 +268,8 @@ describe("ChannelRoute message surface ownership", () => {mockedMessageList.mockClear()mockOpenerGate.mockClear()mockSearchParams.value = "msg=m_target&keep=1"+ mockSplitMode.value = "full"+ mockSplitParentSurface.mockClear()mockBreakpoint.value = "desktop"mockHeaderServerNavigate.current = undefinedmockHeaderParentNavigate.current = undefined@@ -320,6 +337,57 @@ describe("ChannelRoute message surface ownership", () => {)})+ it("composes a wide child route as parent + thread with fullscreen and close actions", () => {+ configureThreadRoute()+ mockSplitMode.value = "split"+ mockSearchParams.value = "keep=1"+ mockedUseChannelMessageFeed.mockReturnValue(feed())+ let renderer!: TestRenderer.ReactTestRenderer++ act(() => {+ renderer = TestRenderer.create(React.createElement(ChannelRoute, {+ serverParam: "server_1",+ channelId: "channel_1",+ }))+ })++ expect(renderer.root.findByProps({ "data-testid": "community-thread-split" }).props["data-layout"]).toBe("split")+ expect(mockSplitParentSurface).toHaveBeenCalledWith(expect.objectContaining({+ channel: expect.objectContaining({ id: "parent_1", type: "text" }),+ }), undefined)++ act(() => renderer.root.findByProps({ "data-testid": "community-thread-split-fullscreen" }).props.onClick())+ expect(mockRouter.push).toHaveBeenCalledWith(+ "/c/channels/server_1/channel_1?keep=1&threadView=full",+ { scroll: false },+ )++ act(() => renderer.root.findByProps({ "data-testid": "community-thread-split-close" }).props.onClick())+ expect(mockUiHandlers.replacePath).toHaveBeenCalledWith("/c/channels/server_1/parent_1")+ })++ it("uses the same split parent contract for a forum post", () => {+ configureThreadRoute()+ mockSplitMode.value = "split"+ mockRouteModel.parent = { id: "parent_1", name: "questions", type: "forum" }+ mockRouteModel.isForumPostChild = true+ mockRouteModel.server.categories = [{+ channels: [{ id: "parent_1", name: "questions", type: "forum" }],+ }]+ mockedUseChannelMessageFeed.mockReturnValue(feed())++ act(() => {+ TestRenderer.create(React.createElement(ChannelRoute, {+ serverParam: "server_1",+ channelId: "channel_1",+ }))+ })++ expect(mockSplitParentSurface).toHaveBeenCalledWith(expect.objectContaining({+ channel: expect.objectContaining({ id: "parent_1", type: "forum" }),+ }), undefined)+ })+afterEach(() => {vi.useRealTimers()vi.clearAllMocks()diff --git a/src/web/src/components/community/channels/channel-route.tsx b/src/web/src/components/community/channels/channel-route.tsxindex 46aa09a0d..d8b142ec5 100644--- a/src/web/src/components/community/channels/channel-route.tsx+++ b/src/web/src/components/community/channels/channel-route.tsx@@ -9,6 +9,8 @@ import { ComposerSkeleton } from "@/components/community/messages/composer"import { ForumViewSkeleton } from "@/components/community/channels/forum-view"import { TextChannelSurface } from "@/components/community/channels/text-channel-surface"import { ThreadChannelSurface } from "@/components/community/channels/thread-channel-surface"+import { ThreadSplitView } from "@/components/community/channels/thread-split-view"+import { ThreadSplitParentSurface } from "@/components/community/channels/thread-split-parent-surface"import { ForumChannelSurface } from "@/components/community/channels/forum-channel-surface"import { useChannelMemberViewModel } from "@/components/community/members/channel-member-view-model"import type { OpenProfile } from "@/components/community/social/profile-types"@@ -31,6 +33,9 @@ import {THREAD_OPENER_HANDOFF_PARAM,useThreadOpenerRouteGate,} from "@/hooks/community/thread-opener-read-handoff"+import { useThreadSplitMode } from "@/hooks/community/use-thread-split-mode"++const THREAD_VIEW_PARAM = "threadView"/*** /c/channels/:serverId/:channelId@@ -124,6 +129,10 @@ export function ChannelRoute({ serverParam, channelId }: {const notifs = useNotificationSettings()const channelNotif = notifs.channelconst { mutate: setChannelNotif } = useSetChannelNotif()+ const threadSplit = useThreadSplitMode({+ parentChannelId: currentChannelMeta?.parentChannelId ?? null,+ forceFullscreen: searchParams.get(THREAD_VIEW_PARAM) === "full",+ })const navigateServerRoot = useCallback(() => {uiHandlers.replacePath?.(serverRootHref(serverParam))@@ -158,6 +167,11 @@ export function ChannelRoute({ serverParam, channelId }: {channelHref(serverParam, id),)}, [serverParam])+ const openThreadFullscreen = useCallback(() => {+ const params = new URLSearchParams(searchParams.toString())+ params.set(THREAD_VIEW_PARAM, "full")+ router.push(`${channelHref(serverParam, channelId)}?${params.toString()}`, { scroll: false })+ }, [channelId, router, searchParams, serverParam])const openProfile = useCallback<OpenProfile>((name, e, discriminator, userId) => {uiHandlers.openProfile?.(name, e, discriminator, userId)@@ -203,36 +217,67 @@ export function ChannelRoute({ serverParam, channelId }: {// ── Child channel view (forum post / thread opened via URL) ─────────────if (isChildChannel) {+ const split = threadSplit.mode === "split" && !!currentServer && !!parentChannelInServerreturn (- <ThreadChannelSurface- channelId={channelId}- serverId={serverId}- serverParam={serverParam}- channelName={channelName}- viewer={currentUser}- anchorMessageId={jumpTargetId}- parentChannelId={currentChannelMeta?.parentChannelId ?? null}- parentMessageId={currentChannelMeta?.parentMessageId ?? null}- parentChannelName={parentChannelInServer?.name ?? "channel"}- parentIsForum={isForumPostChild}- threadOpenerHandoff={threadOpenerHandoff}- childCreatorId={currentChannelMeta?.creatorId}- canRenameThread={canManageServer(myRole)}- headerServer={currentServer- ? { id: currentServer.id, name: currentServer.name, icon: currentServer.icon, onNavigate: navigateServerRoot }- : undefined}- onNavigateParent={navigateParent}- notificationLevel={(channelNotif[channelId] as ChannelNotifLevel) ?? USE_SERVER_DEFAULT}- onSetNotificationLevel={setNotificationLevel}- composerMembers={composerMembers}- composerMentionCandidates={composerMentionCandidates}- channelRefCandidates={channelRefCandidates}- memberPanelProps={memberPanelProps}- manageMembersDialog={manageMembersDialog}- uiHandlers={uiHandlers}- onOpenChild={enterThread}- onOpenProfile={openProfile}- resolveUserName={resolveUserName}+ <ThreadSplitView+ containerRef={threadSplit.containerRef}+ split={split}+ parent={split && currentServer && parentChannelInServer ? (+ <ThreadSplitParentSurface+ serverId={serverId}+ serverParam={serverParam}+ server={currentServer}+ channel={parentChannelInServer}+ viewer={currentUser}+ headerServer={{+ id: currentServer.id,+ name: currentServer.name,+ icon: currentServer.icon,+ onNavigate: navigateServerRoot,+ }}+ channelRefCandidates={channelRefCandidates}+ uiHandlers={uiHandlers}+ onOpenChild={enterThread}+ onOpenProfile={openProfile}+ />+ ) : null}+ thread={(+ <ThreadChannelSurface+ channelId={channelId}+ serverId={serverId}+ serverParam={serverParam}+ channelName={channelName}+ viewer={currentUser}+ anchorMessageId={jumpTargetId}+ parentChannelId={currentChannelMeta?.parentChannelId ?? null}+ parentMessageId={currentChannelMeta?.parentMessageId ?? null}+ parentChannelName={parentChannelInServer?.name ?? "channel"}+ parentIsForum={isForumPostChild}+ threadOpenerHandoff={threadOpenerHandoff}+ childCreatorId={currentChannelMeta?.creatorId}+ canRenameThread={canManageServer(myRole)}+ headerServer={currentServer+ ? { id: currentServer.id, name: currentServer.name, icon: currentServer.icon, onNavigate: navigateServerRoot }+ : undefined}+ onNavigateParent={navigateParent}+ notificationLevel={(channelNotif[channelId] as ChannelNotifLevel) ?? USE_SERVER_DEFAULT}+ onSetNotificationLevel={setNotificationLevel}+ composerMembers={composerMembers}+ composerMentionCandidates={composerMentionCandidates}+ channelRefCandidates={channelRefCandidates}+ memberPanelProps={memberPanelProps}+ manageMembersDialog={manageMembersDialog}+ uiHandlers={uiHandlers}+ onOpenChild={enterThread}+ onOpenProfile={openProfile}+ resolveUserName={resolveUserName}+ embedded+ splitActions={split ? {+ onFullscreen: openThreadFullscreen,+ onClose: navigateParent,+ } : undefined}+ />+ )}/>)}diff --git a/src/web/src/components/community/channels/forum-channel-surface.tsx b/src/web/src/components/community/channels/forum-channel-surface.tsxindex 5b42133d1..47ef027af 100644--- a/src/web/src/components/community/channels/forum-channel-surface.tsx+++ b/src/web/src/components/community/channels/forum-channel-surface.tsx@@ -34,6 +34,7 @@ export function ForumChannelSurface({manageMembersDialog,onOpenPost,onOpenProfile,+ embedded = false,}: {serverId: stringchannelId: string@@ -49,6 +50,7 @@ export function ForumChannelSurface({manageMembersDialog: ReactNodeonOpenPost: (postId: string) => voidonOpenProfile: OpenProfile+ embedded?: boolean}) {const [panelState, setPanelState] = useState<{ channelId: string; panel: RightPanel }>({channelId,@@ -85,6 +87,7 @@ export function ForumChannelSurface({onOpenPost(data.threadId)}, [channelId, createForumThreadMut, onOpenPost])const canManage = canManageServer(viewerRole)+ const Body = embedded ? "div" : "main"return (<ChannelShell@@ -101,7 +104,7 @@ export function ForumChannelSurface({/>)}body={(- <main className="flex min-h-0 min-w-0 flex-1 flex-col">+ <Body className="flex min-h-0 min-w-0 flex-1 flex-col"><ForumSurfaceserverId={serverId}forumChannelId={channelId}@@ -138,7 +141,7 @@ export function ForumChannelSurface({)}}/>- </main>+ </Body>)}panels={rightPanel && (<CommunityPaneldiff --git a/src/web/src/components/community/channels/text-channel-surface.tsx b/src/web/src/components/community/channels/text-channel-surface.tsxindex bda42a861..da0e6e261 100644--- a/src/web/src/components/community/channels/text-channel-surface.tsx+++ b/src/web/src/components/community/channels/text-channel-surface.tsx@@ -14,6 +14,7 @@ import { useAuthorMentionInsertion } from "@/components/community/messages/use-aimport {MessageChannelController,} from "@/components/community/messages/message-channel-controller"+import { MessagePaneNavigationProvider } from "@/components/community/messages/message-pane-navigation"import type { FileAttachment, ImagePreview } from "@/lib/community/models/message"import type { OpenProfile } from "@/components/community/social/profile-types"import type { RightPanel } from "@/components/community/shell/panel-types"@@ -38,6 +39,7 @@ export function TextChannelSurface({onOpenThread,onOpenProfile,resolveUserName,+ embedded = false,}: {channelId: stringserverId: string@@ -61,6 +63,7 @@ export function TextChannelSurface({onOpenThread: (threadId: string) => voidonOpenProfile: OpenProfileresolveUserName: (userId: string) => string+ embedded?: boolean}) {const breakpoint = useBreakpoint()const [rightPanel, setRightPanel] = useState<RightPanel>(null)@@ -84,6 +87,7 @@ export function TextChannelSurface({const togglePanel = (panel: Exclude<RightPanel, null>) => {setRightPanel((current) => current === panel ? null : panel)}+ const Body = embedded ? "div" : "main"return (<MessageChannelController@@ -100,8 +104,13 @@ export function TextChannelSurface({resolveUserName={resolveUserName}>{(controller) => (- <ChannelShell- header={(+ <MessagePaneNavigationProvider+ channelId={channelId}+ jumpToSeq={controller.jumpToSeq}+ openMessageContext={controller.setContextTarget}+ >+ <ChannelShell+ header={(<ChannelHeaderchannel={channelName}rightPanel={rightPanel}@@ -111,8 +120,8 @@ export function TextChannelSurface({mobileServer={headerServer}/>)}- body={(- <main className="flex min-h-0 min-w-0 flex-1 flex-col">+ body={(+ <Body className="flex min-h-0 min-w-0 flex-1 flex-col"><MessageListkey={channelId}channel={channelName}@@ -163,9 +172,9 @@ export function TextChannelSurface({draftKey={`${serverId}/${channelId}`}/></div>- </main>+ </Body>)}- panels={rightPanel && (+ panels={rightPanel && (<CommunityPanelopenonOpenChange={(open) => { if (!open) setRightPanel(null) }}@@ -184,7 +193,7 @@ export function TextChannelSurface({onSearch={controller.search}/>)}- dialogs={(+ dialogs={(<>{manageMembersDialog}<MessageContextSheet@@ -200,7 +209,8 @@ export function TextChannelSurface({/></>)}- />+ />+ </MessagePaneNavigationProvider>)}</MessageChannelController>)diff --git a/src/web/src/components/community/channels/thread-channel-surface.tsx b/src/web/src/components/community/channels/thread-channel-surface.tsxindex bce48a970..81169a50f 100644--- a/src/web/src/components/community/channels/thread-channel-surface.tsx+++ b/src/web/src/components/community/channels/thread-channel-surface.tsx@@ -11,10 +11,12 @@ import { ChannelShell } from "@/components/community/channels/channel-shell"import { CommunityPanel } from "@/components/community/shell/community-panel"import { Composer, ComposerSkeleton } from "@/components/community/messages/composer"import { MessageChannelController } from "@/components/community/messages/message-channel-controller"+import { MessagePaneNavigationProvider } from "@/components/community/messages/message-pane-navigation"import { MessageContextSheet } from "@/components/community/messages/message-context-sheet"import { MessageList } from "@/components/community/messages/message-list"import { useAuthorMentionInsertion } from "@/components/community/messages/use-author-mention-insertion"import { ThreadOpener } from "@/components/community/messages/thread-opener"+import { ThreadPanelActions } from "@/components/community/channels/thread-panel-actions"import type { FileAttachment, ImagePreview } from "@/lib/community/models/message"import type { OpenProfile } from "@/components/community/social/profile-types"import type { RightPanel } from "@/components/community/shell/panel-types"@@ -54,6 +56,8 @@ export function ThreadChannelSurface({onOpenChild,onOpenProfile,resolveUserName,+ embedded = false,+ splitActions,}: {channelId: stringserverId: string@@ -85,6 +89,8 @@ export function ThreadChannelSurface({onOpenChild: (childId: string) => voidonOpenProfile: OpenProfileresolveUserName: (userId: string) => string+ embedded?: boolean+ splitActions?: { onFullscreen: () => void; onClose: () => void }}) {const router = useRouter()const breakpoint = useBreakpoint()@@ -117,6 +123,7 @@ export function ThreadChannelSurface({anchorMessageId,})const displayName = localName ?? channelName+ const Body = embedded ? "div" : "main"useEffect(() => {setRightPanel(null)@@ -162,10 +169,10 @@ export function ThreadChannelSurface({return (<><ChannelHeaderSkeleton />- <main className="flex min-h-0 min-w-0 flex-1 flex-col">+ <Body className="flex min-h-0 min-w-0 flex-1 flex-col"><MessageList key={channelId} channel="" messages={[]} loading onOpenThread={ignoreNestedThread} /><ComposerSkeleton />- </main>+ </Body></>)}@@ -209,8 +216,13 @@ export function ThreadChannelSurface({resolveUserName={resolveUserName}>{(controller) => (- <ChannelShell- header={(+ <MessagePaneNavigationProvider+ channelId={channelId}+ jumpToSeq={controller.jumpToSeq}+ openMessageContext={controller.setContextTarget}+ >+ <ChannelShell+ header={(<ChannelHeaderchannel={parentChannelName}forum={parentIsForum}@@ -226,12 +238,19 @@ export function ThreadChannelSurface({label: displayName,titleRename: parentIsForum,onNavigate: onNavigateParent,- onRename: rename,+ onRename: splitActions ? undefined : rename,} : undefined}+ compactActions={!!splitActions}+ endActions={splitActions ? (+ <ThreadPanelActions+ onFullscreen={splitActions.onFullscreen}+ onClose={splitActions.onClose}+ />+ ) : undefined}/>)}- body={(- <main className="flex min-h-0 min-w-0 flex-1 flex-col">+ body={(+ <Body className="flex min-h-0 min-w-0 flex-1 flex-col"><MessageListkey={channelId}channel={displayName}@@ -283,9 +302,9 @@ export function ThreadChannelSurface({draftKey={`${serverId}/${channelId}`}/></div>- </main>+ </Body>)}- panels={rightPanel && (+ panels={rightPanel && (<CommunityPanelopenonOpenChange={(open) => { if (!open) setRightPanel(null) }}@@ -304,7 +323,7 @@ export function ThreadChannelSurface({onOpenProfile={onOpenProfile}/>)}- dialogs={(+ dialogs={(<>{manageMembersDialog}<MessageContextSheet@@ -320,7 +339,8 @@ export function ThreadChannelSurface({/></>)}- />+ />+ </MessagePaneNavigationProvider>)}</MessageChannelController>)diff --git a/src/web/src/components/community/channels/thread-panel-actions.tsx b/src/web/src/components/community/channels/thread-panel-actions.tsxnew file mode 100644index 000000000..4f9e3e59b--- /dev/null+++ b/src/web/src/components/community/channels/thread-panel-actions.tsx@@ -0,0 +1,40 @@+import { Maximize2, X } from "lucide-react"+import { Button } from "@/components/ui/button"+import { tid } from "@/lib/community/testids"++export function ThreadPanelActions({+ onFullscreen,+ onClose,+}: {+ onFullscreen: () => void+ onClose: () => void+}) {+ return (+ <div className="flex shrink-0 items-center gap-1 border-l border-border/60 pl-1">+ <Button+ type="button"+ variant="ghost"+ size="icon-sm"+ data-testid={tid.threadSplitFullscreen}+ onClick={onFullscreen}+ className="text-muted-foreground hover:text-foreground"+ aria-label="Open thread full screen"+ title="Open full screen"+ >+ <Maximize2 className="size-4" />+ </Button>+ <Button+ type="button"+ variant="ghost"+ size="icon-sm"+ data-testid={tid.threadSplitClose}+ onClick={onClose}+ className="text-muted-foreground hover:text-foreground"+ aria-label="Close thread"+ title="Close thread"+ >+ <X className="size-4" />+ </Button>+ </div>+ )+}diff --git a/src/web/src/components/community/channels/thread-split-parent-surface.tsx b/src/web/src/components/community/channels/thread-split-parent-surface.tsxnew file mode 100644index 000000000..63c555b82--- /dev/null+++ b/src/web/src/components/community/channels/thread-split-parent-surface.tsx@@ -0,0 +1,105 @@+"use client"++import type { ComponentProps } from "react"+import { isForum, USE_SERVER_DEFAULT } from "@alook/shared"+import { toastApiError } from "@/lib/api/client"+import type { Channel } from "@/lib/community/models/navigation"+import type { ServerDetail } from "@/hooks/community/use-servers"+import { useNotificationSettings } from "@/hooks/community/use-notification-settings"+import { useSetChannelNotif } from "@/hooks/community/mutations"+import { useChannelMemberViewModel } from "@/components/community/members/channel-member-view-model"+import type { ComposerProps } from "@/components/community/messages/composer"+import type { OpenProfile } from "@/components/community/social/profile-types"+import { ForumChannelSurface } from "@/components/community/channels/forum-channel-surface"+import { TextChannelSurface } from "@/components/community/channels/text-channel-surface"+import type { ChannelNotifLevel } from "@/components/community/channels/channel-header"++export function ThreadSplitParentSurface({+ serverId,+ serverParam,+ server,+ channel,+ viewer,+ headerServer,+ channelRefCandidates,+ uiHandlers,+ onOpenChild,+ onOpenProfile,+}: {+ serverId: string+ serverParam: string+ server: ServerDetail+ channel: Channel+ viewer: { id: string; name: string; discriminator?: string; avatar: string }+ headerServer?: { id: string; name: string; icon: string | null; onNavigate: () => void }+ channelRefCandidates: ComposerProps["channelRefCandidates"]+ uiHandlers: ComponentProps<typeof TextChannelSurface>["uiHandlers"]+ onOpenChild: (childId: string) => void+ onOpenProfile: OpenProfile+}) {+ const members = useChannelMemberViewModel({+ serverId,+ channelId: channel.id,+ channelName: channel.name,+ currentServer: server,+ channelInServer: channel,+ currentChannelMeta: null,+ isChildChannel: false,+ isNotifyUnit: false,+ currentUser: viewer,+ })+ const notifs = useNotificationSettings()+ const { mutate: setChannelNotif } = useSetChannelNotif()+ const notificationLevel = (notifs.channel[channel.id] as ChannelNotifLevel) ?? USE_SERVER_DEFAULT+ const setNotificationLevel = (level: ChannelNotifLevel) => {+ setChannelNotif({ channelId: channel.id, level }, {+ onError: (error) => toastApiError(error, "Failed to update notification level"),+ })+ }++ if (isForum(channel.type)) {+ return (+ <ForumChannelSurface+ serverId={serverId}+ channelId={channel.id}+ channelName={channel.name}+ viewer={viewer}+ viewerRole={members.myRole}+ headerServer={headerServer}+ notificationLevel={notificationLevel}+ onSetNotificationLevel={setNotificationLevel}+ composerMembers={members.composerMembers}+ composerMentionCandidates={members.composerMentionCandidates}+ memberPanelProps={members.memberPanelProps}+ manageMembersDialog={members.manageMembersDialog}+ onOpenPost={onOpenChild}+ onOpenProfile={onOpenProfile}+ embedded+ />+ )+ }++ return (+ <TextChannelSurface+ channelId={channel.id}+ serverId={serverId}+ serverParam={serverParam}+ channelName={channel.name}+ viewer={viewer}+ anchorMessageId={null}+ headerServer={headerServer}+ notificationLevel={notificationLevel}+ onSetNotificationLevel={setNotificationLevel}+ composerMembers={members.composerMembers}+ composerMentionCandidates={members.composerMentionCandidates}+ channelRefCandidates={channelRefCandidates}+ memberPanelProps={members.memberPanelProps}+ manageMembersDialog={members.manageMembersDialog}+ uiHandlers={uiHandlers}+ onOpenThread={onOpenChild}+ onOpenProfile={onOpenProfile}+ resolveUserName={members.resolveUserName}+ embedded+ />+ )+}diff --git a/src/web/src/components/community/channels/thread-split-view.tsx b/src/web/src/components/community/channels/thread-split-view.tsxnew file mode 100644index 000000000..751033660--- /dev/null+++ b/src/web/src/components/community/channels/thread-split-view.tsx@@ -0,0 +1,49 @@+/* Hallmark · modern-minimal · focused/utilitarian · inherited neutral palette+ * macrostructure: parallel-conversation-panel · pre-emit: P5 H5 E4 S5 R5 V4 · slop: pass+ */+import type { ReactNode, RefCallback } from "react"+import { cn } from "@/lib/utils"+import { tid } from "@/lib/community/testids"++export function ThreadSplitView({+ containerRef,+ split,+ parent,+ thread,+}: {+ containerRef: RefCallback<HTMLElement>+ split: boolean+ parent: ReactNode+ thread: ReactNode+}) {+ return (+ <main+ ref={containerRef}+ data-testid={tid.threadSplit}+ data-layout={split ? "split" : "full"}+ className="flex min-h-0 min-w-0 flex-1"+ >+ {split && (+ <section+ data-testid={tid.threadSplitParent}+ aria-label="Parent conversation"+ className="flex min-h-0 min-w-0 flex-1 flex-col"+ >+ {parent}+ </section>+ )}+ <section+ data-testid={tid.threadSplitPanel}+ aria-label={split ? "Thread panel" : "Thread"}+ className={cn(+ "flex min-h-0 min-w-0 flex-col bg-background",+ split+ ? "w-[clamp(26rem,44%,32rem)] shrink-0 border-l border-border/60"+ : "flex-1",+ )}+ >+ {thread}+ </section>+ </main>+ )+}diff --git a/src/web/src/components/community/messages/channel-ref-pill.pane-navigation.test.ts b/src/web/src/components/community/messages/channel-ref-pill.pane-navigation.test.tsnew file mode 100644index 000000000..1a604b119--- /dev/null+++ b/src/web/src/components/community/messages/channel-ref-pill.pane-navigation.test.ts@@ -0,0 +1,103 @@+import React from "react"+import TestRenderer, { act } from "react-test-renderer"+import { beforeEach, describe, expect, it, vi } from "vitest"+import { ChannelRefPill } from "./channel-ref-pill"+import { ChannelPill } from "./inline-marks"+import { MessagePaneNavigationProvider } from "./message-pane-navigation"++const mocks = vi.hoisted(() => ({+ routeChannelId: "child",+ globalJump: vi.fn(),+ globalContext: vi.fn(),+}))++vi.mock("@/stores/community", () => ({+ useCommunityStore: (selector: (state: {+ currentServerId: string+ currentChannelId: string+ }) => unknown) => selector({+ currentServerId: "server",+ currentChannelId: mocks.routeChannelId,+ }),+ useUiHandlers: () => ({+ jumpToSeq: mocks.globalJump,+ openMessageContext: mocks.globalContext,+ navigate: vi.fn(),+ }),+}))++vi.mock("@/hooks/community/use-channel-ref-directory", () => ({+ useChannelRefDirectory: () => ({ directory: {} }),+}))++vi.mock("@/hooks/community/use-channel-panels", () => ({+ useThreads: () => ({ threads: [], isLoading: false }),+}))++vi.mock("@/lib/community/channel-ref", () => ({+ resolveChannelRefBase: () => ({+ server: { id: "server", name: "Server" },+ channel: { id: "parent", name: "parent" },+ seq: 7,+ }),+}))++function renderRef(+ channelId: string,+ jumpToSeq: (seq: number) => void,+ openMessageContext: (target: {+ serverId: string+ channelId: string+ label: string+ seq: number+ }) => void,+) {+ return React.createElement(+ MessagePaneNavigationProvider,+ { channelId, jumpToSeq, openMessageContext },+ React.createElement(ChannelRefPill, null, "/server/parent#7"),+ )+}++describe("ChannelRefPill pane navigation ownership", () => {+ beforeEach(() => vi.clearAllMocks())++ it("routes a parent-pane message ref to the parent controller while the route owns the child", () => {+ const parentJump = vi.fn()+ const parentContext = vi.fn()+ let renderer: TestRenderer.ReactTestRenderer++ act(() => {+ renderer = TestRenderer.create(renderRef("parent", parentJump, parentContext))+ })++ act(() => renderer!.root.findByType(ChannelPill).props.onClick())++ expect(parentJump).toHaveBeenCalledWith(7)+ expect(parentContext).not.toHaveBeenCalled()+ expect(mocks.globalJump).not.toHaveBeenCalled()+ expect(mocks.globalContext).not.toHaveBeenCalled()+ })++ it("opens cross-channel context in the child pane that contains the ref", () => {+ const childJump = vi.fn()+ const childContext = vi.fn()+ let renderer: TestRenderer.ReactTestRenderer++ act(() => {+ renderer = TestRenderer.create(renderRef("child", childJump, childContext))+ })++ act(() => renderer!.root.findByType(ChannelPill).props.onClick())++ expect(childJump).not.toHaveBeenCalled()+ expect(childContext).toHaveBeenCalledWith({+ serverId: "server",+ channelId: "parent",+ label: "parent",+ seq: 7,+ })+ expect(mocks.globalJump).not.toHaveBeenCalled()+ expect(mocks.globalContext).not.toHaveBeenCalled()+ })+})diff --git a/src/web/src/components/community/messages/channel-ref-pill.tsx b/src/web/src/components/community/messages/channel-ref-pill.tsxindex 92ddc69c8..b7c4ac57a 100644--- a/src/web/src/components/community/messages/channel-ref-pill.tsx+++ b/src/web/src/components/community/messages/channel-ref-pill.tsx@@ -8,6 +8,7 @@ import { useChannelRefDirectory } from "@/hooks/community/use-channel-ref-directimport { useThreads } from "@/hooks/community/use-channel-panels"import { useCommunityStore, useUiHandlers } from "@/stores/community"import { tid } from "@/lib/community/testids"+import { useMessagePaneNavigation } from "./message-pane-navigation"export type ChannelRefPillView =| { kind: "muted"; label: string; showIcon?: boolean }@@ -120,8 +121,10 @@ export function describeChannelRefPillView(args: {export function ChannelRefPill({ children }: { children?: React.ReactNode }) {const ref = String(children ?? "")const currentServerId = useCommunityStore((s) => s.currentServerId)- const currentChannelId = useCommunityStore((s) => s.currentChannelId)+ const routeChannelId = useCommunityStore((s) => s.currentChannelId)const uiHandlers = useUiHandlers()+ const paneNavigation = useMessagePaneNavigation()+ const currentChannelId = paneNavigation?.channelId ?? routeChannelIdconst { directory } = useChannelRefDirectory()// The debt record's own verification (see finding #6) confirmed the@@ -162,8 +165,8 @@ export function ChannelRefPill({ children }: { children?: React.ReactNode }) {const sameChannel = view.href.channelId === currentChannelIdconst onClick = isMsgRef? sameChannel- ? () => uiHandlers.jumpToSeq?.(view.messageSuffix!)- : () => uiHandlers.openMessageContext?.({+ ? () => (paneNavigation?.jumpToSeq ?? uiHandlers.jumpToSeq)?.(view.messageSuffix!)+ : () => (paneNavigation?.openMessageContext ?? uiHandlers.openMessageContext)?.({serverId: view.href.serverId,channelId: view.href.channelId,label: view.label,diff --git a/src/web/src/components/community/messages/message-channel-controller-state.test.ts b/src/web/src/components/community/messages/message-channel-controller-state.test.tsindex c6628310e..db7d3569e 100644--- a/src/web/src/components/community/messages/message-channel-controller-state.test.ts+++ b/src/web/src/components/community/messages/message-channel-controller-state.test.ts@@ -306,7 +306,7 @@ describe("useMessageChannelController", () => {expect(latest.replyTo).toBeNull()})- it("preserves pending/context/seq navigation and UI handler cleanup", () => {+ it("preserves pending/context/seq navigation without claiming global pane handlers", () => {mocks.seq = "7"const navigate = vi.fn()let renderer: TestRenderer.ReactTestRenderer@@ -321,9 +321,7 @@ describe("useMessageChannelController", () => {expect(mocks.router.replace).toHaveBeenCalledWith("/c/channels/server_1/channel_1?keep=1", { scroll: false },)- expect(mocks.storeState.registerUiHandlers).toHaveBeenCalledWith({- jumpToSeq: expect.any(Function), openMessageContext: expect.any(Function),- })+ expect(mocks.storeState.registerUiHandlers).not.toHaveBeenCalled()act(() => latest.setContextTarget({serverId: "server_2", channelId: "channel_2", label: "other", seq: 2,@@ -335,9 +333,7 @@ describe("useMessageChannelController", () => {})expect(navigate).toHaveBeenCalledWith("server_2", "channel_2")act(() => renderer!.unmount())- expect(mocks.storeState.registerUiHandlers).toHaveBeenLastCalledWith({- jumpToSeq: undefined, openMessageContext: undefined,- })+ expect(mocks.storeState.registerUiHandlers).not.toHaveBeenCalled()})it("consumes seq on the current canonical child route and preserves other query state", () => {diff --git a/src/web/src/components/community/messages/message-channel-controller-state.ts b/src/web/src/components/community/messages/message-channel-controller-state.tsindex c5f73c147..060466237 100644--- a/src/web/src/components/community/messages/message-channel-controller-state.ts+++ b/src/web/src/components/community/messages/message-channel-controller-state.ts@@ -183,18 +183,6 @@ export function useMessageChannelController({else setContextTarget({ serverId, channelId, label: channelName, seq })}, [serverId, channelId, channelName])- const openMessageContext = useCallback((target: MessageContextTarget) => {- setContextTarget(target)- }, [])-- useEffect(() => {- useCommunityStore.getState().registerUiHandlers({ jumpToSeq, openMessageContext })- return () => useCommunityStore.getState().registerUiHandlers({- jumpToSeq: undefined,- openMessageContext: undefined,- })- }, [jumpToSeq, openMessageContext])-const seqParam = searchParams.get("seq")const searchParamsString = searchParams.toString()useEffect(() => {diff --git a/src/web/src/components/community/messages/message-pane-navigation.tsx b/src/web/src/components/community/messages/message-pane-navigation.tsxnew file mode 100644index 000000000..32c6bd8df--- /dev/null+++ b/src/web/src/components/community/messages/message-pane-navigation.tsx@@ -0,0 +1,39 @@+"use client"++import {+ createContext,+ type ReactNode,+ useContext,+ useMemo,+} from "react"+import type { MessageContextTarget } from "./message-channel-controller-types"++type MessagePaneNavigation = {+ channelId: string+ jumpToSeq: (seq: number) => void+ openMessageContext: (target: MessageContextTarget) => void+}++const MessagePaneNavigationContext = createContext<MessagePaneNavigation | null>(null)++export function MessagePaneNavigationProvider({+ channelId,+ jumpToSeq,+ openMessageContext,+ children,+}: MessagePaneNavigation & { children: ReactNode }) {+ const value = useMemo(+ () => ({ channelId, jumpToSeq, openMessageContext }),+ [channelId, jumpToSeq, openMessageContext],+ )++ return (+ <MessagePaneNavigationContext.Provider value={value}>+ {children}+ </MessagePaneNavigationContext.Provider>+ )+}++export function useMessagePaneNavigation() {+ return useContext(MessagePaneNavigationContext)+}diff --git a/src/web/src/hooks/community/community-ws/handler-context.ts b/src/web/src/hooks/community/community-ws/handler-context.tsindex c1c7338f6..f60890b97 100644--- a/src/web/src/hooks/community/community-ws/handler-context.ts+++ b/src/web/src/hooks/community/community-ws/handler-context.ts@@ -7,6 +7,8 @@ import type { CommunityWsEvent } from "@alook/shared"export type Subscription = {// The focused regular channel/thread.channelId?: string+ // The parent channel/forum that remains mounted beside a focused thread.+ secondaryChannelId?: string// The focused DM's channel id. A DM is a channel now; this slot keeps its// name only to mark "the focused channel is a DM" so the handler routes its// events into the `dmMessages` cache and the `dm:` typing scope.diff --git a/src/web/src/hooks/community/community-ws/message-events.test.ts b/src/web/src/hooks/community/community-ws/message-events.test.tsindex 6f0fe5762..ca2dc1537 100644--- a/src/web/src/hooks/community/community-ws/message-events.test.ts+++ b/src/web/src/hooks/community/community-ws/message-events.test.ts@@ -237,6 +237,46 @@ describe("useCommunityWs — message.create", () => {expect([...getMessageOverlay({ kind: "channel", id: "ch_1", serverId: "s1" }).liveById]).toHaveLength(1)})+ it("projects a split-view parent into its own live overlay", async () => {+ await mountHook()+ const { useCommunityStore } = await import("@/stores/community")+ const store = useCommunityStore.getState()+ store.subscribe({ channelId: "thread_1" })+ store.claimSecondaryChannel(Symbol("split"), "parent_1")+ resetHookMemoization()+ await mountHook()++ capturedOnMessage!(messageCreate("parent_1", "parent_message"))+ capturedOnMessage!(messageCreate("thread_1", "thread_message"))++ expect([+ ...getMessageOverlay({ kind: "channel", id: "parent_1", serverId: "s1" }).liveById,+ ].map(([id]) => id)).toEqual(["parent_message"])+ expect([+ ...getMessageOverlay({ kind: "channel", id: "thread_1", serverId: "s1" }).liveById,+ ].map(([id]) => id)).toEqual(["thread_message"])+ })++ it("stops treating the parent as focused immediately after the split owner releases it", async () => {+ const { useCommunityStore } = await import("@/stores/community")+ const store = useCommunityStore.getState()+ const owner = Symbol("split")+ store.subscribe({ channelId: "thread_1" })+ store.claimSecondaryChannel(owner, "parent_hidden")+ resetHookMemoization()+ await mountHook()++ store.releaseSecondaryChannel(owner)+ capturedOnMessage!(messageCreate("parent_hidden", "hidden_parent_message"))+ capturedOnMessage!(messageCreate("thread_1", "visible_thread_message"))++ expect(getMessageOverlay({ kind: "channel", id: "parent_hidden", serverId: "s1" }).liveById)+ .toHaveLength(0)+ expect([+ ...getMessageOverlay({ kind: "channel", id: "thread_1", serverId: "s1" }).liveById,+ ].map(([id]) => id)).toEqual(["visible_thread_message"])+ })+it("heals a first-seen event replay once the focused serverId becomes available", async () => {await mountHook()const { useCommunityStore } = await import("@/stores/community")@@ -945,6 +985,34 @@ describe("useCommunityWs — message.updated", () => {expect(getMessageOverlay(scope).liveById.get("m_channel")?.approval).toEqual(approval)})++ it("refreshes approval fields on a secondary focused channel", async () => {+ const { useCommunityStore } = await import("@/stores/community")+ useCommunityStore.getState().claimSecondaryChannel(Symbol("split"), "ch_parent")+ await mountHook()+ const scope = { kind: "channel" as const, id: "ch_parent", serverId: "s1" }+ useMessageStreamStore.getState().dispatch(scope, {+ type: "wsMessage",+ message: { id: "m_parent", seq: 4, type: "chat", content: "approval" },+ })+ const profile = { id: "u_other", name: "Other", discriminator: "0001", image: null, avatarVersion: 0 }+ const approval = {+ friendshipId: "friendship_1",+ status: "approved" as const,+ waitingOn: null,+ otherProfile: profile,+ botProfile: { ...profile, id: "bot_1", name: "Bot" },+ }++ capturedOnMessage!({+ type: "community:message.updated",+ channelId: "ch_parent",+ messageId: "m_parent",+ approval,+ })++ expect(getMessageOverlay(scope).liveById.get("m_parent")?.approval).toEqual(approval)+ })})describe("useCommunityWs — pin.add", () => {diff --git a/src/web/src/hooks/community/community-ws/message-events.ts b/src/web/src/hooks/community/community-ws/message-events.tsindex 2b062722c..556165b98 100644--- a/src/web/src/hooks/community/community-ws/message-events.ts+++ b/src/web/src/hooks/community/community-ws/message-events.ts@@ -51,6 +51,7 @@ export function handleMessageCreate(sub,viewerUserIdRef,deliveryMode,+ matchesFocus,scheduleInboxInvalidate,projection,}: MessageEventContext,@@ -58,7 +59,7 @@ export function handleMessageCreate(const viewerId = viewerUserIdRef.currentconst hasSeenMessage = wsStore.hasSeenMessage(event.message.id)const isForeignFocused = event.message.authorId !== viewerId- && (event.channelId === sub.channelId || event.channelId === sub.dmConversationId)+ && matchesFocus(event)if (isForeignFocused && !hasSeenMessage) {armInboxReadReservationCandidate(queryClient, {channelId: event.channelId,@@ -70,7 +71,7 @@ export function handleMessageCreate(wsStore.beginProfileSnapshot(),messageProfilePatches([projected]),)- if (event.channelId === sub.channelId) {+ if (event.channelId === sub.channelId || event.channelId === sub.secondaryChannelId) {const serverId = useCommunityStore.getState().currentServerIdif (serverId) {void scheduleFocusedMessageGapRepair(diff --git a/src/web/src/hooks/community/community-ws/message-projections.ts b/src/web/src/hooks/community/community-ws/message-projections.tsindex 84a27cbfe..55ed307cb 100644--- a/src/web/src/hooks/community/community-ws/message-projections.ts+++ b/src/web/src/hooks/community/community-ws/message-projections.ts@@ -79,7 +79,7 @@ export function projectReactionCopies(: cache,)}- if (event.channelId === sub.channelId) {+ if (event.channelId === sub.channelId || event.channelId === sub.secondaryChannelId) {const serverId = useCommunityStore.getState().currentServerIdif (serverId) {refreshOverlayCopy(@@ -109,7 +109,11 @@ export function projectApprovalCopies() {const { projection, queryClient, sub } = contextprojection.project(() => {- if (event.channelId === sub.dmConversationId || event.channelId === sub.channelId) {+ if (+ event.channelId === sub.dmConversationId+ || event.channelId === sub.channelId+ || event.channelId === sub.secondaryChannelId+ ) {queryClient.setQueryData<PageCache>(communityKeys.dmMessages(event.channelId),(cache) => patchApprovalInCache(cache, event.messageId, event.approval),@@ -127,7 +131,7 @@ export function projectApprovalCopies(event.messageId,(message) => ({ ...message, approval: event.approval }),)- } else if (event.channelId === sub.channelId) {+ } else if (event.channelId === sub.channelId || event.channelId === sub.secondaryChannelId) {const serverId = useCommunityStore.getState().currentServerIdif (serverId) {refreshOverlayCopy(diff --git a/src/web/src/hooks/community/community-ws/reconnect.test.ts b/src/web/src/hooks/community/community-ws/reconnect.test.tsindex 62a75b2c7..1818c95b9 100644--- a/src/web/src/hooks/community/community-ws/reconnect.test.ts+++ b/src/web/src/hooks/community/community-ws/reconnect.test.ts@@ -255,6 +255,34 @@ describe("useCommunityWs — resyncs machines on WS reconnect", () => {).toBe(true)})+ it("reconciles both visible split panes and drops the hidden parent after owner cleanup", async () => {+ const { useCommunityStore } = await import("@/stores/community")+ const store = useCommunityStore.getState()+ const owner = Symbol("split")+ store.subscribe({ channelId: "thread_focus" })+ store.claimSecondaryChannel(owner, "parent_focus")+ await mountHook()+ const spy = vi.spyOn(capturedQueryClient, "invalidateQueries")++ await capturedOnReconnect!({ reconnectDurationMs: 0 })+ const firstKeys = spy.mock.calls.map((call) => JSON.stringify(call[0]?.queryKey))+ for (const channelId of ["thread_focus", "parent_focus"]) {+ expect(firstKeys).toContain(JSON.stringify(communityKeys.channelMembers(channelId)))+ expect(firstKeys).toContain(JSON.stringify(communityKeys.channelAddableMembers(channelId)))+ expect(firstKeys).toContain(JSON.stringify(communityKeys.pins(channelId)))+ expect(firstKeys).toContain(JSON.stringify(communityKeys.threads(channelId)))+ expect(firstKeys).toContain(JSON.stringify(communityKeys.threadParticipants(channelId)))+ }++ store.releaseSecondaryChannel(owner)+ spy.mockClear()+ await capturedOnReconnect!({ reconnectDurationMs: 0 })+ const hiddenParentKeys = spy.mock.calls+ .map((call) => JSON.stringify(call[0]?.queryKey))+ .filter((key) => key.includes("parent_focus"))+ expect(hiddenParentKeys).toEqual([])+ })+it("invalidates the focused thread opener's single-message query on reconnect", async () => {const { useCommunityStore } = await import("@/stores/community")useCommunityStore.getState().setCurrentChannelMeta({diff --git a/src/web/src/hooks/community/community-ws/reconnect.ts b/src/web/src/hooks/community/community-ws/reconnect.tsindex e1c85a073..236aca550 100644--- a/src/web/src/hooks/community/community-ws/reconnect.ts+++ b/src/web/src/hooks/community/community-ws/reconnect.ts@@ -137,6 +137,13 @@ function policyExecutors(sub.channelId,))}+ if (sub.secondaryChannelId) {+ operations.push(reconcileFocusedMessageQueries(+ queryClient,+ "channel",+ sub.secondaryChannelId,+ ))+ }if (sub.dmConversationId) {operations.push(reconcileFocusedMessageQueries(queryClient,@@ -158,28 +165,37 @@ function policyExecutors(},"focused-channel-roster": async () => {if (!sub.channelId) return+ const channelIds = [sub.channelId, sub.secondaryChannelId]+ .filter((channelId): channelId is string => !!channelId)const settled = await Promise.allSettled([- queryClient.invalidateQueries({- queryKey: communityKeys.channelMembers(sub.channelId),+ ...channelIds.map((channelId) => queryClient.invalidateQueries({+ queryKey: communityKeys.channelMembers(channelId),refetchType: "active",- }),- queryClient.invalidateQueries({- queryKey: communityKeys.channelAddableMembers(sub.channelId),+ })),+ ...channelIds.map((channelId) => queryClient.invalidateQueries({+ queryKey: communityKeys.channelAddableMembers(channelId),refetchType: "active",- }),+ })),])if (settled.some((result) => result.status === "rejected")) throw new Error("focused roster failed")},"focused-pins": async () => {- const channelId = sub.channelId ?? sub.dmConversationId- if (!channelId) return- await queryClient.invalidateQueries({ queryKey: communityKeys.pins(channelId), refetchType: "active" })+ const channelIds = [sub.channelId, sub.secondaryChannelId, sub.dmConversationId]+ .filter((channelId): channelId is string => !!channelId)+ if (channelIds.length === 0) return+ await Promise.all(channelIds.map((channelId) =>+ queryClient.invalidateQueries({ queryKey: communityKeys.pins(channelId), refetchType: "active" }),+ ))},"focused-threads": async () => {if (!sub.channelId) returnconst settled = await Promise.allSettled([queryClient.invalidateQueries({ queryKey: communityKeys.threads(sub.channelId), refetchType: "active" }),queryClient.invalidateQueries({ queryKey: communityKeys.threadParticipants(sub.channelId), refetchType: "active" }),+ ...(sub.secondaryChannelId ? [+ queryClient.invalidateQueries({ queryKey: communityKeys.threads(sub.secondaryChannelId), refetchType: "active" }),+ queryClient.invalidateQueries({ queryKey: communityKeys.threadParticipants(sub.secondaryChannelId), refetchType: "active" }),+ ] : []),])if (settled.some((result) => result.status === "rejected")) throw new Error("focused threads failed")},diff --git a/src/web/src/hooks/community/use-community-ws.test.ts b/src/web/src/hooks/community/use-community-ws.test.tsindex 0a379cd62..c26f13e1f 100644--- a/src/web/src/hooks/community/use-community-ws.test.ts+++ b/src/web/src/hooks/community/use-community-ws.test.ts@@ -43,16 +43,32 @@ describe("useCommunityWs — public helper contracts", () => {expect(await mountHook({ viewerUserId: "u_viewer" })).toBeUndefined()})- it("free subscribe/unsubscribe helpers preserve then clear both subscription slots", async () => {- const { communityWsSubscribe, communityWsUnsubscribe } = await import("./use-community-ws")+ it("free subscription helpers preserve primary, secondary, and DM slots", async () => {+ const {+ communityWsClaimSecondaryChannel,+ communityWsReleaseSecondaryChannel,+ communityWsSubscribe,+ communityWsUnsubscribe,+ } = await import("./use-community-ws")const { useCommunityStore } = await import("@/stores/community")const target = { channelId: "ch_contract", dmConversationId: "dm_contract" }communityWsSubscribe(target)expect(useCommunityStore.getState().subscription).toEqual(target)+ const owner = Symbol("split")+ communityWsClaimSecondaryChannel(owner, "ch_parent")+ expect(useCommunityStore.getState().subscription).toEqual({+ ...target,+ secondaryChannelId: "ch_parent",+ })++ communityWsReleaseSecondaryChannel(owner)+ expect(useCommunityStore.getState().subscription).toEqual(target)+communityWsUnsubscribe()expect(useCommunityStore.getState().subscription.channelId).toBeUndefined()+ expect(useCommunityStore.getState().subscription.secondaryChannelId).toBeUndefined()expect(useCommunityStore.getState().subscription.dmConversationId).toBeUndefined()})diff --git a/src/web/src/hooks/community/use-community-ws.ts b/src/web/src/hooks/community/use-community-ws.tsindex 6de7a184f..d3b922379 100644--- a/src/web/src/hooks/community/use-community-ws.ts+++ b/src/web/src/hooks/community/use-community-ws.ts@@ -163,7 +163,9 @@ export function _resetActiveSend_forTesting() {* Subscribe to a channel/thread/DM. Free helper so any component can update* the focused subscription without holding a reference to `useCommunityWs`.*/-export function communityWsSubscribe(target: Subscription) {+export function communityWsSubscribe(+ target: Pick<Subscription, "channelId" | "dmConversationId">,+) {useCommunityStore.getState().subscribe(target)}@@ -171,6 +173,14 @@ export function communityWsUnsubscribe() {useCommunityStore.getState().unsubscribe()}+export function communityWsClaimSecondaryChannel(owner: symbol, channelId: string) {+ useCommunityStore.getState().claimSecondaryChannel(owner, channelId)+}++export function communityWsReleaseSecondaryChannel(owner: symbol) {+ useCommunityStore.getState().releaseSecondaryChannel(owner)+}+/*** Send a typing indicator. Client-side debounced at 8s per channelId (a DM is* a channel now, so its id is a channelId too). If no WS is connected, the@@ -355,7 +365,9 @@ export function useCommunityWs(options?: UseCommunityWsOptions): void {// channelId matches either slot.const matchesFocus = (e: { channelId?: string }): boolean => {if (!e.channelId) return false- return e.channelId === sub.channelId || e.channelId === sub.dmConversationId+ return e.channelId === sub.channelId+ || e.channelId === sub.secondaryChannelId+ || e.channelId === sub.dmConversationId}const context = (deliveryMode: "single" | "batch",diff --git a/src/web/src/hooks/community/use-dm-route-verification.test.ts b/src/web/src/hooks/community/use-dm-route-verification.test.tsindex 8d6e603ed..f6d8f1d80 100644--- a/src/web/src/hooks/community/use-dm-route-verification.test.ts+++ b/src/web/src/hooks/community/use-dm-route-verification.test.ts@@ -142,6 +142,31 @@ describe("DM route verification", () => {expect(apiFetchMock).not.toHaveBeenCalled()})+ it("trusts a projected canonical row while the layout observer snapshot lags", async () => {+ const queryClient = client()+ const projected: DM = {+ id: "dm-projected",+ userId: "u-projected",+ name: "Projected peer",+ discriminator: "5555",+ avatar: "P",+ status: "offline",+ preview: "",+ }+ queryClient.setQueryData(communityKeys.dms(), { conversations: [projected] })+ apiFetchMock.mockResolvedValue({ conversations: [] })+ const statuses: DmRouteVerificationStatus[] = []+ const renderer = await renderHook(queryClient, {+ dmId: projected.id,+ dms: [],+ onRender: (status) => statuses.push(status),+ })++ expect(statuses.at(-1)).toBe("present")+ expect(apiFetchMock).not.toHaveBeenCalled()+ renderer.unmount()+ })+it.each([403, 404])("classifies explicit %s as denied", async (status) => {expect(classifyDmRouteAuthorityError({ status })).toBe("denied")})diff --git a/src/web/src/hooks/community/use-dm-route-verification.ts b/src/web/src/hooks/community/use-dm-route-verification.tsindex fae8e4cff..8149d247c 100644--- a/src/web/src/hooks/community/use-dm-route-verification.ts+++ b/src/web/src/hooks/community/use-dm-route-verification.ts@@ -70,7 +70,14 @@ export function useDmRouteVerification(canonicalUnsettled: boolean,): DmRouteVerificationResult {const queryClient = useQueryClient()- const present = !!dmId && dms.some((dm) => dm.id === dmId)+ const canonical = queryClient.getQueryData<DmsResponse>(communityKeys.dms())+ // Inbox navigation writes the destination into the canonical cache before+ // routing. The layout's observer snapshot can trail that synchronous write+ // by one render, so consult the cache directly before starting authority.+ const present = !!dmId && (+ dms.some((dm) => dm.id === dmId)+ || canonical?.conversations.some((dm) => dm.id === dmId) === true+ )const verification = useQuery({...verificationOptions(queryClient, dmId ?? "__none__"),enabled: !!dmId && !canonicalUnsettled && !present,diff --git a/src/web/src/hooks/community/use-dms.test.ts b/src/web/src/hooks/community/use-dms.test.tsindex cb0d5b782..e34c1c62a 100644--- a/src/web/src/hooks/community/use-dms.test.ts+++ b/src/web/src/hooks/community/use-dms.test.ts@@ -38,6 +38,39 @@ describe("useDms / dmsQueryFn", () => {expect(qc.getQueryData(key)).toEqual({ conversations: [] })})+ it("reuses a projected DM across layout mounts without refetching the canonical list", async () => {+ const conversations = [{+ id: "dm_projected",+ userId: "u_1",+ name: "Alice",+ discriminator: "0001",+ avatar: "a",+ status: "offline",+ preview: "projected from inbox",+ }]+ apiFetchMock.mockResolvedValue({ conversations })+ const { useDms } = await import("./use-dms")+ const qc = new QueryClient({ defaultOptions: { queries: { retry: false } } })+ qc.setQueryData(communityKeys.dms(), { conversations })++ function Probe() {+ useDms()+ return null+ }++ let renderer!: TestRenderer.ReactTestRenderer+ await act(async () => {+ renderer = TestRenderer.create(React.createElement(+ QueryClientProvider,+ { client: qc },+ React.createElement(Probe),+ ))+ })++ expect(apiFetchMock).not.toHaveBeenCalled()+ await act(async () => renderer.unmount())+ })+it("projects the canonical peer profile without rewriting the raw DM cache", async () => {const { useDms } = await import("./use-dms")const qc = new QueryClient({ defaultOptions: { queries: { staleTime: Infinity } } })diff --git a/src/web/src/hooks/community/use-dms.ts b/src/web/src/hooks/community/use-dms.tsindex 3b4e4999c..855a8ce60 100644--- a/src/web/src/hooks/community/use-dms.ts+++ b/src/web/src/hooks/community/use-dms.ts@@ -45,6 +45,11 @@ export function useDms(): UseQueryResult<DmsResponse> & { dms: DM[] } {const query = useQuery({queryKey: communityKeys.dms(),queryFn: dmsQueryFn,+ // Inbox navigation projects the destination into this canonical cache+ // before routing. Reusing that projection across /c/me layout mounts keeps+ // the transition request-neutral; WS and reconnect invalidations still+ // refetch this active key explicitly.+ staleTime: Infinity,})const profilesByUserId = useProfilesByUserId()useEffect(() => {diff --git a/src/web/src/hooks/community/use-thread-split-mode.test.ts b/src/web/src/hooks/community/use-thread-split-mode.test.tsnew file mode 100644index 000000000..f35c7b831--- /dev/null+++ b/src/web/src/hooks/community/use-thread-split-mode.test.ts@@ -0,0 +1,141 @@+import React from "react"+import TestRenderer, { act } from "react-test-renderer"+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"+import {+ resolveThreadSplitMode,+ THREAD_SPLIT_MIN_CONTENT_WIDTH,+ useThreadSplitMode,+} from "./use-thread-split-mode"++const mocks = vi.hoisted(() => ({+ breakpoint: "desktop" as "desktop" | "mobile" | "unknown",+ claimSecondary: vi.fn(),+ releaseSecondary: vi.fn(),+}))++vi.mock("@/hooks/use-mobile", () => ({ useBreakpoint: () => mocks.breakpoint }))+vi.mock("@/hooks/community/use-community-ws", () => ({+ communityWsClaimSecondaryChannel: (...args: unknown[]) => mocks.claimSecondary(...args),+ communityWsReleaseSecondaryChannel: (...args: unknown[]) => mocks.releaseSecondary(...args),+}))++function Harness({ forceFullscreen = false }: { forceFullscreen?: boolean }) {+ const split = useThreadSplitMode({ parentChannelId: "parent_1", forceFullscreen })+ return React.createElement("div", { ref: split.containerRef, "data-mode": split.mode })+}++describe("resolveThreadSplitMode", () => {+ it("uses split only when a desktop content pane can hold both conversations", () => {+ expect(resolveThreadSplitMode({+ breakpoint: "desktop",+ contentWidth: THREAD_SPLIT_MIN_CONTENT_WIDTH,+ forceFullscreen: false,+ })).toBe("split")+ expect(resolveThreadSplitMode({+ breakpoint: "desktop",+ contentWidth: THREAD_SPLIT_MIN_CONTENT_WIDTH - 1,+ forceFullscreen: false,+ })).toBe("full")+ })++ it("keeps mobile, unresolved, and explicit fullscreen layouts single-pane", () => {+ for (const breakpoint of ["mobile", "unknown"] as const) {+ expect(resolveThreadSplitMode({ breakpoint, contentWidth: 2000, forceFullscreen: false })).toBe("full")+ }+ expect(resolveThreadSplitMode({+ breakpoint: "desktop",+ contentWidth: 2000,+ forceFullscreen: true,+ })).toBe("full")+ })+})++describe("useThreadSplitMode secondary live subscription", () => {+ let observerCallback: ResizeObserverCallback | null++ beforeEach(() => {+ mocks.breakpoint = "desktop"+ mocks.claimSecondary.mockClear()+ mocks.releaseSecondary.mockClear()+ observerCallback = null+ vi.stubGlobal("ResizeObserver", class {+ constructor(callback: ResizeObserverCallback) { observerCallback = callback }+ observe() {}+ disconnect() {}+ })+ })++ afterEach(() => vi.unstubAllGlobals())++ it("adds the parent only for split mode and clears it for fullscreen", () => {+ let renderer!: TestRenderer.ReactTestRenderer+ act(() => {+ renderer = TestRenderer.create(React.createElement(Harness), {+ createNodeMock: () => ({+ getBoundingClientRect: () => ({ width: THREAD_SPLIT_MIN_CONTENT_WIDTH }),+ }),+ })+ })+ expect(renderer.root.findByType("div").props["data-mode"]).toBe("split")+ expect(mocks.claimSecondary).toHaveBeenCalledWith(expect.any(Symbol), "parent_1")++ act(() => renderer.update(React.createElement(Harness, { forceFullscreen: true })))+ expect(renderer.root.findByType("div").props["data-mode"]).toBe("full")+ expect(mocks.releaseSecondary).toHaveBeenCalledWith(expect.any(Symbol))++ act(() => renderer.unmount())+ expect(mocks.releaseSecondary).toHaveBeenCalledWith(expect.any(Symbol))+ expect(observerCallback).not.toBeNull()+ })++ it("releases the parent before a pane hidden by resize or mobile fallback can stay focused", () => {+ let renderer!: TestRenderer.ReactTestRenderer+ act(() => {+ renderer = TestRenderer.create(React.createElement(Harness), {+ createNodeMock: () => ({+ getBoundingClientRect: () => ({ width: THREAD_SPLIT_MIN_CONTENT_WIDTH }),+ }),+ })+ })+ const owner = mocks.claimSecondary.mock.calls.at(-1)?.[0]++ act(() => {+ observerCallback?.([{+ contentRect: { width: THREAD_SPLIT_MIN_CONTENT_WIDTH - 1 },+ } as unknown as ResizeObserverEntry], {} as ResizeObserver)+ })+ expect(renderer.root.findByType("div").props["data-mode"]).toBe("full")+ expect(mocks.releaseSecondary).toHaveBeenCalledWith(owner)++ mocks.breakpoint = "mobile"+ act(() => renderer.update(React.createElement(Harness)))+ expect(renderer.root.findByType("div").props["data-mode"]).toBe("full")+ expect(mocks.releaseSecondary).toHaveBeenLastCalledWith(owner)+ })++ it("falls back to window resize events when ResizeObserver is unavailable", () => {+ vi.stubGlobal("ResizeObserver", undefined)+ const addEventListener = vi.fn()+ const removeEventListener = vi.fn()+ vi.stubGlobal("window", { addEventListener, removeEventListener })+ let width = THREAD_SPLIT_MIN_CONTENT_WIDTH+ let renderer!: TestRenderer.ReactTestRenderer++ act(() => {+ renderer = TestRenderer.create(React.createElement(Harness), {+ createNodeMock: () => ({ getBoundingClientRect: () => ({ width }) }),+ })+ })+ expect(renderer.root.findByType("div").props["data-mode"]).toBe("split")+ const resizeListener = addEventListener.mock.calls+ .find(([type]) => type === "resize")?.[1] as () => void+ expect(resizeListener).toEqual(expect.any(Function))++ width -= 1+ act(() => resizeListener())+ expect(renderer.root.findByType("div").props["data-mode"]).toBe("full")++ act(() => renderer.unmount())+ expect(removeEventListener).toHaveBeenCalledWith("resize", resizeListener)+ })+})diff --git a/src/web/src/hooks/community/use-thread-split-mode.ts b/src/web/src/hooks/community/use-thread-split-mode.tsnew file mode 100644index 000000000..875fdc0d0--- /dev/null+++ b/src/web/src/hooks/community/use-thread-split-mode.ts@@ -0,0 +1,67 @@+"use client"++import { useCallback, useLayoutEffect, useState, type RefCallback } from "react"+import { useBreakpoint, type Breakpoint } from "@/hooks/use-mobile"+import {+ communityWsClaimSecondaryChannel,+ communityWsReleaseSecondaryChannel,+} from "@/hooks/community/use-community-ws"++export const THREAD_SPLIT_MIN_CONTENT_WIDTH = 880++export function resolveThreadSplitMode({+ breakpoint,+ contentWidth,+ forceFullscreen,+}: {+ breakpoint: Breakpoint+ contentWidth: number+ forceFullscreen: boolean+}): "split" | "full" {+ if (forceFullscreen || breakpoint !== "desktop") return "full"+ return contentWidth >= THREAD_SPLIT_MIN_CONTENT_WIDTH ? "split" : "full"+}++export function useThreadSplitMode({+ parentChannelId,+ forceFullscreen,+}: {+ parentChannelId: string | null+ forceFullscreen: boolean+}): {+ containerRef: RefCallback<HTMLElement>+ mode: "split" | "full"+} {+ const breakpoint = useBreakpoint()+ const [subscriptionOwner] = useState(() => Symbol("thread-split-secondary"))+ const [container, setContainer] = useState<HTMLElement | null>(null)+ const [contentWidth, setContentWidth] = useState(0)+ const containerRef = useCallback((node: HTMLElement | null) => setContainer(node), [])++ useLayoutEffect(() => {+ if (!container) return+ const measure = () => setContentWidth(container.getBoundingClientRect().width)+ measure()+ if (typeof ResizeObserver === "undefined") {+ window.addEventListener("resize", measure)+ return () => window.removeEventListener("resize", measure)+ }+ const observer = new ResizeObserver(([entry]) => {+ setContentWidth(entry?.contentRect.width ?? container.getBoundingClientRect().width)+ })+ observer.observe(container)+ return () => observer.disconnect()+ }, [container])++ const mode = resolveThreadSplitMode({ breakpoint, contentWidth, forceFullscreen })+ useLayoutEffect(() => {+ if (mode === "split" && parentChannelId) {+ communityWsClaimSecondaryChannel(subscriptionOwner, parentChannelId)+ } else {+ communityWsReleaseSecondaryChannel(subscriptionOwner)+ }+ return () => communityWsReleaseSecondaryChannel(subscriptionOwner)+ }, [mode, parentChannelId, subscriptionOwner])++ return { containerRef, mode }+}diff --git a/src/web/src/lib/community/testids.test.ts b/src/web/src/lib/community/testids.test.tsindex f587f756e..159fee1d3 100644--- a/src/web/src/lib/community/testids.test.ts+++ b/src/web/src/lib/community/testids.test.ts@@ -54,6 +54,14 @@ describe("community QA selectors", () => {expect(tid.reactionEmpty("message_1")).toBe("community-reaction-empty-message_1")})+ it("exposes the desktop thread split surfaces and actions", () => {+ expect(tid.threadSplit).toBe("community-thread-split")+ expect(tid.threadSplitParent).toBe("community-thread-split-parent")+ expect(tid.threadSplitPanel).toBe("community-thread-split-panel")+ expect(tid.threadSplitFullscreen).toBe("community-thread-split-fullscreen")+ expect(tid.threadSplitClose).toBe("community-thread-split-close")+ })+it("keys a pending channel sidebar by its target server", () => {expect(tid.channelSidebarPending("server_1")).toBe("community-channel-sidebar-pending-server_1")diff --git a/src/web/src/lib/community/testids.ts b/src/web/src/lib/community/testids.tsindex b33ba1021..bb9fd4e61 100644--- a/src/web/src/lib/community/testids.ts+++ b/src/web/src/lib/community/testids.ts@@ -143,6 +143,21 @@ export const tid = {`message-share-image-${msgId}-${index}`,messageShareCopy: `community-message-share-copy`,threadIndicator: (msgId: string) => `community-thread-indicator-${msgId}`,+ get threadSplit() {+ return "community-thread-split" as const+ },+ get threadSplitParent() {+ return "community-thread-split-parent" as const+ },+ get threadSplitPanel() {+ return "community-thread-split-panel" as const+ },+ get threadSplitFullscreen() {+ return "community-thread-split-fullscreen" as const+ },+ get threadSplitClose() {+ return "community-thread-split-close" as const+ },railUnreadBadge: (serverId: string) => `community-rail-unread-badge-${serverId}`,// Forum post feed (ForumView). `forumThreadCard` is the whole clickable card;// `forumThreadTitle` / `forumThreadTitleText` expose the clamped title clusterdiff --git a/src/web/src/stores/community/index.test.ts b/src/web/src/stores/community/index.test.tsindex 979283905..ac7a54b7a 100644--- a/src/web/src/stores/community/index.test.ts+++ b/src/web/src/stores/community/index.test.ts@@ -18,6 +18,7 @@ describe("useCommunityStore", () => {expect(s.lastTypingSent.size).toBe(0)expect(s.reactionTimers.size).toBe(0)expect(s.pendingMachineTokenId).toBeNull()+ expect(s.secondaryChannelOwner).toBeNull()expect(s.subscription).toEqual({})expect(s.uiHandlers).toEqual({})})@@ -48,9 +49,7 @@ describe("useCommunityStore", () => {it("subscribe / unsubscribe mutate the subscription slot", () => {useCommunityStore.getState().subscribe({ channelId: "c1" })- expect(useCommunityStore.getState().subscription).toEqual({- channelId: "c1",- })+ expect(useCommunityStore.getState().subscription).toEqual({ channelId: "c1" })useCommunityStore.getState().subscribe({ dmConversationId: "d1" })expect(useCommunityStore.getState().subscription).toEqual({@@ -61,6 +60,57 @@ describe("useCommunityStore", () => {expect(useCommunityStore.getState().subscription).toEqual({})})+ it("sets and clears the split-view secondary channel without replacing the primary", () => {+ const store = useCommunityStore.getState()+ const owner = Symbol("split")+ store.subscribe({ channelId: "thread" })++ store.claimSecondaryChannel(owner, "parent")+ expect(useCommunityStore.getState().subscription).toEqual({+ channelId: "thread",+ secondaryChannelId: "parent",+ })++ const first = useCommunityStore.getState().subscription+ store.claimSecondaryChannel(owner, "parent")+ expect(useCommunityStore.getState().subscription).toBe(first)++ store.releaseSecondaryChannel(owner)+ expect(useCommunityStore.getState().subscription).toEqual({ channelId: "thread" })+ })++ it("preserves the owned secondary channel when the primary route re-subscribes", () => {+ const store = useCommunityStore.getState()+ const owner = Symbol("split")+ store.subscribe({ channelId: "thread_1" })+ store.claimSecondaryChannel(owner, "parent")++ store.subscribe({ channelId: "thread_2" })+ expect(useCommunityStore.getState().subscription).toEqual({+ channelId: "thread_2",+ secondaryChannelId: "parent",+ })+ expect(useCommunityStore.getState().secondaryChannelOwner).toBe(owner)+ })++ it("does not let a stale split cleanup erase the current secondary or primary", () => {+ const store = useCommunityStore.getState()+ const staleOwner = Symbol("stale")+ const currentOwner = Symbol("current")+ store.subscribe({ channelId: "thread_2" })+ store.claimSecondaryChannel(staleOwner, "parent_1")+ store.claimSecondaryChannel(currentOwner, "parent_2")++ store.releaseSecondaryChannel(staleOwner)+ expect(useCommunityStore.getState().subscription).toEqual({+ channelId: "thread_2",+ secondaryChannelId: "parent_2",+ })++ store.releaseSecondaryChannel(currentOwner)+ expect(useCommunityStore.getState().subscription).toEqual({ channelId: "thread_2" })+ })+it("subscribe bails out when the target is unchanged (identity foot-gun fix)", () => {// The pre-fix behaviour spread `{ ...target }` on every call, producing a// fresh object even when the pointers were identical — every subscriber@@ -160,6 +210,7 @@ describe("useCommunityStore", () => {expect(after.lastTypingSent.size).toBe(0)expect(after.reactionTimers.size).toBe(0)expect(after.pendingMachineTokenId).toBeNull()+ expect(after.secondaryChannelOwner).toBeNull()expect(after.subscription).toEqual({})expect(after.uiHandlers).toEqual({})} finally {diff --git a/src/web/src/stores/community/index.ts b/src/web/src/stores/community/index.tsindex bf3e3c6bc..9bc0edd34 100644--- a/src/web/src/stores/community/index.ts+++ b/src/web/src/stores/community/index.ts@@ -65,6 +65,10 @@ type CurrentChannelMeta = {type CommunitySubscription = {channelId?: string+ // A second visible channel in desktop thread split view. This is never a+ // second transport subscription: the user socket already receives both;+ // it only tells the client projector that both mounted feeds are focused.+ secondaryChannelId?: string// The focused DM's channel id. A DM is a channel now; the slot name is kept// only to distinguish "the focused channel is a DM" for the WS handler's// cache-routing (see `use-community-ws.ts`).@@ -78,12 +82,10 @@ type CommunityUiHandlers = {goBackMobile?: () => voidnavigatePath?: (href: string) => voidreplacePath?: (href: string) => void- // Jump to message `seq` within the CURRENT channel/DM — the page registers- // this (message already loaded → scroll to it; otherwise open the context- // sheet, which resolves seq→id server-side). A same-channel message ref pill- // (`/server/channel#N` where the channel is the open one) invokes it so- // clicking still scrolls to the message — the behavior the bare-`#N` pill had- // before message-ref-upgrade.md removed it.+ // Jump to message `seq` within the CURRENT DM. Channel surfaces provide the+ // same behavior through a pane-local context so two visible split panes never+ // compete for this global slot. A same-scope message ref pill invokes it when+ // the message is loaded; otherwise its owning pane opens message context.jumpToSeq?: (seq: number) => voidcancelPendingNavigation?: () => void// Navigate to a server (channelId omitted) or a channel. Registered by the@@ -96,10 +98,10 @@ type CommunityUiHandlers = {// (A message ref does NOT navigate — it opens the context sheet in place via// `openMessageContext`; only a plain channel/server ref navigates.)navigate?: (serverId: string, channelId?: string) => void- // Open the message context side sheet IN PLACE for a message ref — the- // channel page registers this. A message ref's intent is "see that message's- // context", not "go to that channel" (Gus #417), so clicking it never- // navigates: the sheet resolves the target channel's seq→id + surrounding+ // Fallback for surfaces without a pane-local message-navigation context.+ // Channel panes own this behavior locally; a message ref's intent remains+ // "see that message's context", not "go to that channel" (Gus #417). The+ // sheet resolves the target channel's seq→id + surrounding// messages (via the access-checked read path — a private channel the viewer// can't see returns not-found, no leak) and shows them without leaving the// current channel. `label` is the source channel's display name for the sheet@@ -148,6 +150,8 @@ export type CommunityStoreState = {// Reply → navigate → destination page seeds its composer). See `PendingReply`.pendingReply: PendingReply | null+ secondaryChannelOwner: symbol | null+// What the WS handler should treat as "focused" for setQueryData vs// invalidate routing.subscription: CommunitySubscription@@ -160,7 +164,9 @@ export type CommunityStoreState = {setCurrentServerId: (id: string | null) => voidsetCurrentChannelId: (id: string | null) => voidsetCurrentChannelMeta: (meta: CurrentChannelMeta | null) => void- subscribe: (target: CommunitySubscription) => void+ subscribe: (target: Pick<CommunitySubscription, "channelId" | "dmConversationId">) => void+ claimSecondaryChannel: (owner: symbol, id: string) => void+ releaseSecondaryChannel: (owner: symbol) => voidunsubscribe: () => voidsetPendingMachineTokenId: (tokenId: string | null) => voidsetPendingReply: (reply: PendingReply | null) => void@@ -181,6 +187,7 @@ const initialState = (): Pick<| "reactionTimers"| "pendingMachineTokenId"| "pendingReply"+ | "secondaryChannelOwner"| "subscription"| "uiHandlers"> => ({@@ -193,6 +200,7 @@ const initialState = (): Pick<reactionTimers: new Map(),pendingMachineTokenId: null,pendingReply: null,+ secondaryChannelOwner: null,subscription: {},uiHandlers: {},})@@ -215,7 +223,8 @@ export const useCommunityStore = create<CommunityStoreState>((set, get) => ({// `set({ subscription: { ...target } })` on every mount would produce a// fresh reference each call and force every subscriber to re-render even// when nothing changed. Deep-compare the two known keys; only write on a- // real diff.+ // real diff. Secondary focus has a separate owner and lifecycle, so route+ // subscriptions preserve it rather than racing the split layout effect.const prev = get().subscriptionif (prev.channelId === target.channelId &&@@ -223,15 +232,38 @@ export const useCommunityStore = create<CommunityStoreState>((set, get) => ({) {return}- set({ subscription: { ...target } })+ set({+ subscription: {+ ...target,+ ...(prev.secondaryChannelId ? { secondaryChannelId: prev.secondaryChannelId } : {}),+ },+ })+ },++ claimSecondaryChannel: (owner, id) => {+ const prev = get().subscription+ if (get().secondaryChannelOwner === owner && prev.secondaryChannelId === id) return+ set({+ subscription: {+ ...prev,+ secondaryChannelId: id,+ },+ secondaryChannelOwner: owner,+ })+ },++ releaseSecondaryChannel: (owner) => {+ if (get().secondaryChannelOwner !== owner) return+ const { secondaryChannelId: _secondaryChannelId, ...subscription } = get().subscription+ set({ subscription, secondaryChannelOwner: null })},unsubscribe: () => {// Same reasoning as `subscribe` — don't churn the reference if it's// already empty.const prev = get().subscription- if (!prev.channelId && !prev.dmConversationId) return- set({ subscription: {} })+ if (!prev.channelId && !prev.secondaryChannelId && !prev.dmConversationId) return+ set({ subscription: {}, secondaryChannelOwner: null })},setPendingMachineTokenId: (tokenId) =>diff --git a/src/web/src/test/e2e-ui/04-dm.spec.ts b/src/web/src/test/e2e-ui/04-dm.spec.tsindex 691043eee..02b919699 100644--- a/src/web/src/test/e2e-ui/04-dm.spec.ts+++ b/src/web/src/test/e2e-ui/04-dm.spec.ts@@ -201,17 +201,21 @@ test.describe.serial("direct messages", () => {try {await alice.page.goto(`/c/me/${missingDmId}`)- await expect(alice.page.getByRole("alert").filter({+ const verificationAlert = alice.page.getByRole("alert").filter({hasText: "Couldn\'t verify this conversation",- })).toBeVisible()+ })+ await expect(verificationAlert).toBeVisible()await expect(alice.page).toHaveURL(new RegExp(`/c/me/${missingDmId}$`))await expect.poll(() => wsProxy.heldConnectionCount()).toBe(1)expect(dmsGets).toBe(2)- await alice.page.getByRole("button", { name: "Retry" }).click()+ expect(wsProxy.releaseHeldConnections((frame) => frame.type === "auth.ok")).toBe(1)+ await expect(alice.page.getByTestId(tid.wsReconnectOverlay)).toHaveCount(0)+ await verificationAlert.getByRole("button", { name: "Retry" }).click()await expect.poll(() => dmsGets).toBe(3)await expect.poll(() => new URL(alice.page.url()).pathname).toBe("/c/me/friends")} finally {+ wsProxy.releaseHeldConnections()await alice.page.unroute(dmsPattern)}})diff --git a/src/web/src/test/e2e-ui/09-forum-thread.spec.ts b/src/web/src/test/e2e-ui/09-forum-thread.spec.tsindex 9b9ca2177..059444283 100644--- a/src/web/src/test/e2e-ui/09-forum-thread.spec.ts+++ b/src/web/src/test/e2e-ui/09-forum-thread.spec.ts@@ -54,11 +54,12 @@ test.describe.serial("threads", () => {const threadId = new URL(page.url()).pathname.split("/").at(-1)!const threadMessagesResponse = await threadMessagesLoadedexpect(new URL(threadMessagesResponse.url()).pathname).toBe(`/api/community/channels/${threadId}/messages`)- await expect(composerEditable(page)).toBeVisible()+ const threadPanel = page.getByTestId(tid.threadSplitPanel)+ await expect(composerEditable(page, threadPanel)).toBeVisible()// The thread is usable: a reply posts and appears in the thread view.const reply = `first reply ${Date.now()}`- await sendMessage(page, reply)+ await sendMessage(page, reply, threadPanel)await expect(page.getByText(reply, { exact: false }).first()).toBeVisible({ timeout: 15_000 })const exactChannelRequests = requests.filter((requestUrl) =>diff --git a/src/web/src/test/e2e-ui/15-mention-scope.spec.ts b/src/web/src/test/e2e-ui/15-mention-scope.spec.tsindex 2ebb6bd82..30d056fe2 100644--- a/src/web/src/test/e2e-ui/15-mention-scope.spec.ts+++ b/src/web/src/test/e2e-ui/15-mention-scope.spec.ts@@ -1,3 +1,4 @@+import type { Locator, Page } from "@playwright/test"import { test, expect, userId } from "./_fixtures/community-fixture"import { tid } from "./_fixtures/testids"import { composerEditable } from "./_fixtures/actions"@@ -78,8 +79,8 @@ test.describe.serial("mentions — candidate scope", () => {// virtual row id is the literal "everyone". (@here was removed —// plans/remove-here-mention.md; `here` is exposed here only to assert its// ABSENCE.)- async function openMentionPopup(page: import("@playwright/test").Page) {- const editable = composerEditable(page)+ async function openMentionPopup(page: Page, root: Page | Locator = page) {+ const editable = composerEditable(page, root)await editable.click()await editable.pressSequentially("@")return {@@ -149,7 +150,7 @@ test.describe.serial("mentions — candidate scope", () => {await page.goto(`/c/channels/${serverId}/${threadId}`)await page.waitForURL(new RegExp(threadId), { timeout: 20_000, waitUntil: "commit" })- const opt = await openMentionPopup(page)+ const opt = await openMentionPopup(page, page.getByTestId(tid.threadSplitPanel))// Bob is in the PARENT channel's audience; a thread has no roster of its own,// so bob is mentionable here even though he isn't a thread participant yet.await expect(opt.bob).toBeVisible({ timeout: 15_000 })@@ -163,7 +164,7 @@ test.describe.serial("mentions — candidate scope", () => {await page.goto(`/c/channels/${serverId}/${privatePostId}`)await page.waitForURL(new RegExp(privatePostId), { timeout: 20_000, waitUntil: "commit" })- const opt = await openMentionPopup(page)+ const opt = await openMentionPopup(page, page.getByTestId(tid.threadSplitPanel))await expect(opt.bob).toBeVisible({ timeout: 15_000 })await expect(opt.everyone).toBeVisible()await expect(opt.carol).toHaveCount(0)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.tsindex d1e62a8a8..6d36d5a56 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@@ -60,6 +60,10 @@ async function routeStability(page: Page) {}).__routeStability)}+function childPanel(page: Page) {+ return page.getByTestId(tid.threadSplitPanel)+}+async function participantUserIds(page: Page, channelId: string): Promise<string[]> {const response = await page.request.get(`/api/community/channels/${channelId}/members`)expect(response.status()).toBe(200)@@ -194,8 +198,8 @@ test.describe.serial("forum sidebar Stage B request shape", () => {await expect.poll(() => new URL(page.url()).pathname).toBe(`/c/channels/${serverId}/${threadId}`,)- await expect(page.getByRole("heading", { name: forumTitle })).toBeVisible({ timeout: 20_000 })- await expect(page.getByText("post body", { exact: true })).toBeVisible({ timeout: 20_000 })+ await expect(childPanel(page).getByRole("heading", { name: forumTitle })).toBeVisible({ timeout: 20_000 })+ await expect(childPanel(page).getByText("post body", { exact: true })).toBeVisible({ timeout: 20_000 })await expect(page.locator('[data-slot="skeleton"]')).toHaveCount(0)const coldSidebarRequests = requests.filter((url) => isSidebarRequest(url, serverId))@@ -229,8 +233,8 @@ test.describe.serial("forum sidebar Stage B request shape", () => {await expect.poll(() => new URL(page.url()).pathname).toBe(`/c/channels/${serverId}/${threadId}`,)- await expect(page.getByRole("heading", { name: forumTitle })).toBeVisible({ timeout: 20_000 })- await expect(page.getByText("post body", { exact: true })).toBeVisible({ timeout: 20_000 })+ await expect(childPanel(page).getByRole("heading", { name: forumTitle })).toBeVisible({ timeout: 20_000 })+ await expect(childPanel(page).getByText("post body", { exact: true })).toBeVisible({ timeout: 20_000 })await expect(page.locator('[data-slot="skeleton"]')).toHaveCount(0)await page.waitForTimeout(2_000) // late exact-channel/message fetch exclusion window@@ -268,8 +272,8 @@ test.describe.serial("forum sidebar Stage B request shape", () => {await expect.poll(() => new URL(page.url()).pathname).toBe(`/c/channels/${serverId}/${threadId}`,)- await expect(page.getByRole("heading", { name: forumTitle })).toBeVisible({ timeout: 20_000 })- await expect(page.getByText("post body", { exact: true })).toBeVisible({ timeout: 20_000 })+ await expect(childPanel(page).getByRole("heading", { name: forumTitle })).toBeVisible({ timeout: 20_000 })+ await expect(childPanel(page).getByText("post body", { exact: true })).toBeVisible({ timeout: 20_000 })await expect(page.locator('[data-slot="skeleton"]')).toHaveCount(0)await page.waitForTimeout(2_000) // late duplicate anchored/unanchored fetch exclusion window@@ -305,8 +309,8 @@ test.describe.serial("forum sidebar Stage B request shape", () => {expect(await participantUserIds(page, threadId)).not.toContain(userId("bob"))await page.goto(`/c/channels/${serverId}/${threadId}`)- await expect(page.getByTestId(tid.channelComposerShell)).toBeVisible({ timeout: 20_000 })- await expect(page.getByText("post body", { exact: true })).toBeVisible({ timeout: 20_000 })+ await expect(childPanel(page).getByTestId(tid.channelComposerShell)).toBeVisible({ timeout: 20_000 })+ await expect(childPanel(page).getByText("post body", { exact: true })).toBeVisible({ timeout: 20_000 })await expect.poll(() => sidebarResponses.some(({ url }) =>new URL(url).searchParams.get("retainId") === threadId,)).toBe(true)@@ -322,7 +326,7 @@ test.describe.serial("forum sidebar Stage B request shape", () => {expect(await participantUserIds(page, threadId)).not.toContain(userId("bob"))const reply = `bob joins ${Date.now()}`- await sendMessage(page, reply)+ await sendMessage(page, reply, childPanel(page))await expect(page.getByText(reply, { exact: true })).toBeVisible({ timeout: 20_000 })await expect.poll(async () => participantUserIds(page, threadId)).toContain(userId("bob"))})@@ -351,8 +355,8 @@ test.describe.serial("forum sidebar Stage B request shape", () => {await expect.poll(() => new URL(page.url()).pathname).toBe(`/c/channels/${serverId}/${threadId}`,)- await expect(page.getByTestId(tid.channelComposerShell)).toBeVisible({ timeout: 20_000 })- await expect(page.getByText("post body", { exact: true })).toBeVisible({ timeout: 20_000 })+ await expect(childPanel(page).getByTestId(tid.channelComposerShell)).toBeVisible({ timeout: 20_000 })+ await expect(childPanel(page).getByText("post body", { exact: true })).toBeVisible({ timeout: 20_000 })await expect.poll(() => sidebarResponses.filter(({ url }) =>new URL(url).searchParams.get("retainId") === threadId,).length).toBe(1)@@ -384,8 +388,8 @@ test.describe.serial("forum sidebar Stage B request shape", () => {expect(await participantUserIds(page, ordinaryThreadId)).not.toContain(userId("bob"))await page.goto(`/c/channels/${serverId}/${ordinaryThreadId}`)- await expect(page.getByTestId(tid.channelComposerShell)).toBeVisible({ timeout: 20_000 })- await expect(page.getByText("ordinary thread opener", { exact: true })).toBeVisible({ timeout: 20_000 })+ await expect(childPanel(page).getByTestId(tid.channelComposerShell)).toBeVisible({ timeout: 20_000 })+ await expect(childPanel(page).getByText("ordinary thread opener", { exact: true })).toBeVisible({ timeout: 20_000 })await page.waitForTimeout(2_000)expect(successfulResponses.filter((url) => isExactChannelRequest(url, ordinaryThreadId)))@@ -426,7 +430,7 @@ test.describe.serial("forum sidebar Stage B request shape", () => {await expect.poll(() => new URL(page.url()).pathname).toBe(`/c/channels/${serverId}/${threadId}`,)- await expect(page.getByRole("heading", { name: forumTitle })).toBeVisible({ timeout: 20_000 })+ await expect(childPanel(page).getByRole("heading", { name: forumTitle })).toBeVisible({ timeout: 20_000 })expect(requests.filter((url) => isSidebarRequest(url, serverId))).toHaveLength(0)await page.goBack()@@ -489,11 +493,11 @@ test.describe.serial("forum sidebar archived opener projection", () => {expect((await exact.json() as { archived: boolean | number }).archived).toBeFalsy()await viewer.page.goto(`/c/channels/${serverId}/${archivedId}`)- await expect(viewer.page.getByRole("heading", { name: titles.get(archivedId)! })).toBeVisible({+ await expect(childPanel(viewer.page).getByRole("heading", { name: titles.get(archivedId)! })).toBeVisible({timeout: 20_000,})- await expect(viewer.page.getByText(bodies.get(archivedId)!, { exact: true })).toBeVisible()- await expect(viewer.page.getByTestId(tid.channelComposerShell)).toBeVisible()+ await expect(childPanel(viewer.page).getByText(bodies.get(archivedId)!, { exact: true })).toBeVisible()+ await expect(childPanel(viewer.page).getByTestId(tid.channelComposerShell)).toBeVisible()await expect(viewer.page.getByTestId(tid.forumSidebarThread(archivedId))).toHaveCount(0)await viewer.page.goto(`/c/channels/${serverId}/${forumId}`)diff --git a/src/web/src/test/e2e-ui/33-picker-async-layout.spec.ts b/src/web/src/test/e2e-ui/33-picker-async-layout.spec.tsindex cffb01dc4..b823a54ed 100644--- a/src/web/src/test/e2e-ui/33-picker-async-layout.spec.ts+++ b/src/web/src/test/e2e-ui/33-picker-async-layout.spec.ts@@ -1,5 +1,6 @@-import type { Locator } from "@playwright/test"+import type { Locator, Page } from "@playwright/test"import { expect, test, userId } from "./_fixtures/community-fixture"+import { tid } from "./_fixtures/testids"import {memberInfo,renameUser,@@ -28,6 +29,15 @@ async function expectTitleClearOfClose(dialog: Locator, width: 390 | 1280) {.toBeLessThanOrEqual(close!.x)}+async function openDesktopThreadMemberList(page: Page) {+ const shell = page.getByTestId(tid.threadSplit)+ const threadPanel = page.getByTestId(tid.threadSplitPanel)+ await expect(shell).toHaveAttribute("data-layout", "split", { timeout: 20_000 })+ await threadPanel.getByTestId(tid.threadSplitFullscreen).click()+ await expect(shell).toHaveAttribute("data-layout", "full")+ await threadPanel.getByRole("button", { name: "Member list" }).click()+}+test.describe.serial("invite and participant picker async states", () => {test.setTimeout(180_000)@@ -200,8 +210,7 @@ test.describe.serial("invite and participant picker async states", () => {})await page.goto(`/c/channels/${participantServerId}/${failureThreadId}`)- await expect(page.getByRole("button", { name: /member/i }).first()).toBeVisible({ timeout: 20_000 })- await page.getByRole("button", { name: /member/i }).first().click()+ await openDesktopThreadMemberList(page)await expect(page.getByRole("button", { name: "Add members" })).toBeVisible({ timeout: 20_000 })await page.getByRole("button", { name: "Add members" }).click()const dialog = page.getByRole("dialog")@@ -238,8 +247,7 @@ test.describe.serial("invite and participant picker async states", () => {})await page.goto(`/c/channels/${participantServerId}/${emptyThreadId}`)- await expect(page.getByRole("button", { name: /member/i }).first()).toBeVisible({ timeout: 20_000 })- await page.getByRole("button", { name: /member/i }).first().click()+ await openDesktopThreadMemberList(page)await page.getByRole("button", { name: "Add members" }).click()const dialog = page.getByRole("dialog")await expect(dialog.locator('[data-slot="people-picker-loading"]')).toBeVisible()@@ -272,8 +280,7 @@ test.describe.serial("invite and participant picker async states", () => {})await page.goto(`/c/channels/${participantServerId}/${parentFailureThreadId}`)- await expect(page.getByRole("button", { name: /member/i }).first()).toBeVisible({ timeout: 20_000 })- await page.getByRole("button", { name: /member/i }).first().click()+ await openDesktopThreadMemberList(page)await page.getByRole("button", { name: "Add members" }).click()const dialog = page.getByRole("dialog")await expect(dialog.getByText("Couldn't load people.", { exact: true })).toBeVisible({ timeout: 20_000 })@@ -296,8 +303,9 @@ test.describe.serial("invite and participant picker async states", () => {const { page } = await asUser("alice")await page.setViewportSize({ width: 390, height: 844 })await page.goto(`/c/channels/${participantServerId}/${mutationThreadId}`)- await expect(page.getByRole("button", { name: /member/i }).first()).toBeVisible({ timeout: 20_000 })- await page.getByRole("button", { name: /member/i }).first().click()+ const threadPanel = page.getByTestId(tid.threadSplitPanel)+ await expect(threadPanel.getByRole("button", { name: /member/i }).first()).toBeVisible({ timeout: 20_000 })+ await threadPanel.getByRole("button", { name: /member/i }).first().click()await page.getByRole("button", { name: "Add members" }).click()const dialog = page.getByRole("dialog")await expect(dialog.getByText(bobName, { exact: true })).toBeVisible({ timeout: 20_000 })diff --git a/src/web/src/test/e2e-ui/34-inbox-read-race.spec.ts b/src/web/src/test/e2e-ui/34-inbox-read-race.spec.tsindex a0aea76e5..28d67835e 100644--- a/src/web/src/test/e2e-ui/34-inbox-read-race.spec.ts+++ b/src/web/src/test/e2e-ui/34-inbox-read-race.spec.ts@@ -364,6 +364,8 @@ test.describe.serial("Inbox/read refresh ownership", () => {expect(first).toMatchObject({ openerUnread: true })expect(later).toMatchObject({ openerUnread: true })+ await page.setViewportSize({ width: 768, height: 844 })+const parentTargets: string[] = []const childTargets: string[] = []page.on("request", (request) => {@@ -430,6 +432,7 @@ test.describe.serial("Inbox/read refresh ownership", () => {await seedMessage("alice", nonParticipantChildId, `Invisible child reply ${stamp}`)await seedMessage("alice", parentId, `Later parent message ${stamp}`)+ await page.setViewportSize({ width: 768, height: 844 })await gotoAfterUserWsAuth(page, "/c/me")const unreadResponse = await page.request.get("/api/community/users/me/inbox/unreads")expect(unreadResponse.status()).toBe(200)diff --git a/src/web/src/test/e2e-ui/38-community-navigation-checkpoint-matrix.spec.ts b/src/web/src/test/e2e-ui/38-community-navigation-checkpoint-matrix.spec.tsindex dc3aaf436..b51e672f3 100644--- a/src/web/src/test/e2e-ui/38-community-navigation-checkpoint-matrix.spec.ts+++ b/src/web/src/test/e2e-ui/38-community-navigation-checkpoint-matrix.spec.ts@@ -24,6 +24,10 @@ async function holdRoute(page: Page, pathname: string) {}}+function channelHeader(page: Page, name: string) {+ return page.getByRole("banner").getByText(name, { exact: true })+}+test("community checkpoint keeps the committed frame live until navigation commits", async ({ asUser }) => {test.setTimeout(120_000)const stamp = Date.now()@@ -35,7 +39,7 @@ test("community checkpoint keeps the committed frame live until navigation commiconst { page } = await asUser("alice")await page.setViewportSize({ width: 1280, height: 900 })await page.goto(`/c/channels/${serverId}/${channelA}`)- await expect(page.getByRole("heading", { name: channelAName })).toBeVisible({ timeout: 30_000 })+ await expect(channelHeader(page, channelAName)).toBeVisible({ timeout: 30_000 })const readOnlyPostPaths = new Set(["/api/community/messages/batch",@@ -56,12 +60,12 @@ test("community checkpoint keeps the committed frame live until navigation commiawait page.getByTestId(tid.channelRow(channelB)).click({ noWaitAfter: true })await expect.poll(leafGate.held).toBeGreaterThan(0)await expect(page.getByLabel("Loading conversation")).toHaveCount(0)- await expect(page.getByRole("heading", { name: channelAName })).toBeVisible()+ await expect(channelHeader(page, channelAName)).toBeVisible()await page.waitForTimeout(150)await expect(page.getByLabel("Loading conversation")).toHaveCount(0)- await expect(page.getByRole("heading", { name: channelAName })).toBeVisible()+ await expect(channelHeader(page, channelAName)).toBeVisible()await leafGate.release()- await expect(page.getByRole("heading", { name: channelBName })).toBeVisible({ timeout: 30_000 })+ await expect(channelHeader(page, channelBName)).toBeVisible({ timeout: 30_000 })await page.setViewportSize({ width: 390, height: 844 })const rootGate = await holdRoute(page, `/c/channels/${serverId}`)@@ -69,12 +73,12 @@ test("community checkpoint keeps the committed frame live until navigation commiawait expect.poll(rootGate.held).toBeGreaterThan(0)await page.setViewportSize({ width: 1280, height: 900 })await expect(page.getByLabel("Loading conversation")).toHaveCount(0)- await expect(page.getByRole("heading", { name: channelBName })).toBeVisible()+ await expect(channelHeader(page, channelBName)).toBeVisible()await page.waitForTimeout(150)await expect(page.getByLabel("Loading conversation")).toHaveCount(0)- await expect(page.getByRole("heading", { name: channelBName })).toBeVisible()+ await expect(channelHeader(page, channelBName)).toBeVisible()await rootGate.release()- await expect(page.getByRole("heading", { name: channelBName })).toBeVisible({ timeout: 30_000 })+ await expect(channelHeader(page, channelBName)).toBeVisible({ timeout: 30_000 })await page.goto("/c/me/friends")await expect(page.getByPlaceholder("Search friends")).toBeVisible({ timeout: 30_000 })diff --git a/src/web/src/test/e2e-ui/40-mobile-server-header-hierarchy.spec.ts b/src/web/src/test/e2e-ui/40-mobile-server-header-hierarchy.spec.tsindex 0a40f6aaa..1859cd568 100644--- a/src/web/src/test/e2e-ui/40-mobile-server-header-hierarchy.spec.ts+++ b/src/web/src/test/e2e-ui/40-mobile-server-header-hierarchy.spec.ts@@ -1,4 +1,4 @@-import type { Page } from "@playwright/test"+import type { Page, Request } from "@playwright/test"import { test, expect } from "./_fixtures/community-fixture"import {seedChannel,@@ -32,6 +32,42 @@ async function expectParentBack(page: Page, serverId: string) {return back}+function observeColdBootServerReconciliation(page: Page, serverId: string) {+ const readStatePath = "/api/community/users/me/read-state"+ const expectedPaths = new Set([+ `/api/community/servers/${serverId}/categories`,+ `/api/community/servers/${serverId}/channels`,+ `/api/community/servers/${serverId}/unreads`,+ ])+ const reconciliationPaths = new Set(["/api/community/servers", ...expectedPaths])+ const observedPaths = new Set<string>()+ const pending = new Set<Request>()+ let readStateSettled = false++ const onRequest = (request: Request) => {+ const pathname = new URL(request.url()).pathname+ if (!readStateSettled || !reconciliationPaths.has(pathname)) return+ if (expectedPaths.has(pathname)) observedPaths.add(pathname)+ pending.add(request)+ }+ const onSettled = (request: Request) => {+ if (new URL(request.url()).pathname === readStatePath) readStateSettled = true+ pending.delete(request)+ }+ page.on("request", onRequest)+ page.on("requestfinished", onSettled)+ page.on("requestfailed", onSettled)++ return {+ done: () => observedPaths.size === expectedPaths.size && pending.size === 0,+ dispose: () => {+ page.off("request", onRequest)+ page.off("requestfinished", onSettled)+ page.off("requestfailed", onSettled)+ },+ }+}+test.describe.serial("mobile server header direct hierarchy", () => {let serverId: stringlet textId: string@@ -95,11 +131,16 @@ test.describe.serial("mobile server header direct hierarchy", () => {test("639↔640 preserves the header and composer owners without resize requests", async ({ asUser }) => {const { page } = await asUser("alice")+ const coldBootReconciliation = observeColdBootServerReconciliation(page, serverId)await page.setViewportSize({ width: 639, height: 844 })await page.goto(`/c/channels/${serverId}/${threadId}`, { waitUntil: "commit" })await expect(page.getByTestId(tid.composerInput)).toBeVisible({ timeout: 20_000 })await expectParentBack(page, serverId)- await page.waitForTimeout(200)+ await expect.poll(coldBootReconciliation.done, {+ message: "cold-boot read-state server reconciliation to settle",+ timeout: 10_000,+ }).toBe(true)+ coldBootReconciliation.dispose()await page.evaluate(({ composerTestId }) => {const backControl = document.querySelector('button[aria-label="Back"]')diff --git a/src/web/src/test/e2e-ui/43-composer-attachment-drafts.spec.ts b/src/web/src/test/e2e-ui/43-composer-attachment-drafts.spec.tsindex 84e23eaf8..712da0f7f 100644--- a/src/web/src/test/e2e-ui/43-composer-attachment-drafts.spec.ts+++ b/src/web/src/test/e2e-ui/43-composer-attachment-drafts.spec.ts@@ -118,9 +118,10 @@ test.describe.serial("same-tab Community attachment drafts", () => {await expect(composerAttachments(page).getByText("scope-image.png", { exact: true })).toBeVisible()await page.getByTestId(tid.threadIndicator(openerId)).click()await page.waitForURL((url) => url.pathname === `/c/channels/${serverId}/${threadId}`)- await expect(composerEditable(page)).toBeVisible()- await expect(composerEditable(page)).toHaveText("")- await expect(page.getByRole("button", { name: "Remove file" })).toHaveCount(0)+ const threadPanel = page.getByTestId(tid.threadSplitPanel)+ await expect(composerEditable(page, threadPanel)).toBeVisible()+ await expect(composerEditable(page, threadPanel)).toHaveText("")+ await expect(threadPanel.getByRole("button", { name: "Remove file" })).toHaveCount(0)await navigateDm(page, dmId)await expect(composerEditable(page)).toHaveText("")await expect(page.getByRole("button", { name: "Remove file" })).toHaveCount(0)diff --git a/src/web/src/test/e2e-ui/45-desktop-thread-split-view.spec.ts b/src/web/src/test/e2e-ui/45-desktop-thread-split-view.spec.tsnew file mode 100644index 000000000..15ab649c0--- /dev/null+++ b/src/web/src/test/e2e-ui/45-desktop-thread-split-view.spec.ts@@ -0,0 +1,143 @@+import { expect, test } from "./_fixtures/community-fixture"+import {+ seedChannel,+ seedForumThread,+ seedMessage,+ seedServer,+ seedThread,+} from "./_fixtures/seed"+import { tid } from "./_fixtures/testids"++test.describe.serial("desktop thread split view", () => {+ let serverId: string+ let textChannelId: string+ let threadId: string+ let forumId: string+ let forumPostId: string+ let parentBody: string+ let threadBody: string+ let forumTitle: string++ test.beforeAll(async () => {+ serverId = await seedServer("alice", `Split view ${Date.now()}`)+ textChannelId = await seedChannel("alice", serverId, "split-parent")+ parentBody = `parent opener ${Date.now()}`+ const openerId = await seedMessage("alice", textChannelId, parentBody)+ threadId = await seedThread("alice", openerId, "Focused thread")+ threadBody = `thread reply ${Date.now()}`+ await seedMessage("alice", threadId, threadBody)++ forumId = await seedChannel("alice", serverId, "split-forum", "forum")+ forumTitle = `Forum post ${Date.now()}`+ forumPostId = await seedForumThread("alice", forumId, forumTitle, "Forum reply")+ })++ test("keeps parent and thread live, supports fullscreen/close, and falls back below the width threshold", async ({ asUser }, testInfo) => {+ test.setTimeout(120_000)+ const { page } = await asUser("alice")+ await page.setViewportSize({ width: 1280, height: 900 })+ await page.goto(`/c/channels/${serverId}/${threadId}`)++ const shell = page.getByTestId(tid.threadSplit)+ const parent = page.getByTestId(tid.threadSplitParent)+ const thread = page.getByTestId(tid.threadSplitPanel)+ await expect(shell).toHaveAttribute("data-layout", "split", { timeout: 20_000 })+ await expect(parent.getByText(parentBody, { exact: false })).toBeVisible()+ await expect(thread.getByText(threadBody, { exact: false })).toBeVisible()+ await expect(thread.getByTestId(tid.threadSplitFullscreen)).toBeVisible()+ await expect(thread.getByTestId(tid.threadSplitClose)).toBeVisible()+ await expect(thread.getByRole("button", { name: "Rename" })).toHaveCount(0)+ await expect(thread.getByRole("button", { name: "Member list" })).toHaveCount(0)+ await expect(thread.getByRole("button", { name: "Channel notifications" })).toHaveCount(0)+ await expect(thread.getByRole("button", { name: "More channel options" })).toHaveCount(0)+ expect(await page.evaluate(() => document.documentElement.scrollWidth <= document.documentElement.clientWidth))+ .toBe(true)+ const desktopLight = testInfo.outputPath("1280-light-split.png")+ await page.screenshot({ path: desktopLight })+ await testInfo.attach("1280-light-split", { path: desktopLight, contentType: "image/png" })++ await page.emulateMedia({ colorScheme: "dark" })+ await expect(page.locator("html")).toHaveClass(/dark/)+ const desktopDark = testInfo.outputPath("1280-dark-split.png")+ await page.screenshot({ path: desktopDark })+ await testInfo.attach("1280-dark-split", { path: desktopDark, contentType: "image/png" })+ await page.emulateMedia({ colorScheme: "light" })+ await expect(page.locator("html")).not.toHaveClass(/dark/)++ const parentLive = `parent live ${Date.now()}`+ const threadLive = `thread live ${Date.now()}`+ await seedMessage("alice", textChannelId, parentLive)+ await seedMessage("alice", threadId, threadLive)+ await expect(parent.getByText(parentLive, { exact: false })).toBeVisible({ timeout: 20_000 })+ await expect(thread.getByText(threadLive, { exact: false })).toBeVisible({ timeout: 20_000 })++ await page.getByTestId(tid.threadSplitFullscreen).click()+ await page.waitForURL(`/c/channels/${serverId}/${threadId}?threadView=full`)+ await expect(shell).toHaveAttribute("data-layout", "full")+ await expect(page.getByTestId(tid.threadSplitParent)).toHaveCount(0)+ await expect(thread.getByRole("button", { name: "Rename" })).toBeVisible()+ await expect(thread.getByRole("button", { name: "Member list" })).toBeVisible()+ await expect(thread.getByRole("button", { name: "Channel notifications" })).toBeVisible()+ await expect(thread.getByRole("button", { name: "More channel options" })).toBeVisible()++ await page.goBack()+ await expect(shell).toHaveAttribute("data-layout", "split")+ await page.getByTestId(tid.threadSplitClose).click()+ await page.waitForURL(`/c/channels/${serverId}/${textChannelId}`)++ await page.goto(`/c/channels/${serverId}/${threadId}`)+ await expect(shell).toHaveAttribute("data-layout", "split")+ await expect(page.getByTestId(tid.threadSplitPanel).getByText(parentBody, { exact: false }))+ .toBeVisible({ timeout: 20_000 })+ await page.setViewportSize({ width: 1050, height: 900 })+ await expect(shell).toHaveAttribute("data-layout", "full")+ await expect(page.getByTestId(tid.threadSplitParent)).toHaveCount(0)+ expect(await page.evaluate(() => document.documentElement.scrollWidth <= document.documentElement.clientWidth))+ .toBe(true)+ const narrowLight = testInfo.outputPath("1050-light-fallback.png")+ await page.screenshot({ path: narrowLight })+ await testInfo.attach("1050-light-fallback", { path: narrowLight, contentType: "image/png" })++ await page.setViewportSize({ width: 390, height: 844 })+ await expect(shell).toHaveAttribute("data-layout", "full")+ await expect(page.getByTestId(tid.threadSplitFullscreen)).toHaveCount(0)+ await expect(page.getByTestId(tid.threadSplitClose)).toHaveCount(0)+ expect(await page.evaluate(() => document.documentElement.scrollWidth <= document.documentElement.clientWidth))+ .toBe(true)+ const mobileLight = testInfo.outputPath("390-light-full.png")+ await page.screenshot({ path: mobileLight })+ await testInfo.attach("390-light-full", { path: mobileLight, contentType: "image/png" })++ await page.emulateMedia({ colorScheme: "dark" })+ await expect(page.locator("html")).toHaveClass(/dark/)+ const mobileDark = testInfo.outputPath("390-dark-full.png")+ await page.screenshot({ path: mobileDark })+ await testInfo.attach("390-dark-full", { path: mobileDark, contentType: "image/png" })+ })++ test("opens forum posts in the same desktop split contract", async ({ asUser }, testInfo) => {+ const { page } = await asUser("alice")+ await page.setViewportSize({ width: 1280, height: 900 })+ await page.goto(`/c/channels/${serverId}/${forumPostId}`)++ await expect(page.getByTestId(tid.threadSplit)).toHaveAttribute("data-layout", "split", {+ timeout: 20_000,+ })+ const parent = page.getByTestId(tid.threadSplitParent)+ await expect(parent.getByTestId(tid.forumPostList)).toBeVisible()+ await expect(parent.getByTestId(tid.forumThreadTitleText(forumPostId)))+ .toHaveText(forumTitle)+ const post = page.getByTestId(tid.threadSplitPanel)+ await expect(post.getByText("Forum reply", { exact: false })).toBeVisible()+ await expect(post.getByTestId(tid.threadSplitFullscreen)).toBeVisible()+ await expect(post.getByTestId(tid.threadSplitClose)).toBeVisible()+ await expect(post.getByRole("button", { name: "Rename" })).toHaveCount(0)+ await expect(post.getByRole("button", { name: "Member list" })).toHaveCount(0)+ await expect(post.getByRole("button", { name: "Channel notifications" })).toHaveCount(0)+ await expect(post.getByRole("button", { name: "More channel options" })).toHaveCount(0)++ const forumSplit = testInfo.outputPath("1280-light-forum-split.png")+ await page.screenshot({ path: forumSplit })+ await testInfo.attach("1280-light-forum-split", { path: forumSplit, contentType: "image/png" })+ })+})diff --git a/src/web/src/test/e2e-ui/_fixtures/actions.ts b/src/web/src/test/e2e-ui/_fixtures/actions.tsindex 5a4e01690..b141e327c 100644--- a/src/web/src/test/e2e-ui/_fixtures/actions.ts+++ b/src/web/src/test/e2e-ui/_fixtures/actions.ts@@ -1,4 +1,4 @@-import { type Page, type WebSocket, expect } from "@playwright/test"+import { type Locator, type Page, type WebSocket, expect } from "@playwright/test"import { tid } from "./testids"const HOVER_FINE_QUERY = "(hover: hover) and (pointer: fine)"@@ -133,15 +133,19 @@ export async function openChannel(page: Page, channelId: string): Promise<void>// The ProseMirror contenteditable inside the composer wrapper. Clicking the// wrapper's testid alone doesn't always land the caret in the editable, so// target the contenteditable directly for typing.-export function composerEditable(page: Page) {- return page.getByTestId(tid.composerInput).locator("[contenteditable='true']")+export function composerEditable(page: Page, root: Page | Locator = page) {+ return root.getByTestId(tid.composerInput).locator("[contenteditable='true']")}-export async function sendMessage(page: Page, text: string): Promise<void> {- const editable = composerEditable(page)+export async function sendMessage(+ page: Page,+ text: string,+ root: Page | Locator = page,+): Promise<void> {+ const editable = composerEditable(page, root)await editable.click()await editable.pressSequentially(text)- const sendButton = page.getByTestId(tid.composerSend)+ const sendButton = root.getByTestId(tid.composerSend)if (await sendButton.isVisible()) {await expect(sendButton).toBeVisible()await expect(sendButton).toBeEnabled()