From 8af6d76311ab99a45dbbc78a4dba2de6f1431a51 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 03:35:04 +0000 Subject: [PATCH 1/5] feat(console): phone app menu bar with pinned entries and a starred full menu Claude-Session: https://claude.ai/code/session_01WGufzimyx6JQRaukBK3z17 Co-authored-by: Claude --- .changeset/34594-phone-app-menu-bar.md | 19 ++ .../app-shell/src/layout/AppHeader.tsx | 30 +- .../app-shell/src/layout/ConsoleLayout.tsx | 31 +- .../app-shell/src/layout/PhoneAppNavBar.tsx | 227 ++++++++++++++ .../app-shell/src/layout/UnifiedSidebar.tsx | 91 +++++- .../AppHeader.sidebarTrigger-12429.test.tsx | 39 ++- ...oleLayout.phoneRecordOneBar-28483.test.tsx | 57 +++- .../UnifiedSidebar.phoneNavBar-34594.test.tsx | 286 ++++++++++++++++++ ui/packages/i18n/src/locales/ar.ts | 4 + ui/packages/i18n/src/locales/de.ts | 4 + ui/packages/i18n/src/locales/en.ts | 4 + ui/packages/i18n/src/locales/es.ts | 4 + ui/packages/i18n/src/locales/fr.ts | 4 + ui/packages/i18n/src/locales/ja.ts | 4 + ui/packages/i18n/src/locales/ko.ts | 4 + ui/packages/i18n/src/locales/pt-BR.ts | 4 + ui/packages/i18n/src/locales/ru.ts | 4 + ui/packages/i18n/src/locales/zh-Hans.ts | 4 + ui/packages/i18n/src/locales/zh-Hant.ts | 4 + ui/packages/layout/src/AppSchemaRenderer.tsx | 52 +--- ui/packages/layout/src/NavigationRenderer.tsx | 32 +- ui/packages/layout/src/navOrder.ts | 9 +- 22 files changed, 857 insertions(+), 60 deletions(-) create mode 100644 .changeset/34594-phone-app-menu-bar.md create mode 100644 ui/packages/app-shell/src/layout/PhoneAppNavBar.tsx create mode 100644 ui/packages/app-shell/src/layout/__tests__/UnifiedSidebar.phoneNavBar-34594.test.tsx diff --git a/.changeset/34594-phone-app-menu-bar.md b/.changeset/34594-phone-app-menu-bar.md new file mode 100644 index 00000000000..b2b0eecae47 --- /dev/null +++ b/.changeset/34594-phone-app-menu-bar.md @@ -0,0 +1,19 @@ +--- +'@object-ui/app-shell': patch +'@object-ui/layout': patch +'@object-ui/i18n': patch +--- + +feat(console): on a phone, an app's menu is a bar along the bottom edge, and 「More」 opens the full menu with a star on every entry + +Clause-②: yes (widening) — one new public export of `@object-ui/layout` (`drawnNavigationEntries`) and three new `console.nav` keys in every `@object-ui/i18n` pack; nothing that worked before is refused +Metadata-protocol: none + +Below 768 px, inside an app, the Console draws a menu bar at the bottom of every list, dashboard, report and page. Before, the app's menu was only in the sidebar drawer, behind an unlabeled icon at the top left. + +- The bar holds up to four of the app's entries, then **More**. The four are the entries the user pinned in this app, in their pinned order, then the app's own entries in menu order. Pins are the existing per-user pins (the desktop sidebar's Favorites), so a pin made on one device shows on the others. No metadata key is involved. +- **More** opens the full menu: the app's groups, a search box, and a star on every entry. A tap on the star pins or unpins the entry, and the bar follows at once. +- The top-left control on a phone now goes back to the environment's home. From 768 px up it is still the sidebar toggle. +- A record page and a record form (create or edit) draw no bar: their bottom edge belongs to the record's actions and the form's buttons. + +`@object-ui/layout` exports `drawnNavigationEntries(items, options)`: the entries a navigation tree draws, in the sidebar's reading order, through the sidebar's own guards. `AppSchemaRenderer`'s bottom navigation now uses it too, with no change in what it shows. diff --git a/ui/packages/app-shell/src/layout/AppHeader.tsx b/ui/packages/app-shell/src/layout/AppHeader.tsx index 58464aba442..5aef9dfb7c4 100644 --- a/ui/packages/app-shell/src/layout/AppHeader.tsx +++ b/ui/packages/app-shell/src/layout/AppHeader.tsx @@ -68,7 +68,9 @@ import { Eye, MoreHorizontal, Info, + ChevronLeft, } from 'lucide-react'; +import { usePhoneViewport } from '../hooks/usePhoneViewport.js'; import { useState, useEffect, useLayoutEffect, useCallback, useRef, type RefObject } from 'react'; import { useOffline } from '@object-ui/react'; @@ -444,6 +446,10 @@ export function AppHeader({ // landing, so the chrome cannot offer a second, contradicting "home". const homePath = useHomePath(); useGoHomeShortcut(isApp, homePath); + // objectstack#34594 — on a phone inside an app the menu is the bottom bar + // (its 「More」 opens the drawer), so the bar's leftmost control goes back + // to the environment's home instead of opening the drawer. + const phone = usePhoneViewport(); const { isOnline } = useOffline(); // Idempotent, direct open of the ⌘K command palette (ADR-0054 C1). Replaces a // synthetic `⌘K` KeyboardEvent re-dispatch that did nothing under automation. @@ -875,12 +881,24 @@ export function AppHeader({
{/* ── LEFT: Logo / App / Object path ── */}
- {/* The shell's one sidebar trigger, at every width (objectui#12429): - the drawer button on a phone, the collapse/expand toggle for the - sidebar and its icon rail above that. It is the bar's leftmost - control inside an app, so it never moves when the sidebar - collapses; the sidebar itself carries no trigger. */} - {isApp ? ( + {/* The shell's one sidebar trigger (objectui#12429): the + collapse/expand toggle for the sidebar and its icon rail from + 768 px up. It is the bar's leftmost control inside an app, so it + never moves when the sidebar collapses; the sidebar itself carries + no trigger. On a phone that slot goes back to the environment's + home, and the drawer opens from the bottom menu bar's 「More」 + (objectstack#34594). */} + {isApp && phone ? ( + + + + ) : isApp ? ( ) : ( // objectui#12605 — the product mark sits at the same x on every diff --git a/ui/packages/app-shell/src/layout/ConsoleLayout.tsx b/ui/packages/app-shell/src/layout/ConsoleLayout.tsx index 8fe19e043a5..5ffc6675c7a 100644 --- a/ui/packages/app-shell/src/layout/ConsoleLayout.tsx +++ b/ui/packages/app-shell/src/layout/ConsoleLayout.tsx @@ -11,7 +11,7 @@ import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'; import { useLocation, useNavigate } from 'react-router-dom'; import { AppShell } from '@object-ui/layout'; -import { useIsMobile } from '@object-ui/components'; +import { cn, useIsMobile } from '@object-ui/components'; import { useObjectLabel, useObjectTranslation } from '@object-ui/i18n'; // Lightweight FAB stub — the heavy chat chunk graph (plugin-chatbot, @@ -137,6 +137,19 @@ export function isRecordPagePath(pathname: string): boolean { return /^\/apps\/[^/]+\/[^/]+\/record\/[^/]+(?:\/page\/[^/]+)?\/?$/.test(pathname); } +/** + * Does `pathname` keep the phone's bottom menu bar off (objectstack#34594)? A + * record page (its bottom edge is the record's action bar) and a record form, + * create (`/apps/APP/OBJECT/new`) or edit (`.../record/ID/edit`), whose bottom + * edge is its submit buttons. Every other app route draws the bar. + */ +export function hidesPhoneNavBar(pathname: string): boolean { + return ( + isRecordPagePath(pathname) || + /^\/apps\/[^/]+\/[^/]+\/(?:new|record\/[^/]+\/edit)\/?$/.test(pathname) + ); +} + /** Inner component that can access SidebarProvider context */ function ConsoleLayoutInner({ children }: { children: React.ReactNode }) { useResponsiveSidebar(); @@ -196,6 +209,10 @@ export function ConsoleLayout({ // page draws its phone face at, so the two never disagree for a frame. const phone = usePhoneViewport(); const recordPageOwnsTopBar = phone && isRecordPagePath(location.pathname); + // objectstack#34594 — on a phone the app's menu is a bar along the bottom + // edge, except where that edge belongs to a record's actions or a form's + // submit buttons. The route slot leaves the bar's height free at its end. + const phoneNavBar = phone && !hidesPhoneNavBar(location.pathname); // objectstack#30043 — the page in view, handed to the dock as its // `context.surface` (cloud#1610's shape): the object of a list, the object // and record id of a record page, the dashboard, report or page. Read off the @@ -270,6 +287,7 @@ export function ConsoleLayout({ activeAppName={activeAppName} onAppChange={onAppChange} railOverlay + phoneNavBar={phoneNavBar} /> } showHeader={!recordPageOwnsTopBar} @@ -291,7 +309,16 @@ export function ConsoleLayout({ // overflowed the inset by the banner's height: a second scroller over // the table's, the record-count footer below the fold. The phone keeps // block layout. - className="!p-0 overflow-y-auto overflow-x-hidden bg-muted/5 lg:flex lg:flex-col" + // + // objectstack#34594 — while the phone menu bar is drawn, the inset keeps + // the bar's height (h-12 plus the safe area) free at its bottom: a page + // that bounds itself to the inset ends above the bar (the inset's + // content box is that much shorter), and a taller page scrolls its last + // row out from under the bar (a scroll container's end padding scrolls). + className={cn( + '!p-0 overflow-y-auto overflow-x-hidden bg-muted/5 lg:flex lg:flex-col', + phoneNavBar && '!pb-[calc(3rem+env(safe-area-inset-bottom))]', + )} rightRail={ dockEnabled && dock.expanded && !isMobile ? ( boolean, + cells: number = PHONE_NAV_BAR_ENTRY_CELLS, +): NavigationItem[] { + // The drawer's rows in its reading order (the walk every tab bar shares), + // less `action` entries (an action runs something; a cell opens a page) and + // entries whose target resolves to no address. + const entries: NavigationItem[] = drawnNavigationEntries(items, guards).filter( + (entry) => entry.type !== 'action' && hasAddress(entry), + ); + const byId = new Map(entries.map((entry) => [entry.id, entry])); + const chosen: NavigationItem[] = []; + const taken = new Set(); + for (const id of pinnedIds) { + const entry = byId.get(id); + if (!entry || taken.has(id)) continue; + chosen.push(entry); + taken.add(id); + if (chosen.length === cells) return chosen; + } + for (const entry of entries) { + if (taken.has(entry.id)) continue; + chosen.push(entry); + taken.add(entry.id); + if (chosen.length === cells) break; + } + return chosen; +} + +export interface PhoneAppNavBarProps { + /** The app's navigation tree, as the sidebar holds it (pruned, every visible area). */ + items: NavigationItem[]; + /** The pinned navigation ids, in the user's order (`useNavPins().pinnedIds`). */ + pinnedIds: readonly string[]; + /** The app's address, `/apps/SEGMENT`. */ + basePath: string; + /** The sidebar's guard inputs. */ + guards: NavigationVisibilityOptions; + templateContext?: NavTemplateContext; + resolveTargetLabel?: NavTargetLabelResolver; + resolveTargetIcon?: NavTargetIconResolver; + locale?: string; + t: (key: string, options?: any) => string; + /** Whether the full menu is open, so 「More」 reads as the current cell. */ + menuOpen: boolean; + /** Opens the full menu (the drawer). */ + onOpenMenu: () => void; +} + +/** One cell's box: a 44 px-tall target, icon over label. */ +const CELL_CLASS = + 'relative flex min-w-0 flex-1 flex-col items-center justify-center gap-0.5 px-1 text-[11px] leading-tight transition-colors outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring'; + +export function PhoneAppNavBar({ + items, + pinnedIds, + basePath, + guards, + templateContext, + resolveTargetLabel, + resolveTargetIcon, + locale, + t, + menuOpen, + onOpenMenu, +}: PhoneAppNavBarProps) { + const location = useLocation(); + const hasAddress = (item: NavigationItem) => { + const { href } = resolveHref(item, basePath, templateContext); + return !!href && href !== '#'; + }; + const entries = phoneNavBarEntries(items, pinnedIds, guards, hasAddress); + // The row the drawer lights, elected over the whole tree as the drawer + // elects it, so at most one cell lights and it is that row. + const activeId = menuOpen + ? null + : resolveActiveNavItem(items, location.pathname, location.search, basePath, templateContext)?.id ?? null; + const moreLabel = t('common.more', { defaultValue: 'More' }); + + return ( + + ); +} + +export interface PhoneMenuStarProps { + /** The text the row shows. */ + label: string; + /** The entry is pinned (it is offered to the bottom bar). */ + pinned: boolean; + onToggle: () => void; + t: (key: string, options?: any) => string; +} + +/** + * The star a full-menu row carries on a phone (objectstack#34594): one tap + * pins the entry, through the same pin store the desktop sidebar's ⋯ menu + * writes, so it joins the bottom bar; another tap unpins it. Drawn at rest, + * not on hover (a phone has none), centred on the 44 px row. + */ +export function PhoneMenuStar({ label, pinned, onToggle, t }: PhoneMenuStarProps) { + const name = pinned + ? t('console.nav.unpinItem', { defaultValue: 'Unpin {{name}}', name: label }) + : t('console.nav.pinItem', { defaultValue: 'Pin {{name}}', name: label }); + return ( + + + + ); +} diff --git a/ui/packages/app-shell/src/layout/UnifiedSidebar.tsx b/ui/packages/app-shell/src/layout/UnifiedSidebar.tsx index 3e16d47df66..c0149c8638c 100644 --- a/ui/packages/app-shell/src/layout/UnifiedSidebar.tsx +++ b/ui/packages/app-shell/src/layout/UnifiedSidebar.tsx @@ -28,6 +28,7 @@ import { SidebarMenuItem, SidebarMenuButton, SidebarMenuAction, + SidebarInput, cn, useSidebar, } from '@object-ui/components'; @@ -80,6 +81,7 @@ import { SortableFavoriteRows, type FavoriteRowDragProps } from './SortableFavor import { favoriteAppSegment } from './listViewFavorites.js'; import { electSidebarArea, type SidebarAreaRoute } from './sidebarAreaElection.js'; import type { FavoriteItem } from '../hooks/useFavorites.js'; +import { PhoneAppNavBar, PhoneMenuStar } from './PhoneAppNavBar.js'; /** * The class the Recent group's label carries so that, once the sidebar @@ -153,6 +155,13 @@ interface UnifiedSidebarProps { * provider says at every width. */ railOverlay?: boolean; + /** + * On a phone, draw the app's bottom menu bar (objectstack#34594) and give the + * drawer, which its 「More」 cell opens, a search box and a star per entry. + * The console layout decides it: a phone, inside an app, not on a record + * page or a record form. Ignored outside an app and from 768 px up. + */ + phoneNavBar?: boolean; } function isMetadataDirectoryItem(item: NavigationItem): boolean { @@ -170,8 +179,8 @@ function isOverviewGroup(item: NavigationItem): boolean { return id === 'overview' || label === 'overview'; } -export function UnifiedSidebar({ activeAppName, railOverlay = false }: UnifiedSidebarProps) { - const { isMobile, setOpenMobile } = useSidebar(); +export function UnifiedSidebar({ activeAppName, railOverlay = false, phoneNavBar = false }: UnifiedSidebarProps) { + const { isMobile, openMobile, setOpenMobile } = useSidebar(); const location = useLocation(); const { t, language } = useObjectTranslation(); const { appLabel } = useServedAppLabel(); @@ -500,6 +509,31 @@ export function UnifiedSidebar({ activeAppName, railOverlay = false }: UnifiedSi // Recent section collapsed by default const [recentExpanded, setRecentExpanded] = React.useState(false); + // objectstack#34594 — the phone's bottom menu bar and the full menu its + // 「More」 cell opens. The bar reads every visible area of the app (the drawer + // shows one area at a time; a pin from another area keeps its cell), and the + // same pruned trees the drawer draws. Studio's menu is the rewritten one the + // drawer shows. + const phoneMenu = isMobile && phoneNavBar && context === 'app' && !!activeApp; + const phoneBarItems: NavigationItem[] = isStudioApp + ? studioNavigationItems + : visibleAreas.length > 0 + ? visibleAreas.flatMap((area) => area.navigation ?? []) + : readableAppNavigation ?? []; + // The full menu's search: ephemeral, cleared whenever the drawer closes. + const [menuQuery, setMenuQuery] = React.useState(''); + React.useEffect(() => { + if (!openMobile) setMenuQuery(''); + }, [openMobile]); + const renderPhoneMenuStar = (item: NavigationItem, row: NavItemActionContext) => ( + togglePin(item.id, !item.pinned, item, row.basePath)} + t={t} + /> + ); + // One ⋯ menu on every entry, in place of the pin action (objectui#12427): // its first entry adds the entry to Favorites or removes it, through the // same pin store the pin action wrote. Not on a phone, where the sidebar @@ -601,6 +635,26 @@ export function UnifiedSidebar({ activeAppName, railOverlay = false }: UnifiedSi
+ {/* objectstack#34594 — the full menu the bottom bar's 「More」 + opens: searchable, and each entry's star offers it to the bar. */} + {phoneMenu && ( +
+ setMenuQuery(event.target.value)} + placeholder={t('console.nav.searchMenu', { defaultValue: 'Search menu' })} + aria-label={t('console.nav.searchMenu', { defaultValue: 'Search menu' })} + data-testid="phone-menu-search" + className="h-10 text-[15px]" + /> +

+ {t('console.nav.phoneBarHint', { + defaultValue: 'Star an entry to put it in the bottom bar. The bar shows the first four.', + })} +

+
+ )} )} @@ -673,7 +727,11 @@ export function UnifiedSidebar({ activeAppName, railOverlay = false }: UnifiedSi checkCapability={checkCap} checkDocTarget={checkDocTarget} enablePinning={!isMobile} - renderItemAction={isMobile ? undefined : renderNavItemAction} + // On a phone the drawer draws no ⋯ menu (objectui#1055); where it + // is the bottom bar's full menu, each entry carries a star + // instead (objectstack#34594). + renderItemAction={isMobile ? (phoneMenu ? renderPhoneMenuStar : undefined) : renderNavItemAction} + searchQuery={phoneMenu ? menuQuery : undefined} extraFavorites={contentFavoriteRows} pinnedOrder={pinnedIds} onPinnedReorder={reorderPins} @@ -838,10 +896,29 @@ export function UnifiedSidebar({ activeAppName, railOverlay = false }: UnifiedSi {/* No footer trigger: the app bar's left slot holds the shell's one sidebar trigger at every width (objectui#12429). */} - {/* Mobile bottom-tab navigation removed — the drawer (☰) already - surfaces the full navigation tree, so a bottom strip of the - first 5 leaves was pure duplication and ate ~52px of vertical - space. Pattern follows Notion / Linear (drawer-only). */} + {/* objectstack#34594 — the phone's bottom menu bar. After the sidebar, + so it takes the sidebar's place before the page in reading order. */} + {phoneMenu && ( + setOpenMobile(true)} + /> + )}
); } diff --git a/ui/packages/app-shell/src/layout/__tests__/AppHeader.sidebarTrigger-12429.test.tsx b/ui/packages/app-shell/src/layout/__tests__/AppHeader.sidebarTrigger-12429.test.tsx index 269bac914f4..0139953f50c 100644 --- a/ui/packages/app-shell/src/layout/__tests__/AppHeader.sidebarTrigger-12429.test.tsx +++ b/ui/packages/app-shell/src/layout/__tests__/AppHeader.sidebarTrigger-12429.test.tsx @@ -11,6 +11,12 @@ * sidebar carries none (`UnifiedSidebar` side: the sibling test * `LocalizedSidebarTrigger.appBar-12429.test.tsx`). * + * Below 768 px that slot changed with objectstack#34594 (the maintainer's + * direction on epic objectstack#34571): inside an app the menu is the bottom + * menu bar, whose 「More」 opens the drawer, so the slot goes back to the + * environment's home instead (the last describe). The describes above run at + * jsdom's 1024 px. + * * Harness: `AppHeader.appIdentity-12201.test.tsx`'s, with the trigger and the * workspace switcher as recorders. Layout is not measured; the responsive * classes and the DOM order are what the header controls, so they are what is @@ -18,7 +24,7 @@ */ import '@testing-library/jest-dom/vitest'; -import { describe, it, expect, vi, beforeEach } from 'vitest'; +import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'; import { render, screen } from '@testing-library/react'; import React from 'react'; import { MePermissionsProvider, type MePermissionsAuthenticatedResponse } from '@object-ui/permissions'; @@ -224,3 +230,34 @@ describe('the app bar carries the one sidebar trigger at every width (objectui#1 expect(screen.queryByTestId('sidebar-trigger-stub')).not.toBeInTheDocument(); }); }); + +describe('on a phone the left slot goes back to the environment home (objectstack#34594)', () => { + const setWidth = (width: number) => + Object.defineProperty(window, 'innerWidth', { value: width, configurable: true, writable: true }); + afterEach(() => setWidth(1024)); + + it('at 375 px inside an app: a 44 px 「Back to home」 link to the home path, first in the slot, and no trigger', () => { + setWidth(375); + mountApp(); + expect(screen.queryByTestId('sidebar-trigger-stub')).not.toBeInTheDocument(); + const back = screen.getByTestId('app-bar-phone-home'); + expect(back).toHaveAccessibleName('Back to home'); + expect(back).toHaveAttribute('href', '/home'); + expect(back.className.split(/\s+/)).toContain('size-11'); + expect(back.parentElement!.firstElementChild).toBe(back); + }); + + it('CONTROL — at 768 px the slot holds the sidebar trigger, and no back link', () => { + setWidth(768); + mountApp(); + expect(screen.getByTestId('sidebar-trigger-stub')).toBeInTheDocument(); + expect(screen.queryByTestId('app-bar-phone-home')).not.toBeInTheDocument(); + }); + + it('CONTROL — at 375 px off an app (Home) neither is drawn', () => { + setWidth(375); + mountHome(); + expect(screen.queryByTestId('app-bar-phone-home')).not.toBeInTheDocument(); + expect(screen.queryByTestId('sidebar-trigger-stub')).not.toBeInTheDocument(); + }); +}); diff --git a/ui/packages/app-shell/src/layout/__tests__/ConsoleLayout.phoneRecordOneBar-28483.test.tsx b/ui/packages/app-shell/src/layout/__tests__/ConsoleLayout.phoneRecordOneBar-28483.test.tsx index b760b21c2f0..39ae6ea34a9 100644 --- a/ui/packages/app-shell/src/layout/__tests__/ConsoleLayout.phoneRecordOneBar-28483.test.tsx +++ b/ui/packages/app-shell/src/layout/__tests__/ConsoleLayout.phoneRecordOneBar-28483.test.tsx @@ -26,7 +26,11 @@ import { createI18n, I18nProvider } from '@object-ui/i18n'; vi.mock('../../hooks/useAiSurface', () => ({ useAiSurfaceEnabled: () => ({ enabled: false, isLoading: false }), })); -vi.mock('../UnifiedSidebar', () => ({ UnifiedSidebar: () =>