From 6618a9897fa0950a72040a590e67cfc34c828fb8 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 04:16:56 +0000 Subject: [PATCH 1/4] wip(app-shell): inbox bell opens a right-side full-height panel with pending approvals decidable in place Claude-Session: https://claude.ai/code/session_01WGufzfdKUNrJJjV88a19v2 Co-authored-by: Claude --- .../app-shell/src/hooks/sharedUserFeeds.ts | 20 ++ .../app-shell/src/hooks/useInboxBell.ts | 23 +- .../app-shell/src/layout/AppHeader.tsx | 4 + .../src/layout/InboxApprovalItem.tsx | 90 ++++++++ .../app-shell/src/layout/InboxPopover.tsx | 212 ++++++++++++++---- .../views/global-notifications-renderer.tsx | 4 + ui/packages/i18n/src/locales/ar.ts | 2 + ui/packages/i18n/src/locales/de.ts | 2 + ui/packages/i18n/src/locales/en.ts | 2 + ui/packages/i18n/src/locales/es.ts | 2 + ui/packages/i18n/src/locales/fr.ts | 2 + ui/packages/i18n/src/locales/ja.ts | 2 + ui/packages/i18n/src/locales/ko.ts | 2 + ui/packages/i18n/src/locales/pt-BR.ts | 2 + ui/packages/i18n/src/locales/ru.ts | 2 + ui/packages/i18n/src/locales/zh-Hans.ts | 2 + ui/packages/i18n/src/locales/zh-Hant.ts | 2 + 17 files changed, 331 insertions(+), 44 deletions(-) create mode 100644 ui/packages/app-shell/src/layout/InboxApprovalItem.tsx diff --git a/ui/packages/app-shell/src/hooks/sharedUserFeeds.ts b/ui/packages/app-shell/src/hooks/sharedUserFeeds.ts index f8036dc7af3..45aeb3d4314 100644 --- a/ui/packages/app-shell/src/hooks/sharedUserFeeds.ts +++ b/ui/packages/app-shell/src/hooks/sharedUserFeeds.ts @@ -831,6 +831,15 @@ export interface PendingApprovalRequest { /** The flow's machine name, as served. */ processName?: string; createdAt?: string; + /** + * The request row as the approvals list served it, carrying the + * server-computed `viewer` block (`can_act`, `can_override`). It is the + * dispatch record the inbox panel hands `DeclaredActionsBar`, so an inline + * Approve / Reject runs the request's own declared action, gated by its own + * `visible` predicate, and resolves `{id}` from this row (objectstack#34589). + * Optional so a surface that only lists titles builds the shape without it. + */ + row?: Record; } /** @@ -1019,6 +1028,7 @@ export function useSharedPendingApprovalRequests(): SharedFeedSnapshot<{ recordTitle: str(row.record_title), processName: str(row.process_name), createdAt: str(row.created_at), + row, }); } return { requests, total }; @@ -1615,6 +1625,16 @@ export function notifyUserFeedPushed(feed: 'inbox' | 'approvals'): void { (feed === 'inbox' ? inboxFeed : approvalsFeed).pushedChange(); } +/** + * Read the pending approvals once, now: a decision taken in this tab changed + * them, so the bell badge and every list cut from the feed must not wait for + * the next poll to drop the decided request (objectstack#34589). Same refresh + * {@link notifyUserFeedPushed} runs for a pushed change. Package-internal. + */ +export function refreshSharedPendingApprovals(): void { + approvalsFeed.pushedChange(); +} + /** * Test seam: drop every shared feed's cached value, key and in-flight state so * cases do not inherit each other's reads. Not part of the public surface. diff --git a/ui/packages/app-shell/src/hooks/useInboxBell.ts b/ui/packages/app-shell/src/hooks/useInboxBell.ts index 0872d022e0e..fb2cda55a61 100644 --- a/ui/packages/app-shell/src/hooks/useInboxBell.ts +++ b/ui/packages/app-shell/src/hooks/useInboxBell.ts @@ -23,7 +23,7 @@ * One hook, two consumers — the two surfaces have no representable state in * which they disagree, because there is no second read and no second overlay. * - * NOTHING is fetched here: `useSharedInboxFeed` / `useSharedPendingApprovalsCount` + * NOTHING is fetched here: `useSharedInboxFeed` / `useSharedPendingApprovalRequests` * own the polling, its cadence, its hidden-tab throttle and its failure backoff. * This hook adds only the optimistic read overlay and the mark-read writes. * @@ -31,7 +31,13 @@ */ import { useCallback, useMemo, useState } from 'react'; import { bearerAuthHeaders } from '../utils/authToken.js'; -import { useSharedInboxFeed, useSharedPendingApprovalsCount, type SharedFeedStatus } from './sharedUserFeeds.js'; +import { + refreshSharedPendingApprovals, + useSharedInboxFeed, + useSharedPendingApprovalRequests, + type PendingApprovalRequest, + type SharedFeedStatus, +} from './sharedUserFeeds.js'; import { useInboxArrivalNotifier } from './useInboxArrivalNotifier.js'; import type { InboxNotification } from '../layout/inboxGrouping.js'; @@ -54,6 +60,13 @@ export interface InboxBell { unreadCount: number; /** The badge's second addend — pending approvals waiting on this user. */ pendingApprovalsCount: number; + /** + * The first page of those requests, from the same one read as the count — + * the rows the inbox panel pins under "Needs your action" (objectstack#34589). + */ + pendingApprovals: PendingApprovalRequest[]; + /** Re-read the approvals now — after a decision taken from the panel. */ + refreshPendingApprovals: () => void; markAllRead: () => Promise; markRead: (id: string) => Promise; markManyRead: (ids: string[]) => Promise; @@ -95,7 +108,9 @@ export function useInboxBell(): InboxBell { * Shared with Home's To-do card (#4197): one polled request serves both, so * the badge and the card can no longer disagree. */ - const pendingApprovalsCount = useSharedPendingApprovalsCount(); + const { value: approvalPage } = useSharedPendingApprovalRequests(); + const pendingApprovalsCount = approvalPage.total; + const pendingApprovals = approvalPage.requests; const unreadCount = notifications.reduce((n, x) => n + (x.is_read ? 0 : 1), 0); @@ -182,6 +197,8 @@ export function useInboxBell(): InboxBell { status, unreadCount, pendingApprovalsCount, + pendingApprovals, + refreshPendingApprovals: refreshSharedPendingApprovals, markAllRead, markRead, markManyRead, diff --git a/ui/packages/app-shell/src/layout/AppHeader.tsx b/ui/packages/app-shell/src/layout/AppHeader.tsx index 58464aba442..f0ce66e5e09 100644 --- a/ui/packages/app-shell/src/layout/AppHeader.tsx +++ b/ui/packages/app-shell/src/layout/AppHeader.tsx @@ -576,6 +576,8 @@ export function AppHeader({ notifications, unreadCount, pendingApprovalsCount, + pendingApprovals, + refreshPendingApprovals, markAllRead, markRead: markNotificationRead, markManyRead, @@ -1138,6 +1140,8 @@ export function AppHeader({ onMarkAllRead={markAllRead} onMarkRead={markNotificationRead} onMarkManyRead={markManyRead} + pendingApprovals={pendingApprovals} + onApprovalDecided={refreshPendingApprovals} /> diff --git a/ui/packages/app-shell/src/layout/InboxApprovalItem.tsx b/ui/packages/app-shell/src/layout/InboxApprovalItem.tsx new file mode 100644 index 00000000000..d988439ce68 --- /dev/null +++ b/ui/packages/app-shell/src/layout/InboxApprovalItem.tsx @@ -0,0 +1,90 @@ +/** + * ObjectUI + * Copyright (c) 2024-present ObjectStack Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +/** + * One pending approval request in the inbox panel, decidable in place + * (objectstack#34589). + * + * The decision levers are NOT drawn here: they are the request's own declared + * actions at `list_item` (`approval_approve`, `approval_reject` on + * `sys_approval_request`), run through `DeclaredActionsBar` — the governed + * path the record page and the decision panel already run them through. So + * whether a viewer sees a lever is the action's own `visible` predicate over + * the row's server-computed `viewer` block, a request that asks for decision + * outputs collects them in the action's param dialog, and the request a click + * sends is the declared one. No third approvals client is written here. + * + * "View details" opens the request in the Approvals inbox, the target Home's + * "My work" approvals row opens. + * + * @module + */ + +import { useObjectTranslation, useDisplayLocale } from '@object-ui/i18n'; +import type { PendingApprovalRequest } from '../hooks/sharedUserFeeds.js'; +import { DeclaredActionsBar } from '../views/DeclaredActionsBar.js'; +import { timeAgo } from '../utils/relativeTime.js'; + +/** The object whose declared actions decide a request. */ +const APPROVAL_REQUEST_OBJECT = 'sys_approval_request'; + +/** The declared location of the inline levers (approve / reject). */ +const INLINE_DECISION_LOCATION = 'list_item'; + +/** The phone tap floor, as the rest of the panel spells it. */ +const PHONE_TAP = 'max-md:min-h-11'; + +/** The flow's label and the record's title, as Home's approvals row names it. */ +export function approvalRequestTitle(r: PendingApprovalRequest): string { + return [r.processLabel || r.processName, r.recordTitle].filter(Boolean).join(' · ') || r.id; +} + +export interface InboxApprovalItemProps { + request: PendingApprovalRequest; + /** Open the request in the Approvals inbox. */ + onOpen: (request: PendingApprovalRequest) => void; + /** A declared action on this request succeeded. */ + onDecided: (request: PendingApprovalRequest) => void; +} + +export function InboxApprovalItem({ request, onOpen, onDecided }: InboxApprovalItemProps) { + const { t } = useObjectTranslation(); + const displayLocale = useDisplayLocale(); + return ( +
+
+ +
+
{approvalRequestTitle(request)}
+ {request.createdAt && ( +
+ {timeAgo(request.createdAt, displayLocale)} +
+ )} +
+ {request.row && ( + onDecided(request)} + /> + )} + +
+
+
+
+ ); +} diff --git a/ui/packages/app-shell/src/layout/InboxPopover.tsx b/ui/packages/app-shell/src/layout/InboxPopover.tsx index dc6f78fa498..f9b18dfe6dd 100644 --- a/ui/packages/app-shell/src/layout/InboxPopover.tsx +++ b/ui/packages/app-shell/src/layout/InboxPopover.tsx @@ -8,7 +8,14 @@ * - Activity (the recent activity the caller may read; no tab at all for a * caller without read on `sys_activity`, objectui#12081) * - * Rendered as a single bell button + popover with a tabbed body. The badge + * Rendered as a single bell button + a full-height panel on the right with a + * tabbed body (objectstack#34589): the page beside it stays visible and usable, + * so opening a notification lands its record in the page while the panel + * stays open on the next one. Pending approvals are pinned on top of the + * Notifications tab under "Needs your action", each decidable in place + * through the request's own declared actions. The panel yields when the record + * drawer opens (the two never stack on the right), and fills a phone. The + * badge * shows the combined unread pressure — distinct unread *topics* + pending * approvals — so a recurring notification (e.g. a scheduled digest that fires * once a minute) can't inflate the badge to "9+" on its own (#2765). @@ -22,20 +29,22 @@ */ import { useState, useEffect, useRef, useMemo } from 'react'; -import { useNavigate, useParams } from 'react-router-dom'; +import { useLocation, useNavigate, useParams } from 'react-router-dom'; import { Button, - Popover, - PopoverContent, - PopoverTrigger, + Sheet, + SheetContent, + SheetTitle, + SheetTrigger, Tabs, TabsList, TabsTrigger, TabsContent, + useIsMobile, } from '@object-ui/components'; -import { Bell, CheckSquare, Activity as ActivityIcon, ChevronRight, CircleAlert, Lock } from 'lucide-react'; +import { Bell, Check, CheckSquare, Activity as ActivityIcon, ChevronRight, CircleAlert, Lock } from 'lucide-react'; import { useObjectTranslation, useDisplayLocale } from '@object-ui/i18n'; -import type { ActivityFeedReading } from '../hooks/sharedUserFeeds.js'; +import type { ActivityFeedReading, PendingApprovalRequest } from '../hooks/sharedUserFeeds.js'; import { useNavigationContext } from '../context/NavigationContext.js'; import { useMetadata } from '../providers/MetadataProvider.js'; import { resolveHostAppSegment } from '../utils/appRoute.js'; @@ -45,6 +54,8 @@ import type { InboxNotification, NotificationGroup } from './inboxGrouping.js'; import { openInboxNotification } from './openInboxNotification.js'; import { ActivityObjectLabel } from './ActivityObjectLabel.js'; import { confirmUnsavedLeave } from '../chrome/unsavedEdits.js'; +import { RECORD_DRAWER_PARAM } from '../urlParams.js'; +import { InboxApprovalItem } from './InboxApprovalItem.js'; // Re-exported so importers of the notification/group shapes keep resolving // through this module (the pure logic itself lives in inboxGrouping.ts). @@ -113,10 +124,28 @@ const PHONE_TAP = 'max-md:min-h-11'; /** * Below `md` the three tabs share the strip by content width with their icons - * dropped, so the third tab is not pushed past a 359 px popover. + * dropped, so the third tab is never pushed off a phone's width. */ const TAB_TRIGGER_CLASS = `text-xs gap-1.5 data-[state=active]:bg-transparent ${PHONE_TAP} max-md:flex-auto max-md:px-1.5`; +/** + * The panel (objectstack#34589): the full height of the viewport on the right, + * 440 px wide from `md` up and the whole screen below it, a flex column whose + * open tab takes the height the header and tab strip leave. + */ +const PANEL_CLASS = 'flex w-full max-w-none flex-col gap-0 p-0 sm:max-w-none md:w-[440px]'; + +/** An open tab: fills the panel's remaining height, the rows scroll inside it. */ +const TAB_PANEL_CLASS = 'm-0 flex min-h-0 flex-1 flex-col'; + +/** + * The per-row "mark read" lever: an icon that shows on hover or keyboard focus + * instead of a column every row pays for; a phone has no hover, so it stays + * shown below `md`. + */ +const MARK_READ_ICON_CLASS = + 'shrink-0 self-center mr-2 inline-flex h-7 w-7 items-center justify-center rounded-md border text-muted-foreground hover:text-foreground hover:bg-accent transition-opacity opacity-0 group-hover:opacity-100 focus-visible:opacity-100 max-md:opacity-100 max-md:h-11 max-md:w-11'; + export interface InboxPopoverProps { notifications: InboxNotification[]; unreadCount: number; @@ -150,16 +179,27 @@ export interface InboxPopoverProps { * the component still works for callers that only wire the single-mark path. */ onMarkManyRead?: (ids: string[]) => void; + /** + * The first page of the requests `pendingApprovalsCount` counts, from the + * same read (objectstack#34589), pinned on top of the Notifications tab and + * listed in the Approvals tab. Absent ⇒ the panel lists none and keeps the + * count and the drill into the Approvals inbox. + */ + pendingApprovals?: PendingApprovalRequest[]; + /** A declared decision on one of them succeeded: re-read the approvals. */ + onApprovalDecided?: () => void; } export function InboxPopover({ notifications, unreadCount, - pendingApprovalsCount, + pendingApprovalsCount: servedApprovalsCount, activity, onMarkAllRead, onMarkRead, onMarkManyRead, + pendingApprovals, + onApprovalDecided, }: InboxPopoverProps) { const { t } = useObjectTranslation(); // Every relative time below reads the DISPLAY locale, never the UI language @@ -169,7 +209,22 @@ export function InboxPopover({ const params = useParams(); const { currentAppName } = useNavigationContext(); const { apps } = useMetadata(); + const location = useLocation(); + const isMobile = useIsMobile(); const [open, setOpen] = useState(false); + // Requests decided from this panel, hidden until the feed's re-read drops + // them, so a decided row leaves at once (objectstack#34589). + const [decidedIds, setDecidedIds] = useState>(() => new Set()); + const shownApprovals = useMemo( + () => (pendingApprovals ?? []).filter((r) => !decidedIds.has(r.id)), + [pendingApprovals, decidedIds], + ); + // The count the panel shows, less the decided requests the feed still lists: + // the same optimistic overlay, so the badge drops with the row. + const pendingApprovalsCount = Math.max( + 0, + servedApprovalsCount - ((pendingApprovals?.length ?? 0) - shownApprovals.length), + ); // Chosen on every open by `handleOpenChange` below, never while open, so a // count that changes under an open popover does not move the tab. const [tab, setTab] = useState('notifications'); @@ -195,6 +250,13 @@ export function InboxPopover({ const unreadTopics = allGroups.reduce((sum, g) => sum + (g.unreadCount > 0 ? 1 : 0), 0); const totalBadge = unreadTopics + pendingApprovalsCount; + + // The record drawer opens on the right too: the panel yields to it rather + // than stacking beside it (objectstack#34589). + const drawerRecordId = new URLSearchParams(location.search).get(RECORD_DRAWER_PARAM); + useEffect(() => { + if (drawerRecordId) setOpen(false); + }, [drawerRecordId]); // The bell's accessible name carries what its badge says: the badge is // content inside a named button, so a screen reader never reads it. Each // non-zero addend is spelled out with the plural forms the popover's own @@ -289,6 +351,18 @@ export function InboxPopover({ leaveTo(`/apps/${hostAppSegment}/system/approvals`); }; + // One request in the Approvals inbox — the target Home's "My work" approvals + // row opens. The panel stays open beside the page, as for a notification. + const openApproval = (r: PendingApprovalRequest) => { + if (isMobile) setOpen(false); + leaveTo(`/apps/${hostAppSegment}/system/approvals?request=${encodeURIComponent(r.id)}`); + }; + + const handleApprovalDecided = (r: PendingApprovalRequest) => { + setDecidedIds((prev) => new Set(prev).add(r.id)); + onApprovalDecided?.(); + }; + const goToAllNotifications = () => { setOpen(false); // `?view=mine` selects the user-scoped "Notifications" view, matching the @@ -334,12 +408,18 @@ export function InboxPopover({ // the same question. `goToAllNotifications` closes the popover and lands on // the same `?view=mine` page the row came from, which is where a linkless // notification can still be read in full. + // + // A followed link leaves the panel OPEN (objectstack#34589): the record + // lands in the page beside it and the next notification is one click away. + // On a phone the panel covers the page, so it closes there. const handleNotificationClick = (n: InboxNotification) => openInboxNotification({ id: n.id, actionUrl: n.action_url }, hostAppSegment, { markRead: onMarkRead, goTo: leaveTo, openInbox: goToAllNotifications, - beforeFollow: () => setOpen(false), + beforeFollow: () => { + if (isMobile) setOpen(false); + }, }); const toggleGroup = (key: string) => { @@ -363,10 +443,11 @@ export function InboxPopover({ // component) so it closes over `displayLocale`/`handleNotificationClick` without // remounting the subtree on every parent render. const renderRow = (n: InboxNotification, nested: boolean) => ( +
+ {!n.is_read && ( + + )} +
+ ); + + // "Needs your action" (objectstack#34589): the pending requests, each + // decidable in place. Rendered inside one open tab at a time, so each + // request mounts one set of declared levers. + const renderApprovals = () => ( +
    + {shownApprovals.map((r) => ( +
  • + +
  • + ))} +
); return ( - - + + - - {/* Never wider than the viewport less a 0.5 rem gutter on each side, and - kept that far from its edges: a 375 px phone is narrower than w-96. */} - + {/* Non-modal, no overlay, and a click in the page does not close it: the + page beside the panel stays usable (objectstack#34589). It closes on + its own close button, Escape, the bell, or when the record drawer + opens. */} + e.preventDefault()} + data-testid="inbox-panel" + className={PANEL_CLASS} > -
-
+ {/* pr-12 keeps "Mark all read" clear of the panel's close button. */} +
+ {t('sidebar.inbox', { defaultValue: 'Inbox' })} -
+ {tab === 'notifications' && unreadCount > 0 && (
)} - - + + {t('sidebar.notifications', { defaultValue: 'Notifications' })} @@ -502,11 +613,11 @@ export function InboxPopover({ )} - + {/* Unread/All sub-filter. Keeps the surface compact (matches the Linear / GitHub inbox pattern) without bloating the primary Tabs strip. */} -
+
+
+ {shownApprovals.length > 0 && ( +
+

+ {t('notifications.needsYou', { defaultValue: 'Needs your action' })} +

+ {renderApprovals()} +
+ )} {(() => { const visible = notifFilter === 'unread' @@ -567,12 +687,12 @@ export function InboxPopover({ const isExpanded = expandedGroups.has(group.key); return (
  • -
    +
    0 ? 'bg-accent/40' : ''}`}> )}
    @@ -648,10 +773,12 @@ export function InboxPopover({ ); })()} - {/* Footer link to the dedicated /sys_inbox_message list. The popover - only shows the 20 most-recent rows; users need a path to the - full inbox for bulk operations and older history. */} -
    +
    + {/* Footer link to the dedicated /sys_inbox_message list, pinned + under the scrolling rows. The panel only shows the 20 + most-recent rows; users need a path to the full inbox for bulk + operations and older history. */} +
    ); diff --git a/ui/packages/i18n/src/locales/ar.ts b/ui/packages/i18n/src/locales/ar.ts index 72efb958c72..34e47360b99 100644 --- a/ui/packages/i18n/src/locales/ar.ts +++ b/ui/packages/i18n/src/locales/ar.ts @@ -4083,6 +4083,8 @@ const ar = { viewApprovals: "عرض الموافقات", noPendingApprovals: "لا توجد موافقات معلقة", openApprovalsInbox: "فتح صندوق الموافقات", + needsYou: "يتطلب إجراءً منك", + viewApprovalDetails: "عرض التفاصيل", badgeTotal: "{{total}} إجمالاً", badgeNotifications: "مواضيع غير مقروءة: {{count}}", badgeNotifications_zero: "مواضيع غير مقروءة: {{count}}", diff --git a/ui/packages/i18n/src/locales/de.ts b/ui/packages/i18n/src/locales/de.ts index da6f91f7201..0d5e9dde1e9 100644 --- a/ui/packages/i18n/src/locales/de.ts +++ b/ui/packages/i18n/src/locales/de.ts @@ -3766,6 +3766,8 @@ const de = { viewApprovals: "Genehmigungen anzeigen", noPendingApprovals: "Keine ausstehenden Genehmigungen", openApprovalsInbox: "Genehmigungs-Posteingang öffnen", + needsYou: "Wartet auf Ihre Aktion", + viewApprovalDetails: "Details anzeigen", badgeTotal: "{{total}} insgesamt", badgeNotifications: "{{count}} ungelesene Themen", badgeNotifications_one: "{{count}} ungelesenes Thema", diff --git a/ui/packages/i18n/src/locales/en.ts b/ui/packages/i18n/src/locales/en.ts index e964af1979a..d306620fe6e 100644 --- a/ui/packages/i18n/src/locales/en.ts +++ b/ui/packages/i18n/src/locales/en.ts @@ -4661,6 +4661,8 @@ const en = { viewApprovals: 'View approvals', noPendingApprovals: 'No pending approvals', openApprovalsInbox: 'Open Approvals Inbox', + needsYou: 'Needs your action', + viewApprovalDetails: 'View details', // Bell-badge breakdown (objectstack-ai/objectstack#7233): the badge sums unread notification topics // and pending approvals, then clamps at "9+". These three spell the sum // out inside the popover so the number is explainable. diff --git a/ui/packages/i18n/src/locales/es.ts b/ui/packages/i18n/src/locales/es.ts index 8d8f467dcc6..a0777680173 100644 --- a/ui/packages/i18n/src/locales/es.ts +++ b/ui/packages/i18n/src/locales/es.ts @@ -3846,6 +3846,8 @@ const es = { viewApprovals: "Ver aprobaciones", noPendingApprovals: "Sin aprobaciones pendientes", openApprovalsInbox: "Abrir bandeja de aprobaciones", + needsYou: "Requiere su acción", + viewApprovalDetails: "Ver detalles", badgeTotal: "{{total}} en total", badgeNotifications: "{{count}} temas sin leer", badgeNotifications_one: "{{count}} tema sin leer", diff --git a/ui/packages/i18n/src/locales/fr.ts b/ui/packages/i18n/src/locales/fr.ts index 4e885702b09..06d71444867 100644 --- a/ui/packages/i18n/src/locales/fr.ts +++ b/ui/packages/i18n/src/locales/fr.ts @@ -3842,6 +3842,8 @@ const fr = { viewApprovals: "Voir les approbations", noPendingApprovals: "Aucune approbation en attente", openApprovalsInbox: "Ouvrir la boîte d'approbations", + needsYou: "Requiert votre action", + viewApprovalDetails: "Voir les détails", badgeTotal: "{{total}} au total", badgeNotifications: "{{count}} sujets non lus", badgeNotifications_one: "{{count}} sujet non lu", diff --git a/ui/packages/i18n/src/locales/ja.ts b/ui/packages/i18n/src/locales/ja.ts index af4bfb59474..26047944cea 100644 --- a/ui/packages/i18n/src/locales/ja.ts +++ b/ui/packages/i18n/src/locales/ja.ts @@ -3768,6 +3768,8 @@ const ja = { viewApprovals: "承認を表示", noPendingApprovals: "承認待ちはありません", openApprovalsInbox: "承認ボックスを開く", + needsYou: "あなたの対応が必要", + viewApprovalDetails: "詳細を表示", badgeTotal: "合計 {{total}} 件", badgeNotifications: "未読トピック {{count}} 件", badgeNotifications_one: "未読トピック {{count}} 件", diff --git a/ui/packages/i18n/src/locales/ko.ts b/ui/packages/i18n/src/locales/ko.ts index bde20d27652..ba94b2350c2 100644 --- a/ui/packages/i18n/src/locales/ko.ts +++ b/ui/packages/i18n/src/locales/ko.ts @@ -3765,6 +3765,8 @@ const ko = { viewApprovals: "승인 보기", noPendingApprovals: "대기 중인 승인 없음", openApprovalsInbox: "승인 보관함 열기", + needsYou: "처리가 필요한 항목", + viewApprovalDetails: "자세히 보기", badgeTotal: "총 {{total}}건", badgeNotifications: "읽지 않은 주제 {{count}}건", badgeNotifications_one: "읽지 않은 주제 {{count}}건", diff --git a/ui/packages/i18n/src/locales/pt-BR.ts b/ui/packages/i18n/src/locales/pt-BR.ts index a306ffd97b7..4b3ba855e8a 100644 --- a/ui/packages/i18n/src/locales/pt-BR.ts +++ b/ui/packages/i18n/src/locales/pt-BR.ts @@ -3841,6 +3841,8 @@ const pt = { viewApprovals: "Ver aprovações", noPendingApprovals: "Sem aprovações pendentes", openApprovalsInbox: "Abrir caixa de aprovações", + needsYou: "Requer sua ação", + viewApprovalDetails: "Ver detalhes", badgeTotal: "{{total}} no total", badgeNotifications: "{{count}} tópicos não lidos", badgeNotifications_one: "{{count}} tópico não lido", diff --git a/ui/packages/i18n/src/locales/ru.ts b/ui/packages/i18n/src/locales/ru.ts index 444ba14609d..14cdaf421af 100644 --- a/ui/packages/i18n/src/locales/ru.ts +++ b/ui/packages/i18n/src/locales/ru.ts @@ -3935,6 +3935,8 @@ const ru = { viewApprovals: "Показать утверждения", noPendingApprovals: "Нет ожидающих утверждений", openApprovalsInbox: "Открыть входящие утверждений", + needsYou: "Требует вашего действия", + viewApprovalDetails: "Подробнее", badgeTotal: "Всего: {{total}}", badgeNotifications: "{{count}} непрочитанных тем", badgeNotifications_one: "{{count}} непрочитанная тема", diff --git a/ui/packages/i18n/src/locales/zh-Hans.ts b/ui/packages/i18n/src/locales/zh-Hans.ts index 75afc8b6309..98d924965e2 100644 --- a/ui/packages/i18n/src/locales/zh-Hans.ts +++ b/ui/packages/i18n/src/locales/zh-Hans.ts @@ -4017,6 +4017,8 @@ const zh = { viewApprovals: '查看审批', noPendingApprovals: '暂无待审批事项', openApprovalsInbox: '打开审批中心', + needsYou: '需要你处理', + viewApprovalDetails: '查看详情', badgeTotal: '共 {{total}} 项', badgeNotifications: '{{count}} 个未读主题', badgeNotifications_one: '{{count}} 个未读主题', diff --git a/ui/packages/i18n/src/locales/zh-Hant.ts b/ui/packages/i18n/src/locales/zh-Hant.ts index 7fc5e0b4bed..175a2d3c8d6 100644 --- a/ui/packages/i18n/src/locales/zh-Hant.ts +++ b/ui/packages/i18n/src/locales/zh-Hant.ts @@ -4017,6 +4017,8 @@ const zhHant = { viewApprovals: '檢視審批', noPendingApprovals: '暫無待審批事項', openApprovalsInbox: '開啟審批中心', + needsYou: '需要你處理', + viewApprovalDetails: '查看詳情', badgeTotal: '共 {{total}} 項', badgeNotifications: '{{count}} 個未讀主題', badgeNotifications_one: '{{count}} 個未讀主題', From 4e332a8d10578419ddd5e095eaf3a6308001ddb2 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 04:31:16 +0000 Subject: [PATCH 2/4] test(app-shell): pin the inbox right-side panel and the approvals pinned on top Claude-Session: https://claude.ai/code/session_01WGufzfdKUNrJJjV88a19v2 Co-authored-by: Claude --- .changeset/34589-inbox-right-panel.md | 18 ++ .../sharedInboxFeed.twoSurfaces.test.tsx | 7 +- .../useHomeInbox.myWork-12602.test.tsx | 6 +- ...pHeader.deferredChromeReads-12980.test.tsx | 7 +- .../__tests__/AppHeader.inboxVariant.test.tsx | 7 +- ...boxPopover.approvalsSegment-11818.test.tsx | 8 +- .../InboxPopover.badgeBreakdown.test.tsx | 8 +- .../InboxPopover.badgePlural-13133.test.tsx | 8 +- .../InboxPopover.linklessFallback.test.tsx | 15 +- ...InboxPopover.notificationDeepLink.test.tsx | 8 +- .../InboxPopover.oneStory-27704.test.tsx | 8 +- .../InboxPopover.phoneWidth-29076.test.tsx | 10 +- .../InboxPopover.rightPanel-34589.test.tsx | 269 ++++++++++++++++++ ...oxPopover.unsavedEditsLeave-13253.test.tsx | 8 +- .../InboxPopover.viewAllTarget.test.tsx | 8 +- 15 files changed, 353 insertions(+), 42 deletions(-) create mode 100644 .changeset/34589-inbox-right-panel.md create mode 100644 ui/packages/app-shell/src/layout/__tests__/InboxPopover.rightPanel-34589.test.tsx diff --git a/.changeset/34589-inbox-right-panel.md b/.changeset/34589-inbox-right-panel.md new file mode 100644 index 00000000000..42f95fb86ff --- /dev/null +++ b/.changeset/34589-inbox-right-panel.md @@ -0,0 +1,18 @@ +--- +'@object-ui/app-shell': patch +'@object-ui/i18n': patch +--- + +feat(app-shell): the notification bell opens a full-height panel on the right, with pending approvals on top and decidable in place + +Clause-②: yes (widening) — two new locale keys in the `notifications` namespace of every `@object-ui/i18n` pack (`needsYou`, `viewApprovalDetails`); nothing that worked before is refused +Metadata-protocol: none + +The bell in the console header (and the `global:notifications` page block) used to open a 384 px popover whose lists stopped at 320 px, about three rows. It now opens a panel the full height of the window on the right, 440 px wide, and the lists take all the height the header and tabs leave. + +- **The page stays usable.** The panel has no overlay, and a click in the page does not close it. Opening a notification takes the page to its record while the panel stays open on the next one. The panel closes from its close button, Escape or the bell, and it gives way when the record drawer opens, so the two never stack on the right. +- **Approvals come first.** The Notifications tab opens with "Needs your action": the pending approval requests the bell counts, each with its approve and reject buttons and "View details". The buttons are the request's own declared actions (`approval_approve`, `approval_reject` at `list_item`), run through the same declared-actions bar the request's record page uses. So a viewer sees a button only when its `visible` rule passes, a request that needs decision fields collects them in the action's dialog, and the request sent is the declared one. A decided request leaves the list and the badge at once, and the approvals are read again. The Approvals tab lists the same requests. +- **"Mark read" is an icon** that shows when a row is hovered or focused, instead of a column on every row. "Mark all read" and "View all notifications" stay. +- **On a phone the panel fills the screen**, and following a link closes it. + +The notification data, its grouping and the three tabs are unchanged. diff --git a/ui/packages/app-shell/src/hooks/__tests__/sharedInboxFeed.twoSurfaces.test.tsx b/ui/packages/app-shell/src/hooks/__tests__/sharedInboxFeed.twoSurfaces.test.tsx index b197ca7f872..986044b1172 100644 --- a/ui/packages/app-shell/src/hooks/__tests__/sharedInboxFeed.twoSurfaces.test.tsx +++ b/ui/packages/app-shell/src/hooks/__tests__/sharedInboxFeed.twoSurfaces.test.tsx @@ -114,9 +114,10 @@ vi.mock('@object-ui/components', async (importOriginal) => { Avatar: Pass, AvatarImage: () => null, AvatarFallback: Pass, - Popover: Pass, - PopoverTrigger: Pass, - PopoverContent: Pass, + Sheet: Pass, + SheetTrigger: Pass, + SheetContent: Pass, + SheetTitle: Pass, Tabs: Pass, TabsList: Pass, TabsTrigger: ({ children }: any) => , diff --git a/ui/packages/app-shell/src/hooks/__tests__/useHomeInbox.myWork-12602.test.tsx b/ui/packages/app-shell/src/hooks/__tests__/useHomeInbox.myWork-12602.test.tsx index a6120a772d2..26141fb0d5e 100644 --- a/ui/packages/app-shell/src/hooks/__tests__/useHomeInbox.myWork-12602.test.tsx +++ b/ui/packages/app-shell/src/hooks/__tests__/useHomeInbox.myWork-12602.test.tsx @@ -96,9 +96,11 @@ describe('the approval requests behind the count (objectui#12602)', () => { // The count is the answer's `total`, the route's own count — not a fold // of the page (objectui#13027). This fixture's route totals its 3 rows. expect(result.current.pendingApprovalsCount).toBe(3); + // `row` is the served row itself — the inbox panel's dispatch record for + // the request's declared actions (objectstack#34589). expect(result.current.pendingApprovals).toEqual([ - { id: 'a1', processName: 'discount', processLabel: 'Discount approval', recordTitle: 'QUO-0007', createdAt: '2026-10-16T01:00:00Z' }, - { id: 'a2', processName: 'contract', processLabel: undefined, recordTitle: undefined, createdAt: undefined }, + { id: 'a1', processName: 'discount', processLabel: 'Discount approval', recordTitle: 'QUO-0007', createdAt: '2026-10-16T01:00:00Z', row: rows[0] }, + { id: 'a2', processName: 'contract', processLabel: undefined, recordTitle: undefined, createdAt: undefined, row: rows[2] }, ]); }); diff --git a/ui/packages/app-shell/src/layout/__tests__/AppHeader.deferredChromeReads-12980.test.tsx b/ui/packages/app-shell/src/layout/__tests__/AppHeader.deferredChromeReads-12980.test.tsx index b77cd6932dd..5301740aef0 100644 --- a/ui/packages/app-shell/src/layout/__tests__/AppHeader.deferredChromeReads-12980.test.tsx +++ b/ui/packages/app-shell/src/layout/__tests__/AppHeader.deferredChromeReads-12980.test.tsx @@ -82,9 +82,10 @@ vi.mock('@object-ui/components', async (importOriginal) => { Avatar: Pass, AvatarImage: () => null, AvatarFallback: Pass, - Popover: Pass, - PopoverTrigger: Pass, - PopoverContent: Pass, + Sheet: Pass, + SheetTrigger: Pass, + SheetContent: Pass, + SheetTitle: Pass, Tabs: Pass, TabsList: Pass, TabsTrigger: ({ children }: any) => , diff --git a/ui/packages/app-shell/src/layout/__tests__/AppHeader.inboxVariant.test.tsx b/ui/packages/app-shell/src/layout/__tests__/AppHeader.inboxVariant.test.tsx index f17ac961c1e..b7f6a1067ca 100644 --- a/ui/packages/app-shell/src/layout/__tests__/AppHeader.inboxVariant.test.tsx +++ b/ui/packages/app-shell/src/layout/__tests__/AppHeader.inboxVariant.test.tsx @@ -80,9 +80,10 @@ vi.mock('@object-ui/components', async (importOriginal) => { Avatar: Pass, AvatarImage: () => null, AvatarFallback: Pass, - Popover: Pass, - PopoverTrigger: Pass, - PopoverContent: Pass, + Sheet: Pass, + SheetTrigger: Pass, + SheetContent: Pass, + SheetTitle: Pass, Tabs: Pass, TabsList: Pass, TabsTrigger: ({ children }: any) => , diff --git a/ui/packages/app-shell/src/layout/__tests__/InboxPopover.approvalsSegment-11818.test.tsx b/ui/packages/app-shell/src/layout/__tests__/InboxPopover.approvalsSegment-11818.test.tsx index 8ab6aaebd15..e78c939bc59 100644 --- a/ui/packages/app-shell/src/layout/__tests__/InboxPopover.approvalsSegment-11818.test.tsx +++ b/ui/packages/app-shell/src/layout/__tests__/InboxPopover.approvalsSegment-11818.test.tsx @@ -44,6 +44,7 @@ let appsFixture: Array> = []; vi.mock('react-router-dom', () => ({ useNavigate: () => navigateMock, useParams: () => ({ appName: routeAppNameFixture }), + useLocation: () => ({ pathname: '/', search: '' }), })); vi.mock('../../context/NavigationContext', () => ({ @@ -70,9 +71,10 @@ vi.mock('@object-ui/i18n', async (importOriginal) => ({ vi.mock('@object-ui/components', async (importOriginal) => ({ ...(await importOriginal>()), Button: ({ children, ...p }: any) => , - Popover: ({ children }: any) =>
    {children}
    , - PopoverTrigger: ({ children }: any) =>
    {children}
    , - PopoverContent: ({ children }: any) =>
    {children}
    , + Sheet: ({ children }: any) =>
    {children}
    , + SheetTrigger: ({ children }: any) =>
    {children}
    , + SheetContent: ({ children }: any) =>
    {children}
    , + SheetTitle: ({ children }: any) =>
    {children}
    , Tabs: ({ children }: any) =>
    {children}
    , TabsList: ({ children }: any) =>
    {children}
    , TabsTrigger: ({ children }: any) => , diff --git a/ui/packages/app-shell/src/layout/__tests__/InboxPopover.badgeBreakdown.test.tsx b/ui/packages/app-shell/src/layout/__tests__/InboxPopover.badgeBreakdown.test.tsx index aa684bbe998..1aebd5acf82 100644 --- a/ui/packages/app-shell/src/layout/__tests__/InboxPopover.badgeBreakdown.test.tsx +++ b/ui/packages/app-shell/src/layout/__tests__/InboxPopover.badgeBreakdown.test.tsx @@ -38,6 +38,7 @@ vi.mock('@object-ui/i18n', async (importOriginal) => ({ vi.mock('react-router-dom', () => ({ useNavigate: () => vi.fn(), useParams: () => ({ appName: 'setup' }), + useLocation: () => ({ pathname: '/', search: '' }), })); vi.mock('../../context/NavigationContext', () => ({ @@ -49,9 +50,10 @@ vi.mock('../../context/NavigationContext', () => ({ vi.mock('@object-ui/components', async (importOriginal) => ({ ...(await importOriginal>()), Button: ({ children, ...p }: any) => , - Popover: ({ children }: any) =>
    {children}
    , - PopoverTrigger: ({ children }: any) =>
    {children}
    , - PopoverContent: ({ children }: any) =>
    {children}
    , + Sheet: ({ children }: any) =>
    {children}
    , + SheetTrigger: ({ children }: any) =>
    {children}
    , + SheetContent: ({ children }: any) =>
    {children}
    , + SheetTitle: ({ children }: any) =>
    {children}
    , Tabs: ({ children }: any) =>
    {children}
    , TabsList: ({ children }: any) =>
    {children}
    , TabsTrigger: ({ children }: any) => , diff --git a/ui/packages/app-shell/src/layout/__tests__/InboxPopover.badgePlural-13133.test.tsx b/ui/packages/app-shell/src/layout/__tests__/InboxPopover.badgePlural-13133.test.tsx index 8824cc603b6..be048d0bfdd 100644 --- a/ui/packages/app-shell/src/layout/__tests__/InboxPopover.badgePlural-13133.test.tsx +++ b/ui/packages/app-shell/src/layout/__tests__/InboxPopover.badgePlural-13133.test.tsx @@ -22,6 +22,7 @@ import { createI18n, I18nProvider } from '@object-ui/i18n'; vi.mock('react-router-dom', () => ({ useNavigate: () => vi.fn(), useParams: () => ({ appName: 'setup' }), + useLocation: () => ({ pathname: '/', search: '' }), })); vi.mock('../../context/NavigationContext', () => ({ @@ -39,9 +40,10 @@ vi.mock('@object-ui/components', async (importOriginal) => ({ {children} ), - Popover: ({ children }: Slot) =>
    {children}
    , - PopoverTrigger: ({ children }: Slot) =>
    {children}
    , - PopoverContent: ({ children }: Slot) =>
    {children}
    , + Sheet: ({ children }: Slot) =>
    {children}
    , + SheetTrigger: ({ children }: Slot) =>
    {children}
    , + SheetContent: ({ children }: Slot) =>
    {children}
    , + SheetTitle: ({ children }: Slot) =>
    {children}
    , Tabs: ({ children }: Slot) =>
    {children}
    , TabsList: ({ children }: Slot) =>
    {children}
    , TabsTrigger: ({ children }: Slot) => , diff --git a/ui/packages/app-shell/src/layout/__tests__/InboxPopover.linklessFallback.test.tsx b/ui/packages/app-shell/src/layout/__tests__/InboxPopover.linklessFallback.test.tsx index cdad779c723..a61d4ec708a 100644 --- a/ui/packages/app-shell/src/layout/__tests__/InboxPopover.linklessFallback.test.tsx +++ b/ui/packages/app-shell/src/layout/__tests__/InboxPopover.linklessFallback.test.tsx @@ -48,6 +48,7 @@ let appsFixture: any[] = []; vi.mock('react-router-dom', () => ({ useNavigate: () => navigateMock, useParams: () => ({ appName: routeAppNameFixture }), + useLocation: () => ({ pathname: '/', search: '' }), })); vi.mock('../../context/NavigationContext', () => ({ @@ -69,7 +70,7 @@ vi.mock('@object-ui/i18n', async (importOriginal) => ({ }), })); -// Passthrough primitives, as in the sibling suites — except `Popover`, which +// Passthrough primitives, as in the sibling suites — except `Sheet`, which // here REPORTS the controlled `open` prop and exposes an opener that drives // `onOpenChange`. The sibling mocks swallow both, which is fine for asserting a // navigation target but makes "the popover closes" unobservable, and staying @@ -77,7 +78,7 @@ vi.mock('@object-ui/i18n', async (importOriginal) => ({ vi.mock('@object-ui/components', async (importOriginal) => ({ ...(await importOriginal>()), Button: ({ children, ...p }: any) => , - Popover: ({ open, onOpenChange, children }: any) => ( + Sheet: ({ open, onOpenChange, children }: any) => (
    ), - PopoverTrigger: ({ children }: any) =>
    {children}
    , - PopoverContent: ({ children }: any) =>
    {children}
    , + SheetTrigger: ({ children }: any) =>
    {children}
    , + SheetContent: ({ children }: any) =>
    {children}
    , + SheetTitle: ({ children }: any) =>
    {children}
    , Tabs: ({ children }: any) =>
    {children}
    , TabsList: ({ children }: any) =>
    {children}
    , TabsTrigger: ({ children }: any) => , @@ -200,7 +202,10 @@ describe('A linkless bell notification opens the full inbox (objectui#5190)', () notif({ id: 'n1', action_url: '/showcase_task/t_42' }), ); expect(target).toBe('/apps/crm/showcase_task/t_42'); - expect(isOpen).toBe(false); + // A followed link leaves the panel open beside the page, on the next row + // (objectstack#34589); only the linkless fallback, a drill into the full + // inbox, closes it. + expect(isOpen).toBe(true); }); }); diff --git a/ui/packages/app-shell/src/layout/__tests__/InboxPopover.notificationDeepLink.test.tsx b/ui/packages/app-shell/src/layout/__tests__/InboxPopover.notificationDeepLink.test.tsx index 7e3943f3987..5bb98e86a32 100644 --- a/ui/packages/app-shell/src/layout/__tests__/InboxPopover.notificationDeepLink.test.tsx +++ b/ui/packages/app-shell/src/layout/__tests__/InboxPopover.notificationDeepLink.test.tsx @@ -46,6 +46,7 @@ let appsFixture: any[] = []; vi.mock('react-router-dom', () => ({ useNavigate: () => navigateMock, useParams: () => ({ appName: routeAppNameFixture }), + useLocation: () => ({ pathname: '/', search: '' }), })); vi.mock('../../context/NavigationContext', () => ({ @@ -70,9 +71,10 @@ vi.mock('@object-ui/i18n', async (importOriginal) => ({ vi.mock('@object-ui/components', async (importOriginal) => ({ ...(await importOriginal>()), Button: ({ children, ...p }: any) => , - Popover: ({ children }: any) =>
    {children}
    , - PopoverTrigger: ({ children }: any) =>
    {children}
    , - PopoverContent: ({ children }: any) =>
    {children}
    , + Sheet: ({ children }: any) =>
    {children}
    , + SheetTrigger: ({ children }: any) =>
    {children}
    , + SheetContent: ({ children }: any) =>
    {children}
    , + SheetTitle: ({ children }: any) =>
    {children}
    , Tabs: ({ children }: any) =>
    {children}
    , TabsList: ({ children }: any) =>
    {children}
    , TabsTrigger: ({ children }: any) => , diff --git a/ui/packages/app-shell/src/layout/__tests__/InboxPopover.oneStory-27704.test.tsx b/ui/packages/app-shell/src/layout/__tests__/InboxPopover.oneStory-27704.test.tsx index 503939beea8..256b4948dce 100644 --- a/ui/packages/app-shell/src/layout/__tests__/InboxPopover.oneStory-27704.test.tsx +++ b/ui/packages/app-shell/src/layout/__tests__/InboxPopover.oneStory-27704.test.tsx @@ -21,6 +21,7 @@ import { createI18n, I18nProvider } from '@object-ui/i18n'; vi.mock('react-router-dom', () => ({ useNavigate: () => vi.fn(), useParams: () => ({ appName: 'setup' }), + useLocation: () => ({ pathname: '/', search: '' }), })); vi.mock('../../context/NavigationContext', () => ({ @@ -38,9 +39,10 @@ vi.mock('@object-ui/components', async (importOriginal) => ({ {children} ), - Popover: ({ children }: Slot) =>
    {children}
    , - PopoverTrigger: ({ children }: Slot) =>
    {children}
    , - PopoverContent: ({ children }: Slot) =>
    {children}
    , + Sheet: ({ children }: Slot) =>
    {children}
    , + SheetTrigger: ({ children }: Slot) =>
    {children}
    , + SheetContent: ({ children }: Slot) =>
    {children}
    , + SheetTitle: ({ children }: Slot) =>
    {children}
    , Tabs: ({ children }: Slot) =>
    {children}
    , TabsList: ({ children }: Slot) =>
    {children}
    , TabsTrigger: ({ children }: Slot) => , diff --git a/ui/packages/app-shell/src/layout/__tests__/InboxPopover.phoneWidth-29076.test.tsx b/ui/packages/app-shell/src/layout/__tests__/InboxPopover.phoneWidth-29076.test.tsx index 02eb201298e..b9bfaf1e924 100644 --- a/ui/packages/app-shell/src/layout/__tests__/InboxPopover.phoneWidth-29076.test.tsx +++ b/ui/packages/app-shell/src/layout/__tests__/InboxPopover.phoneWidth-29076.test.tsx @@ -6,7 +6,7 @@ * The mobile app hosts the Console, so below `md` this popover is a phone UI. * Measured on a 375 px viewport, the popover was `w-96` (384 px) and lost its * right 9 px, and its own controls were 16–36 px tall. These pin the two - * rules: the popover is capped at the viewport less a gutter, and every + * rules: the inbox fits the viewport (it fills it since objectstack#34589), and every * control the popover draws besides the rows (which are tall by content) * carries the phone tap floor. * @@ -71,12 +71,12 @@ function choose(dialog: HTMLElement, name: RegExp) { } describe('InboxPopover at phone width (objectstack#29076)', () => { - it('is never wider than the viewport less a 0.5 rem gutter on each side', () => { + it('fills the phone, and is 440 px wide from md up (objectstack#34589)', () => { render(bell(0)); const dialog = openInbox(); - expect(dialog.className).toContain('max-w-[calc(100vw-1rem)]'); - // the desktop width stays - expect(dialog.className).toContain('w-96'); + for (const cls of ['w-full', 'max-w-none', 'sm:max-w-none', 'md:w-[440px]']) { + expect(dialog.className.split(/\s+/), cls).toContain(cls); + } }); it('gives the Notifications tab controls the 44 px phone floor', () => { diff --git a/ui/packages/app-shell/src/layout/__tests__/InboxPopover.rightPanel-34589.test.tsx b/ui/packages/app-shell/src/layout/__tests__/InboxPopover.rightPanel-34589.test.tsx new file mode 100644 index 00000000000..0aa77e4ec91 --- /dev/null +++ b/ui/packages/app-shell/src/layout/__tests__/InboxPopover.rightPanel-34589.test.tsx @@ -0,0 +1,269 @@ +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. + +/** + * The bell opens a full-height panel on the right, with pending approvals + * pinned on top and decidable in place (objectstack#34589). + * + * What these pin: + * - the panel is a right-side, full-height sheet with no overlay, and a click + * in the page beside it neither closes it nor is swallowed by it; + * - "Needs your action" heads the Notifications tab, one item per pending + * request, and each item's levers are the request's OWN declared actions + * (`DeclaredActionsBar` over `sys_approval_request` at `list_item`, with + * the served row as the dispatch record), not a third approvals client; + * - a decision taken there drops the row and the badge at once and asks the + * feed to re-read; + * - following a notification or "View details" keeps the panel open beside + * the page, and the panel yields when the record drawer opens; + * - at 375 px the panel fills the screen and a followed link closes it; + * - "mark read" is an icon shown on hover or focus, not a column. + * + * Real Radix sheet and tabs, real router and i18n pack. Only the declared + * actions bar is stood in for: its own gates and dialogs are pinned in its own + * suites, and what this panel owes is the wiring into it. + */ + +import React from 'react'; +import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; +import { act, cleanup, fireEvent, render, screen, within } from '@testing-library/react'; +import { MemoryRouter, useLocation, useNavigate } from 'react-router-dom'; +import { I18nProvider } from '@object-ui/i18n'; + +const barProps: Array> = []; + +vi.mock('../../views/DeclaredActionsBar', () => ({ + DeclaredActionsBar: (props: Record) => { + barProps.push(props); + return ( +
    + +
    + ); + }, +})); + +import { InboxPopover, type InboxNotification } from '../InboxPopover'; +import type { PendingApprovalRequest } from '../../hooks/sharedUserFeeds'; + +const notifications: InboxNotification[] = [ + { id: 'n1', type: 'task.assigned', title: 'Task assigned', is_read: false, created_at: '2026-10-01T10:00:00Z', action_url: '/task/t1' }, + { id: 'n2', type: 'lead.assigned', title: 'Lead assigned', is_read: true, created_at: '2026-10-01T09:00:00Z' }, +]; + +const request = (id: string, title: string): PendingApprovalRequest => ({ + id, + processLabel: 'Purchase approval', + recordTitle: title, + createdAt: '2026-10-01T08:00:00Z', + row: { id, status: 'pending', record_title: title, viewer: { can_act: true, can_override: false, is_submitter: false } }, +}); + +const approvals = [request('req-1', 'PO-001'), request('req-2', 'PO-002')]; + +function LocationProbe() { + const location = useLocation(); + return {`${location.pathname}${location.search}`}; +} + +function PageButtons() { + const navigate = useNavigate(); + return ( + <> + + + + ); +} + +function bell(props: Partial> = {}) { + return ( + + + + + {}} + onMarkRead={() => {}} + {...props} + /> + + + ); +} + +function openInbox(): HTMLElement { + fireEvent.click(screen.getByRole('button', { name: /^Notifications(,|$)/ })); + return screen.getByRole('dialog'); +} + +function setViewport(width: number) { + Object.defineProperty(window, 'innerWidth', { configurable: true, writable: true, value: width }); + window.dispatchEvent(new Event('resize')); +} + +beforeEach(() => { + barProps.length = 0; + setViewport(1440); +}); + +afterEach(() => { + cleanup(); + window.sessionStorage.clear(); + setViewport(1024); +}); + +describe('InboxPopover — a right-side full-height panel (objectstack#34589)', () => { + it('opens on the right at full height, 440 px wide, with no overlay over the page', () => { + render(bell()); + const panel = openInbox(); + expect(panel.getAttribute('data-testid')).toBe('inbox-panel'); + const classes = panel.className.split(/\s+/); + for (const cls of ['inset-y-0', 'right-0', 'h-full', 'md:w-[440px]', 'flex-col']) { + expect(classes, cls).toContain(cls); + } + // the popover's 320 px list cap is gone: the rows scroll in the height left + expect(panel.innerHTML).not.toContain('max-h-80'); + expect(within(panel).getByTestId('inbox-notifications-scroll').className).toContain('flex-1'); + // no dimming layer is mounted over the page + expect(document.querySelector('.bg-black\\/80')).toBeNull(); + }); + + it('stays open when the page beside it is clicked, and the click reaches the page', () => { + render(bell()); + openInbox(); + const control = screen.getByTestId('page-control'); + const onClick = vi.fn(); + control.addEventListener('click', onClick); + fireEvent.pointerDown(control); + fireEvent.mouseDown(control); + fireEvent.click(control); + expect(onClick).toHaveBeenCalledTimes(1); + expect(screen.queryByRole('dialog')).not.toBeNull(); + }); + + it('yields when the record drawer opens, so the two never stack on the right', () => { + render(bell()); + openInbox(); + fireEvent.click(screen.getByRole('button', { name: 'Open drawer' })); + expect(screen.getByTestId('location').textContent).toContain('recordId=t1'); + expect(screen.queryByRole('dialog')).toBeNull(); + }); +}); + +describe('InboxPopover — pending approvals pinned on top, decided in place (objectstack#34589)', () => { + it('heads the Notifications tab with "Needs your action", one item per request', () => { + render(bell()); + const panel = openInbox(); + const scroll = within(panel).getByTestId('inbox-notifications-scroll'); + const section = within(scroll).getByTestId('inbox-needs-you'); + // first in the scrolling list, above every notification row + expect(scroll.firstElementChild).toBe(section); + expect(within(section).getByRole('heading', { name: 'Needs your action' })).toBeTruthy(); + expect(within(section).getAllByTestId('inbox-approval-item')).toHaveLength(2); + expect(within(section).getByText('Purchase approval · PO-001')).toBeTruthy(); + }); + + it("runs each request's own declared actions at list_item, with the served row as the dispatch record", () => { + render(bell()); + openInbox(); + expect(barProps).toHaveLength(2); + expect(barProps.map((p) => p.objectName)).toEqual(['sys_approval_request', 'sys_approval_request']); + expect(barProps.map((p) => p.location)).toEqual(['list_item', 'list_item']); + // the row carrying the server-computed `viewer` block the actions gate on + expect(barProps[0].record).toBe(approvals[0].row); + expect(barProps[1].record).toBe(approvals[1].row); + }); + + it('drops a decided request and its share of the badge at once, and asks the feed to re-read', () => { + const onApprovalDecided = vi.fn(); + render(bell({ onApprovalDecided })); + const badge = screen.getByTestId('inbox-bell-badge'); + expect(badge.textContent).toBe('3'); // 1 unread topic + 2 approvals + const panel = openInbox(); + const [first] = within(panel).getAllByTestId('inbox-approval-item'); + act(() => { + fireEvent.click(within(first).getByRole('button', { name: 'Approve' })); + }); + expect(onApprovalDecided).toHaveBeenCalledTimes(1); + expect(within(panel).getAllByTestId('inbox-approval-item')).toHaveLength(1); + expect(within(panel).queryByText('Purchase approval · PO-001')).toBeNull(); + expect(screen.getByTestId('inbox-bell-badge').textContent).toBe('2'); + }); + + it('opens "View details" in the Approvals inbox and stays open beside the page', () => { + render(bell()); + const panel = openInbox(); + const [first] = within(panel).getAllByTestId('inbox-approval-item'); + fireEvent.click(within(first).getByRole('button', { name: 'View details' })); + expect(screen.getByTestId('location').textContent).toMatch(/\/system\/approvals\?request=req-1$/); + expect(screen.queryByRole('dialog')).not.toBeNull(); + }); + + it('lists the same requests in the Approvals tab', () => { + render(bell({ notifications: [], unreadCount: 0 })); + // nothing unread: the panel opens on Approvals (objectui#11698) + const panel = openInbox(); + expect(within(panel).getByRole('tab', { name: /Approvals/, selected: true })).toBeTruthy(); + expect(within(panel).getByTestId('inbox-approvals-list')).toBeTruthy(); + expect(within(panel).getAllByTestId('inbox-approval-item')).toHaveLength(2); + }); +}); + +describe('InboxPopover — following a link and marking read (objectstack#34589)', () => { + it('keeps the panel open while the notification opens its record in the page', () => { + const onMarkRead = vi.fn(); + render(bell({ onMarkRead })); + const panel = openInbox(); + fireEvent.click(within(panel).getByText('Task assigned')); + expect(onMarkRead).toHaveBeenCalledWith('n1'); + expect(screen.getByTestId('location').textContent).toMatch(/\/task\/t1$/); + expect(screen.queryByRole('dialog')).not.toBeNull(); + }); + + it('marks one row read from an icon shown on hover or focus, not a standing column', () => { + const onMarkRead = vi.fn(); + render(bell({ onMarkRead })); + const panel = openInbox(); + const mark = within(panel).getByRole('button', { name: 'Mark read' }); + const classes = mark.className.split(/\s+/); + for (const cls of ['opacity-0', 'group-hover:opacity-100', 'focus-visible:opacity-100']) { + expect(classes, cls).toContain(cls); + } + expect(mark.textContent).toBe(''); + fireEvent.click(mark); + expect(onMarkRead).toHaveBeenCalledWith('n1'); + // a read row offers no lever + expect(within(panel).getAllByRole('button', { name: 'Mark read' })).toHaveLength(1); + }); +}); + +describe('InboxPopover at 375 px (objectstack#34589)', () => { + it('fills the screen, keeps the mark-read icon shown, and closes on a followed link', () => { + setViewport(375); + render(bell()); + const panel = openInbox(); + const classes = panel.className.split(/\s+/); + for (const cls of ['w-full', 'max-w-none', 'h-full', 'inset-y-0']) { + expect(classes, cls).toContain(cls); + } + // no hover on a phone: the icon is shown below md, and tappable + const mark = within(panel).getByRole('button', { name: 'Mark read' }); + expect(mark.className).toContain('max-md:opacity-100'); + expect(mark.className).toContain('max-md:h-11'); + // the panel covers the page, so following a link closes it + fireEvent.click(within(panel).getByText('Task assigned')); + expect(screen.getByTestId('location').textContent).toMatch(/\/task\/t1$/); + expect(screen.queryByRole('dialog')).toBeNull(); + }); +}); diff --git a/ui/packages/app-shell/src/layout/__tests__/InboxPopover.unsavedEditsLeave-13253.test.tsx b/ui/packages/app-shell/src/layout/__tests__/InboxPopover.unsavedEditsLeave-13253.test.tsx index 6472ae7b29d..a5cd4b0c845 100644 --- a/ui/packages/app-shell/src/layout/__tests__/InboxPopover.unsavedEditsLeave-13253.test.tsx +++ b/ui/packages/app-shell/src/layout/__tests__/InboxPopover.unsavedEditsLeave-13253.test.tsx @@ -26,6 +26,7 @@ const navigateMock = vi.fn(); vi.mock('react-router-dom', () => ({ useNavigate: () => navigateMock, useParams: () => ({ appName: 'crm' }), + useLocation: () => ({ pathname: '/', search: '' }), })); vi.mock('../../context/NavigationContext', () => ({ @@ -52,9 +53,10 @@ vi.mock('@object-ui/i18n', async (importOriginal) => ({ vi.mock('@object-ui/components', async (importOriginal) => ({ ...(await importOriginal>()), Button: ({ children, ...p }: any) => , - Popover: ({ children }: any) =>
    {children}
    , - PopoverTrigger: ({ children }: any) =>
    {children}
    , - PopoverContent: ({ children }: any) =>
    {children}
    , + Sheet: ({ children }: any) =>
    {children}
    , + SheetTrigger: ({ children }: any) =>
    {children}
    , + SheetContent: ({ children }: any) =>
    {children}
    , + SheetTitle: ({ children }: any) =>
    {children}
    , Tabs: ({ children }: any) =>
    {children}
    , TabsList: ({ children }: any) =>
    {children}
    , TabsTrigger: ({ children }: any) => , diff --git a/ui/packages/app-shell/src/layout/__tests__/InboxPopover.viewAllTarget.test.tsx b/ui/packages/app-shell/src/layout/__tests__/InboxPopover.viewAllTarget.test.tsx index 2f0ca311e8e..967c12fc4ee 100644 --- a/ui/packages/app-shell/src/layout/__tests__/InboxPopover.viewAllTarget.test.tsx +++ b/ui/packages/app-shell/src/layout/__tests__/InboxPopover.viewAllTarget.test.tsx @@ -47,6 +47,7 @@ let appsFixture: any[] = []; vi.mock('react-router-dom', () => ({ useNavigate: () => navigateMock, useParams: () => ({ appName: routeAppNameFixture }), + useLocation: () => ({ pathname: '/', search: '' }), })); vi.mock('../../context/NavigationContext', () => ({ @@ -73,9 +74,10 @@ vi.mock('@object-ui/i18n', async (importOriginal) => ({ vi.mock('@object-ui/components', async (importOriginal) => ({ ...(await importOriginal>()), Button: ({ children, ...p }: any) => , - Popover: ({ children }: any) =>
    {children}
    , - PopoverTrigger: ({ children }: any) =>
    {children}
    , - PopoverContent: ({ children }: any) =>
    {children}
    , + Sheet: ({ children }: any) =>
    {children}
    , + SheetTrigger: ({ children }: any) =>
    {children}
    , + SheetContent: ({ children }: any) =>
    {children}
    , + SheetTitle: ({ children }: any) =>
    {children}
    , Tabs: ({ children }: any) =>
    {children}
    , TabsList: ({ children }: any) =>
    {children}
    , TabsTrigger: ({ children }: any) => , From 3b6bb0067f6213a515ae6b91dd697c6e5b5f582e Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 04:32:35 +0000 Subject: [PATCH 3/4] test(app-shell): let the outside-pointer listener arm before the outside click Claude-Session: https://claude.ai/code/session_01WGufzfdKUNrJJjV88a19v2 Co-authored-by: Claude --- .../layout/__tests__/InboxPopover.rightPanel-34589.test.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ui/packages/app-shell/src/layout/__tests__/InboxPopover.rightPanel-34589.test.tsx b/ui/packages/app-shell/src/layout/__tests__/InboxPopover.rightPanel-34589.test.tsx index 0aa77e4ec91..23cd8f221db 100644 --- a/ui/packages/app-shell/src/layout/__tests__/InboxPopover.rightPanel-34589.test.tsx +++ b/ui/packages/app-shell/src/layout/__tests__/InboxPopover.rightPanel-34589.test.tsx @@ -139,9 +139,13 @@ describe('InboxPopover — a right-side full-height panel (objectstack#34589)', expect(document.querySelector('.bg-black\\/80')).toBeNull(); }); - it('stays open when the page beside it is clicked, and the click reaches the page', () => { + it('stays open when the page beside it is clicked, and the click reaches the page', async () => { render(bell()); openInbox(); + // Radix arms its outside-pointer listener a task after opening; let it. + await act(async () => { + await new Promise((resolve) => setTimeout(resolve, 0)); + }); const control = screen.getByTestId('page-control'); const onClick = vi.fn(); control.addEventListener('click', onClick); From a8d2748076f928cba3f1710e1765484ea8da6017 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 04:38:00 +0000 Subject: [PATCH 4/4] chore(i18n): regenerate zh-Hant from zh-Hans Claude-Session: https://claude.ai/code/session_01WGufzfdKUNrJJjV88a19v2 Co-authored-by: Claude --- ui/packages/i18n/src/locales/zh-Hant.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/packages/i18n/src/locales/zh-Hant.ts b/ui/packages/i18n/src/locales/zh-Hant.ts index 175a2d3c8d6..8f97c84528c 100644 --- a/ui/packages/i18n/src/locales/zh-Hant.ts +++ b/ui/packages/i18n/src/locales/zh-Hant.ts @@ -4018,7 +4018,7 @@ const zhHant = { noPendingApprovals: '暫無待審批事項', openApprovalsInbox: '開啟審批中心', needsYou: '需要你處理', - viewApprovalDetails: '查看詳情', + viewApprovalDetails: '檢視詳情', badgeTotal: '共 {{total}} 項', badgeNotifications: '{{count}} 個未讀主題', badgeNotifications_one: '{{count}} 個未讀主題',