Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .changeset/37528-impersonation-banner-height.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
'@object-ui/app-shell': patch
'@object-ui/layout': patch
'@object-ui/console': patch
---

fix(app-shell): a full-height console page gives the impersonation banner its height back

Clause-②: no
Metadata-protocol: none

- While an administrator impersonates a user, the console draws its banner above the page. Where it is drawn in place (every page on a phone, and Studio, Home and the organization pages on a desktop) the page below still took the whole viewport, so the document was taller than the window by the banner's height: a list's footer and bulk action bar sat below the fold and the page gained a second scrollbar. The same held for the read-rate and storage banners beside it.
- The banners drawn in place now publish their height as the CSS custom property `--os-chrome-banners` on the document root, and the console's full-height shells take the viewport less it: `AppShell` (`@object-ui/layout`, whose sidebar wrapper's own minimum height is overridden to match), Studio and its access-required screen, Home, the AI chat page, the organization layouts and the app-unavailable and no-app screens. While no banner is drawn in place, and anywhere outside the console, the property is unset and every shell keeps its viewport height. Inside an app on a desktop the banners are drawn into the content area, as before, and publish nothing.
2 changes: 1 addition & 1 deletion ui/apps/console/src/components/StudioRoute.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ function StudioAccessRequired({ home }: { home: string }) {
// page, so the button says so, as the shell's other way-home buttons do.
const phone = usePhoneViewport();
return (
<div className="flex h-screen items-center justify-center p-4">
<div className="flex h-[calc(100vh-var(--os-chrome-banners,0px))] items-center justify-center p-4">
<Empty data-testid="studio-access-required">
<div className="mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-muted">
<Lock className="h-6 w-6 text-muted-foreground" />
Expand Down
9 changes: 5 additions & 4 deletions ui/packages/app-shell/src/console/AppContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { useState, useEffect, useLayoutEffect, useCallback, useRef, lazy, Suspen
import { useAssistant } from '../assistant/assistantBus.js';
import { LazyModalForm } from '../views/lazyFormSurfaces.js';
import { ConsoleFormOwnerLine } from '../views/consoleFormOwnerLine.js';
import { Empty, EmptyTitle, EmptyDescription, Button, DataErrorState } from '@object-ui/components';
import { Empty, EmptyTitle, EmptyDescription, Button, DataErrorState, cn } from '@object-ui/components';
import { toast } from 'sonner';
import { useActionRunner, useGlobalUndo, useMutationInvalidationBridge, notifyDataChanged, FilterScopeProvider, resolveApprovalLock, claimAnswerWarnings, toastRecordSave, type AnswerWarningClaim, type AnsweredLoadFailure, type RecordSaveFeedback } from '@object-ui/react';
import { useRecordApprovals, openApprovalOf } from '../hooks/useRecordApprovals.js';
Expand Down Expand Up @@ -45,6 +45,7 @@ import type { NavigationItem } from '@object-ui/types';

// Components (eagerly loaded — always needed)
import { ConsoleLayout } from '../layout/ConsoleLayout.js';
import { CONSOLE_FULL_HEIGHT } from '../layout/chromeBannerHost.js';
import { CommandPalette } from '../chrome/CommandPalette.js';
import { ErrorBoundary } from '../chrome/ErrorBoundary.js';
import { LoadingScreen } from '../chrome/LoadingScreen.js';
Expand Down Expand Up @@ -1318,7 +1319,7 @@ export function AppContent({ extraRoutes, extraRoutesNoApp }: AppContentProps =

// One screen for both branches that draw a `denied` verdict below.
const renderAppAccessDenied = () => (
<div className="h-screen flex items-center justify-center">
<div className={cn(CONSOLE_FULL_HEIGHT.screen, 'flex items-center justify-center')}>
<Empty data-testid="app-access-denied">
<EmptyTitle>
{t('empty.appAccessDenied', { defaultValue: "You don't have access to this app" })}
Expand Down Expand Up @@ -1398,7 +1399,7 @@ export function AppContent({ extraRoutes, extraRoutesNoApp }: AppContentProps =
return (
<NotFoundState
testId={verdictScreen.testId}
className="h-screen p-0"
className={cn(CONSOLE_FULL_HEIGHT.screen, 'p-0')}
title={verdictScreen.title}
description={verdictScreen.description}
actions={
Expand Down Expand Up @@ -1474,7 +1475,7 @@ export function AppContent({ extraRoutes, extraRoutesNoApp }: AppContentProps =
}

if (!activeApp && !isCreateAppRoute && !isSystemRoute && !isMetadataRoute) return (
<div className="h-screen flex items-center justify-center">
<div className={cn(CONSOLE_FULL_HEIGHT.screen, 'flex items-center justify-center')}>
<Empty>
<EmptyTitle>{t('empty.noAppsConfigured')}</EmptyTitle>
<EmptyDescription>
Expand Down
3 changes: 2 additions & 1 deletion ui/packages/app-shell/src/console/ai/AiChatPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { useServedAppLabel } from '../../hooks/useServedAppLabel.js';
import { toast } from 'sonner';
import { Package as PackageIcon, Sparkles as SparklesIcon } from 'lucide-react';
import { useAdapter } from '../../providers/AdapterProvider.js';
import { CONSOLE_FULL_HEIGHT } from '../../layout/chromeBannerHost.js';
import { isPlatformBuiltinApp } from '../../utils/platformApp.js';
import { useMetadata } from '../../providers/MetadataProvider.js';
import { formatPublishFailures, type PublishFailure } from '../../views/studio-design/metadataError.js';
Expand Down Expand Up @@ -1567,7 +1568,7 @@ export function AiChatPage({ apiBase: apiBaseProp, defaultAgent: defaultAgentPro
);

return (
<div className="flex h-svh w-full flex-col bg-background" data-testid="ai-chat-page">
<div className={cn('flex w-full flex-col bg-background', CONSOLE_FULL_HEIGHT.svh)} data-testid="ai-chat-page">
<header className={cn(CONSOLE_TOP_BAR, 'bg-background/95 backdrop-blur')}>
{/* Mobile: open the chats list as a sheet. The DESKTOP collapse toggle
is NOT in the top nav — it lives at the bottom-left of the chats
Expand Down
3 changes: 2 additions & 1 deletion ui/packages/app-shell/src/console/home/HomeLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import React, { useEffect, useMemo, useState } from 'react';
import { useNavigate } from 'react-router-dom';
import { cn } from '@object-ui/components';
import { useNavigationContext } from '../../context/NavigationContext.js';
import { CONSOLE_FULL_HEIGHT } from '../../layout/chromeBannerHost.js';
import { CommandPaletteProvider, useCommandPalette } from '../../context/CommandPaletteProvider.js';
import { CommandPalette } from '../../chrome/CommandPalette.js';
import { AppHeader } from '../../layout/AppHeader.js';
Expand Down Expand Up @@ -182,7 +183,7 @@ export function HomeLayout({ children, variant = 'home' }: HomeLayoutProps) {
{/* With the drawer's rail open the page is bounded to the window, so the
rail spans it and the page scrolls in its own box beside it. */}
<div
className={cn('flex w-full flex-col bg-background', chatDock.rail ? 'h-svh' : 'min-h-svh')}
className={cn('flex w-full flex-col bg-background', chatDock.rail ? CONSOLE_FULL_HEIGHT.svh : CONSOLE_FULL_HEIGHT.minSvh)}
data-testid="home-layout"
>
{/* The provider wraps the bar and the palette only: the page below
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import React, { useEffect } from 'react';
import { useNavigationContext } from '../../context/NavigationContext.js';
import { AppHeader } from '../../layout/AppHeader.js';
import { CONSOLE_TOP_BAR } from '../../layout/consoleTopBar.js';
import { CONSOLE_FULL_HEIGHT } from '../../layout/chromeBannerHost.js';

interface OrganizationsLayoutProps {
children: React.ReactNode;
Expand All @@ -25,7 +26,7 @@ export function OrganizationsLayout({ children }: OrganizationsLayoutProps) {
}, [setContext]);

return (
<div className="flex min-h-svh w-full flex-col bg-background" data-testid="organizations-layout">
<div className={`flex ${CONSOLE_FULL_HEIGHT.minSvh} w-full flex-col bg-background`} data-testid="organizations-layout">
<header className={CONSOLE_TOP_BAR}>
<AppHeader variant="orgs" />
</header>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { Button } from '@object-ui/components';
import { useNavigationContext } from '../../../context/NavigationContext.js';
import { AppHeader } from '../../../layout/AppHeader.js';
import { CONSOLE_TOP_BAR } from '../../../layout/consoleTopBar.js';
import { CONSOLE_FULL_HEIGHT } from '../../../layout/chromeBannerHost.js';

export function OrganizationLayout() {
const { t } = useObjectTranslation();
Expand Down Expand Up @@ -79,7 +80,7 @@ export function OrganizationLayout() {
];

return (
<div className="flex min-h-svh w-full flex-col bg-background" data-testid="organization-layout">
<div className={`flex ${CONSOLE_FULL_HEIGHT.minSvh} w-full flex-col bg-background`} data-testid="organization-layout">
<header className={CONSOLE_TOP_BAR}>
<AppHeader variant="orgs" />
</header>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.

/**
* The banners drawn in place, above the console's routes, publish their
* height as `--os-chrome-banners` so a full-height page can give it back
* (objectstack#37528). Drawn into an app layout's host they publish nothing:
* the host sits inside the content area the page already sizes.
*/
import { describe, it, expect, afterEach, beforeEach, vi } from 'vitest';
import { render, cleanup, act } from '@testing-library/react';
import * as React from 'react';
import {
CHROME_BANNERS_HEIGHT_VAR,
CONSOLE_FULL_HEIGHT,
ChromeBannerHost,
ChromeBannerSlot,
} from '../chromeBannerHost';

const observers: Array<{ callback: () => void }> = [];

class FakeResizeObserver {
callback: () => void;
constructor(callback: () => void) {
this.callback = callback;
observers.push(this);
}
observe() {}
unobserve() {}
disconnect() {}
}

/** Every element with `data-h` reports that many pixels of height. */
function stubHeights() {
return vi.spyOn(HTMLElement.prototype, 'getBoundingClientRect').mockImplementation(function (this: HTMLElement) {
const height = Number(this.getAttribute('data-h') ?? 0);
return { height, width: 0, top: 0, left: 0, right: 0, bottom: height, x: 0, y: 0, toJSON: () => ({}) } as DOMRect;
});
}

const published = () => document.documentElement.style.getPropertyValue(CHROME_BANNERS_HEIGHT_VAR);

beforeEach(() => {
observers.length = 0;
vi.stubGlobal('ResizeObserver', FakeResizeObserver);
document.documentElement.style.removeProperty(CHROME_BANNERS_HEIGHT_VAR);
});

afterEach(() => {
cleanup();
vi.unstubAllGlobals();
vi.restoreAllMocks();
});

describe('ChromeBannerSlot — the in-place banners publish their height (objectstack#37528)', () => {
it('in place: the summed height of the drawn banners, cleared on unmount', () => {
stubHeights();
const { unmount } = render(
<ChromeBannerSlot>
<div data-h="53">impersonating</div>
<div data-h="24">read rate</div>
</ChromeBannerSlot>,
);
expect(published()).toBe('77px');

unmount();
expect(published(), 'nothing drawn, nothing given back').toBe('');
});

it('in place with no banner drawn (an ordinary session): nothing is published', () => {
stubHeights();
render(<ChromeBannerSlot>{null}</ChromeBannerSlot>);
expect(published()).toBe('');
});

it('follows a banner that grows (it wraps on a narrow screen) or goes away', () => {
stubHeights();
const Banners = ({ show, height }: { show: boolean; height: number }) => (
<ChromeBannerSlot>{show ? <div data-h={String(height)}>impersonating</div> : null}</ChromeBannerSlot>
);
const { rerender, container } = render(<Banners show height={41} />);
expect(published()).toBe('41px');

container.querySelector('[data-h]')!.setAttribute('data-h', '77');
act(() => observers.forEach((o) => o.callback()));
expect(published(), 'a resize republishes').toBe('77px');

rerender(<Banners show={false} height={77} />);
act(() => observers.forEach((o) => o.callback()));
expect(published(), 'the banner ended').toBe('');
});

it("drawn into an app layout's host: nothing is published", () => {
stubHeights();
render(
<>
<ChromeBannerHost />
<ChromeBannerSlot>
<div data-h="53">impersonating</div>
</ChromeBannerSlot>
</>,
);
expect(document.querySelector('[data-testid="console-chrome-banners"]')?.textContent).toContain('impersonating');
expect(published()).toBe('');
});

it('the full-height classes take the viewport less the published height, 0 when unset', () => {
for (const cls of Object.values(CONSOLE_FULL_HEIGHT)) {
expect(cls).toContain(`var(${CHROME_BANNERS_HEIGHT_VAR},0px)`);
}
});
});
77 changes: 75 additions & 2 deletions ui/packages/app-shell/src/layout/chromeBannerHost.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,81 @@ export function ChromeBannerHost() {
return <div ref={ref} data-testid="console-chrome-banners" className="contents" />;
}

/** Draws `children` into the app layout's host when one is mounted, in place otherwise. */
/**
* The CSS custom property that carries the height of the banners drawn in
* place, above the console's routes: `0px` (unset) while none is drawn there.
*/
export const CHROME_BANNERS_HEIGHT_VAR = '--os-chrome-banners';

/**
* Full-height classes that give the banners drawn in place their height back
* (objectstack#37528). A banner in place is in flow above the page, so a page
* that takes the whole viewport would be taller than the window by the
* banner's height. Outside the console, or while no banner is drawn in place,
* the property is unset and these are the plain viewport heights.
*
* Literal strings, so Tailwind's scan sees every class.
*/
export const CONSOLE_FULL_HEIGHT = {
/** `h-screen` less the banners. */
screen: 'h-[calc(100vh-var(--os-chrome-banners,0px))]',
/** `h-svh` less the banners. */
svh: 'h-[calc(100svh-var(--os-chrome-banners,0px))]',
/** `min-h-svh` less the banners. */
minSvh: 'min-h-[calc(100svh-var(--os-chrome-banners,0px))]',
} as const;

/**
* Publishes the summed height of `wrapper`'s children as
* {@link CHROME_BANNERS_HEIGHT_VAR} on the document root, and clears it on
* unmount. The wrapper is `display: contents`, so the banners keep their own
* boxes (and the impersonation banner its `sticky`); each child is measured.
*/
function usePublishedBannerHeight(wrapper: React.RefObject<HTMLDivElement | null>) {
React.useLayoutEffect(() => {
const el = wrapper.current;
if (!el || typeof ResizeObserver === 'undefined') return undefined;
const root = document.documentElement;
const publish = () => {
let height = 0;
for (const child of Array.from(el.children)) height += child.getBoundingClientRect().height;
if (height > 0) root.style.setProperty(CHROME_BANNERS_HEIGHT_VAR, `${height}px`);
else root.style.removeProperty(CHROME_BANNERS_HEIGHT_VAR);
};
const sizes = new ResizeObserver(publish);
const observeChildren = () => {
sizes.disconnect();
for (const child of Array.from(el.children)) sizes.observe(child);
publish();
};
const children = typeof MutationObserver === 'undefined' ? null : new MutationObserver(observeChildren);
children?.observe(el, { childList: true });
observeChildren();
return () => {
sizes.disconnect();
children?.disconnect();
root.style.removeProperty(CHROME_BANNERS_HEIGHT_VAR);
};
}, [wrapper]);
}

function InPlaceBanners({ children }: { children: React.ReactNode }) {
const wrapper = React.useRef<HTMLDivElement | null>(null);
usePublishedBannerHeight(wrapper);
return (
<div ref={wrapper} className="contents" data-testid="console-chrome-banners-inline">
{children}
</div>
);
}

/**
* Draws `children` into the app layout's host when one is mounted, in place
* otherwise. In place, their height is published for the full-height pages
* below them ({@link CONSOLE_FULL_HEIGHT}); in the host it is not, since the
* host sits inside the content area the page already sizes.
*/
export function ChromeBannerSlot({ children }: { children: React.ReactNode }) {
const target = useChromeBannerHost();
return target ? createPortal(children, target) : <>{children}</>;
return target ? createPortal(children, target) : <InPlaceBanners>{children}</InPlaceBanners>;
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import { canonicalMetaUrlType } from '@objectstack/spec/shared';
import { resolveI18nLabel, type I18nLabel } from '@objectstack/spec/ui';
import { StudioChatDock, type StudioCopilotStatus, type StudioSurfaceLabel } from './StudioAiCopilot.js';
import { StudioRightSlot } from './StudioRightSlot.js';
import { CONSOLE_FULL_HEIGHT } from '../../layout/chromeBannerHost.js';
import { StudioTitleRowProvider } from './studioTitleRow.js';
import { useStudioAccentOnBody } from './studioAccent.js';
import { AssistantTopBarButton } from '../../layout/AssistantTopBarButton.js';
Expand Down Expand Up @@ -1351,7 +1352,7 @@ function StudioDesignSurfaceBody({ aiSlot, area }: StudioDesignSurfaceProps): Re
sidebar's, under Studio's own collapse cookie (`StudioMenu.tsx`). */}
{/* objectstack#37455 — Studio's graphite on its root: nothing Studio
draws takes the app's theme colour (decision 4 of #37424). */}
<StudioMenuProvider className={cn('h-screen min-h-0 overflow-hidden bg-background text-foreground', STUDIO_ACCENT)}>
<StudioMenuProvider className={cn(CONSOLE_FULL_HEIGHT.screen, 'min-h-0 overflow-hidden bg-background text-foreground', STUDIO_ACCENT)}>
{/* The ADR-0080 `aiSlot` seam — a cloud edition may still inject its own
* left copilot panel; the built-in copilot is the RIGHT dock below. */}
{/* objectstack#32615 — not beside a package that is not there. */}
Expand Down
5 changes: 4 additions & 1 deletion ui/packages/layout/src/AppShell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,10 @@ export function AppShell({
useAppShellBranding(branding, branding?.title);

return (
<SidebarProvider defaultOpen={defaultOpen} className="!flex-col h-svh overflow-hidden">
// The viewport less the banners the console draws above this shell
// (`--os-chrome-banners`, objectstack#37528); unset anywhere else. The
// `min-h-` replaces the sidebar wrapper's own `min-h-svh` (tailwind-merge).
<SidebarProvider defaultOpen={defaultOpen} className="!flex-col h-[calc(100svh-var(--os-chrome-banners,0px))] min-h-[calc(100svh-var(--os-chrome-banners,0px))] overflow-hidden">
{/* 1. Full-width top bar spanning entire screen. 48 px, the height of
every console frame's bar (objectui#12639): the class is the one
`@object-ui/app-shell` spells as `CONSOLE_TOP_BAR`, and that
Expand Down
Loading