Skip to content

Commit 93bd459

Browse files
feat(console): an app's docs pages draw in the app shell from 768 px up (#37193)
repo:objectstack#4 · os-justin · session_01QSeKYnagJvGbCtNg2PhvgW Part of #37150 — this PR carries Change items 1, 3 and 4 (an app's docs pages, `/apps/APP/docs…`, in the app shell from 768 px up; every old docs URL pinned; phone unchanged). Item 2 (the standalone `/docs` portal in the same appearance) is carried by #37197: the maintainer ruled B, an app-less shell variant (#37150 comment 7151721568), design first. Clause-②: no Metadata-protocol: none ## 维护者速读 - 电脑上从应用里打开文档(应用内的文档首页、书、文章)时,顶栏没有了,左侧是和其它应用页面一样的侧栏,侧栏正文换成文档目录;手机不变,独立的文档门户这次没改。 - 属于「去掉顶栏和平台首页那一层」专题的第三阶段:让读者在应用和它的手册之间来回时看到同一种外壳。 - 出错时读者在电脑上看文档会找不到目录或返回应用的入口;改动只在前端,直接撤回这个改动即可恢复原样。 - 不需要你再定什么:独立文档门户的外壳已按你选的 B 方案定下(不属于任何应用的外壳变体,#37150 评论 7151721568),由 #37197 承接,先出设计图给你看,批准后再做。#37197 设计图里唯一会牵动本 PR 的问题是「全部文档」放在侧栏哪里(本 PR 目前放在底部)。 ## What changes - `ConsoleLayout` (app shell): the `isAppDocsPath` exception now holds on a phone only. From 768 px up an app's docs pages mount `UnifiedSidebar` (head: app-name menu, collapse, search, bell; foot: account) and draw no top bar, like every other desktop app page. The connection banner shows there too, since no bar carries it any more. - `UnifiedSidebar` takes `docsNav`: on an app's docs route its body is an empty target (`SidebarDocsNavTarget`) in place of the app's menu and recents (the one-navigation rule of the earlier docs work holds: a reader has one navigation, the docs'). - New `layout/sidebarDocsNavSlot.tsx`: a provider (mounted by `ConsoleLayout`), the sidebar's target element, and `SidebarDocsNav`, a portal the docs page draws its column through, so the column keeps the page's router and data context. Exported from `@object-ui/app-shell` with the two existing page-header slot hooks. - Console docs pages: `DocShell` draws the column into the sidebar when the slot exists (the reader's own column, else `AppDocsNav`: every book of the app, 「← Back to APP」 and 「All documentation」) and draws the page header's button group and expand button at the page's top. `DocPage` stops drawing its in-page column when the sidebar carries it. `usePackageDocsNavBooks` is the reader's former inline memo, lifted so the non-reader pages share it. - `ConsoleBootShell`: the boot fallback matches (sidebar, no bar on an app's docs page from 768 px up; unchanged on a phone). - Unchanged: every route and URL shape (ADR-0046 section 6), the `/docs` portal frame (`DocsPortalRoute`, `DefaultHomeLayout variant="docs"`), the phone. ## Tests - `ConsoleLayout.phoneRecordOneBar-28483.test.tsx`: the route exception's removal: at 768 and 1440 px, `/apps/crm/docs`, `/apps/crm/docs/`, a book, a flat permalink and an article mount the sidebar with `docsNav` and no top bar; PHONE CONTROL at 390 px keeps no sidebar and the app bar; control: other app routes keep the app menu. - `UnifiedSidebar.footerSlot-36739.test.tsx`: the page's column lands in the sidebar body, the app menu is gone, head and foot stay; control without `docsNav`. - `ConsoleBootShell-35981.test.tsx`: the boot fallback at 768/1440 vs 375 px. - `docs-portal.test.tsx` (objectstack#37150 block): the reader's one column is in the sidebar; the page header carries the shell's group; old URL forms in the shell: reader, book, flat permalink, docs index, book NAME, book NAME/DOC, doc-name-that-is-also-a-book-name, canonical SLUG/DOC each land on the same canonical URL and article as before; non-reader pages; CONTROL without the shell (phone, `/docs`): the page draws its own column and back link. The `/docs` URL forms keep their existing pins in the same file (unchanged frame). <details><summary>Test runs (head fd2011e)</summary> All through `scripts/pm/os-verify-lock.sh`, `--maxWorkers=2`, at fd2011e unless noted. - The four pinned files (`ConsoleLayout.phoneRecordOneBar-28483`, `ConsoleLayout.noTopBar-36112`, `UnifiedSidebar.footerSlot-36739`, `ConsoleBootShell-35981`): `Test Files 2 passed`, `Tests 23 passed` for the two ConsoleLayout files at fd2011e; the sidebar and boot files `Test Files 3 passed (3)`, `Tests 27 passed (27)` at 827b3c7 (unchanged since). - `docs-portal.test.tsx`: `Test Files 1 passed (1)`, `Tests 62 passed (62)` at 827b3c7; the objectstack#37150 block with the added URL pins `Tests 13 passed | 53 skipped (66)` at 2ec4312. - Narrowed suite: every app-shell test that names `ConsoleLayout`, `UnifiedSidebar`, `ConsoleBootShell`, `consoleRoutePaths`, `sidebarDocsNavSlot` or `isAppDocsPath` (128 files) and every console test that names a docs page (13 files), at 2ec4312: app-shell `Test Files 1 failed | 127 passed (128)`, the one red was `ConsoleLayout.noTopBar-36112`'s control pinning the old docs-page bar, corrected in fd2011e and green above; console `Test Files 13 passed (13)`, `Tests 122 passed (122)`. - `type-check` (`@object-ui/app-shell`, `@object-ui/console`) after rebuilding the app-shell dependency closure: VERDICT command-exit 0. - Full app-shell and console suites: declared to CI (`Test UI`); the local full run was stopped after 38 minutes holding the shared lock. </details> <details><summary>Ablations (one-shot, restored byte-identical to HEAD)</summary> Both through `scripts/ablation-replace.mjs` (anchor hit 1 -> 0 on disk, restored blob == HEAD, `git diff HEAD` empty). The tests import these sources directly (relative import; `@object-ui/app-shell` aliased to `src` in the console's vite config), so no `dist/` is involved. 1. `ConsoleLayout.tsx`: `phoneDocsPage ? undefined : (` -> `docsPage ? undefined : (` (the sidebar exception back at every width). Expected red; observed: `× at 768 px and 1440 px a docs index, a book, a flat permalink and an article draw the sidebar …`, `Tests 1 failed | 14 passed (15)`; the PHONE CONTROL stayed green. 2. `DocPage.tsx`: `const pageNav = sidebarNav ? null : docsNav;` -> `const pageNav = docsNav;` (the reader draws its in-page column in the shell too). Expected red; observed `Tests 9 failed | 4 passed | 53 skipped (66)`: the one-column test and all eight URL-form pins (two columns). </details> ## Acceptance notes - **Item 2 is not in this PR; it is carried by #37197.** `ConsoleLayout` is app-scoped by construction and `/docs` names no app. The maintainer ruled option B, an app-less shell variant (「B:做一个不属于任何应用的外壳变体(推荐)」, #37150 comment 7151721568), and asked to see the design first. #37197 carries it: stage 1 mockups, then the build after approval and after this PR lands. - With the sidebar collapsed, the docs page's header row draws the shell's expand button; it registers with the shell's header registry, so the content-corner fallback does not draw a second one. - Screenshots were taken at the implementation commits (096ac67), before the `origin/main` merge; the merge's only overlap with this surface is `ui/packages/app-shell/src/index.ts`, merged clean, and no implementation file changed after. ## Verification Read first (by risk): 1. `ui/packages/app-shell/src/layout/ConsoleLayout.tsx`: the `phoneDocsPage` hunk (sidebar mount and `showHeader`), the branch the shell's look hangs on. 2. `ui/apps/console/src/pages/DocShell.tsx`: the sidebar portal and the page-header row. 3. `ui/packages/app-shell/src/layout/UnifiedSidebar.tsx`: the `docsNav` body swap. Two-minute check: in the showcase app (`pnpm dev`), open the Showcase app's documentation from its menu at 1440 px: no top bar, the sidebar head reads 「Showcase」, the sidebar body is the docs column with 「← Back to Showcase」 first and 「All documentation」 last; narrow the window to 390 px and the app bar and the in-page column are back. Desktop, an app's docs reader (no top bar, sidebar body = docs column): ![desktop app docs reader](https://github.com/objectstack-ai/objectstack/blob/claude/issue-37150-screenshots/issue-37150/desktop-app-docs-reader.png?raw=true) Desktop, an app's docs index: ![desktop app docs index](https://github.com/objectstack-ai/objectstack/blob/claude/issue-37150-screenshots/issue-37150/desktop-app-docs-index.png?raw=true) Desktop, a flat doc permalink (lands on the same reader): ![desktop flat permalink](https://github.com/objectstack-ai/objectstack/blob/claude/issue-37150-screenshots/issue-37150/desktop-app-docs-flat-permalink.png?raw=true) Desktop, the `/docs` portal entry (unchanged by this PR; item 2): ![desktop docs portal](https://github.com/objectstack-ai/objectstack/blob/claude/issue-37150-screenshots/issue-37150/desktop-docs-portal-reader-unchanged.png?raw=true) Phone control, 390 px (unchanged: app bar, in-page column): ![phone control](https://github.com/objectstack-ai/objectstack/blob/claude/issue-37150-screenshots/issue-37150/phone-app-docs-reader-control.png?raw=true) Screenshots live on the assets-only branch `claude/issue-37150-screenshots` (never merged). --- _Generated by [Claude Code](https://claude.ai/code/session_01QSeKYnagJvGbCtNg2PhvgW)_ --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent bc3ec37 commit 93bd459

