From 6ea8f67f89f2ace42dc8d7433c54a23cdd0e2fbb Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 27 Sep 2026 19:51:59 +0000 Subject: [PATCH] fix(types,layout,app-shell,runner)!: render an app's branding.logo in the console; retire the top-level logo spelling UnifiedSidebar, the console's mounted sidebar, now reads the active app's branding.logo and shows it as a header image. An app without a logo keeps today's sidebar. Nothing mounted rendered the key before: its only reader was the never-mounted AppSidebar. The logo has one spelling. AppComponentSchema.logo is `never` on the TS face and refused by name on the zod mirror ("Did you mean logo -> branding?", the spec's own answer); wizardDraftToAppSchema stops copying the logo to the top level; AppSchemaRenderer and the runner's LayoutRenderer read branding.logo as an image URL and take an icon name from `icon`. Claude-Session: https://claude.ai/code/session_01MCg3z5cGrV51xEddpGcxEY Co-authored-by: Claude --- .../10827-app-branding-logo-one-spelling.md | 43 ++++ content/docs/core/app-schema.mdx | 11 +- content/docs/guide/console-architecture.md | 6 + .../app-shell/src/layout/UnifiedSidebar.tsx | 19 +- ...nsoleLayout.appBrandingLogo-10827.test.tsx | 217 ++++++++++++++++++ packages/layout/src/AppSchemaRenderer.tsx | 13 +- ...SchemaRenderer.brandingLogo-10827.test.tsx | 76 ++++++ packages/runner/src/LayoutRenderer.tsx | 12 +- ...LayoutRenderer.brandingLogo-10827.test.tsx | 69 ++++++ .../src/__tests__/app-creation-types.test.ts | 3 +- .../app-logo-one-spelling-10827.test.ts | 112 +++++++++ .../page-app-dashboard-spec-parity.test.ts | 6 +- .../src/__tests__/phase2-schemas.test.ts | 3 +- packages/types/src/app.ts | 24 +- packages/types/src/zod/app.zod.ts | 18 +- 15 files changed, 611 insertions(+), 21 deletions(-) create mode 100644 .changeset/10827-app-branding-logo-one-spelling.md create mode 100644 packages/app-shell/src/layout/__tests__/ConsoleLayout.appBrandingLogo-10827.test.tsx create mode 100644 packages/layout/src/__tests__/AppSchemaRenderer.brandingLogo-10827.test.tsx create mode 100644 packages/runner/src/__tests__/LayoutRenderer.brandingLogo-10827.test.tsx create mode 100644 packages/types/src/__tests__/app-logo-one-spelling-10827.test.ts diff --git a/.changeset/10827-app-branding-logo-one-spelling.md b/.changeset/10827-app-branding-logo-one-spelling.md new file mode 100644 index 0000000000..6f978e16b5 --- /dev/null +++ b/.changeset/10827-app-branding-logo-one-spelling.md @@ -0,0 +1,43 @@ +--- +'@object-ui/types': minor +'@object-ui/layout': patch +'@object-ui/app-shell': patch +'@object-ui/runner': patch +--- + +An app's `branding.logo` now shows in the console, and it is the only logo spelling +(objectui#10827). + +**The console renders it.** The designer (`AppCreationWizard`, `BrandingEditor`) writes an +app's `branding.logo` and previews it, but nothing mounted in the console drew it. Its only +reader was `AppSidebar`, which was never mounted and has since been removed. `UnifiedSidebar`, +the console's sidebar, now reads the active app's `branding.logo` and shows it as an image in a +header at the top of the sidebar. The image's alt text is the app's label. An app without a +logo gets no header, so its sidebar looks the same as before. The header appears only inside +an app. On Home the sidebar's fallback app is not the screen's app, so no logo is shown there. +`AppShellBranding` is unchanged: objectui#4818 removed its `logo` key, and this change does not +add it back. + +**One spelling — breaking for a top-level `logo`.** `@objectstack/spec` declares the app logo +only as `branding.logo` (a URL). Its app schema refuses a top-level `logo` and suggests +`branding`. objectui had a second spelling of its own: `AppComponentSchema.logo`, described as +"Logo URL or icon name". This change retires it: + +- `@object-ui/types`: `AppComponentSchema.logo` is now `never` on the TypeScript face, and the + zod mirror refuses a top-level `logo` by name, answering "Did you mean `logo` → `branding`?". + It is a named refusal rather than a deletion because the node is `.passthrough()`, and a + deleted key would be kept without any error. `wizardDraftToAppSchema` no longer copies the + draft's logo to the top level. The logo goes into `branding` only. +- `@object-ui/layout`: `AppSchemaRenderer`'s default sidebar header draws `branding.logo` as + an image. This includes site-relative paths and `data:` URIs, which the old read skipped + because it drew an image only for values starting with `http`. The header's icon now comes + from the app's `icon`. +- `@object-ui/runner`: `LayoutRenderer`'s sidebar brand mark does the same. It draws + `branding.logo` as an image and takes an icon name from `icon`. It no longer guesses the kind + of value from a `/` or `.`. + +Migration: move a top-level `logo` URL to `branding: { logo: '…' }`. An icon name that was +written as `logo` belongs in `icon`. The published 17.6.0 changelog entry that removed +`AppShellBranding.logo` says the top-level `logo` is "rendered directly by +`AppSchemaRenderer`'s default sidebar header". That is no longer true: the header reads +`branding.logo`. diff --git a/content/docs/core/app-schema.mdx b/content/docs/core/app-schema.mdx index 53bb21227a..4ea5765de8 100644 --- a/content/docs/core/app-schema.mdx +++ b/content/docs/core/app-schema.mdx @@ -36,7 +36,7 @@ const app: AppComponentSchema = { type: 'app', name: 'my-crm', title: 'My CRM Application', - logo: '/logo.svg', + branding: { logo: '/logo.svg' }, favicon: '/favicon.ico', layout: 'sidebar', @@ -65,9 +65,14 @@ topic; the declaration remains the complete list. | `name` | `string` | Application system identifier | | `title` | `string` | Display title shown in browser | | `description` | `string` | Application description | -| `logo` | `string` | Logo URL or icon name | +| `icon` | `string` | Lucide icon name | +| `branding.logo` | `string` | Logo image URL (or a `data:` URI) | | `favicon` | `string` | Favicon URL | +The logo has one spelling, `branding.logo`. A top-level `logo` is refused by the validator and +names `branding` as the fix (objectui#10827): it was a second spelling that `@objectstack/spec` +never declared. For an icon name, use `icon`. + ### Layout Configuration | Property | Type | Default | Description | @@ -182,7 +187,7 @@ const crm: AppComponentSchema = { name: 'acme-crm', title: 'Acme CRM', description: 'Customer Relationship Management System', - logo: '/acme-logo.svg', + branding: { logo: '/acme-logo.svg' }, favicon: '/favicon.ico', layout: 'sidebar', diff --git a/content/docs/guide/console-architecture.md b/content/docs/guide/console-architecture.md index 906274888f..b0db5c8b11 100644 --- a/content/docs/guide/console-architecture.md +++ b/content/docs/guide/console-architecture.md @@ -216,6 +216,12 @@ light-mode HSL triple and does not follow the light/dark toggle, whereas `--prim `--accent` carry the mode-adjusted value. Theme against the Shadcn tokens; treat the `--brand-*` names as an alias kept for whatever already consumes it. +**The app's logo is not part of that object.** `AppShellBranding` carries theme values and the +tab title only. An app's `branding.logo` (an image URL — the one logo spelling the app schema +declares) is drawn by `UnifiedSidebar`, which already resolves the active app: a header at the top +of the sidebar shows the image, with the app's label as its alt text. An app without a +`branding.logo` gets no header, so its sidebar is unchanged. + ## Development Mode There is **no bundled mock backend** — offline development is not a thing here. In dev exactly as diff --git a/packages/app-shell/src/layout/UnifiedSidebar.tsx b/packages/app-shell/src/layout/UnifiedSidebar.tsx index 2005a84c3b..0ef580a5b1 100644 --- a/packages/app-shell/src/layout/UnifiedSidebar.tsx +++ b/packages/app-shell/src/layout/UnifiedSidebar.tsx @@ -48,7 +48,7 @@ import { useRecentItems } from '../hooks/useRecentItems.js'; import { useFavorites } from '../hooks/useFavorites.js'; import { useNavPins } from '../hooks/useNavPins.js'; import { useNavActionDispatch } from '../hooks/useNavActionDispatch.js'; -import { matchAppBySegment, appRouteSegment } from '../utils/index.js'; +import { matchAppBySegment, appRouteSegment, resolveKeyedI18nLabel } from '../utils/index.js'; import { useHomePath } from '../hooks/useHomePath.js'; // Aliased for symmetry with objectui's own `resolveKeyedI18nLabel` above (the // names stopped colliding in objectui#4167): this is the spec's resolver (new in @@ -159,7 +159,7 @@ export function UnifiedSidebar({ activeAppName }: UnifiedSidebarProps) { const { isMobile, setOpenMobile } = useSidebar(); const location = useLocation(); const { t, language } = useObjectTranslation(); - const { objectLabel: resolveNavObjectLabel, dashboardLabel: resolveNavDashboardLabel, viewLabel: resolveNavViewLabel } = useObjectLabel(); + const { objectLabel: resolveNavObjectLabel, dashboardLabel: resolveNavDashboardLabel, viewLabel: resolveNavViewLabel, appLabel } = useObjectLabel(); const { context, currentAppName } = useNavigationContext(); const { user, activeOrganization } = useAuth(); const { isAdmin: isWorkspaceAdmin } = useWorkspaceAdminStatus(); @@ -205,6 +205,12 @@ export function UnifiedSidebar({ activeAppName }: UnifiedSidebarProps) { const activeApps = apps.filter((a: any) => a.active !== false && a.hidden !== true); // ADR-0048 (A) — route segment may be a package id; match by it (name fallback). const activeApp = matchAppBySegment(apps.filter((a: any) => a.active !== false), activeAppName || currentAppName) || activeApps[0]; + // The active app's logo (objectui#10827): `branding.logo`, the one spelling + // `@objectstack/spec` declares — an image URL. This is the console chrome's + // only reader of it. App context only: on Home `activeApp` falls back to the + // FIRST app, whose logo is not this screen's. No logo, no header — the + // sidebar renders exactly as it did before the key had a reader. + const appLogo: string | undefined = context === 'app' ? activeApp?.branding?.logo : undefined; // Drag-reorder and pin persistence const { applyOrder, handleReorder } = useNavOrder(activeApp?.name || 'home'); @@ -442,6 +448,15 @@ export function UnifiedSidebar({ activeAppName }: UnifiedSidebarProps) { return ( <> + {appLogo && ( + + {appLabel({ + + )} {/* Mobile-only "Home" affordance — the desktop topbar exposes Home via the platform logo + AppSwitcher pill, but those are hidden on phones. Without this row, users entering an app on mobile diff --git a/packages/app-shell/src/layout/__tests__/ConsoleLayout.appBrandingLogo-10827.test.tsx b/packages/app-shell/src/layout/__tests__/ConsoleLayout.appBrandingLogo-10827.test.tsx new file mode 100644 index 0000000000..bac614458d --- /dev/null +++ b/packages/app-shell/src/layout/__tests__/ConsoleLayout.appBrandingLogo-10827.test.tsx @@ -0,0 +1,217 @@ +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. + +/** + * The console chrome draws the active app's `branding.logo` (objectui#10827). + * + * `branding.logo` is authored by the designer (`AppCreationWizard`, + * `BrandingEditor`), documented, and set by downstream apps, and until this + * card nothing mounted in the console rendered it: its only reader was the + * never-mounted `AppSidebar`, removed by PR #10617. The mounted sidebar, + * `UnifiedSidebar`, now reads it — the chrome's one reader — and draws it as a + * header image. An app without a logo gets no header: today's sidebar, which + * is the control. + * + * ## Real subjects + * + * `ConsoleLayout` with its real `AppShell` (`@object-ui/layout`) and real + * `UnifiedSidebar`, under the real `NavigationProvider` — so the sidebar is in + * `app` context only because `ConsoleLayout` put it there, as in the running + * console. The stand-ins are the providers the sidebar reads (metadata, + * permissions, auth, expressions) and the siblings this card does not touch: + * the top bar (`AppHeader`), the chat dock and FAB, and the preview and + * notification bars. + * + * The logo is read from `[data-sidebar="sidebar"]`, the sidebar's own root, + * so no other surface can answer for it. + */ + +import '@testing-library/jest-dom/vitest'; +import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'; +import React from 'react'; +import { render, cleanup } from '@testing-library/react'; +import { MemoryRouter } from 'react-router-dom'; + +// Partial mock: @object-ui/components also imports from @object-ui/i18n +// (createSafeTranslation), so the rest of the module must stay real. +vi.mock('@object-ui/i18n', async (importOriginal) => ({ + ...(await importOriginal>()), + useObjectTranslation: () => ({ + t: (key: string, options?: Record) => String(options?.defaultValue ?? key), + language: 'en', + }), + useObjectLabel: () => ({ + objectLabel: ({ label }: { label?: string }) => label, + viewLabel: (_o: string, _v: string, fallback?: string) => fallback, + dashboardLabel: ({ label }: { label?: string }) => label, + appLabel: ({ name, label }: { name: string; label?: string }) => label || name, + }), +})); + +vi.mock('@object-ui/auth', async (importOriginal) => ({ + ...(await importOriginal>()), + useAuth: () => ({ user: null, activeOrganization: null }), + useWorkspaceAdminStatus: () => ({ isAdmin: false, isResolved: true }), +})); + +vi.mock('@object-ui/permissions', async (importOriginal) => ({ + ...(await importOriginal()), + usePermissions: () => ({ can: () => true, hasCapabilities: () => true }), +})); + +let metadataState: { apps: unknown[]; objects: unknown[] }; +vi.mock('../../providers/MetadataProvider', () => ({ + useMetadata: () => metadataState, +})); + +vi.mock('../../providers/ExpressionProvider', () => ({ + useExpressionContext: () => ({ evaluator: null }), + evaluateVisibility: (expr: unknown) => expr !== false && expr !== 'false', +})); + +// Lazy lucide DynamicIcon would suspend mid-test; a null icon is enough here. +vi.mock('../../utils/getIcon', () => ({ getIcon: () => () => null })); + +vi.mock('../../hooks/useRecentItems', () => ({ useRecentItems: () => ({ recentItems: [] }) })); +vi.mock('../../hooks/useFavorites', () => ({ + useFavorites: () => ({ favorites: [], removeFavorite: vi.fn() }), +})); +vi.mock('../../hooks/useNavPins', () => ({ + useNavPins: () => ({ togglePin: vi.fn(), applyPins: (items: unknown) => items }), +})); +vi.mock('../../hooks/useNavActionDispatch', () => ({ + useNavActionDispatch: () => vi.fn(), +})); +vi.mock('../ContextSelectors', () => ({ + useAppContextSelectors: () => ({ contextValues: {}, element: null }), + contextSelectorQueryKey: (id: string) => (id === 'active_package' ? 'package' : id), + STUDIO_PACKAGE_SELECTOR_ID: 'active_package', +})); +vi.mock('../LocalizedSidebarTrigger', () => ({ + LocalizedSidebarTrigger: () => null, +})); + +// Siblings in `ConsoleLayout` this card does not touch. +vi.mock('../AppHeader', () => ({ AppHeader: () =>
})); +vi.mock('../../hooks/useAiSurface', () => ({ + useAiSurfaceEnabled: () => ({ enabled: false, isLoading: false }), +})); +vi.mock('../ChatDock', () => ({ + useChatDockState: () => ({ + expanded: false, + width: 420, + dragging: false, + maximized: false, + toggle: vi.fn(), + expand: vi.fn(), + collapse: vi.fn(), + maximize: vi.fn(), + restore: vi.fn(), + onResizePointerDown: vi.fn(), + }), + ChatDockPanel: () => null, + ChatDockMobileSheet: () => null, +})); +vi.mock('../ConsoleChatbotFab', () => ({ ConsoleChatbotFab: () => null })); +vi.mock('../ConsoleNotificationBanners', () => ({ ConsoleNotificationBanners: () => null })); +vi.mock('../../preview/DraftPreviewBar', () => ({ DraftPreviewBar: () => null })); +vi.mock('../../preview/UnpublishedAppBar', () => ({ UnpublishedAppBar: () => null })); + +import { SidebarProvider } from '@object-ui/components'; +import { ConsoleLayout } from '../ConsoleLayout'; +import { UnifiedSidebar } from '../UnifiedSidebar'; +import { NavigationProvider } from '../../context/NavigationContext'; + +const LOGO = 'https://cdn.example.test/acme-logo.svg'; + +const NAV = [{ id: 'n1', type: 'object', label: 'Accounts', objectName: 'account' }]; + +/** The two apps an author can have: one with `branding.logo`, one without. */ +const BRANDED = { name: 'acme_crm', label: 'Acme CRM', active: true, branding: { primaryColor: '#2563eb', logo: LOGO }, navigation: NAV }; +const PLAIN = { name: 'plain_app', label: 'Plain App', active: true, branding: { primaryColor: '#2563eb' }, navigation: NAV }; + +function mountConsole(activeApp: Record, apps: Record[] = [activeApp]) { + metadataState = { apps, objects: [] }; + const name = String(activeApp.name); + return render( + + + +
page
+
+
+
, + ); +} + +function sidebarRoot(): HTMLElement { + const root = document.querySelector('[data-sidebar="sidebar"]'); + if (!root) throw new Error('the console chrome mounted no sidebar'); + return root; +} + +const imagesIn = (el: HTMLElement) => [...el.querySelectorAll('img')].map((img) => img.getAttribute('src')); + +beforeEach(() => { + localStorage.clear(); +}); +afterEach(() => cleanup()); + +describe('the console chrome renders the active app\'s `branding.logo` (objectui#10827)', () => { + it('an app with `branding.logo` shows it at the top of the sidebar, named by the app\'s label', () => { + const view = mountConsole(BRANDED); + // The mount is real: the route content and the sidebar's navigation render. + expect(view.getByTestId('route-content')).toBeInTheDocument(); + expect(view.getByText('Accounts')).toBeInTheDocument(); + + const sidebar = sidebarRoot(); + expect(imagesIn(sidebar)).toEqual([LOGO]); + expect(view.getByRole('img', { name: 'Acme CRM' })).toHaveAttribute('src', LOGO); + }); + + it('CONTROL — an app without a logo keeps today\'s sidebar: no image, same navigation', () => { + const view = mountConsole(PLAIN); + expect(view.getByText('Accounts')).toBeInTheDocument(); + expect(imagesIn(sidebarRoot())).toEqual([]); + }); + + it('the retired top-level `logo` renders nothing — only `branding.logo` is read', () => { + const aliasOnly = { ...PLAIN, name: 'alias_app', logo: LOGO }; + const view = mountConsole(aliasOnly); + expect(view.getByText('Accounts')).toBeInTheDocument(); + expect(imagesIn(sidebarRoot())).toEqual([]); + }); + + it('switching to a branded app shows ITS logo, not the first app\'s', () => { + // `PLAIN` is listed first: the sidebar must follow the active app. + mountConsole(BRANDED, [PLAIN, BRANDED]); + expect(imagesIn(sidebarRoot())).toEqual([LOGO]); + cleanup(); + mountConsole(PLAIN, [BRANDED, PLAIN]); + expect(imagesIn(sidebarRoot())).toEqual([]); + }); +}); + +describe('outside an app, the sidebar draws no app logo (objectui#10827)', () => { + it('home context, with a branded app first in the list, draws no image', () => { + // No `ConsoleLayout`, so nothing moves the context off `home` — where the + // sidebar's `activeApp` falls back to the FIRST app. + metadataState = { apps: [BRANDED, PLAIN], objects: [] }; + render( + + + + + , + ); + expect(imagesIn(sidebarRoot())).toEqual([]); + }); +}); + +/** The real sidebar in the real `SidebarProvider`, as `AppShell` mounts it. */ +function SidebarHost() { + return ( + + + + ); +} diff --git a/packages/layout/src/AppSchemaRenderer.tsx b/packages/layout/src/AppSchemaRenderer.tsx index bb80d37f60..f887fc0127 100644 --- a/packages/layout/src/AppSchemaRenderer.tsx +++ b/packages/layout/src/AppSchemaRenderer.tsx @@ -381,7 +381,12 @@ function InternalSidebar({ enableReorder?: boolean; onReorder?: (reorderedItems: NavigationItem[]) => void; }) { - const Icon = resolveIcon(schema.logo); + // The app logo is `branding.logo`, an image URL (objectui#10827) — the one + // spelling `@objectstack/spec` declares. An icon NAME comes from `icon`, the + // key every other app surface reads; the retired top-level `logo` carried + // both and is read by nothing. + const logo = schema.branding?.logo; + const Icon = resolveIcon(schema.icon); const [searchQuery, setSearchQuery] = useState(''); return ( @@ -393,9 +398,9 @@ function InternalSidebar({
- {schema.logo && schema.logo.startsWith('http') ? ( + {logo ? ( {schema.title @@ -473,7 +478,7 @@ function InternalSidebar({ * Renders a complete application shell from an `AppSchema` JSON document. * * Responsibilities: - * - Reads `name`, `title`, `description`, `logo`, `favicon` for branding + * - Reads `name`, `title`, `description`, `icon`, `branding.logo`, `favicon` for branding * - Renders sidebar navigation from `navigation` or `areas[].navigation` * - Area switcher when multiple areas are VISIBLE — area visibility is * derived from the items inside, not authored (objectui#3311): an area diff --git a/packages/layout/src/__tests__/AppSchemaRenderer.brandingLogo-10827.test.tsx b/packages/layout/src/__tests__/AppSchemaRenderer.brandingLogo-10827.test.tsx new file mode 100644 index 0000000000..d436fd7d4d --- /dev/null +++ b/packages/layout/src/__tests__/AppSchemaRenderer.brandingLogo-10827.test.tsx @@ -0,0 +1,76 @@ +/** + * ObjectUI + * Copyright (c) 2024-present ObjectStack Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +/** + * `AppSchemaRenderer`'s default sidebar header draws the app logo from + * `branding.logo` (objectui#10827). + * + * Before, the header read a top-level `logo` — a second spelling that + * `@objectstack/spec` never declared — as EITHER an image (only when it + * started with `http`) OR a Lucide icon name. `branding.logo`, the spelling + * every designer writes, was never read here. Now the header draws + * `branding.logo` as an image whatever kind of URL it is, and takes an icon + * name from `icon` only. The retired top-level key draws nothing. + * + * The header is read inside the sidebar's own `[data-sidebar="header"]`, so + * a navigation icon elsewhere cannot answer for it. + */ + +import { describe, it, expect, afterEach } from 'vitest'; +import { render, cleanup } from '@testing-library/react'; +import { MemoryRouter } from 'react-router-dom'; +import type { AppComponentSchema } from '@object-ui/types'; +import { AppSchemaRenderer } from '../AppSchemaRenderer'; + +afterEach(() => cleanup()); + +const BASE: AppComponentSchema = { type: 'app', name: 'acme_crm', title: 'Acme CRM' }; + +function sidebarHeader(schema: AppComponentSchema): HTMLElement { + render( + + +
page
+
+
, + ); + const header = document.querySelector('[data-sidebar="header"]'); + if (!header) throw new Error('AppSchemaRenderer drew no sidebar header'); + return header; +} + +const imagesIn = (el: HTMLElement) => [...el.querySelectorAll('img')].map((img) => img.getAttribute('src')); + +describe('AppSchemaRenderer draws `branding.logo` in its sidebar header (objectui#10827)', () => { + it.each([ + ['a site-relative path', '/assets/acme-logo.png'], + ['an absolute URL', 'https://cdn.example.test/acme.svg'], + ['a data URI', 'data:image/png;base64,iVBORw0KGgo='], + ])('draws %s as the header image, with the app title as its alt text', (_kind, url) => { + const header = sidebarHeader({ ...BASE, branding: { logo: url } }); + expect(imagesIn(header)).toEqual([url]); + expect(header.querySelector('img')?.getAttribute('alt')).toBe('Acme CRM'); + }); + + it('CONTROL — an app with no logo draws no image, and the default icon', () => { + const header = sidebarHeader(BASE); + expect(imagesIn(header)).toEqual([]); + expect(header.querySelector('svg.lucide-file-text')).not.toBeNull(); + }); + + it('the retired top-level `logo` draws nothing — not as an image, not as an icon name', () => { + // Cast past the type, as a stale document handed straight to the renderer + // would be: the key is `never` on the TS face and refused by the mirror. + const asImage = sidebarHeader({ ...BASE, logo: 'https://cdn.example.test/acme.svg' } as unknown as AppComponentSchema); + expect(imagesIn(asImage)).toEqual([]); + cleanup(); + const asIconName = sidebarHeader({ ...BASE, logo: 'Briefcase' } as unknown as AppComponentSchema); + // Same tile as the no-logo control: the key is not read as an icon name. + expect(asIconName.querySelector('svg.lucide-file-text')).not.toBeNull(); + }); +}); diff --git a/packages/runner/src/LayoutRenderer.tsx b/packages/runner/src/LayoutRenderer.tsx index ed0cc548d9..dec86db2ca 100644 --- a/packages/runner/src/LayoutRenderer.tsx +++ b/packages/runner/src/LayoutRenderer.tsx @@ -150,7 +150,11 @@ export const LayoutRenderer = ({ app, children, currentPath, onNavigate }: Layou return
{children}
; } - const LogoIcon = app.logo && !app.logo.includes('/') && !app.logo.includes('.') ? getIcon(app.logo) : null; + // The app logo is `branding.logo`, an image URL (objectui#10827), and an + // icon NAME comes from `icon`. The retired top-level `logo` carried both, + // told apart by sniffing for `/` or `.`; nothing reads it now. + const logo = app.branding?.logo; + const LogoIcon = getIcon(app.icon); return (
@@ -163,11 +167,11 @@ export const LayoutRenderer = ({ app, children, currentPath, onNavigate }: Layou `} >
- {LogoIcon ? ( + {logo ? ( + {app.title} + ) : LogoIcon ? ( // eslint-disable-next-line react-hooks/static-components -- getLazyIcon returns a module-cached stable component per name, not one created during render - ) : app.logo ? ( - {app.title} ) : } diff --git a/packages/runner/src/__tests__/LayoutRenderer.brandingLogo-10827.test.tsx b/packages/runner/src/__tests__/LayoutRenderer.brandingLogo-10827.test.tsx new file mode 100644 index 0000000000..113216d3a1 --- /dev/null +++ b/packages/runner/src/__tests__/LayoutRenderer.brandingLogo-10827.test.tsx @@ -0,0 +1,69 @@ +/** + * ObjectUI + * Copyright (c) 2024-present ObjectStack Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +/** + * The runner's sidebar brand mark reads `branding.logo` (objectui#10827). + * + * `LayoutRenderer` used to read a top-level `logo`, a second spelling + * `@objectstack/spec` never declared, and guess its kind: a value with no `/` + * and no `.` was an icon name, anything else an image URL. The logo now has + * one spelling, `branding.logo`, drawn as an image; an icon name comes from + * `icon`; with neither, the `Box` mark stays — the control. + * + * Read inside the `