Skip to content

Commit e78f292

Browse files
committed
fix(app-shell): the docs portal's frame hosts the standing banners and the connection notice at the top of its content; pin its default accent
Claude-Session: https://claude.ai/code/session_01QSeKYo1Rb7aYhQiJdWshkL Co-authored-by: Claude <noreply@anthropic.com>
1 parent 4a5955a commit e78f292

3 files changed

Lines changed: 129 additions & 8 deletions

File tree

‎.changeset/37197-docs-portal-app-less-shell.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ feat(console): the documentation portal draws in the app shell's frame from 768
99
Clause-②: no
1010
Metadata-protocol: none
1111

12-
The documentation portal (`/docs`, a book, an article) was the last desktop page that still drew a top bar, in a frame of its own, while an app's documentation pages draw in the app shell. From 768 px up the portal now draws in the same frame, in a variant that belongs to no app: no top bar; the sidebar with search and notifications in its head and the account at its foot; the page header's assistant and help buttons at the top right. Where an app's name sits in its sidebar, the portal's sidebar shows a neutral 「Documentation」 heading; it opens the list of your apps (none marked current) and 「Add app」, and choosing an app opens it. The sidebar's body is the documentation tree: 「All documentation」 first, a title filter, then every book under the heading of the app that carries it, as the portal's index groups them, with the book being read open. Books are named as the index names them, so a platform app's book reads as the app does (for example 「系统设置」) instead of its package's short name.
12+
The documentation portal (`/docs`, a book, an article) was the one documentation page that still drew a top bar on a desktop, in a frame of its own, while an app's documentation pages draw in the app shell. From 768 px up the portal now draws in the same frame, in a variant that belongs to no app: no top bar; the sidebar with search (when there is an app to search) and notifications in its head and the account at its foot; standing notices (impersonation, usage, storage, a lost connection) at the top of the page's content, beside the sidebar rather than over it; the page header's assistant and help buttons at the top right. Where an app's name sits in its sidebar, the portal's sidebar shows a neutral 「Documentation」 heading; it opens the list of your apps (none marked current) and 「Add app」, and choosing an app opens it. The sidebar's body is the documentation tree: 「All documentation」 first, a title filter, then every book under the heading of the app that carries it, as the portal's index groups them, with the book being read open. Books are named as the index names them, so a platform app's book reads as the app does (for example 「系统设置」) instead of its package's short name.
1313

1414
Opening the portal does not pick an app: no app's colours are applied, and the app you last used, and the one you had open, stay what they were.
1515

