diff --git a/desktop/playwright.config.ts b/desktop/playwright.config.ts index 5c5bdbc566..ec78e272a4 100644 --- a/desktop/playwright.config.ts +++ b/desktop/playwright.config.ts @@ -98,6 +98,7 @@ export default defineConfig({ "**/thread-reply-anchor-roleplay.spec.ts", "**/threadpane-ultrawide.spec.ts", "**/thread-focus-mode.spec.ts", + "**/thread-focus-margins.spec.ts", "**/animated-avatar.spec.ts", "**/reminders.spec.ts", "**/reminder-click-repro.spec.ts", diff --git a/desktop/src/features/channels/lib/threadFocusLayout.ts b/desktop/src/features/channels/lib/threadFocusLayout.ts index f14f3399bd..bc627b420b 100644 --- a/desktop/src/features/channels/lib/threadFocusLayout.ts +++ b/desktop/src/features/channels/lib/threadFocusLayout.ts @@ -16,16 +16,6 @@ */ export const THREAD_FOCUS_SLIVER_WIDTH_PX = 72; -/** - * Max width of the centered message column inside the focus drawer. - * - * The drawer itself spans nearly the whole channel content area, but message - * text set that wide is unreadable. The list and composer share this max width - * with auto horizontal margins so the reading measure stays comfortable no - * matter how wide the window gets. - */ -export const THREAD_FOCUS_COLUMN_MAX_WIDTH_PX = 880; - /** * Horizontal distance the focus drawer travels on enter/exit. * diff --git a/desktop/src/features/channels/lib/threadPanelLayout.ts b/desktop/src/features/channels/lib/threadPanelLayout.ts index 3d441bdaf6..159f014399 100644 --- a/desktop/src/features/channels/lib/threadPanelLayout.ts +++ b/desktop/src/features/channels/lib/threadPanelLayout.ts @@ -1,10 +1,7 @@ import type * as React from "react"; -import { THREAD_FOCUS_COLUMN_MAX_WIDTH_PX } from "@/features/channels/lib/threadFocusLayout"; - export type ThreadPanelLayoutProps = { canResetWidth?: boolean; - columnMaxWidthPx?: number; enterMotion?: boolean; headerLeading?: React.ReactNode; /** Replaces the default "Thread" label. Channel threads leave this unset. */ @@ -38,7 +35,6 @@ export function getThreadPanelLayout({ }: ThreadPanelLayoutOptions): ThreadPanelLayoutProps { return isFocusDrawer ? { - columnMaxWidthPx: THREAD_FOCUS_COLUMN_MAX_WIDTH_PX, headerLeading, isFocusMode: true, isSinglePanelView: true, @@ -46,7 +42,6 @@ export function getThreadPanelLayout({ transparentChrome: false, } : { - columnMaxWidthPx: undefined, headerLeading, isFocusMode: false, isSinglePanelView: useSplitAuxiliaryPane ? false : isSinglePanelView, diff --git a/desktop/src/features/messages/lib/messageThreadPanelLayout.ts b/desktop/src/features/messages/lib/messageThreadPanelLayout.ts index 9467d5d3bf..85b73b9606 100644 --- a/desktop/src/features/messages/lib/messageThreadPanelLayout.ts +++ b/desktop/src/features/messages/lib/messageThreadPanelLayout.ts @@ -8,11 +8,3 @@ export const THREAD_PANEL_MESSAGE_GUTTER_CLASS = "px-2"; /** Inline gutter around the thread composer and its activity row. */ export const THREAD_PANEL_COMPOSER_GUTTER_CLASS = "px-5"; - -/** - * Centers the reading column when a `columnMaxWidthPx` is supplied (focus-mode - * drawer). `px-10` (40px) is the inline gutter between the column and the drawer - * edges; the max-width itself is applied inline since it is a caller-provided - * pixel value. - */ -export const THREAD_PANEL_COLUMN_CLASS = "mx-auto w-full px-10"; diff --git a/desktop/src/features/messages/ui/MessageThreadPanel.tsx b/desktop/src/features/messages/ui/MessageThreadPanel.tsx index 16ee26bcc7..9f48de25c7 100644 --- a/desktop/src/features/messages/ui/MessageThreadPanel.tsx +++ b/desktop/src/features/messages/ui/MessageThreadPanel.tsx @@ -26,7 +26,6 @@ import { cn } from "@/shared/lib/cn"; import { AuxiliaryPanel } from "@/shared/layout/AuxiliaryPanel"; import { AuxiliaryPanelBody } from "@/shared/layout/AuxiliaryPanel"; import { - THREAD_PANEL_COLUMN_CLASS, THREAD_PANEL_COMPOSER_GUTTER_CLASS, THREAD_PANEL_MESSAGE_GUTTER_CLASS, } from "@/features/messages/lib/messageThreadPanelLayout"; @@ -145,7 +144,6 @@ export function MessageThreadPanel({ channel, channelId, channelName, - columnMaxWidthPx, currentPubkey, disabled = false, firstUnreadReplyId, @@ -226,7 +224,6 @@ export function MessageThreadPanel({ onClose, !isHuddleTranscript && (isOverlay || isSinglePanelView || isFocusMode), ); - const hasConstrainedColumn = columnMaxWidthPx != null; // Whether the composer dock trades its quiet-state spacer for the // conditional activity accessory (agent working and/or someone typing). const hasComposerBottomActivity = @@ -515,14 +512,7 @@ export function MessageThreadPanel({ {/* The gallery is intentionally DOM-scoped: only media currently rendered in this open thread participates. Collapsed or unloaded descendants join only after the thread UI renders them. */} -
+
{isHuddleTranscript ? (
@@ -816,12 +806,7 @@ export function MessageThreadPanel({ data-testid="thread-composer-overlay" ref={threadComposerWrapperRef} > -
+
{}, + }), + ); + return new JSDOM(html).window.document; +} + +test("focus and split loading states use identical message and composer gutters", () => { + const focus = renderSkeleton(true); + const split = renderSkeleton(false); + for (const selector of [ + '[data-testid="message-thread-loading"] > div', + ".pointer-events-none.bottom-0 > .pointer-events-auto", + ]) { + const focusedContent = focus.querySelector(selector); + const splitContent = split.querySelector(selector); + assert.ok(focusedContent, `Missing focused skeleton: ${selector}`); + assert.ok(splitContent, `Missing split skeleton: ${selector}`); + assert.equal(focusedContent.outerHTML, splitContent.outerHTML); + } +}); diff --git a/desktop/src/features/messages/ui/MessageThreadPanelSkeleton.tsx b/desktop/src/features/messages/ui/MessageThreadPanelSkeleton.tsx index 763591983d..5a51f530cf 100644 --- a/desktop/src/features/messages/ui/MessageThreadPanelSkeleton.tsx +++ b/desktop/src/features/messages/ui/MessageThreadPanelSkeleton.tsx @@ -1,7 +1,6 @@ import type * as React from "react"; import type { ThreadPanelLayoutProps } from "@/features/channels/lib/threadPanelLayout"; import { - THREAD_PANEL_COLUMN_CLASS, THREAD_PANEL_COMPOSER_GUTTER_CLASS, THREAD_PANEL_MESSAGE_GUTTER_CLASS, } from "@/features/messages/lib/messageThreadPanelLayout"; @@ -105,24 +104,10 @@ export function ThreadMessageSkeleton({ ); } -function ThreadComposerSkeleton({ - columnMaxWidthPx, -}: { - columnMaxWidthPx?: number; -}) { - const hasConstrainedColumn = columnMaxWidthPx != null; - +function ThreadComposerSkeleton() { return (
-
+
-
+
} + footer={} header={ { + localStorage.setItem("buzz.channels.threadViewMode", "split"); + }); + await installMockBridge(page); + await page.goto("/"); + await expect + .poll(() => + page.evaluate( + () => typeof window.__BUZZ_E2E_EMIT_MOCK_MESSAGE__ === "function", + ), + ) + .toBe(true); + await page.evaluate(() => { + window.__BUZZ_E2E_EMIT_MOCK_MESSAGE__?.({ + channelName: "general", + parentEventId: "mock-general-welcome", + content: [ + "The thread should use the available panel width in both layouts. Expanding it keeps the channel visible behind the drawer, while messages and the reply composer retain their normal edge spacing.", + "## Validation notes", + "| Check | Result |\n| --- | --- |\n| Message margins | Match the split pane |\n| Reply composer | Uses the same edge spacing |\n| Channel sliver | Still visible behind the drawer |\n| Long content | Wraps within the panel |", + "This longer paragraph makes the reading measure visible. Switching back to the split pane should preserve the conversation and return to the same pane width, without changing the channel navigation or the drawer’s outer position.", + ].join("\n\n"), + }); + }); + await page.getByTestId("channel-general").click(); + const root = page.locator( + '[data-testid="message-row"][data-message-id="mock-general-welcome"]', + ); + await root.hover(); + await root.getByRole("button", { name: "Reply", exact: true }).click(); + await expect(page.getByTestId("message-thread-body")).toBeVisible(); +} + +async function geometry(page: Page) { + return page.getByTestId("message-thread-body").evaluate((body) => { + const panel = body.closest('[data-testid="message-thread-panel"]'); + const row = body.querySelector('[data-message-id="mock-general-welcome"]'); + const composer = panel?.querySelector('[data-testid="message-composer"]'); + if (!panel || !row || !composer) throw new Error("Missing thread geometry"); + const outer = panel.getBoundingClientRect(); + const message = row.getBoundingClientRect(); + const input = composer.getBoundingClientRect(); + return { + panel: { x: outer.x, width: outer.width }, + row: { + left: message.left - outer.left, + right: outer.right - message.right, + }, + composer: { + left: input.left - outer.left, + right: outer.right - input.right, + }, + overflow: body.scrollWidth - body.clientWidth, + }; + }); +} + +for (const width of [1280, 1720, 2560]) { + test(`focus content keeps split gutters at ${width}px`, async ({ + page, + }, testInfo) => { + await page.setViewportSize({ width, height: 900 }); + await openThread(page); + await waitForAnimations(page); + const split = await geometry(page); + await page.screenshot({ path: testInfo.outputPath("split.png") }); + + await page + .getByRole("button", { name: "Expand thread", exact: true }) + .click(); + await expect(page.getByTestId("focus-thread-drawer")).toBeVisible(); + await waitForAnimations(page); + // Motion's transform can finish on a later animation frame than CSS animations. + await expect + .poll(async () => { + const drawer = await page + .getByTestId("focus-thread-drawer") + .boundingBox(); + const overlay = await page + .getByTestId("focus-thread-drawer-overlay") + .boundingBox(); + return Math.abs((drawer?.x ?? 0) - (overlay?.x ?? 0) - 72); + }) + .toBeLessThan(0.01); + const focus = await geometry(page); + await page.screenshot({ path: testInfo.outputPath("focus.png") }); + await testInfo.attach("geometry", { + body: JSON.stringify({ split, focus }, null, 2), + contentType: "application/json", + }); + + expect(focus.panel.width).toBeGreaterThan(split.panel.width); + expect(focus.overflow).toBe(0); + for (const edge of ["left", "right"] as const) { + expect(focus.row[edge]).toBeCloseTo(split.row[edge], 1); + expect(focus.composer[edge]).toBeCloseTo(split.composer[edge], 1); + } + + // Keep the outer drawer position: the existing 72px channel sliver. + const overlay = await page + .getByTestId("focus-thread-drawer-overlay") + .boundingBox(); + expect(overlay).not.toBeNull(); + expect(focus.panel.x - (overlay?.x ?? 0)).toBeCloseTo(72, 1); + expect(focus.panel.width).toBeCloseTo((overlay?.width ?? 0) - 72, 1); + + await page + .getByRole("button", { name: "Show thread beside channel", exact: true }) + .click(); + await expect(page.getByTestId("focus-thread-drawer")).toHaveCount(0); + await waitForAnimations(page); + expect(await geometry(page)).toEqual(split); + }); +}