Skip to content
Merged
19 changes: 19 additions & 0 deletions .changeset/34594-phone-app-menu-bar.md
Original file line number Diff line number Diff line change
@@ -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 @object-ui/layout export + new @object-ui/i18n locale keys; no metadata key)
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.
6 changes: 5 additions & 1 deletion ui/e2e/record-header-title-width.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,11 @@ const CONSOLE_MAIN = [
'min-w-0',
'overflow-auto',
]),
classByPattern(consoleLayoutSrc, CONSOLE_LAYOUT_FILE, /<AppShell[\s\S]*?className="([^"]+)"/, [
// The first string `ConsoleLayout` hands `AppShell` as `className`, written
// either as a literal or as the first argument of `cn(...)` (objectstack#34594
// adds a phone-only bottom padding as a second, conditional argument; it
// changes no width, so it is not reproduced here).
classByPattern(consoleLayoutSrc, CONSOLE_LAYOUT_FILE, /<AppShell[\s\S]*?className=(?:\{cn\(\s*)?["']([^"']+)["']/, [
'overflow-x-hidden',
]),
].join(' ');
Expand Down
30 changes: 24 additions & 6 deletions ui/packages/app-shell/src/layout/AppHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -875,12 +881,24 @@ export function AppHeader({
<div className="flex items-center justify-between w-full h-full">
{/* ── LEFT: Logo / App / Object path ── */}
<div className="flex items-center min-w-0 flex-1">
{/* 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 ? (
<Link
to={homePath}
data-testid="app-bar-phone-home"
aria-label={t('layout.appSwitcher.backToHome', { defaultValue: 'Back to home' })}
title={t('layout.appSwitcher.backToHome', { defaultValue: 'Back to home' })}
className="inline-flex size-11 shrink-0 items-center justify-center rounded-md text-foreground hover:bg-accent transition-colors outline-none focus-visible:ring-2 focus-visible:ring-ring"
>
<ChevronLeft className="h-5 w-5" aria-hidden />
</Link>
) : isApp ? (
<LocalizedSidebarTrigger className="shrink-0 mr-1 max-md:size-11 max-md:mr-0" aria-label={t('common.toggleSidebar', { defaultValue: 'Toggle sidebar' })} />
) : (
// objectui#12605 — the product mark sits at the same x on every
Expand Down
31 changes: 29 additions & 2 deletions ui/packages/app-shell/src/layout/ConsoleLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -270,6 +287,7 @@ export function ConsoleLayout({
activeAppName={activeAppName}
onAppChange={onAppChange}
railOverlay
phoneNavBar={phoneNavBar}
/>
}
showHeader={!recordPageOwnsTopBar}
Expand All @@ -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 ? (
<ChatDockPanel
Expand Down
226 changes: 226 additions & 0 deletions ui/packages/app-shell/src/layout/PhoneAppNavBar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,226 @@
/**
* PhoneAppNavBar
*
* The phone's bottom menu bar inside an app (objectstack#34594). Below 768 px
* the app's menu lived only in the sidebar drawer, behind an unlabeled icon at
* the top left, and many users never found it. The bar keeps the menu on
* screen: up to four of the app's entries, then 「More」, which opens the full
* menu (the drawer) where every entry carries a star.
*
* Which four: the entries the user pinned (the star, `useNavPins`, the same
* per-user store the desktop sidebar's Favorites section reads), in the
* user's pinned order, then the app's own entries in menu order to fill the
* rest. Pins are stored by navigation id and are not scoped per app, so only
* the pins this app's menu holds are read here. No metadata key is involved.
*
* What it draws is what the drawer draws: the tree it is handed is the
* sidebar's own (already pruned of entries the member may not read), walked by
* `drawnNavigationEntries`, the sidebar's guard statement and order rule.
* A cell opens what its drawer row opens (`resolveHref`), and lights when
* that row lights (`resolveActiveNavItem`).
*
* The console layout decides where the bar is mounted: on a phone, inside an
* app, never on a record page or a record form, whose bottom edge belongs to
* the record's own action bar and submit buttons.
*
* @module
*/

import { Link, useLocation } from 'react-router-dom';
import { MoreHorizontal, Star } from 'lucide-react';
import { SidebarMenuAction, cn } from '@object-ui/components';
import {
drawnNavigationEntries,
resolveActiveNavItem,
resolveHref,
resolveIcon,
resolveNavItemIcon,
resolveNavItemLabel,
type NavigationVisibilityOptions,
type NavTargetIconResolver,
type NavTargetLabelResolver,
type NavTemplateContext,
} from '@object-ui/layout';
import type { NavigationItem } from '@object-ui/types';

/** How many of the app's entries the bar holds; 「More」 is the cell after them. */
export const PHONE_NAV_BAR_ENTRY_CELLS = 4;

/**
* The bar's entries: the app's pinned entries in the user's pinned order,
* then the app's drawn entries in menu order, to at most `cells` entries. A
* pinned id this app's menu does not draw (another app's pin, or an entry the
* member cannot see) takes no cell.
*/
export function phoneNavBarEntries(
items: readonly NavigationItem[],
pinnedIds: readonly string[],
guards: NavigationVisibilityOptions,
hasAddress: (item: NavigationItem) => 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<string>();
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?: Record<string, unknown>) => 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 (
<nav
data-testid="phone-app-nav-bar"
aria-label={t('console.nav.phoneBarLabel', { defaultValue: 'App menu bar' })}
className="fixed inset-x-0 bottom-0 z-40 border-t bg-background/95 pb-[env(safe-area-inset-bottom)] backdrop-blur-sm"
>
<ul className="flex h-12 items-stretch">
{entries.map((item) => {
const { href, external } = resolveHref(item, basePath, templateContext);
const label = resolveNavItemLabel(item, t, resolveTargetLabel, locale);
const Icon = resolveIcon(resolveNavItemIcon(item, resolveTargetIcon));
const active = item.id === activeId;
const className = cn(CELL_CLASS, active ? 'text-primary' : 'text-muted-foreground');
const content = (
<>
<Icon className="h-5 w-5 shrink-0" aria-hidden />
<span className="max-w-full truncate">{label}</span>
</>
);
return (
<li key={item.id} className="flex min-w-0 flex-1">
{external ? (
<a href={href} target="_blank" rel="noopener noreferrer" className={className} data-testid="phone-app-nav-cell">
{content}
</a>
) : (
<Link
to={href}
className={className}
aria-current={active ? 'page' : undefined}
data-testid="phone-app-nav-cell"
data-nav-id={item.id}
>
{content}
</Link>
)}
</li>
);
})}
<li className="flex min-w-0 flex-1">
<button
type="button"
onClick={onOpenMenu}
aria-haspopup="dialog"
aria-expanded={menuOpen}
data-testid="phone-app-nav-more"
className={cn(CELL_CLASS, menuOpen ? 'text-primary' : 'text-muted-foreground')}
>
<MoreHorizontal className="h-5 w-5 shrink-0" aria-hidden />
<span className="max-w-full truncate">{moreLabel}</span>
</button>
</li>
</ul>
</nav>
);
}

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?: Record<string, unknown>) => 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 (
<SidebarMenuAction
onClick={onToggle}
aria-pressed={pinned}
aria-label={name}
title={name}
data-testid="phone-menu-star"
data-pinned={pinned ? 'true' : 'false'}
className="right-1 top-1/2 size-8 -translate-y-1/2 peer-data-[size=default]/menu-button:top-1/2 [&>svg]:size-5"
>
<Star className={pinned ? 'fill-primary text-primary' : 'text-muted-foreground'} aria-hidden />
</SidebarMenuAction>
);
}
Loading
Loading