‎ui/packages/app-shell/src/console/docs/DocsPortalShell.tsx‎

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,12 @@
99
* same `AppShell` and `UnifiedSidebar` an app's docs pages draw in
1010
* (objectstack#37150), so the two entry points to the same documents share one
1111
* frame (ruling A on objectstack#36107). No top bar; the sidebar's head carries
12-
* search and the bell, its foot the account, and the collapse button works as
13-
* on every app page. Two things differ from an app's docs pages:
12+
* search (when there is an app to search) and the bell, its foot the account,
13+
* and the collapse button works as on every app page. The standing banners
14+
* (impersonation, read rate, storage) and the connection notice sit at the top
15+
* of the content area, the content's width, as in an app (`ChromeBannerHost`,
16+
* `ConnectionBanner`): drawn above the route they would span the sidebar's
17+
* column and cover its head. Two things differ from an app's docs pages:
1418
*
1519
* - the head is a neutral 「Documentation」 menu (`SidebarDocsPortalMenu`)
1620
* that lists the viewer's apps and 「Add app」, none of them checked, in
@@ -35,6 +39,7 @@
3539
*/
3640

3741
import React, { useEffect, useMemo, useState } from 'react';
42+
import type { ConnectionState } from '@object-ui/data-objectstack';
3843
import { useNavigate } from 'react-router-dom';
3944
import { AppShell } from '@object-ui/layout';
4045
import { useAuth } from '@object-ui/auth';
@@ -54,6 +59,8 @@ import { UnifiedSidebar } from '../../layout/UnifiedSidebar.js';
5459
import { SidebarDocsNavSlotProvider } from '../../layout/sidebarDocsNavSlot.js';
5560
import { ShellPageActionsScope, ShellSidebarExpandFallback } from '../../layout/ShellPageActions.js';
5661
import { primeConsoleSidebarOpen } from '../../layout/consoleSidebarRail.js';
62+
import { ChromeBannerHost } from '../../layout/chromeBannerHost.js';
63+
import { ConnectionBanner } from '../../layout/ConnectionBanner.js';
5764
import { HomeCommandPalette, HomeLayout } from '../home/HomeLayout.js';
5865

5966
/** Home's `app`, `data` and `features`: none (module constants, as Home's). */
@@ -65,6 +72,26 @@ export interface DocsPortalShellProps {
6572
userId?: string;
6673
}
6774

75+
/**
76+
* The data adapter's connection state, as `AppContent` reads it for an app's
77+
* layout: its current answer, then each change it reports. `undefined` with no
78+
* adapter, or one that reports none.
79+
*/
80+
function useAdapterConnectionState(dataSource: unknown): ConnectionState | undefined {
81+
const adapter = dataSource as {
82+
getConnectionState?: () => ConnectionState;
83+
onConnectionStateChange?: (listener: (event: { state: ConnectionState }) => void) => () => void;
84+
} | null;
85+
const [state, setState] = useState<ConnectionState | undefined>(() => adapter?.getConnectionState?.());
86+
useEffect(() => {
87+
if (!adapter?.onConnectionStateChange) return undefined;
88+
const unsubscribe = adapter.onConnectionStateChange((event) => setState(event.state));
89+
setState(adapter.getConnectionState?.());
90+
return unsubscribe;
91+
}, [adapter]);
92+
return state;
93+
}
94+
6895
/** Inside the sidebar provider: the window's width decides the sidebar's start state, as in an app. */
6996
function DocsPortalShellInner({ children }: { children: React.ReactNode }) {
7097
useResponsiveSidebar();
@@ -80,6 +107,7 @@ function DesktopDocsPortalShell({ children, userId }: DocsPortalShellProps) {
80107
const expressionUser = useMemo(() => buildExpressionUser(user), [user]);
81108
const { apps } = useMetadata();
82109
const dataSource = useAdapter();
110+
const connectionState = useAdapterConnectionState(dataSource);
83111
const navigate = useNavigate();
84112
const { enabled: showChatbot } = useAiSurfaceEnabled();
85113
const chatDock = useConsoleChatDock({ enabled: showChatbot, userId: userId ?? user?.id });
@@ -114,6 +142,14 @@ function DesktopDocsPortalShell({ children, userId }: DocsPortalShellProps) {
114142
>
115143
<DocsPortalShellInner>
116144
<ShellPageActionsScope sidebarExpand appless>
145+
{/* The standing banners and the connection notice, at the top
146+
of the content area and the content's width, as
147+
`ConsoleLayout` draws them; the box keeps its height in
148+
the inset's `lg` flex column. */}
149+
<div data-testid="docs-portal-banners" className="shrink-0">
150+
<ChromeBannerHost />
151+
<ConnectionBanner state={connectionState} />
152+
</div>
117153
<div data-testid="docs-portal-shell" className="h-full lg:min-h-0">
118154
<ShellSidebarExpandFallback />
119155
{children}

‎ui/packages/app-shell/src/console/docs/__tests__/DocsPortalShell-37197.test.tsx‎

Lines changed: 90 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,38 @@ import { useSidebar } from '@object-ui/components';
2727
import '@object-ui/plugin-detail';
2828

2929
const rememberApp = vi.hoisted(() => vi.fn());
30+
/** The data adapter the shell reads its connection state from; none unless a test sets one. */
31+
const adapter = vi.hoisted(() => ({ value: null as null | { getConnectionState: () => string; onConnectionStateChange: () => () => void } }));
3032

3133
vi.mock('../../../hooks/useAiSurface', () => ({
3234
useAiSurfaceEnabled: () => ({ enabled: false, isLoading: false }),
3335
}));
3436
vi.mock('../../../layout/useConsoleChatDock', () => ({
3537
useConsoleChatDock: () => ({ control: null, rail: null, sheet: null }),
3638
}));
39+
// The one app carries its own brand: the portal must not take it (design point 5).
3740
vi.mock('../../../providers/MetadataProvider', () => ({
38-
useMetadata: () => ({ apps: [{ name: 'crm', label: 'CRM', active: true, _packageId: 'com.acme.crm', navigation: [] }] }),
41+
useMetadata: () => ({
42+
apps: [
43+
{
44+
name: 'crm',
45+
label: 'CRM',
46+
active: true,
47+
_packageId: 'com.acme.crm',
48+
navigation: [],
49+
branding: { primaryColor: '#e11d48', accentColor: '#f59e0b' },
50+
},
51+
],
52+
}),
3953
}));
40-
vi.mock('../../../providers/AdapterProvider', () => ({ useAdapter: () => null }));
54+
vi.mock('../../../providers/AdapterProvider', () => ({ useAdapter: () => adapter.value }));
4155
vi.mock('../../../providers/ExpressionProvider', () => ({
4256
ExpressionProvider: ({ children }: { children: React.ReactNode }) => <>{children}</>,
4357
}));
44-
// Mounted by nothing the portal draws; a frame that remembers an app (as an
45-
// app's layout does) calls it.
58+
// A tripwire only: nothing the portal draws calls it, and the last-app check in
59+
// storage is what carries the "no app remembered" pin. A frame that remembers
60+
// an app (as an app's layout does) would call it, and the assertions on it
61+
// would go red with the storage check.
4662
vi.mock('../../../context/LastAppProvider', () => ({
4763
useLastApp: () => ({ lastApp: null, rememberApp }),
4864
}));
@@ -80,6 +96,7 @@ import { DocsPortalShell } from '../DocsPortalShell';
8096
import { NavigationProvider, useNavigationContext } from '../../../context/NavigationContext';
8197
import { SidebarDocsNav } from '../../../layout/sidebarDocsNavSlot';
8298
import { useShellPageActionsSlot, useShellSidebarExpandSlot } from '../../../layout/shellPageActionsSlot';
99+
import { ChromeBannerSlot } from '../../../layout/chromeBannerHost';
83100

84101
function setWidth(width: number) {
85102
Object.defineProperty(window, 'innerWidth', { value: width, configurable: true, writable: true });
@@ -135,13 +152,21 @@ function PhonePageStandIn() {
135152
);
136153
}
137154

138-
function mountAt(path: string, width: number, options: { openedBefore?: string } = {}) {
155+
function mountAt(path: string, width: number, options: { openedBefore?: string; banner?: boolean } = {}) {
139156
setWidth(width);
140157
const phone = width < 768;
141158
return render(
142159
<MemoryRouter initialEntries={[path]}>
143160
<NavigationProvider>
144161
{options.openedBefore ? <OpenedBefore app={options.openedBefore} /> : null}
162+
{/* A standing banner, mounted above the routes as `ConsoleShell` mounts them. */}
163+
{options.banner ? (
164+
<div data-testid="shell-banner-slot">
165+
<ChromeBannerSlot>
166+
<div data-testid="impersonation-banner-stub">Impersonating</div>
167+
</ChromeBannerSlot>
168+
</div>
169+
) : null}
145170
<ContextProbe />
146171
<DocsPortalShell>{phone ? <PhonePageStandIn /> : <DocsPageStandIn />}</DocsPortalShell>
147172
</NavigationProvider>
@@ -154,6 +179,8 @@ const PORTAL_PATHS = ['/docs', '/docs/crm', '/docs/crm/crm_intro'];
154179
afterEach(() => {
155180
cleanup();
156181
rememberApp.mockClear();
182+
adapter.value = null;
183+
for (const name of ['--primary', '--accent', '--ring', '--brand-primary']) document.documentElement.style.removeProperty(name);
157184
document.cookie = 'sidebar_state=; path=/; max-age=0';
158185
window.localStorage.clear();
159186
setWidth(1440);
@@ -236,3 +263,61 @@ describe('the portal\'s page header carries the shell\'s group and expand button
236263
expect(screen.queryByTestId('shell-sidebar-expand')).toBeNull();
237264
});
238265
});
266+
267+
describe('the portal takes no app\'s brand: the default accent (objectstack#37197, design point 5)', () => {
268+
/** The accent variables an app's brand sets on the document root (`AppShell`'s branding). */
269+
const brand = () => ({
270+
primary: document.documentElement.style.getPropertyValue('--primary'),
271+
accent: document.documentElement.style.getPropertyValue('--accent'),
272+
});
273+
274+
it('after an app with a brand was open, the portal draws the default accent: no --primary, no --accent on the root', () => {
275+
// What an app's shell leaves on the root while its page is up.
276+
document.documentElement.style.setProperty('--primary', '347 77% 50%');
277+
document.documentElement.style.setProperty('--accent', '38 92% 50%');
278+
mountAt('/docs/crm/crm_intro', 1440, { openedBefore: 'crm' });
279+
expect(screen.getByTestId('docs-portal-shell')).toBeInTheDocument();
280+
expect(brand()).toEqual({ primary: '', accent: '' });
281+
});
282+
283+
it('PHONE CONTROL — Home\'s docs frame sets no brand either', () => {
284+
mountAt('/docs/crm/crm_intro', 390, { openedBefore: 'crm' });
285+
expect(screen.getByTestId('home-layout')).toHaveAttribute('data-variant', 'docs');
286+
expect(brand()).toEqual({ primary: '', accent: '' });
287+
});
288+
});
289+
290+
describe('the portal\'s standing banners and connection notice sit at the top of its content (objectstack#37197)', () => {
291+
it('at 1440 px a standing banner is drawn once, in the box at the top of the content, not above the shell', () => {
292+
mountAt('/docs/crm/crm_intro', 1440, { banner: true });
293+
const banners = screen.getAllByTestId('impersonation-banner-stub');
294+
expect(banners).toHaveLength(1);
295+
const box = screen.getByTestId('docs-portal-banners');
296+
expect(box).toContainElement(banners[0]);
297+
expect(screen.getByTestId('shell-banner-slot')).not.toContainElement(banners[0]);
298+
// The box comes before the page, at the top of the content area.
299+
expect(box.compareDocumentPosition(screen.getByTestId('page')) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
300+
});
301+
302+
it('a lost connection is a notice in that box; a live one draws nothing', () => {
303+
adapter.value = { getConnectionState: () => 'disconnected', onConnectionStateChange: () => () => {} };
304+
mountAt('/docs/crm/crm_intro', 1440);
305+
const notice = screen.getByTestId('console-connection-banner');
306+
expect(screen.getByTestId('docs-portal-banners')).toContainElement(notice);
307+
expect(notice).toHaveTextContent(/disconnected/i);
308+
cleanup();
309+
adapter.value = { getConnectionState: () => 'connected', onConnectionStateChange: () => () => {} };
310+
mountAt('/docs/crm/crm_intro', 1440);
311+
expect(screen.queryByTestId('console-connection-banner')).toBeNull();
312+
});
313+
314+
it('PHONE CONTROL — on a phone the banner stays where the shell mounts it, drawn once, and no notice box is mounted', () => {
315+
adapter.value = { getConnectionState: () => 'disconnected', onConnectionStateChange: () => () => {} };
316+
mountAt('/docs/crm/crm_intro', 390, { banner: true });
317+
const banners = screen.getAllByTestId('impersonation-banner-stub');
318+
expect(banners).toHaveLength(1);
319+
expect(screen.getByTestId('shell-banner-slot')).toContainElement(banners[0]);
320+
expect(screen.queryByTestId('docs-portal-banners')).toBeNull();
321+
expect(screen.queryByTestId('console-connection-banner')).toBeNull();
322+
});
323+
});

0 commit comments

Comments
 (0)