Multi-Agent Collaboration for Team and Friends
TypeScript agent-automationagent-orchestrationagent-workflowai-agentsai-collaborationai-memoryai-workforceautonomous-agentsclaude-codeclaude-code-skillscodexcoding-agentmulti-agentmultiple-agentone-person-businessone-person-companyone-person-teamopencodesolopreneur
fix(web): isolate inbox digits and retain member navigation (#910)
Genere529dfcf00c5
diff --git a/src/web/src/components/community/channels/channel-sidebar-tree-owner.dom.test.tsx b/src/web/src/components/community/channels/channel-sidebar-tree-owner.dom.test.tsxindex 274a32b3c..4b1bd659c 100644--- a/src/web/src/components/community/channels/channel-sidebar-tree-owner.dom.test.tsx+++ b/src/web/src/components/community/channels/channel-sidebar-tree-owner.dom.test.tsx@@ -170,11 +170,18 @@ describe("ChannelSidebarScope", () => {expect(rendered.container.textContent).not.toContain("source-one")})- it("keeps cached rows and collapsed state while forum children reconcile", () => {+ it("keeps ordinary-member category actions and collapsed state while forum children reconcile", async () => {const rendered = render(createElement(ChannelSidebarScope, scopeProps(targetCategories)))const owner = rendered.container.querySelector("[data-community-channel-tree-scope]")!+ const header = screen.getByRole("button", { name: "Target category" })+ expect(header.tagName).toBe("DIV")+ expect(header).toHaveAttribute("tabindex", "0")+ expect(header).not.toHaveAttribute("aria-disabled", "true")+ expect(header).not.toHaveAttribute("aria-roledescription")+ expect(header).not.toHaveAttribute("aria-describedby")- fireEvent.click(screen.getByText("Target category"))+ const user = setupUser()+ await user.click(header)expect(screen.queryByTestId(tid.channelRow("target-one"))).not.toBeInTheDocument()rendered.rerender(createElement(ChannelSidebarScope, {@@ -194,6 +201,9 @@ describe("ChannelSidebarScope", () => {expect(rendered.container.querySelector("[data-community-channel-tree-scope]")).toBe(owner)expect(rendered.container.querySelector('[data-slot="skeleton"]')).not.toBeInTheDocument()expect(screen.queryByTestId(tid.channelRow("target-one"))).not.toBeInTheDocument()+ expect(screen.getByRole("button", { name: "Target category" })).toBe(header)+ await user.click(header)+ expect(screen.getByTestId(tid.channelRow("target-one"))).not.toHaveAttribute("aria-disabled", "true")})it("reconciles structural data to full data without replacing the scoped owner", () => {diff --git a/src/web/src/components/community/channels/channel-sidebar.navigation.dom.test.tsx b/src/web/src/components/community/channels/channel-sidebar.navigation.dom.test.tsxindex 91d7f7082..b427ccee1 100644--- a/src/web/src/components/community/channels/channel-sidebar.navigation.dom.test.tsx+++ b/src/web/src/components/community/channels/channel-sidebar.navigation.dom.test.tsx@@ -6,13 +6,18 @@ import { useChannelTree } from "./use-channel-tree"vi.mock("next/link", async () => ({ default: (await import("@/test/community-link-mock")).CommunityLinkMock }))-function Sidebar({ onPick }: { onPick: (id: string) => void }) {- const tree = useChannelTree([{ id: "none", name: "", channels: [+function Sidebar({ onPick, isAdmin = true, grouped = false, onReorder }: {+ onPick: (id: string) => void+ isAdmin?: boolean+ grouped?: boolean+ onReorder?: (ids: string[]) => void+}) {+ const tree = useChannelTree([{ id: grouped ? "group" : "none", name: grouped ? "Group" : "", channels: [{ id: "one", name: "One", active: false, unread: false, type: "text" },{ id: "two", name: "Two", active: false, unread: false, type: "forum" },] }])return <ChannelSidebar tree={tree} serverId="server" serverName="Server" activeChannel="one"- setActiveChannel={onPick} noHeader isAdmin />+ setActiveChannel={onPick} onReorderChannels={onReorder} noHeader isAdmin={isAdmin} />}describe("real sortable channel navigation surface", () => {@@ -44,4 +49,28 @@ describe("real sortable channel navigation surface", () => {expect(view.getByText(/was dropped/i)).toBeInTheDocument()expect(onPick).not.toHaveBeenCalled()})++ it.each([false, true])("lets ordinary members navigate without reorder, grouped=%s", async (grouped) => {+ const onPick = vi.fn()+ const onReorder = vi.fn()+ const view = render(<Sidebar onPick={onPick} onReorder={onReorder} isAdmin={false} grouped={grouped} />)+ const anchor = view.getByTestId(tid.channelRow("two"))+ expect(anchor.tagName).toBe("A")+ expect(anchor).toHaveAttribute("role", "link")+ expect(anchor).toHaveAttribute("href", "/c/channels/server/two")+ expect(anchor).not.toHaveAttribute("aria-disabled", "true")+ expect(anchor).not.toHaveAttribute("aria-roledescription")+ expect(anchor).not.toHaveAttribute("aria-describedby")+ const user = setupUser()+ await user.click(anchor)+ expect(onPick.mock.calls).toEqual([["two"]])+ act(() => anchor.focus())+ await user.keyboard(" ")+ expect(anchor).not.toHaveAttribute("aria-pressed", "true")+ expect(view.queryByText(/was picked up/i)).not.toBeInTheDocument()+ expect(onPick.mock.calls).toEqual([["two"]])+ await user.keyboard("{Enter}")+ expect(onPick.mock.calls).toEqual([["two"], ["two"]])+ expect(onReorder).not.toHaveBeenCalled()+ })})diff --git a/src/web/src/components/community/channels/channel-sidebar.touch-dnd.contract.test.ts b/src/web/src/components/community/channels/channel-sidebar.touch-dnd.contract.test.tsindex 3556ab98e..49023a79d 100644--- a/src/web/src/components/community/channels/channel-sidebar.touch-dnd.contract.test.ts+++ b/src/web/src/components/community/channels/channel-sidebar.touch-dnd.contract.test.ts@@ -37,7 +37,6 @@ describe("channel sidebar touch drag contracts", () => {expect(category).not.toContain("useDroppable")for (const source of [channel, category]) {- expect(source).toContain("...attributes")expect(source).toContain("...listeners")expect(source).toContain("touch-manipulation")expect(source).not.toContain("touch-none")diff --git a/src/web/src/components/community/channels/sortable-category.tsx b/src/web/src/components/community/channels/sortable-category.tsxindex b238c8793..d4d3bf76b 100644--- a/src/web/src/components/community/channels/sortable-category.tsx+++ b/src/web/src/components/community/channels/sortable-category.tsx@@ -42,7 +42,7 @@ export function SortableCategory({ id: catDndId, name, open, onToggle, onAddChan// actions, so share its props/children across both branches to avoid drift.const headerProps = {ref: setActivatorNodeRef,- ...attributes,+ ...(canReorder ? attributes : { role: "button", tabIndex: 0 }),...listeners,onTouchStart: undefined,onTouchStartCapture: listeners?.onTouchStartdiff --git a/src/web/src/components/community/channels/sortable-channel.tsx b/src/web/src/components/community/channels/sortable-channel.tsxindex 40e17e16c..e7803cc60 100644--- a/src/web/src/components/community/channels/sortable-channel.tsx+++ b/src/web/src/components/community/channels/sortable-channel.tsx@@ -64,7 +64,7 @@ export function SortableChannel({ ch, href, active, onClick, onEdit, onDelete, oref: setNodeRef,style,"data-testid": tid.channelRow(ch.id),- ...attributes,+ ...(canReorder ? attributes : { role: "button", tabIndex: 0 }),...listeners,className: ["group relative flex h-8 w-full cursor-pointer touch-manipulation items-center gap-2 rounded-md px-2 text-sm select-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none",diff --git a/src/web/src/components/community/shell/inbox-unread-indicator.dom.test.ts b/src/web/src/components/community/shell/inbox-unread-indicator.dom.test.tsindex ad4ca42a6..97af13b02 100644--- a/src/web/src/components/community/shell/inbox-unread-indicator.dom.test.ts+++ b/src/web/src/components/community/shell/inbox-unread-indicator.dom.test.ts@@ -3,17 +3,18 @@ import { describe, expect, it, vi } from "vitest"import { render } from "@/test/react-dom-harness"import { InboxUnreadIndicator } from "./inbox-unread-indicator"-vi.mock("@/components/ui/number-ticker", () => ({ NumberTicker: ({ value }: { value: number }) => createElement("span", { "data-testid": "count" }, value) }))+vi.mock("@/components/ui/number-ticker", () => ({ NumberTicker: ({ value, isolate }: { value: number; isolate?: boolean }) => createElement("span", { "data-testid": "count", "data-isolate": isolate }, value) }))describe("Inbox unread indicator", () => {it("retracts on open, re-enters on close, updates count, and retains the outgoing digit on clear", () => {const view = render(createElement(InboxUnreadIndicator, { count: 0, open: false }))const indicator = () => view.container.querySelector('[data-slot="inbox-unread-indicator"]')!expect(indicator()).toHaveAttribute("data-unread", "false")- for (const count of [3, 8, 2]) {+ for (const count of [1, 9, 10, 99, 2]) {view.rerender(createElement(InboxUnreadIndicator, { count, open: false }))expect(indicator()).toHaveAttribute("data-unread", "true")expect(view.getByTestId("count")).toHaveTextContent(String(count))+ expect(view.getByTestId("count")).toHaveAttribute("data-isolate", "true")}view.rerender(createElement(InboxUnreadIndicator, { count: 2, open: true }))expect(indicator()).toHaveAttribute("data-unread", "false")@@ -32,6 +33,7 @@ describe("Inbox unread indicator", () => {view.rerender(createElement(InboxUnreadIndicator, { count: 99, open: false }))expect(ellipsis()).toBeNull()expect(view.getByTestId("count")).toHaveTextContent("99")+ expect(view.getByTestId("count")).toHaveAttribute("data-isolate", "true")view.rerender(createElement(InboxUnreadIndicator, { count: 100, open: false }))expect(ellipsis()).not.toBeNull()expect(view.queryByTestId("count")).toBeNull()diff --git a/src/web/src/components/community/shell/inbox-unread-indicator.tsx b/src/web/src/components/community/shell/inbox-unread-indicator.tsxindex fce6aa2f0..00efe7580 100644--- a/src/web/src/components/community/shell/inbox-unread-indicator.tsx+++ b/src/web/src/components/community/shell/inbox-unread-indicator.tsx@@ -24,7 +24,7 @@ export function InboxUnreadIndicator({ count, partial = false, open, description<span id={descriptionId} className="sr-only">{count > 0 ? `${count}${partial ? "+" : ""} unread conversations or requests` : "No unread items"}</span><span className={styles.indicator} data-unread={count > 0 && !open} data-count={count} data-partial={partial} aria-hidden="true" data-slot="inbox-unread-indicator"><span className={styles.circle} data-slot="inbox-unread-circle">- {overflow ? <svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor" data-slot="inbox-unread-ellipsis"><circle cx="3" cy="8" r="1.5" /><circle cx="8" cy="8" r="1.5" /><circle cx="13" cy="8" r="1.5" /></svg> : <NumberTicker value={displayCount} duration={220} />}+ {overflow ? <svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor" data-slot="inbox-unread-ellipsis"><circle cx="3" cy="8" r="1.5" /><circle cx="8" cy="8" r="1.5" /><circle cx="13" cy="8" r="1.5" /></svg> : <NumberTicker value={displayCount} duration={220} isolate />}</span><span className={styles.icon}><Inbox className="size-4" /></span></span>diff --git a/src/web/src/components/ui/number-ticker.tsx b/src/web/src/components/ui/number-ticker.tsxindex e23630082..a71829714 100644--- a/src/web/src/components/ui/number-ticker.tsx+++ b/src/web/src/components/ui/number-ticker.tsx@@ -24,6 +24,7 @@ export function NumberTicker({compact = false,className,duration,+ isolate,}: {value: Value/** Fixed number of fraction digits. Defaults to 0 (integer display). */@@ -32,10 +33,12 @@ export function NumberTicker({compact?: booleanclassName?: stringduration?: number+ isolate?: boolean}) {return (<NumberFlowvalue={value}+ isolate={isolate}{...(duration === undefined ? {} : {transformTiming: { duration, easing: "cubic-bezier(0.2, 0.8, 0.2, 1)" },opacityTiming: { duration: Math.min(duration, 160), easing: "ease-out" },diff --git a/src/web/src/test/e2e-ui/53-mobile-inbox-surface.spec.ts b/src/web/src/test/e2e-ui/53-mobile-inbox-surface.spec.tsindex 93db11df6..efa7c1285 100644--- a/src/web/src/test/e2e-ui/53-mobile-inbox-surface.spec.ts+++ b/src/web/src/test/e2e-ui/53-mobile-inbox-surface.spec.ts@@ -1,7 +1,7 @@import type { Page, Request } from "@playwright/test"import { expect, sessionCookie, test } from "./_fixtures/community-fixture"-import { GEOMETRY_EPSILON, gotoAfterUserWsAuth, ignoreNextDevToolsPointerCapture, waitForElementMotion } from "./_fixtures/actions"-import { proxyCommunityWebSockets } from "./_fixtures/community-ws-proxy"+import { GEOMETRY_EPSILON, composerEditable, gotoAfterUserWsAuth, ignoreNextDevToolsPointerCapture, waitForElementMotion } from "./_fixtures/actions"+import { communityFrameEvents, proxyCommunityWebSockets } from "./_fixtures/community-ws-proxy"import { WEB_URL } from "./_setup/paths"import {seedChannel,@@ -164,6 +164,173 @@ function observeWrites(page: Page) {test.describe.serial("mobile Inbox interactive user-bar base", () => {test.setTimeout(180_000)+ test("paints the retained Inbox digits after hidden messages and repeated detail returns", async ({ asUser }, testInfo) => {+ const stamp = Date.now()+ const serverId = await seedServer("alice", `Inbox digits ${stamp}`)+ const landingId = await seedChannel("alice", serverId, `landing-${stamp}`)+ const firstId = await seedChannel("alice", serverId, `unread-${stamp}`)+ await seedJoinServer("alice", "bob", serverId)+ const bob = await asUser("bob", {+ viewport: { width: 390, height: 844 },+ recordVideo: { dir: testInfo.outputPath("inbox-digits-video"), size: { width: 390, height: 844 } },+ })+ const alice = await asUser("alice")+ const ws = await proxyCommunityWebSockets(bob.context)+ const trigger = bob.page.getByTestId(tid.inboxTrigger)+ const indicator = trigger.locator('[data-slot="inbox-unread-indicator"]')+ const flow = indicator.locator("number-flow-react")+ const overlay = bob.page.locator('[data-slot="community-user-bar-overlay"]')+ const snapshots: Array<{ stage: string; count: number; digits: unknown }> = []+ const video = bob.page.video()++ const readDigits = () => flow.evaluate((element) => {+ const number = element.shadowRoot?.querySelector('[part="number"]')+ const circle = element.closest('[data-slot="inbox-unread-circle"]')!+ const circleRect = circle.getBoundingClientRect()+ const rect = number?.getBoundingClientRect()+ const characters = [...element.shadowRoot?.querySelectorAll<HTMLElement>(+ '[part~="integer"] > [part~="digit"]:not([inert]) .digit__num:not([inert])',+ ) ?? []]+ return {+ text: characters.map((character) => character.textContent).join(""),+ width: rect?.width ?? 0,+ height: rect?.height ?? 0,+ storedWidth: (number as HTMLElement | null)?.style.getPropertyValue("--width") ?? "",+ characters: characters.map((character) => {+ const bounds = character.getBoundingClientRect()+ const style = getComputedStyle(character)+ return {+ text: character.textContent,+ width: bounds.width,+ height: bounds.height,+ visibility: style.visibility,+ opacity: style.opacity,+ intersectsCircle: bounds.right > circleRect.left && bounds.left < circleRect.right+ && bounds.bottom > circleRect.top && bounds.top < circleRect.bottom,+ }+ }),+ animations: element.shadowRoot?.getAnimations().map((animation) => ({+ playState: animation.playState,+ pending: animation.pending,+ currentTime: animation.currentTime,+ })) ?? [],+ }+ })+ const capture = async (stage: string, count: number) => {+ const digits = await readDigits()+ snapshots.push({ stage, count, digits })+ await testInfo.attach(`inbox-digits-${stage}.json`, {+ body: JSON.stringify({ stage, count, digits }, null, 2), contentType: "application/json",+ })+ await testInfo.attach(`inbox-digits-${stage}.png`, {+ body: await bob.page.screenshot(), contentType: "image/png",+ })+ if (await trigger.isVisible()) {+ await testInfo.attach(`inbox-digits-${stage}-circle.png`, {+ body: await indicator.locator('[data-slot="inbox-unread-circle"]').screenshot(), contentType: "image/png",+ })+ }+ return digits+ }+ const expectDigits = async (stage: string, count: number) => {+ await expect(indicator).toHaveAttribute("data-count", String(count))+ await expect(indicator).toHaveAttribute("data-unread", "true")+ await expect.poll(async () => (await readDigits()).text).toBe(String(count))+ snapshots.push({ stage: `${stage}-transition`, count, digits: await readDigits() })+ await expect.poll(async () => (await readDigits()).animations.filter((animation) => (+ animation.playState === "running" || animation.pending+ )).length).toBe(0)+ const digits = await capture(stage, count)+ expect(digits.width).toBeGreaterThan(0)+ expect(digits.height).toBeGreaterThan(0)+ expect(digits.characters).toHaveLength(String(count).length)+ for (const character of digits.characters) {+ expect(character.width).toBeGreaterThan(0)+ expect(character.height).toBeGreaterThan(0)+ expect(character.visibility).toBe("visible")+ expect(Number(character.opacity)).toBeGreaterThan(0)+ expect(character.intersectsCircle).toBe(true)+ }+ }+ const send = async (channelId: string, content: string) => {+ await gotoAfterUserWsAuth(alice.page, `/c/channels/${serverId}/${channelId}`)+ const frameStart = ws.frames.length+ const response = alice.page.waitForResponse((candidate) => (+ candidate.request().method() === "POST"+ && new URL(candidate.url()).pathname === `/api/community/channels/${channelId}/messages`+ ))+ await composerEditable(alice.page).fill(content)+ await alice.page.keyboard.press("Enter")+ const result = await response+ expect(result.status()).toBe(201)+ const messageId = (await result.json() as { message: { id: string } }).message.id+ await expect.poll(() => {+ const events = ws.frames.slice(frameStart).flatMap(communityFrameEvents)+ return events.some((event) => event.type === "community:message.create" && event.message?.id === messageId)+ && events.some((event) => event.type === "community:unread.bump" && event.channelId === channelId)+ }, { timeout: 20_000 }).toBe(true)+ await testInfo.attach(`inbox-message-${messageId}.json`, {+ body: JSON.stringify({ channelId, messageId, status: result.status(), events: ws.frames.slice(frameStart).flatMap(communityFrameEvents) }),+ contentType: "application/json",+ })+ }++ try {+ await gotoAfterUserWsAuth(bob.page, `/c/channels/${serverId}`)+ await expect(trigger).toBeVisible()+ await expect(indicator).toHaveAttribute("data-partial", "false")+ const baseCount = Number(await indicator.getAttribute("data-count"))+ expect(Number.isInteger(baseCount)).toBe(true)+ expect(baseCount).toBeLessThan(98)+ await send(firstId, `Visible Inbox digit ${stamp}`)+ await expectDigits("visible", baseCount + 1)+ const targetCount = Math.max(10, baseCount + 2)+ for (let count = baseCount + 1; count < targetCount - 1; count += 1) {+ const id = await seedChannel("alice", serverId, `digit-${stamp}-${count}`)+ await seedMessage("alice", id, `Digit precondition ${stamp} ${count}`)+ await expect(indicator).toHaveAttribute("data-count", String(count + 1))+ }+ await expectDigits("before-detail", targetCount - 1)+ const retained = await flow.elementHandle()+ expect(retained).not.toBeNull()+ const hiddenId = await seedChannel("alice", serverId, `hidden-${stamp}`)+ await bob.page.getByTestId(tid.channelRow(landingId)).click()+ await expect(bob.page).toHaveURL(`/c/channels/${serverId}/${landingId}`)+ await expect(overlay).toHaveCSS("display", "none")+ await send(hiddenId, `Hidden Inbox digit ${stamp}`)+ await expect(indicator).toHaveAttribute("data-count", String(targetCount))+ await capture("hidden-update", targetCount)+ await bob.page.getByRole("banner").getByRole("button", { name: "Back", exact: true }).click()+ await expect(bob.page).toHaveURL(`/c/channels/${serverId}`)+ expect(await flow.evaluate((element, prior) => element === prior, retained)).toBe(true)+ await expectDigits("first-return", targetCount)++ for (let cycle = 0; cycle < 2; cycle += 1) {+ await bob.page.getByTestId(tid.channelRow(landingId)).click()+ await expect(overlay).toHaveCSS("display", "none")+ await send(hiddenId, `Repeated hidden Inbox ${stamp} ${cycle}`)+ await expect(indicator).toHaveAttribute("data-count", String(targetCount))+ await capture(`hidden-repeat-${cycle}`, targetCount)+ await bob.page.getByRole("banner").getByRole("button", { name: "Back", exact: true }).click()+ await expect(bob.page).toHaveURL(`/c/channels/${serverId}`)+ expect(await flow.evaluate((element, prior) => element === prior, retained)).toBe(true)+ await expectDigits(`repeat-return-${cycle}`, targetCount)+ }+ await trigger.click()+ await expect(indicator).toHaveAttribute("data-unread", "false")+ await trigger.click()+ await expectDigits("closed-again", targetCount)+ } finally {+ await testInfo.attach("inbox-digit-stages.json", {+ body: JSON.stringify(snapshots, null, 2), contentType: "application/json",+ })+ await bob.context.close()+ if (video) await testInfo.attach("inbox-hidden-message-return-video", {+ path: await video.path(), contentType: "video/webm",+ })+ }+ })+test("keeps the mobile shell unmasked and dismisses on outside press without writes", async ({ asUser }, testInfo) => {const stamp = Date.now()const serverId = await seedServer("alice", `Inbox surface ${stamp}`)