15 files changed

Lines changed: 503 additions & 78 deletions
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
'@object-ui/app-shell': patch
3+
'@object-ui/console': patch
4+
'@objectstack/console': patch
5+
---
6+
7+
feat(console): an app's documentation pages draw in the app shell from 768 px up
8+
9+
Clause-②: no
10+
Metadata-protocol: none
11+
12+
From 768 px up every app page lost the top bar and keeps the app menu, search, notifications and account in the sidebar. An app's documentation pages (`/apps/APP/docs`, a book, a flat doc link, an article) were the one exception: they kept the top bar at every width and mounted no sidebar. They now draw like every other app page there: no top bar, the resident sidebar with its usual head (the app-name menu, collapse, search, notifications) and foot (the account), and the page header's button group (assistant and help) at the top right.
13+
14+
The documentation still has one navigation, its own: the sidebar's body carries the docs column (「← Back to APP」, every book of the app with the current one open, a title filter and 「All documentation」) in place of the app's menu. The reader no longer draws that column inside the page there. The app's other docs pages (its docs index, a book with no articles, a book or doc that is not found) carry the same column in the sidebar instead of a back link above the page.
15+
16+
Unchanged: every docs address resolves to the same page as before, and a phone keeps its app bar, no sidebar and the in-page column. The `/docs` portal is not changed by this release. Nothing to migrate.

