From d3e5fd1902fb9e125c928e2c398319edcbd3ae5e Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 22 Nov 2026 07:36:53 +0000 Subject: [PATCH 1/5] feat(record-page): the side preview drops the comments icon and panel; comments are the full page's A record drawn embedded (the list's drawer or pane, a record page's drawer) no longer offers the comments icon or the comment panel, and its activity stream keeps giving the comments up, so the preview shows no comment and no composer. The full page keeps its icon, panel and composer. Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01QsR2jRaJbQ4vqdv4J5peqA --- ...ordDetailView.commentsPanel-36075.test.tsx | 93 +++++++++---- .../RecordDetailView.feedRecordScope.test.tsx | 11 +- .../app-shell/src/views/RecordDetailView.tsx | 58 ++++---- .../views/recordCommentsPanel-36075.test.ts | 25 +--- ...dCommentsPanel.drawerEscape-36075.test.tsx | 129 ------------------ .../src/views/recordCommentsPanel.tsx | 64 +++------ .../src/views/recordDrawerContext.ts | 5 - .../app-shell/src/views/recordDrawerStack.tsx | 12 +- 8 files changed, 132 insertions(+), 265 deletions(-) delete mode 100644 ui/packages/app-shell/src/views/recordCommentsPanel.drawerEscape-36075.test.tsx diff --git a/ui/packages/app-shell/src/views/RecordDetailView.commentsPanel-36075.test.tsx b/ui/packages/app-shell/src/views/RecordDetailView.commentsPanel-36075.test.tsx index 8732e7066f4..1641476f9b6 100644 --- a/ui/packages/app-shell/src/views/RecordDetailView.commentsPanel-36075.test.tsx +++ b/ui/packages/app-shell/src/views/RecordDetailView.commentsPanel-36075.test.tsx @@ -11,14 +11,17 @@ * - Whether the panel is open is kept in this browser: a record opened later * opens with the panel as it was left. * - Where it is drawn: beside the record from a 1280 window (the record gives - * way), over the record's right edge in a narrower one, and over the whole - * body of a drawer too narrow to split. + * way), over the record's right edge in a narrower one. * - The comments are the panel's: the page's 动态 stream no longer draws them. * - No icon where the panel is not offered: an object with feeds off, and a * page authored by hand (option C, seat 13:24Z): that page keeps its own * discussion block as it was. It is drawn on the desktop full page only - * (objectstack#36150): the same object's drawer draws the standard page, - * which offers the icon. + * (objectstack#36150). + * - objectstack#36225 — the side preview (the record drawn embedded, in a + * drawer or pane) has no icon and no panel, whatever the page was left + * with, and its 动态 stream draws no comment and no composer either: the + * comments are the full page's. The CONTROL is the full page, whose icon, + * panel and composer stay. */ import * as React from 'react'; @@ -150,6 +153,7 @@ interface MountOptions { embedded?: boolean; /** The record route's query, `?comments=…` for the phone's comment page. */ search?: string; + dataSource?: ReturnType; } /** The router's location now, for the phone's `?comments=` entries. */ @@ -158,7 +162,7 @@ function LocationProbe() { return ; } -async function mount({ objectName = OBJECT_NAME, pages = [], embedded = false, search = '' }: MountOptions = {}) { +async function mount({ objectName = OBJECT_NAME, pages = [], embedded = false, search = '', dataSource = makeDataSource() }: MountOptions = {}) { const rendered = render( @@ -166,7 +170,7 @@ async function mount({ objectName = OBJECT_NAME, pages = [], embedded = false, s {}} objectNameOverride={objectName} @@ -248,19 +252,6 @@ describe('the record comment panel (objectstack#36075)', () => { await waitFor(() => expect(panel(second.container)).not.toBeNull()); }); - it('a drawer too narrow to split gives the panel its whole body, and remembers it apart from the page', async () => { - const page = await mount(); - await waitFor(() => expect(button(page.container)).not.toBeNull()); - fireEvent.click(button(page.container)!); - cleanup(); - const drawer = await mount({ embedded: true }); - await waitFor(() => expect(button(drawer.container)).not.toBeNull()); - // The page was left open; the drawer opens closed. - expect(panel(drawer.container)).toBeNull(); - fireEvent.click(button(drawer.container)!); - expect(placement(drawer.container)).toBe('cover'); - }); - it('the 动态 stream no longer draws the comments', async () => { const { container } = await mount(); await waitFor(() => expect(button(container)).not.toBeNull()); @@ -303,12 +294,68 @@ describe('the record comment panel (objectstack#36075)', () => { expect(panel(container)).toBeNull(); }); - it('the drawer of an object with a hand-written page draws the standard page, so it offers the icon (objectstack#36150)', async () => { - const { container } = await mount({ pages: [AUTHORED_PAGE], embedded: true }); + it('a comment written in the panel is posted on the record (objectstack#36225 CONTROL: the full page keeps the panel)', async () => { + const dataSource = makeDataSource(); + const { container } = await mount({ dataSource }); await waitFor(() => expect(button(container)).not.toBeNull()); - expect(panel(container)).toBeNull(); fireEvent.click(button(container)!); - expect(await within(panel(container)!).findByText(ADA_BODY)).toBeInTheDocument(); + const box = within(panel(container)!.querySelector('[data-comments-composer]') as HTMLElement).getByRole('textbox'); + fireEvent.change(box, { target: { value: 'Ada: written on the full page' } }); + await act(async () => { + fireEvent.keyDown(box, { key: 'Enter', ctrlKey: true }); + }); + await waitFor(() => + expect(dataSource.create).toHaveBeenCalledWith( + 'sys_comment', + expect.objectContaining({ thread_id: THREAD, body: 'Ada: written on the full page' }), + ), + ); + expect(await within(panel(container)!).findByText('Ada: written on the full page')).toBeInTheDocument(); + }); +}); + +/** + * objectstack#36225 — the side preview: a record drawn embedded (the list's + * drawer or pane, a record page's drawer) shows no comments at all. To read + * or write one, the reader opens the full page. + */ +describe('the side preview has no comments (objectstack#36225)', () => { + it('no icon and no panel, though the page was left with the panel open', async () => { + const page = await mount(); + await waitFor(() => expect(button(page.container)).not.toBeNull()); + fireEvent.click(button(page.container)!); + expect(panel(page.container)).not.toBeNull(); + cleanup(); + const preview = await mount({ embedded: true }); + await act(async () => {}); + expect(within(preview.container).getByText(`Case ${RECORD_ID}`)).toBeInTheDocument(); + expect(button(preview.container)).toBeNull(); + expect(panel(preview.container)).toBeNull(); + expect(document.querySelector('[data-comments-button]')).toBeNull(); + expect(document.querySelector('[data-comments-panel]')).toBeNull(); + }); + + it('its 动态 stream draws no comment and no composer', async () => { + const preview = await mount({ embedded: true }); + const activityTab = await within(preview.container).findByRole('tab', { name: /^Activity/ }); + fireEvent.mouseDown(activityTab, { button: 0 }); + fireEvent.click(activityTab); + await act(async () => {}); + expect(activityTab).toHaveAttribute('aria-selected', 'true'); + expect(within(preview.container).queryByText(ADA_BODY)).toBeNull(); + expect(within(preview.container).queryByText(GRACE_BODY)).toBeNull(); + expect(preview.container.querySelector('[data-comments-composer]')).toBeNull(); + expect(within(preview.container).queryByRole('textbox')).toBeNull(); + expect(button(preview.container)).toBeNull(); + }); + + it('a hand-written page’s object: the preview draws the standard page, with no icon (objectstack#36150)', async () => { + const { container } = await mount({ pages: [AUTHORED_PAGE], embedded: true }); + await act(async () => {}); + expect(within(container).getByText(`Case ${RECORD_ID}`)).toBeInTheDocument(); + expect(button(container)).toBeNull(); + expect(panel(container)).toBeNull(); + expect(within(container).queryByText(ADA_BODY)).toBeNull(); }); }); diff --git a/ui/packages/app-shell/src/views/RecordDetailView.feedRecordScope.test.tsx b/ui/packages/app-shell/src/views/RecordDetailView.feedRecordScope.test.tsx index f43d9327f29..374f14715dc 100644 --- a/ui/packages/app-shell/src/views/RecordDetailView.feedRecordScope.test.tsx +++ b/ui/packages/app-shell/src/views/RecordDetailView.feedRecordScope.test.tsx @@ -39,6 +39,7 @@ import { MetadataCtx } from '@object-ui/react'; // I18nProvider is mounted. Selecting through them keeps this file pinned to // the composer/empty-state semantics rather than to a literal string. import { DETAIL_DEFAULT_TRANSLATIONS } from '@object-ui/plugin-detail'; +import { COMMENTS_PANEL_OPEN_KEY } from './recordCommentsPanel'; vi.mock('@object-ui/auth', async (importOriginal) => ({ ...(await importOriginal>()), @@ -225,9 +226,9 @@ function tree(dataSource: any, recordId: string, pages: any[] = []) { onEdit={() => {}} objectNameOverride={OBJECT_NAME} recordIdOverride={recordId} - // objectstack#36150 — an authored page draws on the full page only, - // so its cases mount the full page; the synthesized page's, the drawer. - embedded={pages.length === 0} + // objectstack#36150 — an authored page draws on the full page only; + // objectstack#36225 — the comment panel is the full page's alone. + // So every case mounts the full page. /> @@ -256,10 +257,10 @@ afterEach(() => { describe('RecordDetailView — the feed does not follow the user to the next record (#3268)', () => { // objectstack#36075 — on the synthesized page the record's comments are the - // comment panel's: these open the drawer with it open (the reader left it + // comment panel's: these open the page with it open (the reader left it // so), and it stays open across the record→record navigation. beforeEach(() => { - window.localStorage.setItem('os:record-comments-panel:drawer', 'open'); + window.localStorage.setItem(COMMENTS_PANEL_OPEN_KEY, 'open'); }); afterEach(() => { window.localStorage.clear(); diff --git a/ui/packages/app-shell/src/views/RecordDetailView.tsx b/ui/packages/app-shell/src/views/RecordDetailView.tsx index 619d21967c7..c1a648b1ae3 100644 --- a/ui/packages/app-shell/src/views/RecordDetailView.tsx +++ b/ui/packages/app-shell/src/views/RecordDetailView.tsx @@ -44,8 +44,8 @@ import { RecordEditStateController, bodyTablesSaveTogether, isMasterDetailChild, import { isRecordPagePushed, useRecordPageScrollMemory } from './recordPagePush.js'; import { phoneRecordHeader } from './recordPhoneHeader.js'; import { usePhoneViewport } from '../hooks/usePhoneViewport.js'; -import { PrefetchUpcomingRelatedCounts, RecordDrawerUpcomingContext, RecordPageDrawerHost, RecordPaneBarComments, RecordPaneBarToggles, useRecordPane, useRecordPaneBar, useRecordPageReturn } from './recordDrawerStack.js'; -import { COMMENTS_PANEL_WIDTH, RecordCommentsAside, commentsPanelPlacement, useCommentsPanelOpen, useElementWidth, useWindowWidth } from './recordCommentsPanel.js'; +import { PrefetchUpcomingRelatedCounts, RecordDrawerUpcomingContext, RecordPageDrawerHost, RecordPaneBarToggles, useRecordPane, useRecordPaneBar, useRecordPageReturn } from './recordDrawerStack.js'; +import { COMMENTS_PANEL_WIDTH, RecordCommentsAside, commentsPanelPlacement, useCommentsPanelOpen, useWindowWidth } from './recordCommentsPanel.js'; import { RECORD_PAGE_ACTIVITY_ROWS, RECORD_PAGE_ATTACHMENT_ROWS, @@ -1301,25 +1301,33 @@ export function RecordDetailView({ dataSource, objects, onEdit, objectNameOverri const [pageRootEl, setPageRootEl] = useState(null); const pageColumnsEligible = !assignedPage && !namedPageBlocked; // ─── The record's comment panel (objectstack#36075) ────────────────── - // Offered on the desktop, page and drawer, wherever the page draws the - // platform's own 动态 stream: the default page and a slotted one. That is - // where the stream gives its comments up to the panel; a page whose author - // composed it keeps its discussion where the author put it (a page is what - // its author composes), and an object with feeds off has none. The phone's - // comment page is its own surface. Open or closed is the reader's, kept per - // page and per drawer; beside the record it takes 380 px from the page, - // whose tier is judged on what is left. + // Offered on the desktop full page, wherever the page draws the platform's + // own 动态 stream: the default page and a slotted one. That is where the + // stream gives its comments up to the panel; a page whose author composed + // it keeps its discussion where the author put it (a page is what its + // author composes), and an object with feeds off has none. The phone's + // comment page is its own surface. Open or closed is the reader's, kept in + // this browser; beside the record it takes 380 px from the page, whose tier + // is judged on what is left. + // + // objectstack#36225 — a record drawn embedded (the side preview, and any + // drawer a list or a record page opens) has no comment panel and no + // comments icon: the comments are the full page's, one 「Open as full page」 + // away. Its 动态 stream gives them up all the same, so the preview shows + // no comment and no composer anywhere. const commentsPhone = usePhoneViewport(); - const commentsPanelOffered = - !!objectDef && objectDef.enable?.feeds !== false && pageColumnsEligible && !commentsPhone && !!pureRecordId; + const commentsEligible = !!objectDef && objectDef.enable?.feeds !== false && pageColumnsEligible && !!pureRecordId; + const commentsPanelOffered = commentsEligible && !commentsPhone && !embedded; + const commentsLeftToFullPage = commentsEligible && !!embedded; // objectstack#36076 — the phone's comment page, on the same pages: a page // over the record page, addressed by `?comments=` (empty: the threads; a // top-level comment's id: that thread). A phone draws no drawer or pane. - const commentsPageOffered = - !!objectDef && objectDef.enable?.feeds !== false && pageColumnsEligible && commentsPhone && !embedded && !!pureRecordId; + const commentsPageOffered = commentsEligible && commentsPhone && !embedded; // Either surface holds the record's comments, so the 动态 stream gives - // them up and names its system entries alone. + // them up and names its system entries alone — as it does in a preview, + // whose comments are the full page's. const commentsSurfaceOffered = commentsPanelOffered || commentsPageOffered; + const streamGivesUpComments = commentsSurfaceOffered || commentsLeftToFullPage; const commentsParam = commentsPageOffered ? tabSearchParams.get(RECORD_COMMENTS_PARAM) : null; const commentsPageOpen = commentsParam !== null; const commentsPageThread = commentsParam ? commentsParam : null; @@ -1351,15 +1359,9 @@ export function RecordDetailView({ dataSource, objects, onEdit, objectNameOverri } commentsPageWasOpen.current = commentsPageOpen; }, [commentsPageOpen]); - const [commentsOpenChosen, setCommentsOpen] = useCommentsPanelOpen(embedded ? 'drawer' : 'page'); + const [commentsOpenChosen, setCommentsOpen] = useCommentsPanelOpen(); const commentsOpen = commentsPanelOffered && commentsOpenChosen; - const commentsWindowWidth = useWindowWidth(); - const commentsHostWidth = useElementWidth(embedded ? pageRootEl : null); - const commentsPlacement = commentsPanelPlacement({ - embedded: !!embedded, - windowWidth: commentsWindowWidth, - hostWidth: commentsHostWidth, - }); + const commentsPlacement = commentsPanelPlacement(useWindowWidth()); const recordPageTier = useRecordPageTier(pageRootEl, { enabled: pageColumnsEligible, reservedWidth: commentsOpen && commentsPlacement === 'beside' ? COMMENTS_PANEL_WIDTH : 0, @@ -3896,10 +3898,11 @@ export function RecordDetailView({ dataSource, objects, onEdit, objectNameOverri const timelineServed = feedRecordKey ? timelineCountByRecord[feedRecordKey] ?? null : null; const heldCommentCount = useMemo(() => feedItems.filter((item) => item.type === 'comment').length, [feedItems]); // objectstack#36075, objectstack#36076 — where the comment panel or the - // phone's comment page holds the comments, the 动态 stream names its system + // phone's comment page holds the comments (and in a preview, whose comments + // are the full page's, objectstack#36225), the 动态 stream names its system // entries alone. const timelineTotal = timelineServed - ? Math.max(0, timelineServed.total - timelineServed.comments + (commentsSurfaceOffered ? 0 : heldCommentCount)) + ? Math.max(0, timelineServed.total - timelineServed.comments + (streamGivesUpComments ? 0 : heldCommentCount)) : null; // The comments icon's number: the record's unresolved threads (#36075 item // 8; every thread where the deployment stores no resolution), unknown while @@ -5933,7 +5936,6 @@ export function RecordDetailView({ dataSource, objects, onEdit, objectNameOverri {pageBar} {/* In a pane, the record's ⊟ goes into the pane's own top bar. */} {embedded && paneBar && {panelToggles}} - {embedded && paneBar && {commentsButton}} {/* On a print page the shared chrome joins the print chrome row below, so the row's buttons are not drawn under it. On the page it sits under the top bar, where it sat before the bar. */} @@ -6091,7 +6093,7 @@ export function RecordDetailView({ dataSource, objects, onEdit, objectNameOverri {/* objectstack#27055 — the field changes of the timeline stream, for the synthesized page's `record:activity`; on an assigned page, for its feed blocks (objectstack#33996). */} - + {/* objectstack#30074 — whether this record shows its field history (objectstack#30344: to this reader, whose audit read answered): @@ -6239,7 +6241,7 @@ export function RecordDetailView({ dataSource, objects, onEdit, objectNameOverri // overlay, not the console's pane) keeps its ⊟ at the end of // the header's action row. {commentsButton}{panelToggles} : null} + value={embedded && !paneBar && panelToggles ? panelToggles : null} > { it('the page: beside from a 1280 window, over below it', () => { expect(COMMENTS_PANEL_WIDTH).toBe(380); expect(COMMENTS_PANEL_BESIDE_MIN_WINDOW).toBe(1280); - expect(commentsPanelPlacement({ embedded: false, windowWidth: 1280, hostWidth: 0 })).toBe('beside'); - expect(commentsPanelPlacement({ embedded: false, windowWidth: 1279, hostWidth: 2000 })).toBe('over'); - }); - - it('the drawer: beside from a 760 body, a cover of the body below it (the default 720 drawer)', () => { - expect(COMMENTS_PANEL_DRAWER_SPLIT_MIN_WIDTH).toBe(760); - expect(commentsPanelPlacement({ embedded: true, windowWidth: 1920, hostWidth: 760 })).toBe('beside'); - expect(commentsPanelPlacement({ embedded: true, windowWidth: 1920, hostWidth: 720 })).toBe('cover'); + expect(commentsPanelPlacement(1280)).toBe('beside'); + expect(commentsPanelPlacement(1279)).toBe('over'); }); }); diff --git a/ui/packages/app-shell/src/views/recordCommentsPanel.drawerEscape-36075.test.tsx b/ui/packages/app-shell/src/views/recordCommentsPanel.drawerEscape-36075.test.tsx deleted file mode 100644 index e11e980957a..00000000000 --- a/ui/packages/app-shell/src/views/recordCommentsPanel.drawerEscape-36075.test.tsx +++ /dev/null @@ -1,129 +0,0 @@ -// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. - -/** - * objectstack#36075 — in the record drawer, Esc pressed in the comment panel - * closes the panel and returns to the record, as ✕ does: the drawer neither - * closes nor steps back on it, at the stack's root (a record opened from the - * list) or below it. The focus goes back to the comments icon. - * - * Pinned through the REAL drawer (`NavigationOverlay`, whose dialog layer - * hears Esc on the document in the capture phase, ahead of the panel) around - * the REAL panel (`RecordCommentsAside` → `CommentsPanel`). The CONTROL: an - * Esc pressed in the record outside the panel still does what it did. - */ - -import * as React from 'react'; -import '@testing-library/jest-dom/vitest'; -import { describe, it, expect, vi, afterEach, beforeEach } from 'vitest'; -import { render, screen, cleanup, fireEvent, within } from '@testing-library/react'; -import { NavigationOverlay, type NavigationOverlayProps } from '@object-ui/components'; -import { DiscussionContextProvider } from '@object-ui/react'; -import { RecordCommentsAside } from './recordCommentsPanel'; - -const ITEMS = [ - { id: 'c1', type: 'comment', actor: 'Ada', body: 'first thread', createdAt: '2026-10-01T08:00:00.000Z' }, -]; - -function Record() { - const [open, setOpen] = React.useState(true); - return ( - -
- - - {open && setOpen(false)} />} -
-
- ); -} - -function renderDrawer(props: Partial = {}) { - const setIsOpen = vi.fn(); - const close = vi.fn(); - render( - list} - close={close} - setIsOpen={setIsOpen} - title="Account" - {...props} - > - {() => } - , - ); - return { setIsOpen, close }; -} - -const panel = () => document.querySelector('[data-comments-panel]') as HTMLElement | null; -const composer = () => within(document.querySelector('[data-comments-composer]') as HTMLElement).getByRole('textbox'); -const esc = (target: Element) => fireEvent.keyDown(target, { key: 'Escape' }); - -beforeEach(() => { - try { - window.localStorage.clear(); - } catch { - /* private mode */ - } -}); -afterEach(cleanup); - -describe.each([ - ['at the stack’s root (a record opened from the list)', false], - ['below the root', true], -])('the record drawer, %s', (_label, below) => { - it.each([ - ['the comment box', () => composer()], - ['the panel’s ✕', () => screen.getByRole('button', { name: 'Close comments' })], - ])('Esc in %s closes the panel and returns to the record', (_where, target) => { - const onBack = vi.fn(); - const { setIsOpen, close } = renderDrawer(below ? { onBack } : {}); - const el = target(); - el.focus(); - esc(el); - expect(panel()).toBeNull(); - expect(onBack).not.toHaveBeenCalled(); - expect(setIsOpen).not.toHaveBeenCalledWith(false); - expect(close).not.toHaveBeenCalled(); - expect(screen.getByRole('dialog', { name: 'Account' })).toBeInTheDocument(); - expect(screen.getByRole('button', { name: 'Comments icon' })).toHaveFocus(); - }); - - it('Esc in the @ list closes the list only: the panel and the drawer stay', () => { - const onBack = vi.fn(); - const { setIsOpen } = renderDrawer(below ? { onBack } : {}); - const box = composer(); - box.focus(); - fireEvent.change(box, { target: { value: 'ask @', selectionStart: 5 } }); - expect(screen.getByRole('button', { name: /Zoe/ })).toBeInTheDocument(); - esc(box); - expect(screen.queryByRole('button', { name: /Zoe/ })).toBeNull(); - expect(panel()).not.toBeNull(); - expect(box).toHaveValue('ask @'); - expect(onBack).not.toHaveBeenCalled(); - expect(setIsOpen).not.toHaveBeenCalledWith(false); - }); - - it('CONTROL: Esc on a record control outside the panel does what the drawer always did', () => { - const onBack = vi.fn(); - const { setIsOpen, close } = renderDrawer(below ? { onBack } : {}); - const action = screen.getByRole('button', { name: 'Record action' }); - action.focus(); - esc(action); - if (below) { - expect(onBack).toHaveBeenCalledTimes(1); - } else { - expect(setIsOpen.mock.calls.some(([v]) => v === false) || close.mock.calls.length > 0).toBe(true); - } - }); -}); diff --git a/ui/packages/app-shell/src/views/recordCommentsPanel.tsx b/ui/packages/app-shell/src/views/recordCommentsPanel.tsx index 619c2790f02..381576bb0cf 100644 --- a/ui/packages/app-shell/src/views/recordCommentsPanel.tsx +++ b/ui/packages/app-shell/src/views/recordCommentsPanel.tsx @@ -20,42 +20,30 @@ export const COMMENTS_PANEL_WIDTH = 380; export const COMMENTS_PANEL_BESIDE_MIN_WINDOW = 1280; /** - * From this drawer width the panel sits beside the record inside the drawer, - * leaving the record at least as wide as the panel; a narrower drawer (the - * default `md`, 720) gives the panel the whole drawer body. + * Where the open panel is drawn on the record's full page: `beside` the + * record, which gives it the width; or `over` the page's right edge (a window + * under 1280). A record drawn in a drawer or pane has no panel + * (objectstack#36225): its comments are the full page's. */ -export const COMMENTS_PANEL_DRAWER_SPLIT_MIN_WIDTH = 2 * COMMENTS_PANEL_WIDTH; +export type CommentsPanelPlacement = 'beside' | 'over'; -/** - * Where the open panel is drawn: `beside` the record, which gives it the - * width; `over` the page's right edge (a window under 1280); or as a `cover` - * of the whole drawer body (a drawer under 760). - */ -export type CommentsPanelPlacement = 'beside' | 'over' | 'cover'; - -export function commentsPanelPlacement({ - embedded, - windowWidth, - hostWidth, -}: { - /** The record is drawn in a drawer or pane, not on its own page. */ - embedded: boolean; - windowWidth: number; - /** The width of the record view itself (the drawer's body when embedded). */ - hostWidth: number; -}): CommentsPanelPlacement { - if (embedded) return hostWidth >= COMMENTS_PANEL_DRAWER_SPLIT_MIN_WIDTH ? 'beside' : 'cover'; +export function commentsPanelPlacement(windowWidth: number): CommentsPanelPlacement { return windowWidth >= COMMENTS_PANEL_BESIDE_MIN_WINDOW ? 'beside' : 'over'; } /** - * Whether the reader keeps the comment panel open (objectstack#36075, item 2): - * a preference, kept in this browser, one for the record page and one for - * the drawer, so the drawer (where the panel may cover the record) does not - * open on the comments because the page was left with them open. + * The browser's record of whether the reader keeps the comment panel open + * (objectstack#36075, item 2). */ -export function useCommentsPanelOpen(surface: 'page' | 'drawer'): [boolean, (open: boolean) => void] { - const key = `os:record-comments-panel:${surface}`; +export const COMMENTS_PANEL_OPEN_KEY = 'os:record-comments-panel:page'; + +/** + * Whether the reader keeps the record page's comment panel open + * (objectstack#36075, item 2): a preference, kept in this browser, so a + * record opened later opens with the panel as it was left. + */ +export function useCommentsPanelOpen(): [boolean, (open: boolean) => void] { + const key = COMMENTS_PANEL_OPEN_KEY; const [open, setOpenState] = useState(() => { try { return typeof window !== 'undefined' && window.localStorage.getItem(key) === 'open'; @@ -92,25 +80,9 @@ export function useWindowWidth(): number { return width; } -/** An element's rendered width, re-read whenever it resizes; 0 before it mounts. */ -export function useElementWidth(element: Element | null): number { - const [width, setWidth] = useState(0); - useEffect(() => { - if (!element) return undefined; - const read = () => setWidth(element.getBoundingClientRect().width); - read(); - if (typeof ResizeObserver === 'undefined') return undefined; - const observer = new ResizeObserver(read); - observer.observe(element); - return () => observer.disconnect(); - }, [element]); - return width; -} - const PLACEMENT_CLASS: Record = { beside: 'relative w-[380px] shrink-0 border-l border-border', over: 'absolute inset-y-0 right-0 z-30 w-[380px] max-w-full border-l border-border shadow-xl', - cover: 'absolute inset-0 z-30', }; /** @@ -132,7 +104,7 @@ export function RecordCommentsAside({ const ref = useRef(null); // Closed from inside (✕, Esc), the focus goes back to the record: to the // comments icon that opened the panel, the nearest one round it (the page's - // header, or the drawer's record row). + // header). const close = useCallback(() => { const el = ref.current; const hadFocus = !!el && el.contains(document.activeElement); diff --git a/ui/packages/app-shell/src/views/recordDrawerContext.ts b/ui/packages/app-shell/src/views/recordDrawerContext.ts index 95f1d3f9199..f040123fa4a 100644 --- a/ui/packages/app-shell/src/views/recordDrawerContext.ts +++ b/ui/packages/app-shell/src/views/recordDrawerContext.ts @@ -64,11 +64,6 @@ export function useRecordPane(): RecordPaneApi | null { export interface RecordPaneBarApi { /** The bar's element the record portals its panel switches into; `null` until it mounts. */ toggleSlot: HTMLElement | null; - /** - * The bar's element the record portals its comments switch into, before its - * button group (objectstack#36075); `null` until it mounts. - */ - commentsSlot?: HTMLElement | null; /** The title of the record `recordId` names, once its row has loaded. */ reportTitle(recordId: string, title: string | undefined): void; } diff --git a/ui/packages/app-shell/src/views/recordDrawerStack.tsx b/ui/packages/app-shell/src/views/recordDrawerStack.tsx index 336484b0c5f..943a856261d 100644 --- a/ui/packages/app-shell/src/views/recordDrawerStack.tsx +++ b/ui/packages/app-shell/src/views/recordDrawerStack.tsx @@ -519,7 +519,6 @@ export function RecordStackDrawer({ // reported, by level key: the breadcrumb names the record, and an ancestor // that was not opened with a title is still named by the one it reported. const [toggleSlot, setToggleSlot] = useState(null); - const [commentsSlot, setCommentsSlot] = useState(null); const [titles, setTitles] = useState>>({}); // objectstack#35593 / objectstack#35853 — the record header draws the // record's name and tags, and its button group, into the bar's record row @@ -535,14 +534,13 @@ export function RecordStackDrawer({ const bar = useMemo( () => ({ toggleSlot, - commentsSlot, reportTitle: (recordId: string, title: string | undefined) => { if (!currentObject || !title) return; const key = `${currentObject}:${recordId}`; setTitles((prev) => (prev[key] === title ? prev : { ...prev, [key]: title })); }, }), - [toggleSlot, commentsSlot, currentObject], + [toggleSlot, currentObject], ); const defOf = (objectName: string) => objects.find((o) => (o as { name?: unknown } | null)?.name === objectName); @@ -632,7 +630,6 @@ export function RecordStackDrawer({ recordRow={recordRow} onExpand={pane ? () => pane.openAsPage() : undefined} toggles={} - comments={} > {() => ( @@ -668,13 +665,6 @@ export function RecordPaneBarToggles({ children }: { children: ReactNode }) { return createPortal(children, bar.toggleSlot); } -/** The record's comments switch, drawn into its pane's bar before the button group (objectstack#36075). */ -export function RecordPaneBarComments({ children }: { children: ReactNode }) { - const bar = useContext(RecordPaneBarContext); - if (!bar?.commentsSlot || children == null || children === false) return null; - return createPortal(children, bar.commentsSlot); -} - /** * The page the record header's 「Open as full page」 opens from a pane level: * the record's route, with the levels below it as the `?from=` trail its back From 9461c50d39b6d5a14d54b493f97c16501b177dfb Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 22 Nov 2026 08:09:28 +0000 Subject: [PATCH 2/5] docs(record-page): the comment panel is the full page's; the drawer and pane draw none Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01QsR2jRaJbQ4vqdv4J5peqA --- .changeset/36225-preview-no-comments.md | 12 ++++++++++++ content/docs/frontend/plugins/plugin-detail.mdx | 16 +++++++++------- ...RecordDetailView.commentsPanel-36075.test.tsx | 1 + .../src/views/RecordDetailView.harness.test.tsx | 7 ++++--- ui/packages/plugin-detail/README.md | 8 +++++--- .../plugin-detail/src/recordTimelineStream.ts | 13 +++++++------ 6 files changed, 38 insertions(+), 19 deletions(-) create mode 100644 .changeset/36225-preview-no-comments.md diff --git a/.changeset/36225-preview-no-comments.md b/.changeset/36225-preview-no-comments.md new file mode 100644 index 00000000000..b5df6ed0d23 --- /dev/null +++ b/.changeset/36225-preview-no-comments.md @@ -0,0 +1,12 @@ +--- +'@object-ui/app-shell': patch +--- + +feat(record-page): the side preview drops the comments icon and the comment panel; a record's comments are on its full page + +Clause-②: no +Metadata-protocol: none + +A record opened in the side preview (the drawer or pane a list opens, and the drawer a record page opens over itself) no longer shows the comments icon in its header, and no comment panel can be opened anywhere in it. Its 动态 tab keeps the system entries alone, with no comment and no comment box, so the preview shows no comments at all. To read or write a comment, open the record as a full page from the preview header; the full page's comments icon, panel and comment box are unchanged, and so is the phone's comment page. + +This replaces the lines of the objectstack#36075 record-comment-panel entry that put the icon and the panel in the record drawer: there is no drawer placement any more (no cover of the drawer body under 760 px, no split above it), and the browser keeps one open-or-closed choice, the record page's. No props, exports or metadata change. diff --git a/content/docs/frontend/plugins/plugin-detail.mdx b/content/docs/frontend/plugins/plugin-detail.mdx index a2b792968c6..6ecc834b946 100644 --- a/content/docs/frontend/plugins/plugin-detail.mdx +++ b/content/docs/frontend/plugins/plugin-detail.mdx @@ -198,14 +198,17 @@ declare const handleAddComment: (text: string) => void; ## The record's comment panel On the desktop console, a record's comments live in a panel of their own, -opened from the comments icon in the record header (on the record page and in -the record drawer), and no longer inside the 动态 (Activity) tab -(objectstack#36075): +opened from the comments icon in the record page's header, and no longer inside +the 动态 (Activity) tab (objectstack#36075). The record drawer (the side +preview a list or a record page opens) has no icon and no panel, and its 动态 +tab shows no comments either: the comments are the full page's, one +「Open as full page」 away (objectstack#36225). + - **The icon** shows how many unresolved threads the record holds (a comment and its replies are one thread). A press opens the panel, the next one closes it, and the browser remembers whether it - was left open, once for the record page and once for the drawer. + was left open. - **The panel** is 380 px wide: 「评论」 and ✕ at the top, the threads oldest first, the comment box at the foot. A thread's replies fold to 「N 条回复」 and open in place. A comment's actions (Reply, an emoji, ✓ on a thread's @@ -228,9 +231,8 @@ the record drawer), and no longer inside the 动态 (Activity) tab 「只看我参与的」, the threads you started, replied in or are mentioned in. A reply into a resolved thread reopens it. - **Where it sits**: beside the record from a 1280 px window, the record giving - way; over the record's right edge in a narrower window. In a drawer narrower - than 760 px (the default drawer is 720) it covers the drawer's body, and ✕ or - Esc returns to the record. + way; over the record's right edge in a narrower window. ✕ or Esc returns to + the record. - **The 动态 tab** then holds the system entries only: activity and field changes, with no comment box and no All / Activity / Discussion chips. The Changes chip stays where the record shows its field history; pressed again, diff --git a/ui/packages/app-shell/src/views/RecordDetailView.commentsPanel-36075.test.tsx b/ui/packages/app-shell/src/views/RecordDetailView.commentsPanel-36075.test.tsx index 1641476f9b6..29695d4f433 100644 --- a/ui/packages/app-shell/src/views/RecordDetailView.commentsPanel-36075.test.tsx +++ b/ui/packages/app-shell/src/views/RecordDetailView.commentsPanel-36075.test.tsx @@ -308,6 +308,7 @@ describe('the record comment panel (objectstack#36075)', () => { expect(dataSource.create).toHaveBeenCalledWith( 'sys_comment', expect.objectContaining({ thread_id: THREAD, body: 'Ada: written on the full page' }), + expect.anything(), ), ); expect(await within(panel(container)!).findByText('Ada: written on the full page')).toBeInTheDocument(); diff --git a/ui/packages/app-shell/src/views/RecordDetailView.harness.test.tsx b/ui/packages/app-shell/src/views/RecordDetailView.harness.test.tsx index c1a38577213..f1da9d87b13 100644 --- a/ui/packages/app-shell/src/views/RecordDetailView.harness.test.tsx +++ b/ui/packages/app-shell/src/views/RecordDetailView.harness.test.tsx @@ -1649,7 +1649,7 @@ describe('RecordDetailView.feedRefusal-11195', () => { } as any; } - function renderDetail(dataSource: any) { + function renderDetail(dataSource: any, { embedded = true }: { embedded?: boolean } = {}) { return render( @@ -1659,7 +1659,7 @@ describe('RecordDetailView.feedRefusal-11195', () => { onEdit={() => {}} objectNameOverride={OBJECT_NAME} recordIdOverride={RECORD_ID} - embedded + embedded={embedded} /> , @@ -1811,7 +1811,8 @@ describe('RecordDetailView.feedRefusal-11195', () => { }); window.localStorage.clear(); - renderDetail(dataSource); + // objectstack#36225 — the comment panel is the full page's: a preview has none. + renderDetail(dataSource, { embedded: false }); expect(await screen.findByText('Stage moved to qualified')).toBeTruthy(); // The 动态 stream holds no comments, so their refusal is not its to say. diff --git a/ui/packages/plugin-detail/README.md b/ui/packages/plugin-detail/README.md index 42d59b078b6..5925ee99bd7 100644 --- a/ui/packages/plugin-detail/README.md +++ b/ui/packages/plugin-detail/README.md @@ -963,9 +963,11 @@ Every part reads the record's discussion off the host's `DiscussionContext` (`useRecordComments`) and offers each write exactly where the host hands it, so the panel needs no props beyond `onClose`. Where it sits and how wide is the host's to decide; the console's record page gives it 380 px beside the record -from a 1280 px window, over the record's right edge in a narrower one, and the -whole drawer body in a drawer narrower than 760 px. While the host wraps the -page in `RecordCommentsInPanelContext` (value `true`), the default page's 动态 +from a 1280 px window, over the record's right edge in a narrower one. The +console's record drawer (the side preview) draws no panel and no icon: the +comments are the full page's (objectstack#36225). While the host wraps the +page in `RecordCommentsInPanelContext` (value `true`; the console does so on +the full page and in the drawer alike), the default page's 动态 stream draws the system entries alone: no comment rows, no All / Activity / Discussion chips (the Changes chip stays, a toggle), no comment box, and its count leaves the comments out. diff --git a/ui/packages/plugin-detail/src/recordTimelineStream.ts b/ui/packages/plugin-detail/src/recordTimelineStream.ts index 3e4fd99b0ee..c89f1ad1fd4 100644 --- a/ui/packages/plugin-detail/src/recordTimelineStream.ts +++ b/ui/packages/plugin-detail/src/recordTimelineStream.ts @@ -71,12 +71,13 @@ export const RecordTimelineTotalContext = React.createContext(nul export const RecordTimelineCountContext = React.createContext<((count: number | null) => void) | null>(null); /** - * Whether the record's comments live in its comment panel (objectstack#36075): - * the host draws the panel beside the default record page, so the page's 动态 - * stream — its tab and its peek — draws the system entries alone: no comment, - * no composer, no filter chips, and its count names those entries only. - * `false` (the phone, an authored page, no host saying): the stream carries - * the discussion as before. + * Whether the record's comments live outside its 动态 stream: in its comment + * panel (objectstack#36075), which the host draws beside the default record + * page, or on the full page, for a record the host draws in a side preview + * (objectstack#36225). The page's 动态 stream — its tab and its peek — then + * draws the system entries alone: no comment, no composer, no filter chips, + * and its count names those entries only. `false` (an authored page, no host + * saying): the stream carries the discussion as before. */ export const RecordCommentsInPanelContext = React.createContext(false); From d494e4c8b9c7d44b0c9e043b06898d0dedb2b838 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 22 Nov 2026 09:41:51 +0000 Subject: [PATCH 3/5] test(record-page): the hand-written page's preview is asked once its tab row is drawn Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01QsR2jRaJbQ4vqdv4J5peqA --- .../src/views/RecordDetailView.commentsPanel-36075.test.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ui/packages/app-shell/src/views/RecordDetailView.commentsPanel-36075.test.tsx b/ui/packages/app-shell/src/views/RecordDetailView.commentsPanel-36075.test.tsx index 29695d4f433..7faab7d40e6 100644 --- a/ui/packages/app-shell/src/views/RecordDetailView.commentsPanel-36075.test.tsx +++ b/ui/packages/app-shell/src/views/RecordDetailView.commentsPanel-36075.test.tsx @@ -352,6 +352,8 @@ describe('the side preview has no comments (objectstack#36225)', () => { it('a hand-written page’s object: the preview draws the standard page, with no icon (objectstack#36150)', async () => { const { container } = await mount({ pages: [AUTHORED_PAGE], embedded: true }); + // The standard page is laid out (its tab row is drawn) before anything is asked of it. + await within(container).findByRole('tab', { name: /^Activity/ }); await act(async () => {}); expect(within(container).getByText(`Case ${RECORD_ID}`)).toBeInTheDocument(); expect(button(container)).toBeNull(); From 855a906669a91d5a4416d3f7640f90c648fc9327 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 22 Nov 2026 09:44:00 +0000 Subject: [PATCH 4/5] test(record-page): the hand-written page's preview starts from a page left with its panel open Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01QsR2jRaJbQ4vqdv4J5peqA --- .../src/views/RecordDetailView.commentsPanel-36075.test.tsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ui/packages/app-shell/src/views/RecordDetailView.commentsPanel-36075.test.tsx b/ui/packages/app-shell/src/views/RecordDetailView.commentsPanel-36075.test.tsx index 7faab7d40e6..4763f656d5d 100644 --- a/ui/packages/app-shell/src/views/RecordDetailView.commentsPanel-36075.test.tsx +++ b/ui/packages/app-shell/src/views/RecordDetailView.commentsPanel-36075.test.tsx @@ -63,6 +63,7 @@ import { MetadataCtx } from '@object-ui/react'; import { MePermissionsProvider, type MePermissionsAuthenticatedResponse } from '@object-ui/permissions'; import { toast } from 'sonner'; import { RecordDetailView } from './RecordDetailView'; +import { COMMENTS_PANEL_OPEN_KEY } from './recordCommentsPanel'; import { __clearRecordEditableCache } from '../../../plugin-detail/src/useRecordEditable'; const OBJECT_NAME = 'crm_case'; @@ -351,6 +352,8 @@ describe('the side preview has no comments (objectstack#36225)', () => { }); it('a hand-written page’s object: the preview draws the standard page, with no icon (objectstack#36150)', async () => { + // The reader left the full page's panel open. + window.localStorage.setItem(COMMENTS_PANEL_OPEN_KEY, 'open'); const { container } = await mount({ pages: [AUTHORED_PAGE], embedded: true }); // The standard page is laid out (its tab row is drawn) before anything is asked of it. await within(container).findByRole('tab', { name: /^Activity/ }); From d3ed9585f62be292dd1f26d8431673f36ad5f5e8 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 22 Nov 2026 10:35:27 +0000 Subject: [PATCH 5/5] chore(changeset): plugin-detail's README and RecordCommentsInPanelContext docs ship in this change Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01QsR2jRaJbQ4vqdv4J5peqA --- .changeset/36225-preview-no-comments.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.changeset/36225-preview-no-comments.md b/.changeset/36225-preview-no-comments.md index b5df6ed0d23..c77a060a9d1 100644 --- a/.changeset/36225-preview-no-comments.md +++ b/.changeset/36225-preview-no-comments.md @@ -1,5 +1,6 @@ --- '@object-ui/app-shell': patch +'@object-ui/plugin-detail': patch --- feat(record-page): the side preview drops the comments icon and the comment panel; a record's comments are on its full page @@ -10,3 +11,5 @@ Metadata-protocol: none A record opened in the side preview (the drawer or pane a list opens, and the drawer a record page opens over itself) no longer shows the comments icon in its header, and no comment panel can be opened anywhere in it. Its 动态 tab keeps the system entries alone, with no comment and no comment box, so the preview shows no comments at all. To read or write a comment, open the record as a full page from the preview header; the full page's comments icon, panel and comment box are unchanged, and so is the phone's comment page. This replaces the lines of the objectstack#36075 record-comment-panel entry that put the icon and the panel in the record drawer: there is no drawer placement any more (no cover of the drawer body under 760 px, no split above it), and the browser keeps one open-or-closed choice, the record page's. No props, exports or metadata change. + +The `@object-ui/plugin-detail` README and the docs of `RecordCommentsInPanelContext` now describe the preview case; no code changes there.