From 091900c70b3201f25eb90695e285be135508f5c4 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 25 Nov 2026 00:20:14 +0000 Subject: [PATCH 1/6] feat(console): an app's docs pages draw in the app shell from 768 px up The shell sidebar is mounted on an app's docs pages at desktop width and carries the docs' own navigation in the app menu's place; the top bar is gone there as on every other desktop app page. A phone keeps its bar and its in-page column. Claude-Session: https://claude.ai/code/session_01QSeKYnagJvGbCtNg2PhvgW Co-authored-by: Claude --- ui/apps/console/src/pages/DocPage.tsx | 39 ++++++------ ui/apps/console/src/pages/DocShell.tsx | 49 ++++++++++++--- ui/apps/console/src/pages/DocsNav.tsx | 61 +++++++++++++++++-- .../src/console/ConsoleBootShell.tsx | 15 ++--- ui/packages/app-shell/src/index.ts | 7 +++ .../app-shell/src/layout/ConsoleLayout.tsx | 33 ++++++---- .../app-shell/src/layout/UnifiedSidebar.tsx | 18 +++++- .../app-shell/src/layout/consoleRoutePaths.ts | 5 +- .../src/layout/sidebarDocsNavSlot.tsx | 59 ++++++++++++++++++ 9 files changed, 234 insertions(+), 52 deletions(-) create mode 100644 ui/packages/app-shell/src/layout/sidebarDocsNavSlot.tsx diff --git a/ui/apps/console/src/pages/DocPage.tsx b/ui/apps/console/src/pages/DocPage.tsx index b27fcd9cda1..0a82d5e5354 100644 --- a/ui/apps/console/src/pages/DocPage.tsx +++ b/ui/apps/console/src/pages/DocPage.tsx @@ -9,14 +9,14 @@ import { useCallback, useEffect, useMemo, useRef, useState } from 'react'; import { Link, Navigate, useHref, useLocation, useNavigate, useParams } from 'react-router-dom'; import { AlertCircle, ChevronDown, ChevronRight, FileQuestion, Layers, Loader2, Menu } from 'lucide-react'; -import { useAdapter } from '@object-ui/app-shell'; +import { useAdapter, useSidebarDocsNavSlot } from '@object-ui/app-shell'; import { MarkdownRenderer, MermaidEnlargeContext, extractToc } from '@object-ui/plugin-markdown'; import { useObjectTranslation } from '@object-ui/i18n'; import { rewriteDocLinks } from './doc-links'; import { conflictCandidates, readsByNameAfter } from './doc-address'; import { DocShell } from './DocShell'; import { useAppDocsBackTo } from './useAppDocsBackTo'; -import { DocsNav, type DocsNavBook } from './DocsNav'; +import { DocsNav, usePackageDocsNavBooks } from './DocsNav'; import { DocRefusal } from './BookPage'; import { useBookData } from './use-book-data'; import { useActiveHeading } from './useActiveHeading'; @@ -249,17 +249,14 @@ export default function DocPage() { const docHref = useCallback((docName: string) => `${base}/${slug}/${docName}`, [base, slug]); // objectstack#35424 — the docs column lists every book of the package the // reader is in: the current book's package, else the route's app package. - const packageBooks = useMemo(() => { + const readerPackage = useMemo(() => { const current = books.find((b) => bookSlug(b) === slug); - const pkg = current ? pkgOfBook(current) : appName; - if (!pkg) return []; - return books - .filter((b) => pkgOfBook(b) === pkg) - .map((b) => ({ - slug: bookSlug(b), - book: labelUncategorized(resolveBookTree(b, allDocs, undefined, authoredBooks), uncategorizedLabel), - })); - }, [books, authoredBooks, allDocs, slug, appName, uncategorizedLabel]); + return current ? pkgOfBook(current) : appName; + }, [books, slug, appName]); + const packageBooks = usePackageDocsNavBooks(readerPackage); + // objectstack#37150 — inside an app from 768 px up the shell sidebar carries + // the column (`DocShell` draws it there); elsewhere the page draws it. + const sidebarNav = useSidebarDocsNavSlot() !== null; const neighbours = useMemo( () => (resolvedBook ? articleNeighbours(resolvedBook, name) : { previous: null, next: null }), [resolvedBook, name], @@ -397,31 +394,35 @@ export default function DocPage() { ) : null; const docsLabel = t('help.documentation', { defaultValue: 'Documentation' }); + const pageNav = sidebarNav ? null : docsNav; + return ( - + {/* objectstack#35424 — the docs column is the page's one navigation. - * Inside an app it sits where the app menu would, full height beside - * the article; on narrow screens it folds into a disclosure above it. */} + * Inside an app from 768 px up it is the shell sidebar's body, where the + * app menu would be (objectstack#37150); elsewhere it sits full height + * beside the article, and on narrow screens it folds into a disclosure + * above it. */}
- {docsNav ? ( + {pageNav ? ( ) : null}
- {docsNav ? ( + {pageNav ? (
{resolvedBook?.label ?? docsLabel} -
{docsNav}
+
{pageNav}
) : null}
diff --git a/ui/apps/console/src/pages/DocShell.tsx b/ui/apps/console/src/pages/DocShell.tsx index 4b8dbcacb26..04e5c0ae755 100644 --- a/ui/apps/console/src/pages/DocShell.tsx +++ b/ui/apps/console/src/pages/DocShell.tsx @@ -8,35 +8,66 @@ import type { ReactNode } from 'react'; import { useParams } from 'react-router-dom'; +import { + SidebarDocsNav, + useShellPageActionsSlot, + useShellSidebarExpandSlot, + useSidebarDocsNavSlot, +} from '@object-ui/app-shell'; import { AppDocsBackLink } from './AppDocsBackLink'; +import { AppDocsNav, DocsNavLandmark } from './DocsNav'; import { useAppDocsBackTo } from './useAppDocsBackTo'; /** - * The frame of the package-documentation pages (ADR-0046), inside the - * console's own top bar. It draws no bar of its own (objectstack#35424): + * The frame of the package-documentation pages (ADR-0046). It draws no bar of + * its own (objectstack#35424): * - * - Under an app (`/apps/:appName/docs/...`, ADR-0048) the app bar above reads - * 「APP / Documentation」, and the reader names its book and article above - * the article. An app's docs routes draw no app menu either, so the bar's - * place holds 「← Back to APP」 (`AppDocsBackLink`) on every page but the - * reader, which carries it in its docs column and passes `backLink={false}`. + * - Under an app (`/apps/:appName/docs/...`, ADR-0048), from 768 px up, the + * page is drawn in the app shell like every other app page + * (objectstack#37150, ruling 7142354097 on objectstack#36107): no top bar, + * the resident sidebar, and the page header's button group and expand + * button, which this frame draws at the page's top. The docs' one + * navigation column (the app's books, 「← Back to APP」 and all + * documentation) is the sidebar's body: the page hands it `nav`, the + * reader's own, else every book of the app (`AppDocsNav`). + * - Under an app on a phone the console's app bar is above the page, and the + * page carries 「← Back to APP」 itself: at the top here, on every page but + * the reader, which carries it in its in-page column and passes + * `backLink={false}`. * - The portal (`/docs/...`) is drawn in Home's frame, whose bar reads * 「PRODUCT / Documentation」 and links to the portal's index (`App.tsx`, * the `docs` variant of `AppHeader`). */ export function DocShell({ backLink = true, + nav, children, }: { - /** Inside an app: draw 「← Back to APP」 above the page. The reader turns it off when its column has it. */ + /** Without the shell sidebar: draw 「← Back to APP」 above the page. The reader turns it off when its column has it. */ backLink?: boolean; + /** The page's own docs column, for the shell sidebar (the reader's); else every book of the app. */ + nav?: ReactNode; children: ReactNode; }) { const { appName } = useParams<{ appName?: string }>(); const backTo = useAppDocsBackTo(); + const sidebarNav = useSidebarDocsNavSlot() !== null; + const renderActions = useShellPageActionsSlot(); + const renderExpand = useShellSidebarExpandSlot(); return (
- {appName && backLink && backTo ? ( + {sidebarNav ? ( + + {nav ?? } + + ) : null} + {renderActions || renderExpand ? ( +
+ {renderExpand?.()} +
{renderActions?.({})}
+
+ ) : null} + {appName && backLink && backTo && !sidebarNav ? (
diff --git a/ui/apps/console/src/pages/DocsNav.tsx b/ui/apps/console/src/pages/DocsNav.tsx index 9438b2b30d7..9c0071d4126 100644 --- a/ui/apps/console/src/pages/DocsNav.tsx +++ b/ui/apps/console/src/pages/DocsNav.tsx @@ -6,15 +6,16 @@ * LICENSE file in the root directory of this source tree. */ -import { useId, useState } from 'react'; -import { Link } from 'react-router-dom'; +import { useCallback, useId, useMemo, useState, type ReactNode } from 'react'; +import { Link, useParams } from 'react-router-dom'; import { ArrowRight, ChevronDown, ChevronRight, Search } from 'lucide-react'; import { useObjectTranslation } from '@object-ui/i18n'; import { AppDocsBackLink } from './AppDocsBackLink'; -import type { AppDocsBackTo } from './useAppDocsBackTo'; +import { useAppDocsBackTo, type AppDocsBackTo } from './useAppDocsBackTo'; import { BookSidebar } from './BookSidebar'; import { bookArticles, filterBookArticles } from './docs-reading'; -import type { ResolvedBook } from './book-nav'; +import { bookSlug, labelUncategorized, pkgOfBook, resolveBookTree, type ResolvedBook } from './book-nav'; +import { useBookData } from './use-book-data'; /** One book of the column: its resolved spine and its URL segment. */ export interface DocsNavBook { @@ -128,3 +129,55 @@ export function DocsNav({
); } + +/** + * Every book of package `pkg`, resolved for the column (objectstack#35424): + * the reader's books, and those of an app's other docs pages. Empty with no + * package. + */ +export function usePackageDocsNavBooks(pkg: string | undefined): DocsNavBook[] { + const { t } = useObjectTranslation(); + const { books, authoredBooks, docs } = useBookData(); + const uncategorizedLabel = t('help.uncategorized', { defaultValue: 'Uncategorized' }); + return useMemo(() => { + if (!pkg) return []; + return books + .filter((b) => pkgOfBook(b) === pkg) + .map((b) => ({ + slug: bookSlug(b), + book: labelUncategorized(resolveBookTree(b, docs, undefined, authoredBooks), uncategorizedLabel), + })); + }, [books, authoredBooks, docs, pkg, uncategorizedLabel]); +} + +/** + * The column as the shell sidebar carries it (objectstack#37150): the same + * column, under its own navigation landmark. + */ +export function DocsNavLandmark({ children }: { children: ReactNode }) { + const { t } = useObjectTranslation(); + return ( + + ); +} + +/** + * The column of an app's docs page other than the reader (the app's docs + * index, a book with no articles, a book or doc not found): the app's books, + * the way back to the app and all documentation. The reader builds its own, + * from the book its article is in. + */ +export function AppDocsNav() { + const { appName, slug } = useParams<{ appName?: string; slug?: string }>(); + const books = usePackageDocsNavBooks(appName); + const backTo = useAppDocsBackTo(); + const docHref = useCallback( + (bookSegment: string, doc: string) => `/apps/${appName}/docs/${bookSegment}/${doc}`, + [appName], + ); + return ( + + ); +} diff --git a/ui/packages/app-shell/src/console/ConsoleBootShell.tsx b/ui/packages/app-shell/src/console/ConsoleBootShell.tsx index 5b4ef4be673..58c2fd7b732 100644 --- a/ui/packages/app-shell/src/console/ConsoleBootShell.tsx +++ b/ui/packages/app-shell/src/console/ConsoleBootShell.tsx @@ -11,7 +11,7 @@ * objectui#5619). Each used to draw the full-screen splash. They now draw * {@link ConsoleBootShell}: the chrome's frame (the sidebar at the width the * reader left it, with its head and foot from 768 px up; the 48 px top bar on - * a phone and on a docs page; the route slot) with grey blocks in it and + * a phone; the route slot) with grey blocks in it and * the skeleton of the route the URL names in the slot. The real chrome takes * its place when the gates pass, at the same geometry. * @@ -87,16 +87,17 @@ export function ConsoleBootShell() { // chrome lands. From 768 px up an app draws no top bar: the app menu, the // search and the bell sit in the sidebar's head and the account at its foot // (objectstack#36112). A phone keeps the bar, except on a record page, - // which draws its own (objectstack#28483). A docs page mounts no sidebar - // and keeps the bar at every width (objectstack#35424). + // which draws its own (objectstack#28483). An app's docs page is an app + // page like the others from 768 px up (objectstack#37150); on a phone it + // mounts no sidebar and keeps the bar (objectstack#35424). const phone = usePhoneViewport(); - const docsPage = isAppDocsPath(pathname); + const phoneDocsPage = phone && isAppDocsPath(pathname); const recordPageOwnsTopBar = phone && isRecordPagePath(pathname); - const desktopSidebar = !phone && !docsPage; + const desktopSidebar = !phone; return (
@@ -105,7 +106,7 @@ export function ConsoleBootShell() {
} sidebar={ - docsPage ? undefined : ( + phoneDocsPage ? undefined : ( {desktopSidebar && ( // Where the app menu (and the collapse button), the search and diff --git a/ui/packages/app-shell/src/index.ts b/ui/packages/app-shell/src/index.ts index c90351709c0..85600d4bd24 100644 --- a/ui/packages/app-shell/src/index.ts +++ b/ui/packages/app-shell/src/index.ts @@ -97,6 +97,13 @@ export { type SidebarFooterSlotPlace, } from './layout/sidebarFooterSlot.js'; +// objectstack#37150 — the shell sidebar's place for an app's docs navigation, +// drawn by the console's docs pages; and the page header's two shell slots +// (the top-right button group and the sidebar's expand button), for a docs +// page, which draws no `ConsolePageHeader`. +export { SidebarDocsNav, useSidebarDocsNavSlot } from './layout/sidebarDocsNavSlot.js'; +export { useShellPageActionsSlot, useShellSidebarExpandSlot } from './layout/shellPageActionsSlot.js'; + // Host-app route policy (ADR-0048) — which app's `/apps//…` URL a // framework-owned, app-INDEPENDENT page should build, and the two predicates it // is defined in terms of. Published from the package root (objectui#4280) diff --git a/ui/packages/app-shell/src/layout/ConsoleLayout.tsx b/ui/packages/app-shell/src/layout/ConsoleLayout.tsx index 10cfe56c2d9..c9ac8f25714 100644 --- a/ui/packages/app-shell/src/layout/ConsoleLayout.tsx +++ b/ui/packages/app-shell/src/layout/ConsoleLayout.tsx @@ -26,6 +26,7 @@ import { UnifiedSidebar } from './UnifiedSidebar.js'; import { PhoneAppNavBar, isPhoneTabRoute } from './PhoneAppNavBar.js'; import { PhoneAppHomeSlotProvider } from './PhoneAppHome.js'; import { PhonePageBarProvider } from './PhonePageBar.js'; +import { SidebarDocsNavSlotProvider } from './sidebarDocsNavSlot.js'; import { useLastApp } from '../context/LastAppProvider.js'; import { rememberAppReturnPage } from '../utils/appReturnPage.js'; import { useMetadata } from '../providers/MetadataProvider.js'; @@ -194,9 +195,15 @@ export function ConsoleLayout({ // the top left goes back. The route slot leaves the bar's height free at its // end. const phoneNavBar = phone && isPhoneTabRoute(location.pathname); - // objectstack#35424 — a docs page draws its own left column (the app's - // books and a way back to the app), so the app menu is not mounted there. + // objectstack#35424 — a docs page has one navigation, the docs' own (the + // app's books and a way back to the app), so the app's menu is not drawn + // there. objectstack#37150 (ruling 7142354097 on objectstack#36107) — from + // 768 px up the page still draws in the app shell like every other app page: + // the sidebar is mounted, its head and foot as everywhere, and its body + // carries the docs' navigation in the menu's place. A phone keeps what it + // had: no sidebar, the app bar, and the column in the page. const docsPage = isAppDocsPath(location.pathname); + const phoneDocsPage = phone && docsPage; // objectstack#35881 — the app this person last had open, where a phone // lands after sign-in. Recorded at every width: it is the person's last app. const { rememberApp } = useLastApp(); @@ -273,27 +280,31 @@ export function ConsoleLayout({ {/* objectstack#35883 — a page's own phone top row, drawn by the app bar. */} + {/* objectstack#37150 — the sidebar's place for an app's docs navigation, + shared by the sidebar (which holds it) and the docs page (which draws + its column into it). */} + ) } // objectstack#36112 — from 768 px up an app draws no top bar: the app // menu, search, bell and account are the sidebar's, the page's buttons - // its own header's. A phone keeps its bar (and its record page draws its - // own instead, objectstack#28483). An app's docs pages keep it at every - // width: they mount no sidebar (objectstack#35424), so the bar is still - // where their account, search and bell are. + // its own header's. An app's docs pages are no exception + // (objectstack#37150). A phone keeps its bar (and its record page draws + // its own instead, objectstack#28483). // // objectstack#36362 — while the design mode is on, its bar takes the // top slot instead, across the whole window, on every route. - showHeader={designMode.active || ((phone || docsPage) && !recordPageOwnsTopBar)} + showHeader={designMode.active || (phone && !recordPageOwnsTopBar)} navbar={ designMode.active ? ( @@ -345,7 +356,7 @@ export function ConsoleLayout({ {/* objectstack#36111 — the pages under the shell draw its top-right button group; objectstack#36112 — and the sidebar's expand button at their headers' left edge while it is collapsed. */} - + {/* ADR-0037: unmistakable watermark while rendering the draft overlay (?preview=draft) — with one-click exit and one-click Publish. */} {/* objectui#12463 — the banners sit in one non-shrinking box, so in @@ -355,8 +366,7 @@ export function ConsoleLayout({ (impersonation, read rate, storage) and the connection notice sit here, the content's width, since no top bar carries them. */} {!phone && } - {/* A docs page's bar draws the connection state itself. */} - {!phone && !docsPage && } + {!phone && } {/* ADR-0045: materialized-but-unlisted app — real and interactive, invisible to end users until the Publish visibility flip. */} @@ -398,6 +408,7 @@ export function ConsoleLayout({ {chatDock.sheet} + diff --git a/ui/packages/app-shell/src/layout/UnifiedSidebar.tsx b/ui/packages/app-shell/src/layout/UnifiedSidebar.tsx index 316bd7606f0..68c20d7ded9 100644 --- a/ui/packages/app-shell/src/layout/UnifiedSidebar.tsx +++ b/ui/packages/app-shell/src/layout/UnifiedSidebar.tsx @@ -103,6 +103,7 @@ import { electSidebarArea, type SidebarAreaRoute } from './sidebarAreaElection.j import type { FavoriteItem } from '../hooks/useFavorites.js'; import { usePhoneAppHomeSlot } from './PhoneAppHome.js'; import { useSidebarFooterSlot } from './sidebarFooterSlot.js'; +import { SidebarDocsNavTarget } from './sidebarDocsNavSlot.js'; /** * The app's menu as the design mode edits it (objectstack#36363). Loaded on @@ -186,6 +187,13 @@ interface UnifiedSidebarProps { * every width, collapsed to the primitive's icon rail. */ railOverlay?: boolean; + /** + * objectstack#37150 — the route is one of the app's documentation pages + * (`isAppDocsPath`): the body holds the docs' navigation, which the page + * draws into `SidebarDocsNavTarget`, in place of the app's menu and its + * recent items (objectstack#35424). The head and the foot are unchanged. + */ + docsNav?: boolean; } function isMetadataDirectoryItem(item: NavigationItem): boolean { @@ -203,7 +211,7 @@ function isOverviewGroup(item: NavigationItem): boolean { return id === 'overview' || label === 'overview'; } -export function UnifiedSidebar({ activeAppName, onAppChange, railOverlay = false }: UnifiedSidebarProps) { +export function UnifiedSidebar({ activeAppName, onAppChange, railOverlay = false, docsNav = false }: UnifiedSidebarProps) { const { isMobile, setOpenMobile } = useSidebar(); const location = useLocation(); const { t, language } = useObjectTranslation(); @@ -832,6 +840,12 @@ export function UnifiedSidebar({ activeAppName, onAppChange, railOverlay = false )} + {docsNav && context === 'app' && activeApp ? ( + // objectstack#37150 — an app's docs page: the docs' own navigation, + // drawn here by the page (it carries its own landmark). + + ) : ( + <> {/* The sidebar's one navigation landmark, so assistive tech can jump to it. The `Sidebar` primitive draws a plain `div` (and a dialog on a phone) and is Shadcn-synced, so the landmark rides inside its @@ -969,6 +983,8 @@ export function UnifiedSidebar({ activeAppName, onAppChange, railOverlay = false )} + + )} {shellChrome && ( diff --git a/ui/packages/app-shell/src/layout/consoleRoutePaths.ts b/ui/packages/app-shell/src/layout/consoleRoutePaths.ts index 6c99af365f4..4117c19a895 100644 --- a/ui/packages/app-shell/src/layout/consoleRoutePaths.ts +++ b/ui/packages/app-shell/src/layout/consoleRoutePaths.ts @@ -19,7 +19,10 @@ export function isRecordPagePath(pathname: string): boolean { /** * Is `pathname` one of an app's documentation pages, `/apps/APP/docs` and * everything under it (objectstack#35424)? A reader there has one navigation, - * the docs' own, so the app's menu is not drawn beside it. + * the docs' own, so the app's menu is not drawn beside it: from 768 px up the + * shell sidebar's body carries the docs' navigation instead + * (objectstack#37150); on a phone the page keeps its own column and the app + * bar. */ export function isAppDocsPath(pathname: string): boolean { return /^\/apps\/[^/]+\/docs(?:\/|$)/.test(pathname); diff --git a/ui/packages/app-shell/src/layout/sidebarDocsNavSlot.tsx b/ui/packages/app-shell/src/layout/sidebarDocsNavSlot.tsx new file mode 100644 index 00000000000..89da96bdf06 --- /dev/null +++ b/ui/packages/app-shell/src/layout/sidebarDocsNavSlot.tsx @@ -0,0 +1,59 @@ +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. + +/** + * The shell sidebar's place for an app's documentation navigation + * (objectstack#37150, ruling 7142354097 on objectstack#36107: docs render in + * one appearance, inside the app shell). + * + * From 768 px up an app's docs pages (`/apps/APP/docs…`) draw in the app shell + * like every other app page: the resident sidebar, with its head (the app-name + * menu, the collapse button, search and the bell) and its foot (the account), + * and no top bar. What the sidebar's body carries there is the docs' own + * navigation, not the app's menu (objectstack#35424: a reader has one + * navigation, the docs'). The docs pages build that navigation from the books + * they read, so the sidebar only holds the place: `UnifiedSidebar` draws + * {@link SidebarDocsNavTarget} where the app's menu would be, and the page + * draws its column into it through {@link SidebarDocsNav}, a portal, so the + * column keeps the page's router and data context. + * + * Outside that place (a phone, which keeps its bar and its in-page column; the + * `/docs` portal; a test that mounts a page bare) {@link useSidebarDocsNavSlot} + * answers `null` and the page draws its column itself, as before. + * + * @module + */ + +import * as React from 'react'; +import { createPortal } from 'react-dom'; + +interface SlotContextValue { + slot: HTMLElement | null; + setSlot: (el: HTMLElement | null) => void; +} + +const SidebarDocsNavSlotContext = React.createContext(null); + +/** Holds the sidebar's docs-navigation element for the docs pages to draw into. `ConsoleLayout` mounts it. */ +export function SidebarDocsNavSlotProvider({ children }: { children: React.ReactNode }) { + const [slot, setSlot] = React.useState(null); + const value = React.useMemo(() => ({ slot, setSlot }), [slot]); + return {children}; +} + +/** The element the sidebar holds open for the docs navigation, or `null` where there is none. */ +export function useSidebarDocsNavSlot(): HTMLElement | null { + return React.useContext(SidebarDocsNavSlotContext)?.slot ?? null; +} + +/** The sidebar's side: the element the docs navigation is drawn into, in place of the app's menu. */ +export function SidebarDocsNavTarget() { + const setSlot = React.useContext(SidebarDocsNavSlotContext)?.setSlot; + const ref = React.useCallback((el: HTMLDivElement | null) => setSlot?.(el), [setSlot]); + return
; +} + +/** The page's side: draws `children` in the sidebar's docs place, or nothing where there is none. */ +export function SidebarDocsNav({ children }: { children: React.ReactNode }) { + const slot = useSidebarDocsNavSlot(); + return slot ? createPortal(children, slot) : null; +} From 71f7052c4370b02315b0dd4fb7e871a155999e4b Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 25 Nov 2026 00:22:17 +0000 Subject: [PATCH 2/6] test(console): pin an app's docs pages in the app shell and the phone control Claude-Session: https://claude.ai/code/session_01QSeKYnagJvGbCtNg2PhvgW Co-authored-by: Claude --- .../console/src/pages/docs-portal.test.tsx | 127 ++++++++++++++++++ .../__tests__/ConsoleBootShell-35981.test.tsx | 24 ++-- ui/packages/app-shell/src/index.ts | 14 +- ...oleLayout.phoneRecordOneBar-28483.test.tsx | 51 +++++-- .../UnifiedSidebar.footerSlot-36739.test.tsx | 40 ++++++ 5 files changed, 230 insertions(+), 26 deletions(-) diff --git a/ui/apps/console/src/pages/docs-portal.test.tsx b/ui/apps/console/src/pages/docs-portal.test.tsx index b1aa4ca0ad3..dd06ade4bca 100644 --- a/ui/apps/console/src/pages/docs-portal.test.tsx +++ b/ui/apps/console/src/pages/docs-portal.test.tsx @@ -126,6 +126,9 @@ const { ADAPTER, WORLD, GATED_REASON } = vi.hoisted(() => { const PLATFORM_CONTENT: Record = { setup_overview: 'ADMIN BODY about permission sets' }; const WORLD = { authored: false, + // objectstack#37150 — the shell's page-header group is handed in (the + // console layout's scope, from 768 px up). + shellActions: false, conflict: false, exact: false, platform: false, @@ -163,6 +166,9 @@ vi.mock('@object-ui/app-shell', async (importOriginal) => ({ useAdapter: () => ADAPTER, // The apps `/meta/app` serves this caller (objectstack#35424); none by default. useMetadata: () => ({ apps: WORLD.apps }), + // objectstack#37150 — the shell's top-right group, where the layout hands + // it in; outside the shell the real slot answers `null`. + useShellPageActionsSlot: () => (WORLD.shellActions ? () =>
: null), })); // A `{#id}` marker in a doc body stands for a heading with that anchor id. Like @@ -205,6 +211,7 @@ vi.mock('@object-ui/i18n', async (importOriginal) => ({ })); // Imported AFTER the mocks so the pages pick up the mocked modules. +import { SidebarDocsNavSlotProvider, SidebarDocsNavTarget } from '@object-ui/app-shell'; import DocsLayout from './DocsLayout'; import DocsIndex from './DocsIndex'; import DocsSlug from './DocsSlug'; @@ -955,3 +962,123 @@ describe('objectstack#35424 — 「All documentation」 groups its books by app expect(screen.getByTestId('where')).toHaveTextContent('/docs/manual/showcase_index'); }); }); + +describe('objectstack#37150 — from 768 px up an app\'s docs pages draw in the app shell', () => { + function Where() { + return
{useLocation().pathname}
; + } + /** + * The app routes' docs tree (`AppContent`) inside the shell's two docs + * places: the sidebar's body (`UnifiedSidebar` draws the target) and the + * page-header group (mocked above). + */ + function InShell({ entry }: { entry: string }) { + return ( + + + +
+ + + }> + } /> + } /> + } /> + + +
+
+
+ ); + } + const sidebar = () => screen.getByTestId('shell-sidebar'); + const page = () => screen.getByTestId('shell-route'); + + beforeEach(() => { + WORLD.shellActions = true; + }); + afterEach(() => { + WORLD.shellActions = false; + }); + + it('the reader\'s one docs column is the sidebar\'s body, not a column in the page', async () => { + render(); + await screen.findByTestId('doc-content'); + expect(screen.getAllByTestId('docs-nav')).toHaveLength(1); + const column = within(sidebar()).getByTestId('docs-nav'); + expect(within(sidebar()).getByRole('navigation', { name: 'Documentation navigation' })).toContainElement(column); + expect(within(column).getByTestId('docs-nav-back')).toHaveAttribute('href', '/apps/crm'); + expect(within(column).getByTestId('docs-nav-all-docs')).toHaveAttribute('href', '/docs'); + expect(within(column).getAllByRole('link', { name: 'CRM Intro' })[0]).toHaveAttribute('aria-current', 'page'); + expect(within(page()).queryByTestId('docs-nav')).toBeNull(); + expect(screen.queryByTestId('docs-back-bar')).toBeNull(); + }); + + it('the page header carries the shell\'s button group, as on every app page', async () => { + render(); + await screen.findByTestId('doc-content'); + expect(within(screen.getByTestId('docs-page-header')).getByTestId('shell-page-actions-stub')).toBeInTheDocument(); + }); + + // ADR-0046 section 6: docs are name-addressed and every URL that resolved + // keeps its answer; the shell changes the frame, never the address. + it.each([ + ['the reader', '/apps/crm/docs/crm/crm_intro'], + ['a book (lands on its first article)', '/apps/crm/docs/crm'], + ['a flat doc permalink (redirects into its book)', '/apps/crm/docs/crm_intro'], + ['the app\'s docs index (one book: lands on it)', '/apps/crm/docs'], + ])('%s, %s, reads the same article in the shell', async (_what, entry) => { + render(); + expect(await screen.findByTestId('doc-content')).toHaveTextContent('Welcome to the CRM'); + expect(screen.getByTestId('where')).toHaveTextContent('/apps/crm/docs/crm/crm_intro'); + expect(within(sidebar()).getByTestId('docs-nav')).toBeInTheDocument(); + expect(within(page()).queryByTestId('docs-nav')).toBeNull(); + }); + + it('a page that is not the reader carries the app\'s column in the sidebar, the way back first', async () => { + render(); + await screen.findByText(/not found/i); + const column = within(sidebar()).getByTestId('docs-nav'); + expect(within(column).getByTestId('docs-nav-back')).toHaveAttribute('href', '/apps/crm'); + expect(within(column).getAllByRole('button', { name: /crm/i })).toHaveLength(1); + expect(screen.queryByTestId('docs-back-bar')).toBeNull(); + expect(screen.getByTestId('docs-page-header')).toBeInTheDocument(); + }); + + describe('a package with several books', () => { + beforeEach(() => { + WORLD.authored = true; + }); + afterEach(() => { + WORLD.authored = false; + }); + + it('its docs index lists the books in the page and every book in the sidebar', async () => { + render(); + await within(page()).findByText('Leads Book'); + const column = within(sidebar()).getByTestId('docs-nav'); + expect(within(column).getByRole('button', { name: /Showcase Manual/ })).toBeInTheDocument(); + expect(within(column).getByRole('button', { name: /Leads Book/ })).toBeInTheDocument(); + expect(within(column).queryByRole('button', { name: /Alpha Manual/ })).toBeNull(); + }); + }); + + it('CONTROL — without the shell\'s sidebar (a phone; the /docs portal) the page draws its column and its back link itself', async () => { + WORLD.shellActions = false; + render( + + + }> + } /> + + + , + ); + await screen.findByText(/not found/i); + expect(screen.getByTestId('docs-back-bar')).toBeInTheDocument(); + expect(screen.queryByTestId('docs-page-header')).toBeNull(); + expect(screen.queryByTestId('sidebar-docs-nav')).toBeNull(); + }); +}); diff --git a/ui/packages/app-shell/src/console/__tests__/ConsoleBootShell-35981.test.tsx b/ui/packages/app-shell/src/console/__tests__/ConsoleBootShell-35981.test.tsx index bc7a43a354a..a1ff520c8cb 100644 --- a/ui/packages/app-shell/src/console/__tests__/ConsoleBootShell-35981.test.tsx +++ b/ui/packages/app-shell/src/console/__tests__/ConsoleBootShell-35981.test.tsx @@ -109,8 +109,9 @@ describe('the console boot fallback (objectstack#35981)', () => { // draws is taken away when the chrome lands: from 768 px up no top bar, // and the sidebar's head (app menu, search, bell) and foot (account) // (objectstack#36112); a phone keeps the bar, but not on a record page - // (objectstack#28483); a docs page has no sidebar and keeps the bar at - // every width (objectstack#35424). + // (objectstack#28483); an app's docs page is drawn like every other app + // page from 768 px up (objectstack#37150), and on a phone has no sidebar + // and keeps the bar (objectstack#35424). const width = window.innerWidth; const setWidth = (w: number) => Object.defineProperty(window, 'innerWidth', { value: w, configurable: true, writable: true }); @@ -120,7 +121,7 @@ describe('the console boot fallback (objectstack#35981)', () => { const foot = () => shell()!.querySelector('[data-boot-sidebar-foot]'); try { setWidth(1440); - for (const path of [RECORD, '/apps/crm/account', '/apps/crm/docsearch']) { + for (const path of [RECORD, '/apps/crm/account', '/apps/crm/docsearch', '/apps/crm/docs/manual/intro']) { at(path, ); expect(header(), path).toBeNull(); expect(sidebar(), path).not.toBeNull(); @@ -128,13 +129,16 @@ describe('the console boot fallback (objectstack#35981)', () => { expect(foot(), path).not.toBeNull(); cleanup(); } - for (const w of [1440, 375]) { - setWidth(w); - at('/apps/crm/docs/manual/intro', ); - expect(sidebar(), `docs @${w}`).toBeNull(); - expect(header(), `docs @${w}`).not.toBeNull(); - cleanup(); - } + setWidth(768); + at('/apps/crm/docs/manual/intro', ); + expect(header(), 'docs @768').toBeNull(); + expect(head(), 'docs @768').not.toBeNull(); + cleanup(); + setWidth(375); + at('/apps/crm/docs/manual/intro', ); + expect(sidebar(), 'docs @375').toBeNull(); + expect(header(), 'docs @375').not.toBeNull(); + cleanup(); setWidth(375); at(RECORD, ); diff --git a/ui/packages/app-shell/src/index.ts b/ui/packages/app-shell/src/index.ts index 85600d4bd24..62d5a33e60f 100644 --- a/ui/packages/app-shell/src/index.ts +++ b/ui/packages/app-shell/src/index.ts @@ -98,10 +98,16 @@ export { } from './layout/sidebarFooterSlot.js'; // objectstack#37150 — the shell sidebar's place for an app's docs navigation, -// drawn by the console's docs pages; and the page header's two shell slots -// (the top-right button group and the sidebar's expand button), for a docs -// page, which draws no `ConsolePageHeader`. -export { SidebarDocsNav, useSidebarDocsNavSlot } from './layout/sidebarDocsNavSlot.js'; +// drawn by the console's docs pages (the provider and the target are the +// shell's side, mounted by `ConsoleLayout` and `UnifiedSidebar`); and the page +// header's two shell slots (the top-right button group and the sidebar's +// expand button), for a docs page, which draws no `ConsolePageHeader`. +export { + SidebarDocsNav, + SidebarDocsNavSlotProvider, + SidebarDocsNavTarget, + useSidebarDocsNavSlot, +} from './layout/sidebarDocsNavSlot.js'; export { useShellPageActionsSlot, useShellSidebarExpandSlot } from './layout/shellPageActionsSlot.js'; // Host-app route policy (ADR-0048) — which app's `/apps//…` URL a 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 374057ac5a3..2c9da75ce5e 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 @@ -31,7 +31,11 @@ vi.mock('../../hooks/useAiSurface', () => ({ useAiSurfaceEnabled: () => ({ enabled: false, isLoading: false }), })); vi.mock('../UnifiedSidebar', () => ({ - UnifiedSidebar: () =>