‎ui/apps/console/src/pages/DocPage.tsx‎

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
1010
import { Link, Navigate, useHref, useLocation, useNavigate, useParams } from 'react-router-dom';
1111
import { AlertCircle, ChevronDown, ChevronRight, FileQuestion, Layers, Loader2, Menu } from 'lucide-react';
12-
import { useAdapter } from '@object-ui/app-shell';
12+
import { useAdapter, useSidebarDocsNavSlot } from '@object-ui/app-shell';
1313
import { MarkdownRenderer, MermaidEnlargeContext, extractToc } from '@object-ui/plugin-markdown';
1414
import { useObjectTranslation } from '@object-ui/i18n';
1515
import { rewriteDocLinks } from './doc-links';
1616
import { conflictCandidates, readsByNameAfter } from './doc-address';
1717
import { DocShell } from './DocShell';
1818
import { useAppDocsBackTo } from './useAppDocsBackTo';
19-
import { DocsNav, type DocsNavBook } from './DocsNav';
19+
import { DocsNav, usePackageDocsNavBooks } from './DocsNav';
2020
import { DocRefusal } from './BookPage';
2121
import { useBookData } from './use-book-data';
2222
import { useActiveHeading } from './useActiveHeading';
@@ -249,17 +249,14 @@ export default function DocPage() {
249249
const docHref = useCallback((docName: string) => `${base}/${slug}/${docName}`, [base, slug]);
250250
// objectstack#35424 — the docs column lists every book of the package the
251251
// reader is in: the current book's package, else the route's app package.
252-
const packageBooks = useMemo<DocsNavBook[]>(() => {
252+
const readerPackage = useMemo(() => {
253253
const current = books.find((b) => bookSlug(b) === slug);
254-
const pkg = current ? pkgOfBook(current) : appName;
255-
if (!pkg) return [];
256-
return books
257-
.filter((b) => pkgOfBook(b) === pkg)
258-
.map((b) => ({
259-
slug: bookSlug(b),
260-
book: labelUncategorized(resolveBookTree(b, allDocs, undefined, authoredBooks), uncategorizedLabel),
261-
}));
262-
}, [books, authoredBooks, allDocs, slug, appName, uncategorizedLabel]);
254+
return current ? pkgOfBook(current) : appName;
255+
}, [books, slug, appName]);
256+
const packageBooks = usePackageDocsNavBooks(readerPackage);
257+
// objectstack#37150 — inside an app from 768 px up the shell sidebar carries
258+
// the column (`DocShell` draws it there); elsewhere the page draws it.
259+
const sidebarNav = useSidebarDocsNavSlot() !== null;
263260
const neighbours = useMemo(
264261
() => (resolvedBook ? articleNeighbours(resolvedBook, name) : { previous: null, next: null }),
265262
[resolvedBook, name],
@@ -397,31 +394,35 @@ export default function DocPage() {
397394
) : null;
398395
const docsLabel = t('help.documentation', { defaultValue: 'Documentation' });
399396

397+
const pageNav = sidebarNav ? null : docsNav;
398+
400399
return (
401-
<DocShell backLink={!docsNav}>
400+
<DocShell backLink={!docsNav} nav={docsNav ?? undefined}>
402401
{/* objectstack#35424 — the docs column is the page's one navigation.
403-
* Inside an app it sits where the app menu would, full height beside
404-
* the article; on narrow screens it folds into a disclosure above it. */}
402+
* Inside an app from 768 px up it is the shell sidebar's body, where the
403+
* app menu would be (objectstack#37150); elsewhere it sits full height
404+
* beside the article, and on narrow screens it folds into a disclosure
405+
* above it. */}
405406
<div className="flex min-h-full" data-testid="doc-reader">
406-
{docsNav ? (
407+
{pageNav ? (
407408
<aside className="hidden w-72 shrink-0 border-r lg:block">
408409
<nav
409410
aria-label={t('help.docsNavigation', { defaultValue: 'Documentation navigation' })}
410411
className={`sticky overflow-auto px-4 py-6 ${appName ? 'top-0 max-h-[calc(100svh-3rem)]' : 'top-12 max-h-[calc(100svh-3rem)]'}`}
411412
>
412-
{docsNav}
413+
{pageNav}
413414
</nav>
414415
</aside>
415416
) : null}
416417
<div className="min-w-0 flex-1">
417-
{docsNav ? (
418+
{pageNav ? (
418419
<details className="group mx-4 mt-4 sm:mx-6 lg:hidden">
419420
<summary className="flex cursor-pointer list-none items-center gap-2 rounded-md border bg-muted/30 px-3 py-2 text-sm font-medium [&::-webkit-details-marker]:hidden">
420421
<Menu className="h-4 w-4 text-muted-foreground" />
421422
<span className="truncate">{resolvedBook?.label ?? docsLabel}</span>
422423
<ChevronDown className="ml-auto h-4 w-4 text-muted-foreground transition-transform group-open:rotate-180" />
423424
</summary>
424-
<div className="mt-2 rounded-md border p-3">{docsNav}</div>
425+
<div className="mt-2 rounded-md border p-3">{pageNav}</div>
425426
</details>
426427
) : null}
427428
<div className="mx-auto flex max-w-[1080px] justify-center gap-10 px-4 py-6 sm:px-8 lg:py-8">

‎ui/apps/console/src/pages/DocShell.tsx‎

Lines changed: 40 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,35 +8,66 @@
88

99
import type { ReactNode } from 'react';
1010
import { useParams } from 'react-router-dom';
11+
import {
12+
SidebarDocsNav,
13+
useShellPageActionsSlot,
14+
useShellSidebarExpandSlot,
15+
useSidebarDocsNavSlot,
16+
} from '@object-ui/app-shell';
1117
import { AppDocsBackLink } from './AppDocsBackLink';
18+
import { AppDocsNav, DocsNavLandmark } from './DocsNav';
1219
import { useAppDocsBackTo } from './useAppDocsBackTo';
1320

1421
/**
15-
* The frame of the package-documentation pages (ADR-0046), inside the
16-
* console's own top bar. It draws no bar of its own (objectstack#35424):
22+
* The frame of the package-documentation pages (ADR-0046). It draws no bar of
23+
* its own (objectstack#35424):
1724
*
18-
* - Under an app (`/apps/:appName/docs/...`, ADR-0048) the app bar above reads
19-
* 「APP / Documentation」, and the reader names its book and article above
20-
* the article. An app's docs routes draw no app menu either, so the bar's
21-
* place holds 「← Back to APP」 (`AppDocsBackLink`) on every page but the
22-
* reader, which carries it in its docs column and passes `backLink={false}`.
25+
* - Under an app (`/apps/:appName/docs/...`, ADR-0048), from 768 px up, the
26+
* page is drawn in the app shell like every other app page
27+
* (objectstack#37150, ruling 7142354097 on objectstack#36107): no top bar,
28+
* the resident sidebar, and the page header's button group and expand
29+
* button, which this frame draws at the page's top. The docs' one
30+
* navigation column (the app's books, 「← Back to APP」 and all
31+
* documentation) is the sidebar's body: the page hands it `nav`, the
32+
* reader's own, else every book of the app (`AppDocsNav`).
33+
* - Under an app on a phone the console's app bar is above the page, and the
34+
* page carries 「← Back to APP」 itself: at the top here, on every page but
35+
* the reader, which carries it in its in-page column and passes
36+
* `backLink={false}`.
2337
* - The portal (`/docs/...`) is drawn in Home's frame, whose bar reads
2438
* 「PRODUCT / Documentation」 and links to the portal's index (`App.tsx`,
2539
* the `docs` variant of `AppHeader`).
2640
*/
2741
export function DocShell({
2842
backLink = true,
43+
nav,
2944
children,
3045
}: {
31-
/** Inside an app: draw 「← Back to APP」 above the page. The reader turns it off when its column has it. */
46+
/** Without the shell sidebar: draw 「← Back to APP」 above the page. The reader turns it off when its column has it. */
3247
backLink?: boolean;
48+
/** The page's own docs column, for the shell sidebar (the reader's); else every book of the app. */
49+
nav?: ReactNode;
3350
children: ReactNode;
3451
}) {
3552
const { appName } = useParams<{ appName?: string }>();
3653
const backTo = useAppDocsBackTo();
54+
const sidebarNav = useSidebarDocsNavSlot() !== null;
55+
const renderActions = useShellPageActionsSlot();
56+
const renderExpand = useShellSidebarExpandSlot();
3757
return (
3858
<div className="min-h-full">
39-
{appName && backLink && backTo ? (
59+
{sidebarNav ? (
60+
<SidebarDocsNav>
61+
<DocsNavLandmark>{nav ?? <AppDocsNav />}</DocsNavLandmark>
62+
</SidebarDocsNav>
63+
) : null}
64+
{renderActions || renderExpand ? (
65+
<div className="flex items-center gap-2 px-4 pt-3 sm:px-6" data-testid="docs-page-header">
66+
{renderExpand?.()}
67+
<div className="ml-auto">{renderActions?.({})}</div>
68+
</div>
69+
) : null}
70+
{appName && backLink && backTo && !sidebarNav ? (
4071
<div className="mx-auto flex max-w-3xl px-4 pt-4 sm:px-6" data-testid="docs-back-bar">
4172
<AppDocsBackLink backTo={backTo} />
4273
</div>

‎ui/apps/console/src/pages/DocsNav.tsx‎

Lines changed: 57 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,16 @@
66
* LICENSE file in the root directory of this source tree.
77
*/
88

9-
import { useId, useState } from 'react';
10-
import { Link } from 'react-router-dom';
9+
import { useCallback, useId, useMemo, useState, type ReactNode } from 'react';
10+
import { Link, useParams } from 'react-router-dom';
1111
import { ArrowRight, ChevronDown, ChevronRight, Search } from 'lucide-react';
1212
import { useObjectTranslation } from '@object-ui/i18n';
1313
import { AppDocsBackLink } from './AppDocsBackLink';
14-
import type { AppDocsBackTo } from './useAppDocsBackTo';
14+
import { useAppDocsBackTo, type AppDocsBackTo } from './useAppDocsBackTo';
1515
import { BookSidebar } from './BookSidebar';
1616
import { bookArticles, filterBookArticles } from './docs-reading';
17-
import type { ResolvedBook } from './book-nav';
17+
import { bookSlug, labelUncategorized, pkgOfBook, resolveBookTree, type ResolvedBook } from './book-nav';
18+
import { useBookData } from './use-book-data';
1819

1920
/** One book of the column: its resolved spine and its URL segment. */
2021
export interface DocsNavBook {
@@ -128,3 +129,55 @@ export function DocsNav({
128129
</div>
129130
);
130131
}
132+
133+
/**
134+
* Every book of package `pkg`, resolved for the column (objectstack#35424):
135+
* the reader's books, and those of an app's other docs pages. Empty with no
136+
* package.
137+
*/
138+
export function usePackageDocsNavBooks(pkg: string | undefined): DocsNavBook[] {
139+
const { t } = useObjectTranslation();
140+
const { books, authoredBooks, docs } = useBookData();
141+
const uncategorizedLabel = t('help.uncategorized', { defaultValue: 'Uncategorized' });
142+
return useMemo(() => {
143+
if (!pkg) return [];
144+
return books
145+
.filter((b) => pkgOfBook(b) === pkg)
146+
.map((b) => ({
147+
slug: bookSlug(b),
148+
book: labelUncategorized(resolveBookTree(b, docs, undefined, authoredBooks), uncategorizedLabel),
149+
}));
150+
}, [books, authoredBooks, docs, pkg, uncategorizedLabel]);
151+
}
152+
153+
/**
154+
* The column as the shell sidebar carries it (objectstack#37150): the same
155+
* column, under its own navigation landmark.
156+
*/
157+
export function DocsNavLandmark({ children }: { children: ReactNode }) {
158+
const { t } = useObjectTranslation();
159+
return (
160+
<nav aria-label={t('help.docsNavigation', { defaultValue: 'Documentation navigation' })} className="pt-2">
161+
{children}
162+
</nav>
163+
);
164+
}
165+
166+
/**
167+
* The column of an app's docs page other than the reader (the app's docs
168+
* index, a book with no articles, a book or doc not found): the app's books,
169+
* the way back to the app and all documentation. The reader builds its own,
170+
* from the book its article is in.
171+
*/
172+
export function AppDocsNav() {
173+
const { appName, slug } = useParams<{ appName?: string; slug?: string }>();
174+
const books = usePackageDocsNavBooks(appName);
175+
const backTo = useAppDocsBackTo();
176+
const docHref = useCallback(
177+
(bookSegment: string, doc: string) => `/apps/${appName}/docs/${bookSegment}/${doc}`,
178+
[appName],
179+
);
180+
return (
181+
<DocsNav books={books} currentSlug={slug} docHref={docHref} backTo={backTo} allDocsHref="/docs" />
182+
);
183+
}

0 commit comments

Comments
 (0)