Skip to content

armgit / alook

Public Imported from GitHub
0

Multi-Agent Collaboration for Team and Friends

refactor(web): unify community sheet shell (#516)

Generf8c178cef397
diff --git a/src/web/src/components/community/bots/create-bot-sheet.test.ts b/src/web/src/components/community/bots/create-bot-sheet.test.ts
index 5befd8fe7..2ad731f51 100644
--- a/src/web/src/components/community/bots/create-bot-sheet.test.ts
+++ b/src/web/src/components/community/bots/create-bot-sheet.test.ts
@@ -115,18 +115,17 @@ vi.mock("@/hooks/community/use-bots", () => ({
useUploadBotAvatar: () => ({ mutateAsync: vi.fn() }),
}))
-vi.mock("@/components/ui/sheet", () => {
- const pass = (name: string) =>
- function Passthrough({ children }: { children?: React.ReactNode }) {
- return React.createElement("div", { "data-mock": name }, children)
- }
+vi.mock("@/components/community/shell/community-sheet", () => {
return {
- Sheet: pass("sheet"),
- SheetBody: pass("body"),
- SheetContent: pass("content"),
- SheetFooter: pass("footer"),
- SheetHeader: pass("header"),
- SheetTitle: pass("title"),
+ CommunitySheet: ({ children, footer }: {
+ children?: React.ReactNode
+ footer?: React.ReactNode | ((requestClose: () => void) => React.ReactNode)
+ }) => React.createElement(
+ "div",
+ { "data-mock": "sheet" },
+ children,
+ typeof footer === "function" ? footer(vi.fn()) : footer,
+ ),
}
})
diff --git a/src/web/src/components/community/bots/create-bot-sheet.tsx b/src/web/src/components/community/bots/create-bot-sheet.tsx
index ba64d4159..6ec34fa02 100644
--- a/src/web/src/components/community/bots/create-bot-sheet.tsx
+++ b/src/web/src/components/community/bots/create-bot-sheet.tsx
@@ -5,14 +5,7 @@ import { toast } from "sonner"
import { toastApiError } from "@/lib/api/client"
import { isPresenceOnline, type CommunityMachineSummary } from "@alook/shared"
import { machineName } from "@/lib/community/machine-name"
-import {
- Sheet,
- SheetBody,
- SheetContent,
- SheetFooter,
- SheetHeader,
- SheetTitle,
-} from "@/components/ui/sheet"
+import { CommunitySheet } from "@/components/community/shell/community-sheet"
import { Button } from "@/components/ui/button"
import { Label } from "@/components/ui/label"
import { type AvatarDraft } from "@/components/avatar"
@@ -209,17 +202,22 @@ export function CreateBotSheet({
}
return (
- <Sheet open={open} onOpenChange={onOpenChange} disablePointerDismissal>
- <SheetContent
- side="right"
- showOverlay={false}
- className="data-[side=right]:sm:inset-y-2 data-[side=right]:sm:right-2 data-[side=right]:sm:h-auto data-[side=right]:sm:rounded-xl data-[side=right]:sm:border data-[side=right]:sm:overflow-hidden"
- >
- <SheetHeader>
- <SheetTitle>Create a bot</SheetTitle>
- </SheetHeader>
-
- <SheetBody className="flex flex-col gap-6">
+ <CommunitySheet
+ open={open}
+ onOpenChange={onOpenChange}
+ title="Create a bot"
+ bodyClassName="flex flex-col gap-6"
+ footer={(requestClose) => (
+ <>
+ <Button variant="outline" onClick={requestClose}>
+ Cancel
+ </Button>
+ <Button onClick={submit} disabled={create.isPending}>
+ {create.isPending ? "Creating…" : "Create bot"}
+ </Button>
+ </>
+ )}
+ >
<BotFormFields
avatarDraft={avatarDraft}
onAvatarChange={setAvatarDraft}
@@ -312,17 +310,6 @@ export function CreateBotSheet({
)}
</>
)}
- </SheetBody>
-
- <SheetFooter>
- <Button variant="outline" onClick={() => onOpenChange(false)}>
- Cancel
- </Button>
- <Button onClick={submit} disabled={create.isPending}>
- {create.isPending ? "Creating…" : "Create bot"}
- </Button>
- </SheetFooter>
- </SheetContent>
- </Sheet>
+ </CommunitySheet>
)
}
diff --git a/src/web/src/components/community/bots/edit-bot-sheet.test.ts b/src/web/src/components/community/bots/edit-bot-sheet.test.ts
index a0a5931ed..f2f43d5b0 100644
--- a/src/web/src/components/community/bots/edit-bot-sheet.test.ts
+++ b/src/web/src/components/community/bots/edit-bot-sheet.test.ts
@@ -44,20 +44,18 @@ const HEALTHY_MACHINES = {
],
}
-vi.mock("@/components/ui/sheet", () => {
+vi.mock("@/components/community/shell/community-sheet", () => {
const React = require("react")
- const pass = (name: string) =>
- function P({ children }: { children?: React.ReactNode }) {
- return React.createElement("div", { "data-mock": name }, children)
- }
return {
- Sheet: pass("sheet"),
- SheetBody: pass("body"),
- SheetContent: pass("content"),
- SheetDescription: pass("desc"),
- SheetFooter: pass("footer"),
- SheetHeader: pass("header"),
- SheetTitle: pass("title"),
+ CommunitySheet: ({ children, footer }: {
+ children?: React.ReactNode
+ footer?: React.ReactNode | ((requestClose: () => void) => React.ReactNode)
+ }) => React.createElement(
+ "div",
+ { "data-mock": "sheet" },
+ children,
+ typeof footer === "function" ? footer(vi.fn()) : footer,
+ ),
}
})
diff --git a/src/web/src/components/community/bots/edit-bot-sheet.tsx b/src/web/src/components/community/bots/edit-bot-sheet.tsx
index dbb78b880..6bf19a95e 100644
--- a/src/web/src/components/community/bots/edit-bot-sheet.tsx
+++ b/src/web/src/components/community/bots/edit-bot-sheet.tsx
@@ -3,15 +3,7 @@
import { useEffect, useMemo, useRef, useState } from "react"
import { toast } from "sonner"
import { toastApiError } from "@/lib/api/client"
-import {
- Sheet,
- SheetBody,
- SheetContent,
- SheetDescription,
- SheetFooter,
- SheetHeader,
- SheetTitle,
-} from "@/components/ui/sheet"
+import { CommunitySheet } from "@/components/community/shell/community-sheet"
import { Button } from "@/components/ui/button"
import {
AlertDialog,
@@ -172,20 +164,24 @@ export function EditBotSheet({
}
return (
- <Sheet open={open} onOpenChange={onOpenChange} disablePointerDismissal>
- <SheetContent
- side="right"
- showOverlay={false}
- className="data-[side=right]:sm:inset-y-2 data-[side=right]:sm:right-2 data-[side=right]:sm:h-auto data-[side=right]:sm:rounded-xl data-[side=right]:sm:border data-[side=right]:sm:overflow-hidden"
+ <>
+ <CommunitySheet
+ open={open}
+ onOpenChange={onOpenChange}
+ title={`Edit ${bot?.name ?? "bot"}`}
+ description="Name and description edits take effect on the next wake. Provider and model switches require the bot to be online."
+ bodyClassName="flex flex-col gap-6"
+ footer={(requestClose) => (
+ <>
+ <Button variant="outline" onClick={requestClose}>
+ Cancel
+ </Button>
+ <Button onClick={submit} disabled={update.isPending || !bot}>
+ {update.isPending ? "Saving…" : "Save"}
+ </Button>
+ </>
+ )}
>
- <SheetHeader>
- <SheetTitle>Edit {bot?.name ?? "bot"}</SheetTitle>
- <SheetDescription>
- Name and description edits take effect on the next wake. Provider and model switches require the bot to be online.
- </SheetDescription>
- </SheetHeader>
-
- <SheetBody className="flex flex-col gap-6">
<BotFormFields
avatarDraft={avatarDraft}
onAvatarChange={setAvatarDraft}
@@ -205,17 +201,7 @@ export function EditBotSheet({
onModelChange={setModel}
/>
)}
- </SheetBody>
-
- <SheetFooter>
- <Button variant="outline" onClick={() => onOpenChange(false)}>
- Cancel
- </Button>
- <Button onClick={submit} disabled={update.isPending || !bot}>
- {update.isPending ? "Saving…" : "Save"}
- </Button>
- </SheetFooter>
- </SheetContent>
+ </CommunitySheet>
<AlertDialog open={confirmProviderSwitch} onOpenChange={setConfirmProviderSwitch}>
<AlertDialogContent>
<AlertDialogHeader>
@@ -237,6 +223,6 @@ export function EditBotSheet({
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
- </Sheet>
+ </>
)
}
diff --git a/src/web/src/components/community/channels/channel-header.title-dialog.test.ts b/src/web/src/components/community/channels/channel-header.title-dialog.test.ts
index c992c6afe..30e4a75df 100644
--- a/src/web/src/components/community/channels/channel-header.title-dialog.test.ts
+++ b/src/web/src/components/community/channels/channel-header.title-dialog.test.ts
@@ -34,6 +34,7 @@ describe("ChannelHeader — forum title dialog", () => {
it("gates the title edit affordance to the creator and keeps normal threads on Rename", () => {
let renderer: TestRenderer.ReactTestRenderer
act(() => { renderer = renderHeader() })
+ expect(renderer!.root.findByType("header").props.role).toBe("banner")
expect(renderer!.root.findAllByProps({ "aria-label": "Edit post title" })).toHaveLength(0)
act(() => renderer!.unmount())
diff --git a/src/web/src/components/community/channels/channel-header.tsx b/src/web/src/components/community/channels/channel-header.tsx
index 51211b077..6e0315c28 100644
--- a/src/web/src/components/community/channels/channel-header.tsx
+++ b/src/web/src/components/community/channels/channel-header.tsx
@@ -24,7 +24,7 @@ import { CreateDialogShell } from "../settings/create-dialog-shell"
// doesn't shift when the real header lands.
export function ChannelHeaderSkeleton({ onBack }: { onBack?: () => void }) {
return (
- <header className="flex h-12 shrink-0 items-center gap-1 border-b border-border/40 px-3">
+ <header role="banner" className="flex h-12 shrink-0 items-center gap-1 border-b border-border/40 px-3">
{onBack && (
<Button variant="ghost" size="icon-sm" onClick={onBack} className="text-muted-foreground hover:text-foreground" aria-label="Back"><ChevronLeft className="size-5" /></Button>
)}
@@ -77,7 +77,7 @@ export function ChannelHeader({
</Button>
)
return (
- <header className="flex h-12 shrink-0 items-center gap-1 border-b border-border/40 px-3">
+ <header role="banner" className="flex h-12 shrink-0 items-center gap-1 border-b border-border/40 px-3">
{onBack && (
<Button variant="ghost" size="icon-sm" onClick={onBack} className="text-muted-foreground hover:text-foreground" aria-label="Back"><ChevronLeft className="size-5" /></Button>
)}
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.ts
index 6d7f4d0e1..c5115577d 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
@@ -82,7 +82,7 @@ vi.mock("@/components/community/channels/channel-shell", () => ({
ChannelShell: ({ header, body }: { header: React.ReactNode; body: React.ReactNode }) =>
React.createElement(React.Fragment, null, header, body),
}))
-vi.mock("@/components/community/shell/community-panel-sheet", () => ({ CommunityPanelSheet: () => null }))
+vi.mock("@/components/community/shell/community-panel", () => ({ CommunityPanel: () => null }))
vi.mock("@/components/community/messages/message-context-sheet", () => ({ MessageContextSheet: () => null }))
vi.mock("@/components/community/messages/thread-opener", () => ({ ThreadOpener: () => null }))
vi.mock("@/components/community/members/add-members-dialog", () => ({ AddMembersDialog: () => null }))
diff --git a/src/web/src/components/community/channels/forum-channel-surface.test.ts b/src/web/src/components/community/channels/forum-channel-surface.test.ts
index b954f033d..9bb52ac31 100644
--- a/src/web/src/components/community/channels/forum-channel-surface.test.ts
+++ b/src/web/src/components/community/channels/forum-channel-surface.test.ts
@@ -2,7 +2,7 @@ import React from "react"
import TestRenderer, { act } from "react-test-renderer"
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"
import { ChannelHeader } from "./channel-header"
-import { CommunityPanelSheet } from "../shell/community-panel-sheet"
+import { CommunityPanel } from "../shell/community-panel"
import { ForumChannelSurface } from "./forum-channel-surface"
import { ForumSurface } from "./forum-surface"
@@ -53,15 +53,15 @@ vi.mock("@/components/community/channels/channel-shell", () => ({
dialogs?: React.ReactNode
}) => React.createElement(React.Fragment, null, header, body, panels, dialogs),
}))
-vi.mock("@/components/community/shell/community-panel-sheet", () => ({
- CommunityPanelSheet: vi.fn(() => null),
+vi.mock("@/components/community/shell/community-panel", () => ({
+ CommunityPanel: vi.fn(() => null),
}))
vi.mock("@/components/community/channels/forum-surface", () => ({
ForumSurface: vi.fn(() => null),
}))
const mockedChannelHeader = vi.mocked(ChannelHeader)
-const mockedCommunityPanelSheet = vi.mocked(CommunityPanelSheet)
+const mockedCommunityPanel = vi.mocked(CommunityPanel)
const mockedForumSurface = vi.mocked(ForumSurface)
function surfaceProps(overrides: Record<string, unknown> = {}) {
@@ -217,7 +217,7 @@ describe("ForumChannelSurface ownership", () => {
act(() => {
mockedChannelHeader.mock.calls.at(-1)![0].onToggle("members")
})
- expect(mockedCommunityPanelSheet.mock.calls.at(-1)![0]).toEqual(expect.objectContaining({ kind: "members" }))
+ expect(mockedCommunityPanel.mock.calls.at(-1)![0]).toEqual(expect.objectContaining({ kind: "members" }))
act(() => {
renderer!.update(React.createElement(
@@ -227,6 +227,6 @@ describe("ForumChannelSurface ownership", () => {
})
expect(mockedChannelHeader.mock.calls.at(-1)![0].rightPanel).toBeNull()
- expect(renderer!.root.findAllByType(CommunityPanelSheet)).toHaveLength(0)
+ expect(renderer!.root.findAllByType(CommunityPanel)).toHaveLength(0)
})
})
diff --git a/src/web/src/components/community/channels/forum-channel-surface.tsx b/src/web/src/components/community/channels/forum-channel-surface.tsx
index 3abf752d3..c3fc0f250 100644
--- a/src/web/src/components/community/channels/forum-channel-surface.tsx
+++ b/src/web/src/components/community/channels/forum-channel-surface.tsx
@@ -8,7 +8,7 @@ import type { RightPanel } from "@/components/community/shell/panel-types"
import { ChannelHeader, type ChannelNotifLevel } from "@/components/community/channels/channel-header"
import { ChannelShell } from "@/components/community/channels/channel-shell"
import type { ChannelMemberPanelProps } from "@/components/community/members/channel-member-view-model"
-import { CommunityPanelSheet } from "@/components/community/shell/community-panel-sheet"
+import { CommunityPanel } from "@/components/community/shell/community-panel"
import type { NewForumThread } from "@/components/community/messages/create-forum-thread"
import { ForumSurface } from "@/components/community/channels/forum-surface"
import type { Member } from "@/lib/community/models/people"
@@ -140,7 +140,7 @@ export function ForumChannelSurface({
</main>
)}
panels={rightPanel && (
- <CommunityPanelSheet
+ <CommunityPanel
open
onOpenChange={(open) => { if (!open) setPanelState({ channelId, panel: null }) }}
kind={rightPanel}
diff --git a/src/web/src/components/community/channels/text-channel-surface.tsx b/src/web/src/components/community/channels/text-channel-surface.tsx
index 68334a940..638ede969 100644
--- a/src/web/src/components/community/channels/text-channel-surface.tsx
+++ b/src/web/src/components/community/channels/text-channel-surface.tsx
@@ -5,7 +5,7 @@ import { useBreakpoint } from "@/hooks/use-mobile"
import { useChannelMessageFeed } from "@/hooks/community/use-channel-message-feed"
import { ChannelHeader, type ChannelNotifLevel } from "@/components/community/channels/channel-header"
import { ChannelShell } from "@/components/community/channels/channel-shell"
-import { CommunityPanelSheet } from "@/components/community/shell/community-panel-sheet"
+import { CommunityPanel } from "@/components/community/shell/community-panel"
import type { ChannelMemberPanelProps } from "@/components/community/members/channel-member-view-model"
import { Composer } from "@/components/community/messages/composer"
import { MessageContextSheet } from "@/components/community/messages/message-context-sheet"
@@ -154,7 +154,7 @@ export function TextChannelSurface({
</main>
)}
panels={rightPanel && (
- <CommunityPanelSheet
+ <CommunityPanel
open
onOpenChange={(open) => { if (!open) setRightPanel(null) }}
kind={rightPanel}
diff --git a/src/web/src/components/community/channels/thread-channel-surface.test.ts b/src/web/src/components/community/channels/thread-channel-surface.test.ts
index 4979638b8..e004e14f4 100644
--- a/src/web/src/components/community/channels/thread-channel-surface.test.ts
+++ b/src/web/src/components/community/channels/thread-channel-surface.test.ts
@@ -3,7 +3,7 @@ import TestRenderer, { act } from "react-test-renderer"
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"
import { ThreadChannelSurface } from "./thread-channel-surface"
import { ChannelHeader, ChannelHeaderSkeleton } from "./channel-header"
-import { CommunityPanelSheet } from "../shell/community-panel-sheet"
+import { CommunityPanel } from "../shell/community-panel"
import { Composer } from "../messages/composer"
import { MessageContextSheet } from "../messages/message-context-sheet"
import { MessageList } from "../messages/message-list"
@@ -53,8 +53,8 @@ vi.mock("@/components/community/channels/channel-shell", () => ({
dialogs?: React.ReactNode
}) => React.createElement(React.Fragment, null, header, body, panels, dialogs),
}))
-vi.mock("@/components/community/shell/community-panel-sheet", () => ({
- CommunityPanelSheet: vi.fn(() => null),
+vi.mock("@/components/community/shell/community-panel", () => ({
+ CommunityPanel: vi.fn(() => null),
}))
vi.mock("@/components/community/messages/composer", () => ({
Composer: vi.fn(() => null),
@@ -126,7 +126,7 @@ vi.mock("@/components/community/messages/message-channel-controller", () => ({
const mockedChannelHeader = vi.mocked(ChannelHeader)
const mockedChannelHeaderSkeleton = vi.mocked(ChannelHeaderSkeleton)
-const mockedCommunityPanelSheet = vi.mocked(CommunityPanelSheet)
+const mockedCommunityPanel = vi.mocked(CommunityPanel)
const mockedComposer = vi.mocked(Composer)
const mockedMessageContextSheet = vi.mocked(MessageContextSheet)
const mockedMessageList = vi.mocked(MessageList)
@@ -322,7 +322,7 @@ describe("ThreadChannelSurface ownership", () => {
expect(mocks.router.replace).toHaveBeenCalledWith("/c/channels/server_1/parent_1")
act(() => headerProps.onToggle("pinned"))
- const panelProps = mockedCommunityPanelSheet.mock.calls.at(-1)![0]
+ const panelProps = mockedCommunityPanel.mock.calls.at(-1)![0]
expect(panelProps).toEqual(expect.objectContaining({
kind: "pinned",
pinned: expect.arrayContaining([expect.objectContaining({ id: "pinned_1" })]),
diff --git a/src/web/src/components/community/channels/thread-channel-surface.tsx b/src/web/src/components/community/channels/thread-channel-surface.tsx
index 2acc23bf0..94d1e6e2a 100644
--- a/src/web/src/components/community/channels/thread-channel-surface.tsx
+++ b/src/web/src/components/community/channels/thread-channel-surface.tsx
@@ -8,7 +8,7 @@ import { useChannelMessageFeed } from "@/hooks/community/use-channel-message-fee
import { useEditMessage } from "@/hooks/community/mutations"
import { ChannelHeader, ChannelHeaderSkeleton, type ChannelNotifLevel } from "@/components/community/channels/channel-header"
import { ChannelShell } from "@/components/community/channels/channel-shell"
-import { CommunityPanelSheet } from "@/components/community/shell/community-panel-sheet"
+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 { MessageContextSheet } from "@/components/community/messages/message-context-sheet"
@@ -255,7 +255,7 @@ export function ThreadChannelSurface({
</main>
)}
panels={rightPanel && (
- <CommunityPanelSheet
+ <CommunityPanel
open
onOpenChange={(open) => { if (!open) setRightPanel(null) }}
kind={rightPanel}
diff --git a/src/web/src/components/community/machines/pair-machine-sheet.test.ts b/src/web/src/components/community/machines/pair-machine-sheet.test.ts
index ac73bb30b..ebea7de4d 100644
--- a/src/web/src/components/community/machines/pair-machine-sheet.test.ts
+++ b/src/web/src/components/community/machines/pair-machine-sheet.test.ts
@@ -36,15 +36,16 @@ vi.mock("@/components/ui/button", () => ({
React.createElement("button", props, children),
}))
-vi.mock("@/components/ui/sheet", () => ({
- Sheet: ({ children }: React.PropsWithChildren) => React.createElement("div", {}, children),
- SheetContent: ({ children }: React.PropsWithChildren) => React.createElement("div", {}, children),
- SheetHeader: ({ children }: React.PropsWithChildren) => React.createElement("header", {}, children),
- SheetTitle: ({ children }: React.PropsWithChildren) => React.createElement("h2", {}, children),
- SheetDescription: ({ children }: React.PropsWithChildren) => React.createElement("p", {}, children),
- SheetBody: ({ children }: React.PropsWithChildren) => React.createElement("main", {}, children),
- SheetFooter: ({ children }: React.PropsWithChildren) => React.createElement("footer", {}, children),
- SheetClose: () => null,
+vi.mock("@/components/community/shell/community-sheet", () => ({
+ CommunitySheet: ({ children, footer }: {
+ children?: React.ReactNode
+ footer?: React.ReactNode | ((requestClose: () => void) => React.ReactNode)
+ }) => React.createElement(
+ "div",
+ {},
+ children,
+ typeof footer === "function" ? footer(vi.fn()) : footer,
+ ),
}))
import { PairMachineSheet, PairMachineSteps } from "./pair-machine-sheet"
diff --git a/src/web/src/components/community/machines/pair-machine-sheet.tsx b/src/web/src/components/community/machines/pair-machine-sheet.tsx
index da651fb1d..ec6a6de63 100644
--- a/src/web/src/components/community/machines/pair-machine-sheet.tsx
+++ b/src/web/src/components/community/machines/pair-machine-sheet.tsx
@@ -4,16 +4,7 @@ import { useCallback, useEffect, useRef, useState } from "react"
import { toast } from "sonner"
import { Copy, Loader2 } from "lucide-react"
import { isDesktop, isTauri, tauriInvoke } from "@alook/shared"
-import {
- Sheet,
- SheetContent,
- SheetHeader,
- SheetTitle,
- SheetDescription,
- SheetBody,
- SheetFooter,
- SheetClose,
-} from "@/components/ui/sheet"
+import { CommunitySheet } from "@/components/community/shell/community-sheet"
import { Button } from "@/components/ui/button"
import { apiFetch, toastApiError } from "@/lib/api/client"
import { tid } from "@/lib/community/testids"
@@ -201,22 +192,20 @@ export function PairMachineSheet({
}, [pendingTokenId, runtimeCapability?.available, isReconnect, mode])
return (
- <Sheet open={open} onOpenChange={onOpenChange}>
- <SheetContent
- side="right"
- className="data-[side=right]:sm:inset-y-2 data-[side=right]:sm:right-2 data-[side=right]:sm:h-auto data-[side=right]:sm:rounded-xl data-[side=right]:sm:border"
- >
- <SheetHeader>
- <SheetTitle>
- {isReconnect ? `Reconnect ${mode.hostname || "machine"}` : "Connect a machine"}
- </SheetTitle>
- <SheetDescription>
- {isReconnect
- ? "Run this command before it expires. It safely replaces the running daemon, then rotates its key."
- : "Run this on the computer you want to connect. The key is good for 15 minutes."}
- </SheetDescription>
- </SheetHeader>
- <SheetBody className="flex flex-col gap-6">
+ <CommunitySheet
+ open={open}
+ onOpenChange={onOpenChange}
+ title={isReconnect ? `Reconnect ${mode.hostname || "machine"}` : "Connect a machine"}
+ description={isReconnect
+ ? "Run this command before it expires. It safely replaces the running daemon, then rotates its key."
+ : "Run this on the computer you want to connect. The key is good for 15 minutes."}
+ bodyClassName="flex flex-col gap-6"
+ footer={(requestClose) => (
+ <Button variant="secondary" className="min-h-11!" onClick={requestClose}>
+ Done
+ </Button>
+ )}
+ >
<PairMachineSteps
command={command}
generating={generating || !command}
@@ -230,12 +219,7 @@ export function PairMachineSheet({
onConnectDesktop={connectDesktop}
connectedHostname={connectedHostname}
/>
- </SheetBody>
- <SheetFooter>
- <SheetClose render={<Button variant="secondary">Done</Button>} />
- </SheetFooter>
- </SheetContent>
- </Sheet>
+ </CommunitySheet>
)
}
diff --git a/src/web/src/components/community/members/channel-member-view-model.test.ts b/src/web/src/components/community/members/channel-member-view-model.test.ts
index 60d0b1ed1..ed105e8eb 100644
--- a/src/web/src/components/community/members/channel-member-view-model.test.ts
+++ b/src/web/src/components/community/members/channel-member-view-model.test.ts
@@ -66,8 +66,8 @@ vi.mock("@/stores/community/ws", () => ({
vi.mock("@/components/community/members/add-members-dialog", () => ({
AddMembersDialog: vi.fn(() => null),
}))
-vi.mock("@/components/community/shell/community-panel-sheet", () => ({
- CommunityPanelSheet: () => null,
+vi.mock("@/components/community/shell/community-panel", () => ({
+ CommunityPanel: () => null,
}))
const mockedAddMembersDialog = vi.mocked(AddMembersDialog)
diff --git a/src/web/src/components/community/members/channel-member-view-model.tsx b/src/web/src/components/community/members/channel-member-view-model.tsx
index 81fcb9fa8..ce6ee90c3 100644
--- a/src/web/src/components/community/members/channel-member-view-model.tsx
+++ b/src/web/src/components/community/members/channel-member-view-model.tsx
@@ -4,7 +4,7 @@ import { useEffect, useMemo, useState, type ComponentProps, type ReactNode } fro
import { toast } from "sonner"
import { isForum, type CommunityRole as Role } from "@alook/shared"
import { AddMembersDialog } from "@/components/community/members/add-members-dialog"
-import type { CommunityPanelSheet } from "@/components/community/shell/community-panel-sheet"
+import type { CommunityPanel } from "@/components/community/shell/community-panel"
import type { Member } from "@/lib/community/models/people"
import { toastApiError } from "@/lib/api/client"
import { makeUserNameResolver } from "@/lib/community/display-name"
@@ -23,7 +23,7 @@ import {
import { useKickMember, useSetMemberRole } from "@/hooks/community/mutations"
import { useCommunityWsStore, useOnlineUserIds } from "@/stores/community/ws"
-type PanelProps = ComponentProps<typeof CommunityPanelSheet>
+type PanelProps = ComponentProps<typeof CommunityPanel>
export type ChannelMemberPanelProps = Pick<
PanelProps,
diff --git a/src/web/src/components/community/messages/attachment-preview-sheet.test.ts b/src/web/src/components/community/messages/attachment-preview-sheet.test.ts
index 693c3bc77..73d14cb5f 100644
--- a/src/web/src/components/community/messages/attachment-preview-sheet.test.ts
+++ b/src/web/src/components/community/messages/attachment-preview-sheet.test.ts
@@ -4,13 +4,29 @@ import { afterEach, describe, expect, it, vi } from "vitest"
import { AttachmentPreviewSheet, readAttachmentText } from "./attachment-preview-sheet"
import type { FileAttachment } from "@/lib/community/models/message"
-vi.mock("@/components/ui/sheet", () => ({
- Sheet: ({ children }: { children: React.ReactNode }) => React.createElement("div", null, children),
- SheetContent: ({ children, ...props }: React.ComponentProps<"section">) => React.createElement("section", props, children),
- SheetHeader: ({ children, ...props }: React.ComponentProps<"header">) => React.createElement("header", props, children),
- SheetTitle: ({ children, ...props }: React.ComponentProps<"h2">) => React.createElement("h2", props, children),
- SheetDescription: ({ children, ...props }: React.ComponentProps<"p">) => React.createElement("p", props, children),
- SheetBody: ({ children, ...props }: React.ComponentProps<"main">) => React.createElement("main", props, children),
+vi.mock("@/components/community/shell/community-sheet", () => ({
+ CommunitySheet: ({
+ title,
+ description,
+ headerActions,
+ children,
+ bodyTestId,
+ bodyClassName,
+ }: {
+ title: React.ReactNode
+ description?: React.ReactNode
+ headerActions?: React.ReactNode
+ children: React.ReactNode
+ bodyTestId?: string
+ bodyClassName?: string
+ }) => React.createElement(
+ "div",
+ null,
+ React.createElement("h2", null, title),
+ description != null && React.createElement("p", null, description),
+ headerActions,
+ React.createElement("main", { "data-testid": bodyTestId, className: bodyClassName }, children),
+ ),
}))
vi.mock("@/components/ui/sheet-resize-handle", () => ({
diff --git a/src/web/src/components/community/messages/attachment-preview-sheet.tsx b/src/web/src/components/community/messages/attachment-preview-sheet.tsx
index 33248fd80..03a095854 100644
--- a/src/web/src/components/community/messages/attachment-preview-sheet.tsx
+++ b/src/web/src/components/community/messages/attachment-preview-sheet.tsx
@@ -1,17 +1,9 @@
"use client"
import { useEffect, useState } from "react"
-import { ArrowLeft, Download, Loader2, X } from "lucide-react"
+import { Download, Loader2 } from "lucide-react"
import { buttonVariants } from "@/components/ui/button"
-import {
- Sheet,
- SheetBody,
- SheetContent,
- SheetDescription,
- SheetHeader,
- SheetTitle,
-} from "@/components/ui/sheet"
-import { SheetResizeHandle, useSheetResize } from "@/components/ui/sheet-resize-handle"
+import { CommunitySheet } from "@/components/community/shell/community-sheet"
import { cn } from "@/lib/utils"
import { MessageBody } from "./message-body"
import { CodePreview } from "./code-preview"
@@ -79,12 +71,6 @@ export function AttachmentPreviewSheet({
}) {
const [selected, setSelected] = useState<FileAttachment | null>(attachment)
const [preview, setPreview] = useState<PreviewState>(IDLE_STATE)
- const { width, onPointerDown, onPointerMove, onPointerUp } = useSheetResize({
- defaultWidth: 520,
- minWidth: 320,
- maxWidthRatio: 0.8,
- })
-
useEffect(() => {
if (attachment) setSelected(attachment)
}, [attachment])
@@ -134,83 +120,49 @@ export function AttachmentPreviewSheet({
: ""
return (
- <Sheet open={open} onOpenChange={onOpenChange}>
- <SheetContent
- data-testid={tid.attachmentPreviewSheet}
- side="right"
- showCloseButton={false}
- style={{ width: `min(${width}px, 100vw)`, maxWidth: "none" }}
- className="data-[side=right]:sm:inset-y-2 data-[side=right]:sm:right-2 data-[side=right]:sm:h-auto data-[side=right]:sm:rounded-xl data-[side=right]:sm:border"
- >
- <SheetResizeHandle
- onPointerDown={onPointerDown}
- onPointerMove={onPointerMove}
- onPointerUp={onPointerUp}
- />
- <SheetHeader className="pr-4 sm:pr-6">
- <div className="flex min-w-0 items-center gap-2">
- <button
- type="button"
- className={cn(buttonVariants({ variant: "ghost", size: "icon-sm" }), "size-11 shrink-0 sm:hidden")}
- onClick={() => onOpenChange(false)}
- aria-label="Close attachment preview"
- >
- <ArrowLeft className="size-4" />
- </button>
- <div className="min-w-0 flex-1">
- <SheetTitle className="truncate">{selected?.name ?? "Attachment"}</SheetTitle>
- <SheetDescription className="truncate">
- {[selected?.contentType || presentation?.category, size].filter(Boolean).join(" · ")}
- </SheetDescription>
- </div>
- {selected && (
- <a
- data-testid={tid.attachmentPreviewDownload}
- href={selected.url}
- download={selected.name}
- className={buttonVariants({ variant: "outline", size: "sm", className: "h-11 sm:h-7" })}
- >
- <Download className="size-3.5" />
- Download
- </a>
- )}
- <button
- type="button"
- className={buttonVariants({ variant: "ghost", size: "icon-sm", className: "size-11 sm:size-7" })}
- onClick={() => onOpenChange(false)}
- aria-label="Close attachment preview"
- >
- <X className="size-4" />
- </button>
- </div>
- </SheetHeader>
- <SheetBody
- data-testid={tid.attachmentPreviewContent}
- className={cn(
- "flex min-h-0 flex-col",
- (presentation?.previewKind === "code" || presentation?.previewKind === "text") && "p-0 sm:p-0",
- )}
+ <CommunitySheet
+ open={open}
+ onOpenChange={onOpenChange}
+ title={selected?.name ?? "Attachment"}
+ description={[selected?.contentType || presentation?.category, size].filter(Boolean).join(" · ")}
+ headerActions={selected && (
+ <a
+ data-testid={tid.attachmentPreviewDownload}
+ href={selected.url}
+ download={selected.name}
+ className={buttonVariants({ variant: "outline", size: "sm", className: "h-11 sm:h-7" })}
>
- {preview.status === "loading" && (
- <div className="flex items-center justify-center gap-2 py-8 text-sm text-muted-foreground">
- <Loader2 className="size-4 animate-spin" />
- Loading preview…
- </div>
- )}
- {preview.status === "error" && (
- <div className="flex min-h-40 flex-col items-center justify-center gap-2 text-center">
- <p className="text-sm font-medium">Preview unavailable</p>
- <p className="max-w-72 text-sm text-muted-foreground">{preview.error}</p>
- </div>
- )}
- {preview.status === "ready" && presentation?.previewKind === "markdown" && (
- <MessageBody text={preview.content} />
- )}
- {preview.status === "ready" && presentation?.previewKind !== "markdown" && (
- <CodePreview content={preview.content} language={presentation?.shikiLanguage ?? null} />
- )}
- </SheetBody>
- </SheetContent>
- </Sheet>
+ <Download className="size-3.5" />
+ Download
+ </a>
+ )}
+ resizable
+ closeLabel="Close attachment preview"
+ contentTestId={tid.attachmentPreviewSheet}
+ bodyTestId={tid.attachmentPreviewContent}
+ bodyClassName={cn(
+ "flex min-h-0 flex-col",
+ (presentation?.previewKind === "code" || presentation?.previewKind === "text") && "p-0 sm:p-0",
+ )}
+ >
+ {preview.status === "loading" && (
+ <div className="flex items-center justify-center gap-2 py-8 text-sm text-muted-foreground">
+ <Loader2 className="size-4 animate-spin" />
+ Loading preview…
+ </div>
+ )}
+ {preview.status === "error" && (
+ <div className="flex min-h-40 flex-col items-center justify-center gap-2 text-center">
+ <p className="text-sm font-medium">Preview unavailable</p>
+ <p className="max-w-72 text-sm text-muted-foreground">{preview.error}</p>
+ </div>
+ )}
+ {preview.status === "ready" && presentation?.previewKind === "markdown" && (
+ <MessageBody text={preview.content} />
+ )}
+ {preview.status === "ready" && presentation?.previewKind !== "markdown" && (
+ <CodePreview content={preview.content} language={presentation?.shikiLanguage ?? null} />
+ )}
+ </CommunitySheet>
)
}
diff --git a/src/web/src/components/community/messages/message-context-sheet-header.test.ts b/src/web/src/components/community/messages/message-context-sheet-header.test.ts
index 157875aa0..9fe323701 100644
--- a/src/web/src/components/community/messages/message-context-sheet-header.test.ts
+++ b/src/web/src/components/community/messages/message-context-sheet-header.test.ts
@@ -2,18 +2,16 @@ import { readFileSync } from "node:fs"
import { describe, expect, it } from "vitest"
describe("MessageContextSheet header", () => {
- it("reserves the close-button lane while truncating only the channel label", () => {
+ it("supplies a structured title that truncates only the channel label", () => {
const source = readFileSync(new URL("./message-context-sheet.tsx", import.meta.url), "utf8")
- expect(source).toContain(
- '<SheetHeader className="gap-0 border-b-0 py-3 pr-14 sm:pr-14">',
- )
- expect(source).toContain(
- '<SheetTitle className="flex w-full min-w-0 items-center gap-1.5 text-lg font-semibold tracking-tight">',
- )
+ expect(source).toContain("title={channelLabel ? (")
+ expect(source).toContain('<span className="flex w-full min-w-0 items-center gap-1.5">')
expect(source).toContain('<span className="min-w-0 truncate">{channelLabel}</span>')
expect(source).toContain(
'<span className="shrink-0 font-mono text-base font-normal text-muted-foreground">#{targetSeq ?? ""}</span>',
)
+ expect(source).not.toContain("CommunitySheetHeader")
+ expect(source).not.toContain("CommunitySheetTitle")
})
})
diff --git a/src/web/src/components/community/messages/message-context-sheet.navigation.test.ts b/src/web/src/components/community/messages/message-context-sheet.navigation.test.ts
index 65a333466..8cde285d0 100644
--- a/src/web/src/components/community/messages/message-context-sheet.navigation.test.ts
+++ b/src/web/src/components/community/messages/message-context-sheet.navigation.test.ts
@@ -33,11 +33,8 @@ vi.mock("@tanstack/react-query", () => ({
}),
useQueryClient: () => ({ setQueryData: vi.fn() }),
}))
-vi.mock("@/components/ui/sheet", () => ({
- Sheet: ({ children }: { children: React.ReactNode }) => children,
- SheetContent: ({ children }: { children: React.ReactNode }) => children,
- SheetHeader: ({ children }: { children: React.ReactNode }) => children,
- SheetTitle: ({ children }: { children: React.ReactNode }) => children,
+vi.mock("@/components/community/shell/community-sheet", () => ({
+ CommunitySheet: ({ children }: { children: React.ReactNode }) => children,
}))
vi.mock("@/components/ui/sheet-resize-handle", () => ({
useSheetResize: () => ({
diff --git a/src/web/src/components/community/messages/message-context-sheet.tsx b/src/web/src/components/community/messages/message-context-sheet.tsx
index 663b927bd..acfe0bd03 100644
--- a/src/web/src/components/community/messages/message-context-sheet.tsx
+++ b/src/web/src/components/community/messages/message-context-sheet.tsx
@@ -5,8 +5,7 @@ import { useRouter, useParams } from "next/navigation"
import { toast } from "sonner"
import { useQuery, useQueryClient } from "@tanstack/react-query"
import { deriveThreadName } from "@alook/shared"
-import { Sheet, SheetContent, SheetHeader, SheetTitle } from "@/components/ui/sheet"
-import { useSheetResize, SheetResizeHandle } from "@/components/ui/sheet-resize-handle"
+import { CommunitySheet } from "@/components/community/shell/community-sheet"
import { MessageRow } from "./message-row"
import { MessageShareDialog } from "./message-share-dialog"
import { ChannelIcon } from "../channels/channel-icon"
@@ -162,12 +161,6 @@ export function MessageContextSheet({
onReply?: (target: ReplyTarget) => void
type?: ScopeType
}) {
- const { width, onPointerDown, onPointerMove, onPointerUp } = useSheetResize({
- defaultWidth: 420,
- minWidth: 320,
- maxWidthRatio: 0.6,
- })
-
const currentUser = useCurrentUser()
const uiHandlers = useUiHandlers()
const queryClient = useQueryClient()
@@ -395,76 +388,59 @@ export function MessageContextSheet({
}, [open, anchorId, targetSeq])
return (
- <Sheet open={open} onOpenChange={onOpenChange} modal={false} disablePointerDismissal>
- <SheetContent
- side="right"
- showOverlay={false}
- style={{ width: `min(${width}px, 100vw)`, maxWidth: "none" }}
- className="flex flex-col p-0 data-[side=right]:sm:inset-y-2 data-[side=right]:sm:right-2 data-[side=right]:sm:h-auto data-[side=right]:sm:rounded-xl data-[side=right]:sm:border data-[side=right]:sm:overflow-hidden"
- >
- <SheetResizeHandle onPointerDown={onPointerDown} onPointerMove={onPointerMove} onPointerUp={onPointerUp} />
- {/* Header names WHICH channel's context this is (Gus #417/#423, Alli
- #420): channel icon + name as the primary line, the seq as weaker
- secondary info — the intent here is "reading a channel's context",
- the seq is just the locator. Shown consistently (same- or cross-
- channel) for one message-side-sheet mental model. Frameless (no
- border) matches the existing quiet header. Falls back to just `#N`
- if no label was passed (older callers). */}
- <SheetHeader className="gap-0 border-b-0 py-3 pr-14 sm:pr-14">
- <SheetTitle className="flex w-full min-w-0 items-center gap-1.5 text-lg font-semibold tracking-tight">
- {channelLabel ? (
- <>
- <ChannelIcon className="shrink-0 text-muted-foreground" />
- <span className="min-w-0 truncate">{channelLabel}</span>
- <span className="shrink-0 font-mono text-base font-normal text-muted-foreground">#{targetSeq ?? ""}</span>
- </>
- ) : (
- <span className="font-mono text-2xl">
- <span className="text-muted-foreground">#</span>{targetSeq ?? ""}
- </span>
- )}
- </SheetTitle>
- </SheetHeader>
-
- <div ref={bodyRef} className="flex-1 overflow-y-auto thin-scrollbar px-4 py-3">
- {query.isLoading && <ContextSkeleton />}
-
- {query.isError && (
- <p className="py-8 text-center text-sm text-muted-foreground">
- Couldn&rsquo;t load the message. Check your connection and retry.
- </p>
- )}
-
- {query.data?.notFound && (
- <p className="py-8 text-center text-sm text-muted-foreground">
- Message not found — it may have been deleted.
- </p>
- )}
-
- {!query.isLoading && !query.isError && query.data && !query.data.notFound && (
- <ContextRows
- rows={renderRows}
- viewerUserId={currentUser.id}
- anchorId={anchorId}
- pinnedIds={pinnedIds}
- onOpenProfile={onOpenProfile}
- onOpenThread={type === "channel" ? onOpenThreadId : undefined}
- resolveUserName={resolveUserName}
- onToggleReaction={toggleReaction}
- onReact={toggleReaction}
- onReply={onReply ? onReplyId : undefined}
- onCopy={onCopyId}
- onPin={type === "channel" ? onPinId : undefined}
- onMark={onMarkId}
- onCreateThread={type === "channel" ? onCreateThreadId : undefined}
- onPreviewImage={onPreviewImage}
- onPreviewAttachment={onPreviewAttachment}
- onDownloadFile={onDownloadFile}
- />
- )}
- </div>
- </SheetContent>
- </Sheet>
+ <CommunitySheet
+ open={open}
+ onOpenChange={onOpenChange}
+ title={channelLabel ? (
+ <span className="flex w-full min-w-0 items-center gap-1.5">
+ <ChannelIcon className="shrink-0 text-muted-foreground" />
+ <span className="min-w-0 truncate">{channelLabel}</span>
+ <span className="shrink-0 font-mono text-base font-normal text-muted-foreground">#{targetSeq ?? ""}</span>
+ </span>
+ ) : (
+ <span className="font-mono text-2xl">
+ <span className="text-muted-foreground">#</span>{targetSeq ?? ""}
+ </span>
+ )}
+ bodyRef={bodyRef}
+ bodyClassName="px-4 py-3"
+ >
+ {query.isLoading && <ContextSkeleton />}
+
+ {query.isError && (
+ <p className="py-8 text-center text-sm text-muted-foreground">
+ Couldn&rsquo;t load the message. Check your connection and retry.
+ </p>
+ )}
+
+ {query.data?.notFound && (
+ <p className="py-8 text-center text-sm text-muted-foreground">
+ Message not found — it may have been deleted.
+ </p>
+ )}
+
+ {!query.isLoading && !query.isError && query.data && !query.data.notFound && (
+ <ContextRows
+ rows={renderRows}
+ viewerUserId={currentUser.id}
+ anchorId={anchorId}
+ pinnedIds={pinnedIds}
+ onOpenProfile={onOpenProfile}
+ onOpenThread={type === "channel" ? onOpenThreadId : undefined}
+ resolveUserName={resolveUserName}
+ onToggleReaction={toggleReaction}
+ onReact={toggleReaction}
+ onReply={onReply ? onReplyId : undefined}
+ onCopy={onCopyId}
+ onPin={type === "channel" ? onPinId : undefined}
+ onMark={onMarkId}
+ onCreateThread={type === "channel" ? onCreateThreadId : undefined}
+ onPreviewImage={onPreviewImage}
+ onPreviewAttachment={onPreviewAttachment}
+ onDownloadFile={onDownloadFile}
+ />
+ )}
+ </CommunitySheet>
)
}
diff --git a/src/web/src/components/community/shell/community-panel-sheet.tsx b/src/web/src/components/community/shell/community-panel-sheet.tsx
deleted file mode 100644
index 71e5e77bf..000000000
--- a/src/web/src/components/community/shell/community-panel-sheet.tsx
+++ /dev/null
@@ -1,124 +0,0 @@
-"use client"
-
-import { Sheet, SheetContent, SheetTitle } from "@/components/ui/sheet"
-import { useSheetResize, SheetResizeHandle } from "@/components/ui/sheet-resize-handle"
-import { RightPanelContent } from "./right-panel"
-import type { RightPanel } from "@/components/community/shell/panel-types"
-import type { Member } from "@/lib/community/models/people"
-import type { CommunityRole as Role } from "@alook/shared"
-import type { Msg, Thread } from "@/lib/community/models/message"
-import type { OpenProfile } from "@/components/community/social/profile-types"
-import type { MemberManageContext } from "@/components/community/members/member-management-types"
-
-// Sheet-based right panel for the community channel UI.
-// Renders the channel's threads / pinned / members / search panel as a non-modal Sheet:
-// page content stays interactive, the sheet floats on top with its own shadow and resize
-// handle on desktop, full-width on mobile.
-export function CommunityPanelSheet({
- open,
- onOpenChange,
- kind,
- members,
- membersLoading,
- membersLoadingMore,
- membersHasMore,
- onLoadMoreMembers,
- onSearchMembers,
- onAddMember,
- manageContext,
- pinned,
- pinnedLoading,
- searchResults,
- searchQuery,
- threads,
- threadsLoading,
- onOpenThread,
- onOpenProfile,
- onSetRole,
- onKickMember,
- myRole,
- onJumpToMessage,
- onSearch,
- viewerUserId,
-}: {
- open: boolean
- onOpenChange: (v: boolean) => void
- kind: Exclude<RightPanel, null>
- members: Member[]
- membersLoading?: boolean
- membersLoadingMore?: boolean
- membersHasMore?: boolean
- onLoadMoreMembers?: () => void
- onSearchMembers?: (q: string) => void
- onAddMember?: () => void
- manageContext?: MemberManageContext
- pinned: Msg[]
- pinnedLoading?: boolean
- searchResults: Msg[]
- searchQuery?: string
- threads: Thread[]
- threadsLoading?: boolean
- onOpenThread: (id: string) => void
- onOpenProfile?: OpenProfile
- onSetRole?: (memberId: string, role: Role) => void
- onKickMember?: (memberId: string) => Promise<unknown> | void
- myRole?: Role
- onJumpToMessage?: (seq: number) => void
- onSearch?: (query: string) => void
- viewerUserId?: string
-}) {
- const { width, onPointerDown, onPointerMove, onPointerUp } = useSheetResize({
- defaultWidth: 380,
- minWidth: 280,
- maxWidthRatio: 0.6,
- })
-
- return (
- <Sheet open={open} onOpenChange={onOpenChange} modal={false} disablePointerDismissal>
- <SheetContent
- side="right"
- showOverlay={false}
- style={{ width: `min(${width}px, 100vw)`, maxWidth: "none" }}
- className="data-[side=right]:sm:inset-y-2 data-[side=right]:sm:right-2 data-[side=right]:sm:h-auto data-[side=right]:sm:rounded-xl data-[side=right]:sm:border data-[side=right]:sm:overflow-hidden"
- >
- <SheetTitle className="sr-only">{panelTitle(kind)}</SheetTitle>
- <SheetResizeHandle onPointerDown={onPointerDown} onPointerMove={onPointerMove} onPointerUp={onPointerUp} />
- <RightPanelContent
- kind={kind}
- members={members}
- membersLoading={membersLoading}
- membersLoadingMore={membersLoadingMore}
- membersHasMore={membersHasMore}
- onLoadMoreMembers={onLoadMoreMembers}
- onSearchMembers={onSearchMembers}
- onAddMember={onAddMember}
- manageContext={manageContext}
- pinned={pinned}
- pinnedLoading={pinnedLoading}
- searchResults={searchResults}
- searchQuery={searchQuery}
- threads={threads}
- threadsLoading={threadsLoading}
- showSearchInput
- onOpenThread={onOpenThread}
- onOpenProfile={onOpenProfile}
- onSetRole={onSetRole}
- onKickMember={onKickMember}
- myRole={myRole}
- onJumpToMessage={onJumpToMessage}
- onSearch={onSearch}
- viewerUserId={viewerUserId}
- />
- </SheetContent>
- </Sheet>
- )
-}
-
-function panelTitle(kind: Exclude<RightPanel, null>): string {
- switch (kind) {
- case "members": return "Members"
- case "pinned": return "Pinned Messages"
- case "search": return "Search"
- case "threads": return "Threads"
- }
-}
diff --git a/src/web/src/components/community/shell/community-panel.tsx b/src/web/src/components/community/shell/community-panel.tsx
new file mode 100644
index 000000000..bc2ed9626
--- /dev/null
+++ b/src/web/src/components/community/shell/community-panel.tsx
@@ -0,0 +1,284 @@
+"use client"
+
+import { useState } from "react"
+import { MessagesSquare, Pin, Search, Users } from "lucide-react"
+import { stripInlineMarkup, type CommunityRole as Role } from "@alook/shared"
+
+import { Avatar } from "@/components/community/avatar"
+import { MemberList } from "@/components/community/members/member-list"
+import { Message } from "@/components/community/messages/message"
+import { CommunitySheet } from "@/components/community/shell/community-sheet"
+import { Input } from "@/components/ui/input"
+import { Skeleton } from "@/components/ui/skeleton"
+import { formatRelativeTime } from "@/lib/community/format-time"
+import { onEnterSubmit } from "@/lib/ime"
+import type { MemberManageContext } from "@/components/community/members/member-management-types"
+import type { OpenProfile } from "@/components/community/social/profile-types"
+import type { RightPanel } from "@/components/community/shell/panel-types"
+import type { Msg, RenderMsg, Thread } from "@/lib/community/models/message"
+import type { Member } from "@/lib/community/models/people"
+
+export type CommunityPanelProps = {
+ open: boolean
+ onOpenChange: (open: boolean) => void
+ kind: Exclude<RightPanel, null>
+ members: Member[]
+ membersLoading?: boolean
+ membersLoadingMore?: boolean
+ membersHasMore?: boolean
+ onLoadMoreMembers?: () => void
+ onSearchMembers?: (query: string) => void
+ onAddMember?: () => void
+ manageContext?: MemberManageContext
+ pinned: Msg[]
+ pinnedLoading?: boolean
+ searchResults: Msg[]
+ searchQuery?: string
+ threads: Thread[]
+ threadsLoading?: boolean
+ onOpenThread: (id: string) => void
+ onOpenProfile?: OpenProfile
+ onSetRole?: (memberId: string, role: Role) => void
+ onKickMember?: (memberId: string) => Promise<unknown> | void
+ myRole?: Role
+ onJumpToMessage?: (seq: number) => void
+ onSearch?: (query: string) => void
+ viewerUserId?: string
+}
+
+/** Members, pins, search, and threads business content in the shared modal shell. */
+export function CommunityPanel(props: CommunityPanelProps) {
+ const { open, onOpenChange, kind } = props
+ const { icon: Icon, label } = panelHeading(kind)
+
+ return (
+ <CommunitySheet
+ open={open}
+ onOpenChange={onOpenChange}
+ title={(
+ <span className="flex min-w-0 items-center gap-2">
+ <Icon className="size-4 shrink-0 text-muted-foreground" />
+ <span className="truncate">{label}</span>
+ </span>
+ )}
+ desktopWidth={kind === "members" ? 380 : undefined}
+ bodyClassName={kind === "members" ? "p-0 sm:p-0" : undefined}
+ >
+ {renderCommunityPanelBody(props)}
+ </CommunitySheet>
+ )
+}
+
+function renderCommunityPanelBody({
+ kind,
+ members,
+ membersLoading,
+ membersLoadingMore,
+ membersHasMore,
+ onLoadMoreMembers,
+ onSearchMembers,
+ onAddMember,
+ manageContext,
+ pinned,
+ pinnedLoading,
+ searchResults,
+ searchQuery,
+ threads,
+ threadsLoading,
+ onOpenThread,
+ onOpenProfile,
+ onSetRole,
+ onKickMember,
+ myRole,
+ onJumpToMessage,
+ onSearch,
+ viewerUserId,
+}: CommunityPanelProps) {
+ if (kind === "members") {
+ return (
+ <MemberList
+ members={members}
+ loading={membersLoading}
+ hasMore={membersHasMore}
+ loadingMore={membersLoadingMore}
+ onLoadMore={onLoadMoreMembers}
+ onSearch={onSearchMembers}
+ onAddMember={onAddMember}
+ manageContext={manageContext}
+ myRole={myRole}
+ onOpenProfile={onOpenProfile}
+ onSetRole={onSetRole}
+ onKick={onKickMember}
+ />
+ )
+ }
+
+ if (kind === "pinned") {
+ if (pinnedLoading && pinned.length === 0) return <PinnedListSkeleton />
+ if (pinned.length === 0) {
+ return <div className="py-8 text-center text-sm text-muted-foreground">No pinned messages yet.</div>
+ }
+ return pinned.map((message) => (
+ <button
+ key={message.id}
+ onClick={() => message.seq != null && onJumpToMessage?.(message.seq)}
+ className="flex w-full items-center gap-2 rounded-md px-2 py-2 text-left hover:bg-accent"
+ >
+ <span className="shrink-0">
+ <Avatar label={message.authorAvatar ?? "?"} seed={message.authorId} size={24} />
+ </span>
+ <div className="min-w-0 flex-1">
+ <div className="flex items-baseline gap-2">
+ <span className="text-sm font-medium">{message.authorName}</span>
+ {message.createdAt && (
+ <span className="text-xs text-muted-foreground">
+ {formatRelativeTime(message.createdAt)}
+ </span>
+ )}
+ </div>
+ <div className="truncate text-sm text-muted-foreground">
+ {stripInlineMarkup(message.content ?? "")}
+ </div>
+ </div>
+ </button>
+ ))
+ }
+
+ if (kind === "search") {
+ return (
+ <SearchPanel
+ searchResults={searchResults}
+ initialQuery={searchQuery}
+ onOpenProfile={onOpenProfile}
+ onSearch={onSearch}
+ viewerUserId={viewerUserId}
+ />
+ )
+ }
+
+ if (threadsLoading && threads.length === 0) return <ThreadListSkeleton />
+ return (
+ <>
+ <div className="mb-2 text-xs text-muted-foreground">{threads.length} threads</div>
+ <div className="space-y-1">
+ {threads.map((thread) => (
+ <button
+ key={thread.id}
+ onClick={() => onOpenThread(thread.id)}
+ className="flex w-full items-start gap-3 rounded-md px-2 py-2 text-left hover:bg-accent"
+ >
+ <MessagesSquare className="mt-0.5 size-4 shrink-0 text-muted-foreground" />
+ <div className="min-w-0 flex-1">
+ <div className="truncate text-sm font-medium">{thread.name}</div>
+ <div className="truncate text-xs text-muted-foreground">
+ <span className="font-medium text-foreground/80">{thread.parent.authorName}</span>{" "}
+ {stripInlineMarkup(thread.parent.text)}
+ </div>
+ <div className="mt-1 text-xs text-muted-foreground" suppressHydrationWarning>
+ {thread.messageCount} messages · {formatRelativeTime(thread.lastMessageAt)}
+ </div>
+ </div>
+ </button>
+ ))}
+ </div>
+ </>
+ )
+}
+
+function panelHeading(kind: Exclude<RightPanel, null>) {
+ switch (kind) {
+ case "members":
+ return { icon: Users, label: "Members" }
+ case "pinned":
+ return { icon: Pin, label: "Pinned Messages" }
+ case "search":
+ return { icon: Search, label: "Search" }
+ case "threads":
+ return { icon: MessagesSquare, label: "Threads" }
+ }
+}
+
+function SearchPanel({
+ searchResults,
+ initialQuery,
+ onOpenProfile,
+ onSearch,
+ viewerUserId,
+}: {
+ searchResults: Msg[]
+ initialQuery?: string
+ onOpenProfile?: OpenProfile
+ onSearch?: (query: string) => void
+ viewerUserId?: string
+}) {
+ const [query, setQuery] = useState(initialQuery ?? "")
+ const submit = () => {
+ const nextQuery = query.trim()
+ if (nextQuery) onSearch?.(nextQuery)
+ }
+
+ return (
+ <>
+ <div className="relative mb-3">
+ <Search className="absolute top-1/2 left-2 size-4 -translate-y-1/2 text-muted-foreground" />
+ <Input
+ className="h-9 pl-8"
+ placeholder="Search messages"
+ value={query}
+ onChange={(event) => setQuery(event.target.value)}
+ onKeyDown={onEnterSubmit(submit)}
+ />
+ </div>
+ <div className="mb-2 text-xs text-muted-foreground">{searchResults.length} results</div>
+ {searchResults.map((message) => {
+ const renderMessage: RenderMsg = { ...message, grouped: false }
+ return (
+ <Message
+ key={message.id}
+ m={renderMessage}
+ compact
+ viewerUserId={viewerUserId}
+ onOpenThread={() => {}}
+ onOpenProfile={onOpenProfile}
+ />
+ )
+ })}
+ </>
+ )
+}
+
+function PinnedListSkeleton() {
+ return (
+ <div className="space-y-2">
+ {Array.from({ length: 3 }).map((_, index) => (
+ <div key={index} className="flex gap-2 rounded-md px-2 py-2">
+ <Skeleton className="size-6 shrink-0 rounded-full" />
+ <div className="flex min-w-0 flex-1 flex-col gap-2">
+ <div className="flex items-baseline gap-2">
+ <Skeleton className="h-3 w-20 rounded" />
+ <Skeleton className="h-3 w-10 rounded" />
+ </div>
+ <Skeleton className="h-3 w-5/6 rounded" />
+ </div>
+ </div>
+ ))}
+ </div>
+ )
+}
+
+function ThreadListSkeleton() {
+ return (
+ <div className="space-y-1">
+ {Array.from({ length: 3 }).map((_, index) => (
+ <div key={index} className="flex items-start gap-3 rounded-md px-2 py-2">
+ <Skeleton className="mt-0.5 size-4 shrink-0 rounded" />
+ <div className="flex min-w-0 flex-1 flex-col gap-2">
+ <Skeleton className="h-3.5 w-3/5 rounded" />
+ <Skeleton className="h-3 w-11/12 rounded" />
+ <Skeleton className="h-3 w-2/5 rounded" />
+ </div>
+ </div>
+ ))}
+ </div>
+ )
+}
diff --git a/src/web/src/components/community/shell/community-sheet-migrations.test.ts b/src/web/src/components/community/shell/community-sheet-migrations.test.ts
new file mode 100644
index 000000000..c62617b1f
--- /dev/null
+++ b/src/web/src/components/community/shell/community-sheet-migrations.test.ts
@@ -0,0 +1,76 @@
+import { existsSync, readFileSync } from "node:fs"
+import { describe, expect, it } from "vitest"
+
+const migrations = [
+ "./community-panel.tsx",
+ "../messages/message-context-sheet.tsx",
+ "../messages/attachment-preview-sheet.tsx",
+ "../bots/create-bot-sheet.tsx",
+ "../bots/edit-bot-sheet.tsx",
+ "../machines/pair-machine-sheet.tsx",
+] as const
+
+describe("CommunitySheet migrations", () => {
+ it.each(migrations)("routes %s through the one structured modal shell", (path) => {
+ const source = readFileSync(new URL(path, import.meta.url), "utf8")
+
+ expect(source).toContain("@/components/community/shell/community-sheet")
+ expect(source).toContain("<CommunitySheet")
+ expect(source).toContain("title=")
+ expect(source).not.toContain("@/components/ui/sheet")
+ expect(source).not.toContain("@/components/ui/sheet-resize-handle")
+ expect(source).not.toMatch(/mode="(?:sidecar|task|preview)"/)
+ expect(source).not.toContain("initialWidth=")
+ expect(source).not.toMatch(/CommunitySheet(?:Header|Body|Footer|Title|Description|Close)/)
+ })
+
+ it("allows only Attachment Preview to opt into the fixed resize policy", () => {
+ for (const path of migrations) {
+ const source = readFileSync(new URL(path, import.meta.url), "utf8")
+ if (path.includes("attachment-preview")) expect(source).toContain("resizable")
+ else expect(source).not.toContain("resizable")
+ }
+ })
+
+ it("keeps only Members on the compact desktop width", () => {
+ for (const path of migrations) {
+ const source = readFileSync(new URL(path, import.meta.url), "utf8")
+ if (path === "./community-panel.tsx") {
+ expect(source).toContain('desktopWidth={kind === "members" ? 380 : undefined}')
+ } else {
+ expect(source).not.toContain("desktopWidth=")
+ }
+ }
+ })
+
+ it("collapses the community panel to one business layer", () => {
+ const panel = readFileSync(new URL("./community-panel.tsx", import.meta.url), "utf8")
+ expect(panel).toContain("export function CommunityPanel")
+ expect(panel).not.toContain("RightPanelContent")
+ expect(existsSync(new URL("./community-panel-sheet.tsx", import.meta.url))).toBe(false)
+ expect(existsSync(new URL("./right-panel.tsx", import.meta.url))).toBe(false)
+ expect(existsSync(new URL("./panel-shell.tsx", import.meta.url))).toBe(false)
+ })
+
+ it("leaves Attachment Preview with one wrapper-owned close entry", () => {
+ const source = readFileSync(
+ new URL("../messages/attachment-preview-sheet.tsx", import.meta.url),
+ "utf8",
+ )
+
+ expect(source).toContain('closeLabel="Close attachment preview"')
+ expect(source).not.toContain("ArrowLeft")
+ expect(source).not.toContain("<X")
+ })
+
+ it("routes PairMachine footer close through the shell request", () => {
+ const source = readFileSync(
+ new URL("../machines/pair-machine-sheet.tsx", import.meta.url),
+ "utf8",
+ )
+ expect(source).toContain("footer={(requestClose)")
+ expect(source).toContain("onClick={requestClose}")
+ expect(source).toContain('className="min-h-11!"')
+ expect(source).not.toContain("CommunitySheetClose")
+ })
+})
diff --git a/src/web/src/components/community/shell/community-sheet.test.ts b/src/web/src/components/community/shell/community-sheet.test.ts
new file mode 100644
index 000000000..dc53eff78
--- /dev/null
+++ b/src/web/src/components/community/shell/community-sheet.test.ts
@@ -0,0 +1,136 @@
+import React from "react"
+import TestRenderer, { act } from "react-test-renderer"
+import { beforeEach, describe, expect, it, vi } from "vitest"
+
+const { resizeHandle, resizeHook } = vi.hoisted(() => ({
+ resizeHandle: vi.fn(() => null),
+ resizeHook: vi.fn(() => ({
+ width: 480,
+ onPointerDown: vi.fn(),
+ onPointerMove: vi.fn(),
+ onPointerUp: vi.fn(),
+ })),
+}))
+
+vi.mock("@/components/ui/sheet", () => {
+ const pass = (type: string) =>
+ function Passthrough({ children, ...props }: React.PropsWithChildren<Record<string, unknown>>) {
+ return React.createElement(type, props, children)
+ }
+ return {
+ Sheet: pass("sheet-root"),
+ SheetBody: pass("sheet-body"),
+ SheetContent: pass("sheet-content"),
+ SheetDescription: pass("sheet-description"),
+ SheetFooter: pass("sheet-footer"),
+ SheetHeader: pass("sheet-header"),
+ SheetTitle: pass("sheet-title"),
+ }
+})
+
+vi.mock("@/components/ui/button", () => ({
+ Button: (props: React.PropsWithChildren<Record<string, unknown>>) =>
+ React.createElement("button", props, props.children),
+}))
+
+vi.mock("@/components/ui/sheet-resize-handle", () => ({
+ useSheetResize: resizeHook,
+ SheetResizeHandle: (props: Record<string, unknown>) => resizeHandle(props),
+}))
+
+import { CommunitySheet } from "./community-sheet"
+
+function renderSheet(
+ props: Partial<React.ComponentProps<typeof CommunitySheet>> = {},
+) {
+ const onOpenChange = props.onOpenChange ?? vi.fn()
+ let renderer!: TestRenderer.ReactTestRenderer
+ act(() => {
+ renderer = TestRenderer.create(
+ React.createElement(
+ CommunitySheet,
+ { open: true, onOpenChange, title: "Sheet title", ...props },
+ React.createElement("div", null, "content"),
+ ),
+ )
+ })
+ return { renderer, onOpenChange }
+}
+
+describe("CommunitySheet contracts", () => {
+ beforeEach(() => {
+ resizeHandle.mockClear()
+ resizeHook.mockClear()
+ })
+
+ it("makes every community surface modal, overlay-backed, and 480px on desktop", () => {
+ const { renderer } = renderSheet()
+ expect(renderer.root.findByType("sheet-root").props.modal).toBe(true)
+ const content = renderer.root.findByType("sheet-content")
+ expect(content.props.showOverlay).toBe(true)
+ expect(content.props.style["--community-sheet-width"]).toBe("480px")
+ expect(content.props.style["--community-sheet-max-width"]).toBe("80vw")
+ expect(resizeHook).not.toHaveBeenCalled()
+ expect(resizeHandle).not.toHaveBeenCalled()
+ })
+
+ it("uses the primitive resize policy only when Attachment opts in", () => {
+ const { renderer } = renderSheet({ resizable: true })
+ const content = renderer.root.findByType("sheet-content")
+ expect(content.props.style["--community-sheet-width"]).toBe("480px")
+ expect(content.props.style["--community-sheet-max-width"]).toBe("80vw")
+ expect(resizeHook).toHaveBeenCalledWith({ defaultWidth: 480 })
+ expect(resizeHandle).toHaveBeenCalledOnce()
+ })
+
+ it("accepts a compact desktop width while keeping the internal 320px floor", () => {
+ const compact = renderSheet({ desktopWidth: 380 }).renderer.root.findByType("sheet-content")
+ expect(compact.props.style["--community-sheet-width"]).toBe("380px")
+
+ const clamped = renderSheet({ desktopWidth: 200 }).renderer.root.findByType("sheet-content")
+ expect(clamped.props.style["--community-sheet-width"]).toBe("320px")
+ })
+
+ it("uses one CSS-only 640px geometry checkpoint and a 44px mobile close", () => {
+ const { renderer } = renderSheet()
+ const content = renderer.root.findByType("sheet-content")
+ expect(content.props.className).toContain("data-[side=right]:h-dvh")
+ expect(content.props.className).toContain("data-[side=right]:w-screen")
+ expect(content.props.className).toContain("data-[side=right]:sm:inset-y-2")
+ expect(content.props.className).toContain(
+ "data-[side=right]:sm:w-[clamp(20rem,var(--community-sheet-width),min(var(--community-sheet-max-width),calc(100vw-1rem)))]",
+ )
+ expect(renderer.root.findByProps({ "aria-label": "Close" }).props.className).toContain("size-11")
+ })
+
+ it("owns header, body, footer, and routes every close entry through one request", () => {
+ const onOpenChange = vi.fn()
+ const { renderer } = renderSheet({
+ onOpenChange,
+ title: "Structured title",
+ description: "Structured description",
+ headerActions: React.createElement("a", { "data-action": true }, "Download"),
+ bodyClassName: "body-policy",
+ footer: (requestClose) => React.createElement(
+ "button",
+ { "data-footer-close": true, onClick: requestClose },
+ "Done",
+ ),
+ })
+
+ expect(renderer.root.findByType("sheet-title").children).toEqual(["Structured title"])
+ expect(renderer.root.findByType("sheet-description").children).toEqual(["Structured description"])
+ expect(renderer.root.findByProps({ "data-action": true })).toBeTruthy()
+ expect(renderer.root.findByType("sheet-body").props.className).toBe("body-policy")
+ expect(renderer.root.findByType("sheet-footer").props.className).toContain(
+ "**:data-[slot=button]:min-h-11",
+ )
+
+ act(() => renderer.root.findByType("sheet-root").props.onOpenChange(false))
+ act(() => renderer.root.findByProps({ "aria-label": "Close" }).props.onClick())
+ act(() => renderer.root.findByProps({ "data-footer-close": true }).props.onClick())
+ expect(onOpenChange).toHaveBeenNthCalledWith(1, false)
+ expect(onOpenChange).toHaveBeenNthCalledWith(2, false)
+ expect(onOpenChange).toHaveBeenNthCalledWith(3, false)
+ })
+})
diff --git a/src/web/src/components/community/shell/community-sheet.tsx b/src/web/src/components/community/shell/community-sheet.tsx
new file mode 100644
index 000000000..355e5f24f
--- /dev/null
+++ b/src/web/src/components/community/shell/community-sheet.tsx
@@ -0,0 +1,221 @@
+"use client"
+
+import * as React from "react"
+import { XIcon } from "lucide-react"
+
+import { Button } from "@/components/ui/button"
+import {
+ Sheet,
+ SheetBody,
+ SheetContent,
+ SheetDescription,
+ SheetFooter,
+ SheetHeader,
+ SheetTitle,
+} from "@/components/ui/sheet"
+import {
+ SheetResizeHandle,
+ useSheetResize,
+} from "@/components/ui/sheet-resize-handle"
+import { cn } from "@/lib/utils"
+
+const COMMUNITY_SHEET_WIDTH = 480
+const COMMUNITY_SHEET_MIN_WIDTH = 320
+
+type CommunitySheetProps = {
+ open: boolean
+ onOpenChange: (open: boolean) => void
+ title: React.ReactNode
+ description?: React.ReactNode
+ headerActions?: React.ReactNode
+ footer?: React.ReactNode | ((requestClose: () => void) => React.ReactNode)
+ children: React.ReactNode
+ bodyClassName?: string
+ bodyRef?: React.Ref<HTMLDivElement>
+ desktopWidth?: number
+ resizable?: boolean
+ closeLabel?: string
+ contentTestId?: string
+ bodyTestId?: string
+}
+
+/**
+ * Controlled modal shell for every community right-hand surface.
+ *
+ * The shell owns structure, dismissal, width, and the CSS-only 640px
+ * checkpoint. Callers supply business content through the title, actions,
+ * body, and optional footer slots. Attachment preview is the only caller that
+ * opts into the fixed internal resize policy.
+ */
+export function CommunitySheet({
+ open,
+ onOpenChange,
+ title,
+ description,
+ headerActions,
+ footer,
+ children,
+ bodyClassName,
+ bodyRef,
+ desktopWidth = COMMUNITY_SHEET_WIDTH,
+ resizable = false,
+ closeLabel = "Close",
+ contentTestId,
+ bodyTestId,
+}: CommunitySheetProps) {
+ const requestClose = React.useCallback(() => onOpenChange(false), [onOpenChange])
+ const handleOpenChange = React.useCallback(
+ (nextOpen: boolean) => {
+ if (nextOpen) onOpenChange(true)
+ else requestClose()
+ },
+ [onOpenChange, requestClose],
+ )
+
+ return (
+ <Sheet open={open} onOpenChange={handleOpenChange} modal>
+ {resizable ? (
+ <ResizableCommunitySheetContent
+ title={title}
+ description={description}
+ headerActions={headerActions}
+ footer={footer}
+ bodyClassName={bodyClassName}
+ bodyRef={bodyRef}
+ desktopWidth={desktopWidth}
+ closeLabel={closeLabel}
+ contentTestId={contentTestId}
+ bodyTestId={bodyTestId}
+ requestClose={requestClose}
+ >
+ {children}
+ </ResizableCommunitySheetContent>
+ ) : (
+ <CommunitySheetContent
+ width={clampDesktopWidth(desktopWidth)}
+ maxWidth="80vw"
+ title={title}
+ description={description}
+ headerActions={headerActions}
+ footer={footer}
+ bodyClassName={bodyClassName}
+ bodyRef={bodyRef}
+ closeLabel={closeLabel}
+ contentTestId={contentTestId}
+ bodyTestId={bodyTestId}
+ requestClose={requestClose}
+ >
+ {children}
+ </CommunitySheetContent>
+ )}
+ </Sheet>
+ )
+}
+
+type CommunitySheetContentProps = Pick<
+ CommunitySheetProps,
+ | "title"
+ | "description"
+ | "headerActions"
+ | "footer"
+ | "children"
+ | "bodyClassName"
+ | "bodyRef"
+ | "closeLabel"
+ | "contentTestId"
+ | "bodyTestId"
+> & {
+ width: number
+ maxWidth: string
+ requestClose: () => void
+ resize?: React.ComponentProps<typeof SheetResizeHandle>
+}
+
+function CommunitySheetContent({
+ width,
+ maxWidth,
+ resize,
+ title,
+ description,
+ headerActions,
+ footer,
+ children,
+ bodyClassName,
+ bodyRef,
+ closeLabel,
+ contentTestId,
+ bodyTestId,
+ requestClose,
+}: CommunitySheetContentProps) {
+ const footerContent = typeof footer === "function" ? footer(requestClose) : footer
+
+ return (
+ <SheetContent
+ data-testid={contentTestId}
+ side="right"
+ showOverlay
+ showCloseButton={false}
+ style={{
+ "--community-sheet-width": `${width}px`,
+ "--community-sheet-max-width": maxWidth,
+ maxWidth: "none",
+ } as React.CSSProperties}
+ className={cn(
+ "data-[side=right]:h-dvh data-[side=right]:w-screen data-[side=right]:max-w-none data-[side=right]:overflow-hidden",
+ "data-[side=right]:sm:inset-y-2 data-[side=right]:sm:right-2 data-[side=right]:sm:h-auto data-[side=right]:sm:w-[clamp(20rem,var(--community-sheet-width),min(var(--community-sheet-max-width),calc(100vw-1rem)))] data-[side=right]:sm:rounded-xl data-[side=right]:sm:border",
+ )}
+ >
+ {resize && <SheetResizeHandle {...resize} />}
+ <SheetHeader className="pr-14 sm:pr-14">
+ <div className="flex min-w-0 items-start gap-2">
+ <div className="min-w-0 flex-1">
+ <SheetTitle className="truncate">{title}</SheetTitle>
+ {description != null && <SheetDescription>{description}</SheetDescription>}
+ </div>
+ {headerActions != null && <div className="shrink-0">{headerActions}</div>}
+ </div>
+ </SheetHeader>
+ <SheetBody ref={bodyRef} data-testid={bodyTestId} className={bodyClassName}>
+ {children}
+ </SheetBody>
+ {footerContent != null && (
+ <SheetFooter className="**:data-[slot=button]:min-h-11 sm:**:data-[slot=button]:min-h-0">
+ {footerContent}
+ </SheetFooter>
+ )}
+ <Button
+ type="button"
+ variant="ghost"
+ size="icon-sm"
+ className="absolute top-0.5 right-0.5 z-20 size-11 sm:top-3 sm:right-3 sm:size-7"
+ aria-label={closeLabel}
+ onClick={requestClose}
+ >
+ <XIcon />
+ <span className="sr-only">{closeLabel}</span>
+ </Button>
+ </SheetContent>
+ )
+}
+
+type ResizableCommunitySheetContentProps = Omit<
+ CommunitySheetContentProps,
+ "width" | "maxWidth" | "resize"
+> & { desktopWidth: number }
+
+function ResizableCommunitySheetContent({
+ desktopWidth,
+ ...props
+}: ResizableCommunitySheetContentProps) {
+ const resize = useSheetResize({ defaultWidth: clampDesktopWidth(desktopWidth) })
+
+ return (
+ <CommunitySheetContent {...props} width={resize.width} maxWidth="80vw" resize={resize} />
+ )
+}
+
+function clampDesktopWidth(width: number): number {
+ return Number.isFinite(width)
+ ? Math.max(COMMUNITY_SHEET_MIN_WIDTH, width)
+ : COMMUNITY_SHEET_WIDTH
+}
diff --git a/src/web/src/components/community/shell/panel-shell.tsx b/src/web/src/components/community/shell/panel-shell.tsx
deleted file mode 100644
index 625226fd9..000000000
--- a/src/web/src/components/community/shell/panel-shell.tsx
+++ /dev/null
@@ -1,33 +0,0 @@
-import type React from "react"
-import type { LucideIcon } from "lucide-react"
-import { ChevronLeft } from "lucide-react"
-
-// Right-panel chrome (header + scroll body) shared by members / pinned / search / threads.
-// Rendered inside a Sheet — the Sheet provides the outer frame (rounded card, bg, close
-// button), so this component only contributes the in-content header and the scroll body.
-// Returns a Fragment so SheetContent's rounded corners aren't covered by a square wrapper.
-export function PanelShell({
- icon: Icon, title, children, bodyClassName = "p-4", onBack,
-}: {
- icon: LucideIcon
- title: string
- children: React.ReactNode
- bodyClassName?: string
- onBack?: () => void
-}) {
- return (
- <>
- <header className="flex h-12 shrink-0 items-center gap-2 border-b border-border/40 px-4">
- {onBack ? (
- <button onClick={onBack} className="-ml-1 grid size-7 shrink-0 place-items-center rounded-md text-muted-foreground hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none" aria-label="Back to threads">
- <ChevronLeft className="size-4" />
- </button>
- ) : (
- <Icon className="size-4 text-muted-foreground" />
- )}
- <h2 className="flex-1 truncate text-base font-semibold">{title}</h2>
- </header>
- <div className={`flex-1 overflow-y-auto thin-scrollbar ${bodyClassName}`}>{children}</div>
- </>
- )
-}
diff --git a/src/web/src/components/community/shell/right-panel.tsx b/src/web/src/components/community/shell/right-panel.tsx
deleted file mode 100644
index 102b69eba..000000000
--- a/src/web/src/components/community/shell/right-panel.tsx
+++ /dev/null
@@ -1,234 +0,0 @@
-"use client"
-
-import { useState } from "react"
-import { Users, Pin, Search, MessagesSquare } from "lucide-react"
-import { Input } from "@/components/ui/input"
-import { onEnterSubmit } from "@/lib/ime"
-import { Skeleton } from "@/components/ui/skeleton"
-import { Avatar } from "../avatar"
-import { PanelShell } from "./panel-shell"
-import { MemberList } from "../members/member-list"
-import { Message } from "../messages/message"
-import { formatRelativeTime } from "@/lib/community/format-time"
-import { stripInlineMarkup, type CommunityRole as Role } from "@alook/shared"
-import type { RightPanel } from "@/components/community/shell/panel-types"
-import type { Member } from "@/lib/community/models/people"
-import type { Msg, RenderMsg, Thread } from "@/lib/community/models/message"
-import type { OpenProfile } from "@/components/community/social/profile-types"
-import type { MemberManageContext } from "@/components/community/members/member-management-types"
-
-// Right-panel content router — members / pinned / search / threads. Data via props.
-// Always wraps the active section in PanelShell — the surrounding Sheet provides the
-// outer frame and its own close button, so we don't need a panel-level close affordance.
-export function RightPanelContent({
- kind, members, membersLoading, membersLoadingMore, membersHasMore, onLoadMoreMembers, onSearchMembers,
- onAddMember, manageContext,
- pinned, pinnedLoading, searchResults, searchQuery,
- threads, threadsLoading, showSearchInput = true, onOpenThread, onOpenProfile,
- onSetRole, onKickMember, myRole, onJumpToMessage, onSearch, viewerUserId,
-}: {
- kind: Exclude<RightPanel, null>
- members: Member[]
- membersLoading?: boolean
- membersLoadingMore?: boolean
- membersHasMore?: boolean
- onLoadMoreMembers?: () => void
- onSearchMembers?: (q: string) => void
- onAddMember?: () => void
- manageContext?: MemberManageContext
- pinned: Msg[]
- pinnedLoading?: boolean
- searchResults: Msg[]
- searchQuery?: string
- threads: Thread[]
- threadsLoading?: boolean
- showSearchInput?: boolean
- onOpenThread: (id: string) => void
- onOpenProfile?: OpenProfile
- onSetRole?: (memberId: string, role: Role) => void
- onKickMember?: (memberId: string) => Promise<unknown> | void
- myRole?: Role
- // Jump to a pinned message by its per-channel seq — routes through the same
- // message-ref jump flow (scroll-in-place if loaded, else open the context
- // sheet), so a click always gives feedback even for an out-of-window pin.
- onJumpToMessage?: (seq: number) => void
- onSearch?: (query: string) => void
- viewerUserId?: string
-}) {
- if (kind === "members")
- return (
- <PanelShell icon={Users} title="Members" bodyClassName="p-0">
- <MemberList
- members={members}
- loading={membersLoading}
- hasMore={membersHasMore}
- loadingMore={membersLoadingMore}
- onLoadMore={onLoadMoreMembers}
- onSearch={onSearchMembers}
- onAddMember={onAddMember}
- manageContext={manageContext}
- myRole={myRole}
- onOpenProfile={onOpenProfile}
- onSetRole={onSetRole}
- onKick={onKickMember}
- />
- </PanelShell>
- )
- if (kind === "pinned")
- return (
- <PanelShell icon={Pin} title="Pinned Messages">
- {pinnedLoading && pinned.length === 0 ? (
- <PinnedListSkeleton />
- ) : pinned.length === 0 ? (
- <div className="py-8 text-center text-sm text-muted-foreground">No pinned messages yet.</div>
- ) : (
- pinned.map((m) => (
- <button
- key={m.id}
- onClick={() => m.seq != null && onJumpToMessage?.(m.seq)}
- className="flex w-full items-center gap-2 rounded-md px-2 py-2 text-left hover:bg-accent"
- >
- <span className="shrink-0">
- <Avatar label={m.authorAvatar ?? "?"} seed={m.authorId} size={24} />
- </span>
-
- <div className="min-w-0 flex-1">
- <div className="flex items-baseline gap-2">
- <span className="text-sm font-medium">{m.authorName}</span>
- {m.createdAt && <span className="text-xs text-muted-foreground">{formatRelativeTime(m.createdAt)}</span>}
- </div>
- <div className="truncate text-sm text-muted-foreground">{stripInlineMarkup(m.content ?? "")}</div>
- </div>
- </button>
- ))
- )}
- </PanelShell>
- )
- if (kind === "search")
- return (
- <SearchPanel
- searchResults={searchResults}
- initialQuery={searchQuery}
- showSearchInput={showSearchInput}
- onOpenProfile={onOpenProfile}
- onSearch={onSearch}
- viewerUserId={viewerUserId}
- />
- )
- return (
- <PanelShell icon={MessagesSquare} title="Threads">
- {threadsLoading && threads.length === 0 ? (
- <ThreadListSkeleton />
- ) : (
- <>
- <div className="mb-2 text-xs text-muted-foreground">{threads.length} threads</div>
- <div className="space-y-1">
- {threads.map((t) => (
- <button
- key={t.id}
- onClick={() => onOpenThread(t.id)}
- className="flex w-full items-start gap-3 rounded-md px-2 py-2 text-left hover:bg-accent"
- >
- <MessagesSquare className="mt-0.5 size-4 shrink-0 text-muted-foreground" />
- <div className="min-w-0 flex-1">
- <div className="truncate text-sm font-medium">{t.name}</div>
- <div className="truncate text-xs text-muted-foreground">
- <span className="font-medium text-foreground/80">{t.parent.authorName}</span> {stripInlineMarkup(t.parent.text)}
- </div>
- <div className="mt-1 text-xs text-muted-foreground" suppressHydrationWarning>{t.messageCount} messages · {formatRelativeTime(t.lastMessageAt)}</div>
- </div>
- </button>
- ))}
- </div>
- </>
- )}
- </PanelShell>
- )
-}
-
-// Loading placeholders for the right-panel sub-views — sized to match the
-// real row heights so the panel body doesn't reflow when data lands.
-function PinnedListSkeleton() {
- return (
- <div className="space-y-2">
- {Array.from({ length: 3 }).map((_, i) => (
- <div key={i} className="flex gap-2 rounded-md px-2 py-2">
- <Skeleton className="size-6 shrink-0 rounded-full" />
- <div className="flex min-w-0 flex-1 flex-col gap-2">
- <div className="flex items-baseline gap-2">
- <Skeleton className="h-3 w-20 rounded" />
- <Skeleton className="h-3 w-10 rounded" />
- </div>
- <Skeleton className="h-3 w-5/6 rounded" />
- </div>
- </div>
- ))}
- </div>
- )
-}
-
-function ThreadListSkeleton() {
- return (
- <div className="space-y-1">
- {Array.from({ length: 3 }).map((_, i) => (
- <div key={i} className="flex items-start gap-3 rounded-md px-2 py-2">
- <Skeleton className="mt-0.5 size-4 shrink-0 rounded" />
- <div className="flex min-w-0 flex-1 flex-col gap-2">
- <Skeleton className="h-3.5 w-3/5 rounded" />
- <Skeleton className="h-3 w-11/12 rounded" />
- <Skeleton className="h-3 w-2/5 rounded" />
- </div>
- </div>
- ))}
- </div>
- )
-}
-
-function SearchPanel({
- searchResults,
- initialQuery,
- showSearchInput,
- onOpenProfile,
- onSearch,
- viewerUserId,
-}: {
- searchResults: Msg[]
- initialQuery?: string
- showSearchInput?: boolean
- onOpenProfile?: OpenProfile
- onSearch?: (query: string) => void
- viewerUserId?: string
-}) {
- const [query, setQuery] = useState(initialQuery ?? "")
- const submit = () => { const q = query.trim(); if (q) onSearch?.(q) }
- return (
- <PanelShell icon={Search} title="Search">
- {showSearchInput && (
- <div className="relative mb-3">
- <Search className="absolute left-2 top-1/2 size-4 -translate-y-1/2 text-muted-foreground" />
- <Input
- className="h-9 pl-8"
- placeholder="Search messages"
- value={query}
- onChange={(e) => setQuery(e.target.value)}
- onKeyDown={onEnterSubmit(submit)}
- />
- </div>
- )}
- <div className="mb-2 text-xs text-muted-foreground">{searchResults.length} results</div>
- {searchResults.map((m) => {
- const renderMsg: RenderMsg = { ...m, grouped: false }
- return (
- <Message
- key={m.id}
- m={renderMsg}
- compact
- viewerUserId={viewerUserId}
- onOpenThread={() => {}}
- onOpenProfile={onOpenProfile}
- />
- )
- })}
- </PanelShell>
- )
-}
diff --git a/src/web/src/components/community/shell/shell-frame-view.test.ts b/src/web/src/components/community/shell/shell-frame-view.test.ts
index fdd588294..0a558b4e7 100644
--- a/src/web/src/components/community/shell/shell-frame-view.test.ts
+++ b/src/web/src/components/community/shell/shell-frame-view.test.ts
@@ -1,4 +1,4 @@
-import { createElement } from "react"
+import { createElement, useState } from "react"
import TestRenderer, { act } from "react-test-renderer"
import { beforeEach, describe, expect, it, vi } from "vitest"
import { ShellFrameView } from "./shell-frame-view"
@@ -118,6 +118,7 @@ describe("ShellFrameView", () => {
const group = renderer.root.findByType("panel-group")
expect(group.props.id).toBe("community-shell")
expect(group.props.orientation).toBe("horizontal")
+ expect(group.props.disabled).toBe(false)
const [sidebarPanel, mainPanel] = renderer.root.findAllByType("panel")
expect(sidebarPanel.props).toMatchObject({ id: "sidebar", defaultSize: "24%", minSize: 160, maxSize: 360 })
expect(sidebarPanel.props.className).toContain("pb-15")
@@ -165,7 +166,7 @@ describe("ShellFrameView", () => {
await act(async () => renderer.unmount())
})
- it("keeps mobile nav and messages branches distinct and omits status seeds", async () => {
+ it("keeps one responsive skeleton while mobile nav and detail geometry stay distinct", async () => {
const sidebar = vi.fn(() => createElement("sidebar-content"))
let renderer!: TestRenderer.ReactTestRenderer
await act(async () => {
@@ -186,7 +187,13 @@ describe("ShellFrameView", () => {
expect(mobileSurface.props.className).toContain("rounded-tl-xl")
expect(mobileSurface.props.className).toContain("border-l")
expect(mobileSurface.props.className).toContain("border-t")
- expect(renderer.root.findAllByType("main-content")).toHaveLength(0)
+ expect(renderer.root.findAllByType("main-content")).toHaveLength(1)
+ expect(renderer.root.findAllByType("panel")[0]?.props.hidden).toBe(false)
+ expect(renderer.root.findAllByType("panel")[1]?.props.hidden).toBe(true)
+ expect(renderer.root.findAllByType("panel")[0]?.props["data-mobile-active"]).toBe(true)
+ expect(renderer.root.findAllByType("panel")[1]?.props["data-mobile-active"]).toBeUndefined()
+ expect(renderer.root.findByType("panel-group").props.disabled).toBe(true)
+ expect(renderer.root.findByType("panel-group").props.className).toContain("*:data-[mobile-active=true]:flex-1!")
expect(renderer.root.findAllByType("shell-overlays")).toHaveLength(1)
expect("profileStatusSeeds" in renderer.root.findByType("shell-overlays").props).toBe(false)
expect(sidebar).toHaveBeenCalledWith({ noHeader: false })
@@ -205,11 +212,55 @@ describe("ShellFrameView", () => {
})
expect(renderer.root.findAllByType("server-rail")).toHaveLength(0)
expect(renderer.root.findAllByType("user-bar")).toHaveLength(0)
- expect(renderer.root.findAllByType("app-surface")).toHaveLength(0)
+ expect(renderer.root.findAllByType("app-surface")).toHaveLength(1)
+ expect(renderer.root.findByType("app-surface").props.className).toContain("rounded-none")
expect(renderer.root.findAllByType("main-content")).toHaveLength(1)
+ expect(renderer.root.findAllByType("panel")[0]?.props.hidden).toBe(true)
+ expect(renderer.root.findAllByType("panel")[1]?.props.hidden).toBe(false)
+ expect(renderer.root.findAllByType("panel")[0]?.props["data-mobile-active"]).toBeUndefined()
+ expect(renderer.root.findAllByType("panel")[1]?.props["data-mobile-active"]).toBe(true)
expect(renderer.root.findAllByType("shell-overlays")).toHaveLength(1)
})
+ it("preserves child component identity across the 639 to 640 breakpoint", async () => {
+ let mounts = 0
+ function StatefulMain() {
+ const [identity] = useState(() => ++mounts)
+ return createElement("stateful-main", { identity })
+ }
+ const common = {
+ surface: "detail" as const,
+ navigationPending: false,
+ sidebar: () => createElement("sidebar-content"),
+ cancelPendingNavigation: vi.fn(),
+ rail,
+ profile,
+ inbox,
+ }
+ let renderer!: TestRenderer.ReactTestRenderer
+ await act(async () => {
+ renderer = TestRenderer.create(
+ createElement(
+ ShellFrameView,
+ { ...common, breakpoint: "mobile" },
+ createElement(StatefulMain),
+ ),
+ { createNodeMock: () => ({ offsetWidth: 240 }) },
+ )
+ })
+ expect(renderer.root.findByType("stateful-main").props.identity).toBe(1)
+
+ await act(async () => {
+ renderer.update(createElement(
+ ShellFrameView,
+ { ...common, breakpoint: "desktop" },
+ createElement(StatefulMain),
+ ))
+ })
+ expect(renderer.root.findByType("stateful-main").props.identity).toBe(1)
+ expect(mounts).toBe(1)
+ })
+
it("disconnects and re-subscribes sidebar observation across breakpoint changes", async () => {
const sidebar = vi.fn(() => createElement("sidebar-content"))
const common = {
diff --git a/src/web/src/components/community/shell/shell-frame-view.tsx b/src/web/src/components/community/shell/shell-frame-view.tsx
index 7d2d5d29c..853fc64bf 100644
--- a/src/web/src/components/community/shell/shell-frame-view.tsx
+++ b/src/web/src/components/community/shell/shell-frame-view.tsx
@@ -10,6 +10,7 @@ import { ServerRail } from "./server-rail"
import { UserBar } from "./user-bar"
import { InboxPopover } from "./community-inbox-popover"
import { ShellFrameOverlays } from "./shell-frame-overlays"
+import { cn } from "@/lib/utils"
import {
COMMUNITY_RAIL_WIDTH,
desktopUserBarOverlayWidth,
@@ -45,10 +46,14 @@ export function ShellFrameView({
profile,
inbox,
}: Props) {
- const { defaultLayout, onLayoutChanged } = useDefaultLayout({ id: "community-shell" })
+ const { defaultLayout, onLayoutChanged } = useDefaultLayout({
+ id: "community-shell",
+ onlySaveAfterUserInteractions: true,
+ })
const sidebarPanelRef = useRef<HTMLDivElement>(null)
const [sidebarWidth, setSidebarWidth] = useState(240)
useEffect(() => {
+ if (breakpoint !== "desktop") return
const element = sidebarPanelRef.current
if (!element) return
setSidebarWidth(element.offsetWidth)
@@ -64,6 +69,9 @@ export function ShellFrameView({
avatar: profile.currentUser.avatar,
}
+ const isDesktop = breakpoint === "desktop"
+ const isMobileList = breakpoint === "mobile" && surface === "list"
+ const isMobileDetail = breakpoint === "mobile" && surface === "detail"
if (breakpoint === "unknown") {
return (
<Shell onNavigationIntent={cancelPendingNavigation}>
@@ -74,40 +82,75 @@ export function ShellFrameView({
)
}
- if (breakpoint === "desktop") {
- return (
- <Shell onNavigationIntent={cancelPendingNavigation}>
- <ServerRail {...rail.railProps} bottomInset={60} />
- <div className="relative flex-1 flex flex-col min-w-0 pt-2">
- <AppSurface className={SHELL_SURFACE_CLASS}>
- <ResizablePanelGroup
- id="community-shell"
- orientation="horizontal"
- className="min-h-0 flex-1"
- defaultLayout={defaultLayout}
- onLayoutChanged={onLayoutChanged}
+ return (
+ <Shell onNavigationIntent={cancelPendingNavigation}>
+ {!isMobileDetail && <ServerRail {...rail.railProps} bottomInset={60} />}
+ <div
+ className={cn(
+ "relative flex min-h-0 min-w-0 flex-1 flex-col",
+ !isMobileDetail && "pt-2",
+ )}
+ >
+ <AppSurface
+ className={cn(
+ SHELL_SURFACE_CLASS,
+ isMobileDetail && "rounded-none border-0 bg-background shadow-none ring-0",
+ )}
+ >
+ <ResizablePanelGroup
+ id="community-shell"
+ orientation="horizontal"
+ disabled={!isDesktop}
+ className={cn(
+ "min-h-0 flex-1",
+ !isDesktop && "*:data-[mobile-active=true]:flex-1!",
+ )}
+ defaultLayout={defaultLayout}
+ onLayoutChanged={onLayoutChanged}
+ >
+ <ResizablePanel
+ id="sidebar"
+ defaultSize="24%"
+ minSize={160}
+ maxSize={360}
+ hidden={isMobileDetail}
+ data-mobile-active={isMobileList || undefined}
+ className={cn(
+ "flex flex-col bg-sidebar",
+ isDesktop && "pb-15",
+ )}
+ >
+ <div ref={sidebarPanelRef} className="flex min-h-0 min-w-0 flex-1 flex-col">
+ {!isMobileDetail && (isDesktop ? sidebar() : sidebar({ noHeader: false }))}
+ {isMobileList && (
+ <UserBar
+ user={user}
+ onOpenProfile={profile.openProfile}
+ onEditProfile={profile.openUserSettings}
+ inbox={inboxElement}
+ hasUnread={inbox.hasUnread}
+ inboxOpen={inbox.open}
+ onInboxOpenChange={inbox.onOpenChange}
+ />
+ )}
+ </div>
+ </ResizablePanel>
+ <ResizableHandle className={cn("bg-transparent", !isDesktop && "hidden")} />
+ <ResizablePanel
+ id="main"
+ defaultSize="76%"
+ hidden={isMobileList}
+ data-mobile-active={isMobileDetail || undefined}
+ className={cn(
+ "flex min-w-0 flex-col bg-background",
+ )}
>
- <ResizablePanel
- id="sidebar"
- defaultSize="24%"
- minSize={160}
- maxSize={360}
- className="flex flex-col bg-sidebar pb-15"
- >
- <div ref={sidebarPanelRef} className="flex min-h-0 flex-1 flex-col">
- {sidebar()}
- </div>
- </ResizablePanel>
- <ResizableHandle className="bg-transparent" />
- <ResizablePanel
- id="main"
- defaultSize="76%"
- className="flex min-w-0 flex-col bg-background"
- >
- {navigationPending ? <ChannelLoadingFrame /> : children}
- </ResizablePanel>
- </ResizablePanelGroup>
- </AppSurface>
+ {navigationPending && !isMobileList ? <ChannelLoadingFrame /> : children}
+ </ResizablePanel>
+ </ResizablePanelGroup>
+ </AppSurface>
+
+ {isDesktop && (
<div
className="absolute bottom-0 left-0 z-10"
style={{
@@ -125,58 +168,23 @@ export function ShellFrameView({
onInboxOpenChange={inbox.onOpenChange}
/>
</div>
- </div>
- <ShellFrameOverlays
- controller={profile}
- breakpoint={breakpoint}
- profileStatusSeeds={profile.profile ? {
- initialStatusEmoji: profile.profile.initialStatusEmoji,
- initialStatusText: profile.profile.initialStatusText,
- } : undefined}
- extraDialogs={extraDialogs}
- />
- </Shell>
- )
- }
+ )}
- return (
- <Shell onNavigationIntent={cancelPendingNavigation}>
- {surface === "list" && (
- <>
- <ServerRail {...rail.railProps} bottomInset={60} />
- <div className="relative flex min-h-0 min-w-0 flex-1 flex-col pt-2">
- <AppSurface className={SHELL_SURFACE_CLASS}>
- <div className="flex min-h-0 min-w-0 flex-1 flex-col bg-sidebar">
- <div className="flex min-h-0 min-w-0 flex-1">
- {sidebar({ noHeader: false })}
- </div>
- <UserBar
- user={user}
- onOpenProfile={profile.openProfile}
- onEditProfile={profile.openUserSettings}
- inbox={inboxElement}
- hasUnread={inbox.hasUnread}
- inboxOpen={inbox.open}
- onInboxOpenChange={inbox.onOpenChange}
- />
- </div>
- </AppSurface>
+ {isMobileList && navigationPending && (
+ <div className="absolute inset-0 z-20 flex bg-background">
+ <ChannelLoadingFrame />
</div>
- </>
- )}
- {surface === "detail" && (
- <div className="flex min-h-0 min-w-0 flex-1 flex-col bg-background">
- {navigationPending ? <ChannelLoadingFrame /> : children}
- </div>
- )}
- {surface === "list" && navigationPending && (
- <div className="absolute inset-0 z-20 flex bg-background">
- <ChannelLoadingFrame />
- </div>
- )}
+ )}
+ </div>
<ShellFrameOverlays
controller={profile}
breakpoint={breakpoint}
+ {...(isDesktop && profile.profile ? {
+ profileStatusSeeds: {
+ initialStatusEmoji: profile.profile.initialStatusEmoji,
+ initialStatusText: profile.profile.initialStatusText,
+ },
+ } : {})}
extraDialogs={extraDialogs}
/>
</Shell>
diff --git a/src/web/src/test/e2e-ui/08-mobile.spec.ts b/src/web/src/test/e2e-ui/08-mobile.spec.ts
index f41a43fa4..60dbc4bc5 100644
--- a/src/web/src/test/e2e-ui/08-mobile.spec.ts
+++ b/src/web/src/test/e2e-ui/08-mobile.spec.ts
@@ -1,3 +1,4 @@
+import type { Page } from "@playwright/test"
import { test, expect, userId } from "./_fixtures/community-fixture"
import { tid } from "./_fixtures/testids"
import {
@@ -13,6 +14,22 @@ import {
// lists and leaf paths render detail. Header Back replaces with the parent.
test.use({ viewport: { width: 390, height: 844 } })
+const shellGroup = (page: Page) => page.locator('[data-slot="resizable-panel-group"]')
+const shellPanel = (page: Page, id: "sidebar" | "main") => (
+ page.locator(`[data-slot="resizable-panel"][data-testid="${id}"]`)
+)
+
+async function expectPanelToFillGroup(page: Page, id: "sidebar" | "main"): Promise<void> {
+ const [groupRect, panelRect] = await Promise.all([
+ shellGroup(page).boundingBox(),
+ shellPanel(page, id).boundingBox(),
+ ])
+ expect(groupRect).not.toBeNull()
+ expect(panelRect).not.toBeNull()
+ expect(Math.abs(panelRect!.x - groupRect!.x)).toBeLessThanOrEqual(1)
+ expect(Math.abs(panelRect!.width - groupRect!.width)).toBeLessThanOrEqual(1)
+}
+
test.describe.serial("mobile layout", () => {
let serverId: string
let channelId: string
@@ -29,6 +46,52 @@ test.describe.serial("mobile layout", () => {
dmId = await seedDm("alice", userId("bob"))
})
+ test("whole-page panels fill mobile routes and keep detail identity across 640px", async ({ asUser }) => {
+ const { page } = await asUser("alice")
+
+ for (const width of [375, 639]) {
+ await page.setViewportSize({ width, height: 844 })
+ await page.goto(`/c/channels/${serverId}`)
+ await expect(page.getByTestId(tid.channelRow(channelId))).toBeVisible()
+ await expect(shellPanel(page, "main")).toBeHidden()
+ await expectPanelToFillGroup(page, "sidebar")
+
+ await page.goto(`/c/channels/${serverId}/${channelId}`)
+ await expect(page.getByTestId(tid.composerInput)).toBeVisible()
+ await expect(shellPanel(page, "sidebar")).toBeHidden()
+ await expectPanelToFillGroup(page, "main")
+ }
+
+ const mainPanel = shellPanel(page, "main")
+ await mainPanel.evaluate((element) => { element.dataset.e2eShellIdentity = "stable" })
+ await page.getByRole("button", { name: "Member list" }).click()
+ const membersDialog = page.getByRole("dialog")
+ await expect(membersDialog).toBeVisible()
+ await membersDialog.evaluate((element) => { element.dataset.e2eSheetIdentity = "stable" })
+
+ for (const width of [640, 1280]) {
+ await page.setViewportSize({ width, height: 844 })
+ await expect(shellPanel(page, "sidebar")).toBeVisible()
+ await expect(mainPanel).toBeVisible()
+ await expect(mainPanel).toHaveAttribute("data-e2e-shell-identity", "stable")
+ await expect(membersDialog).toHaveAttribute("data-e2e-sheet-identity", "stable")
+
+ const [groupRect, sidebarRect, mainRect] = await Promise.all([
+ shellGroup(page).boundingBox(),
+ shellPanel(page, "sidebar").boundingBox(),
+ mainPanel.boundingBox(),
+ ])
+ expect(groupRect).not.toBeNull()
+ expect(sidebarRect).not.toBeNull()
+ expect(mainRect).not.toBeNull()
+ expect(sidebarRect!.width).toBeGreaterThanOrEqual(160)
+ expect(mainRect!.width).toBeGreaterThan(0)
+ expect(sidebarRect!.width).toBeLessThan(groupRect!.width)
+ expect(mainRect!.width).toBeLessThan(groupRect!.width)
+ expect(Math.abs(sidebarRect!.width + mainRect!.width - groupRect!.width)).toBeLessThanOrEqual(2)
+ }
+ })
+
test("a direct channel opens detail and Header Back replaces it with the server root", async ({ asUser }) => {
const { page } = await asUser("alice")
await page.goto(`/c/channels/${serverId}/${channelId}`)