Skip to content
Merged
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
12 changes: 12 additions & 0 deletions .changeset/29024-hidden-app-avatar-menu-address.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
'@object-ui/app-shell': patch
---

fix(app-shell): an app that shares its package with the package's first app opens itself from the avatar menu, the ⌘K palette, the app switcher, Home's tiles and the report index's other-apps links

Clause-②: no
Metadata-protocol: none

`/apps/PACKAGE_ID` opens a package's first app, so a link keyed on the package id cannot reach the package's other apps; their name is the only address that does. The avatar menu's entry for a hidden app linked to its package id, so a hidden app shipped beside its package's main app (a settings-style app) opened the main app instead and could not be reached from the menu at all. The ⌘K palette's "Switch app" items, the app switcher's rows, Home's "Your apps" tiles (and the `app:launcher` block, which draws the same tiles) and the empty report index's "Reports in your other apps" links had the same fault for every non-first app of a package.

Each now links to the app's one address, the address the Console already resolves an open app to: the package id when it opens this very app, else the app's name. An app that is the only or first app of its package keeps its package-id address. Home's tiles resolve the address among the full app list, hidden apps included, so a visible app behind its package's hidden first app also opens itself.
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.

/**
* objectstack-ai/objectstack#29024 — the ⌘K palette's "Switch app" item opens
* the app it names, a package's non-first app included.
*
* `/apps/PACKAGE_ID` resolves to the package's FIRST app, so switching by the
* package id opened that first app for every other app of the package (a
* hidden one, which the palette offers too, included). The item now hands
* `onAppChange` the app's one address (`appAddressSegment`): the package id
* where it resolves back to the app, else the app's name.
*
* The harness is `CommandPalette.launcherHiddenApps-26838.test.tsx`'s.
*/

import * as React from 'react';
import { describe, it, expect, vi, afterEach, beforeEach } from 'vitest';
import { render, waitFor, cleanup, fireEvent } from '@testing-library/react';
import { MemoryRouter } from 'react-router-dom';
import { createI18n, I18nProvider } from '@object-ui/i18n';

const state = vi.hoisted(() => ({ apps: [] as Array<Record<string, unknown>> }));

vi.mock('@object-ui/auth', async (importOriginal) => ({
...(await importOriginal<Record<string, unknown>>()),
useAuth: () => ({ user: { id: 'u1' }, activeOrganization: null }),
}));
// The provider reads the app list from the metadata cache; the rest of the
// cache is the real (empty) one the palette's other groups read.
vi.mock('../providers/MetadataProvider', async (importOriginal) => {
const actual = await importOriginal<typeof import('../providers/MetadataProvider')>();
return {
...actual,
useMetadata: () => ({ ...actual.useMetadata(), apps: state.apps, loading: false }),
};
});

import { CommandPalette } from './CommandPalette';
import { CommandPaletteProvider } from '../context/CommandPaletteProvider';
import { LauncherAppsProvider } from '../hooks/useLauncherApps';

const FIRST = { name: 'qsixn_app', label: 'R6 App', _packageId: 'com.qa.r6nav', navigation: [] };
const SECOND = { name: 'qsixn_hidden_app', label: 'R6 Hidden App', hidden: true, _packageId: 'com.qa.r6nav', navigation: [] };
const SOLO = { name: 'solo_app', label: 'Solo', _packageId: 'com.qa.solo', navigation: [] };

function mount(onAppChange: (segment: string) => void) {
render(
<I18nProvider instance={createI18n({ defaultLanguage: 'en', detectBrowserLanguage: false })} persistLanguage={false}>
<MemoryRouter initialEntries={['/apps/com.qa.solo?palette=1']}>
<LauncherAppsProvider endpoint="/me-apps-double" fetcher={(async () => new Response('{}', { status: 404 })) as unknown as typeof fetch}>
<CommandPaletteProvider>
<CommandPalette
apps={state.apps}
activeApp={SOLO}
objects={[]}
onAppChange={onAppChange}
dataSource={{ find: vi.fn(async () => ({ data: [] })), searchAll: vi.fn(async () => ({ hits: [] })) }}
/>
</CommandPaletteProvider>
</LauncherAppsProvider>
</MemoryRouter>
</I18nProvider>,
);
if (!document.querySelector('[cmdk-input]')) throw new Error('the palette did not open');
}

/** The cmdk item of the app labelled `label`. */
function appItem(label: string): Element {
const item = Array.from(document.querySelectorAll('[cmdk-item][data-value^="app "]')).find(
(el) => (el.textContent ?? '').replace(/Current$/, '').trim() === label,
);
if (!item) throw new Error(`no "Switch app" item for ${label}`);
return item;
}

beforeEach(() => {
state.apps = [FIRST, SECOND, SOLO];
});

afterEach(() => cleanup());

describe('the palette switches to the app it names (objectstack-ai/objectstack#29024)', () => {
it('a package\'s second app is switched to by its name', async () => {
const onAppChange = vi.fn();
mount(onAppChange);
await waitFor(() => appItem('R6 Hidden App'));
fireEvent.click(appItem('R6 Hidden App'));
await waitFor(() => expect(onAppChange).toHaveBeenCalledWith('qsixn_hidden_app'));
});

it('a package\'s first app keeps its package-id address', async () => {
const onAppChange = vi.fn();
mount(onAppChange);
await waitFor(() => appItem('R6 App'));
fireEvent.click(appItem('R6 App'));
await waitFor(() => expect(onAppChange).toHaveBeenCalledWith('com.qa.r6nav'));
});
});
2 changes: 1 addition & 1 deletion ui/packages/app-shell/src/chrome/CommandPalette.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,7 @@ function CommandPaletteBody(props: CommandPaletteProps & { gates: NavMemberGates
<CommandItem
key={app.name}
value={`app ${resolveKeyedI18nLabel(app.label, t)} ${app.name}`}
onSelect={() => runCommand(() => confirmUnsavedLeave(() => onAppChange(appRouteSegment(app) ?? app.name)))}
onSelect={() => runCommand(() => confirmUnsavedLeave(() => onAppChange(appAddressSegment(apps, app) ?? app.name)))}
>
<Icon className="mr-2 h-4 w-4" />
<span>{resolveKeyedI18nLabel(app.label, t)}</span>
Expand Down
19 changes: 15 additions & 4 deletions ui/packages/app-shell/src/console/home/HomeAppsStrip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ import { Link } from 'react-router-dom';
import { LayoutGrid, Plus, Settings, Star } from 'lucide-react';
import { cn } from '@object-ui/components';
import { useDisplayLocale, useObjectTranslation, useObjectLabel } from '@object-ui/i18n';
import { appRouteSegment, resolveKeyedI18nLabel } from '../../utils/index.js';
import { resolveKeyedI18nLabel } from '../../utils/index.js';
import { appAddressSegment } from '../../utils/appRoute.js';
import { getIcon } from '../../utils/getIcon.js';
import { timeAgo } from '../../utils/relativeTime.js';
import { TILE_OPENED_TIME_FORMAT } from './appLastOpened.js';
Expand Down Expand Up @@ -101,6 +102,7 @@ function LauncherAppIcon({ app, children }: { app: any; children?: ReactNode })

export function HomeAppsStrip({
apps,
routeApps,
favorites,
onBrowseMarketplace,
isAdmin,
Expand All @@ -111,6 +113,14 @@ export function HomeAppsStrip({
lastOpened,
}: {
apps: any[];
/**
* Every app the console's `/apps/SEGMENT` route resolves against: the
* metadata app list, hidden apps included. A tile links to its app's one
* address among THESE (`appAddressSegment`), never among `apps`: a package
* whose first app is hidden or withheld still opens that first app on its
* package id, so the tile list alone would misaddress the package's others.
*/
routeApps: readonly any[];
favorites: FavoriteItem[];
onBrowseMarketplace: () => void;
isAdmin: boolean;
Expand Down Expand Up @@ -224,9 +234,10 @@ export function HomeAppsStrip({
return (
<Link
key={app.name}
// ADR-0048: the route segment is the package id, falling back to
// the app name for apps with none.
to={`/apps/${appRouteSegment(app)}`}
// ADR-0048: the app's one address — its package id, or its name
// when it is not its package's first app (the package id opens
// that first app instead).
to={`/apps/${appAddressSegment(routeApps, app)}`}
className={TILE_CLASSES}
data-testid={`app-tile-${app.name}`}
>
Expand Down
1 change: 1 addition & 0 deletions ui/packages/app-shell/src/console/home/HomePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -799,6 +799,7 @@ export function HomePage() {
the heading's "System Settings" link rather than a tile */}
<HomeAppsStrip
apps={launcherApps}
routeApps={apps}
favorites={favorites}
settingsHref={setupApp ? setupPath : undefined}
settingsLabel={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ function renderStrip(apps: Record<string, unknown>[], favorites: { id: string }[
<MemoryRouter initialEntries={['/home']}>
<HomeAppsStrip
apps={apps}
routeApps={apps}
favorites={favorites as any}
onBrowseMarketplace={() => {}}
isAdmin={false}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.

/**
* objectstack-ai/objectstack#29024 — a "Your apps" tile opens the app it
* names, a package's second app included.
*
* `/apps/PACKAGE_ID` resolves to the package's FIRST app among the metadata
* app list, so a tile keyed on the package id opened that first app for every
* other app of the package. A tile now links to the app's one address
* (`appAddressSegment`) among `routeApps`, the list the route resolves on:
* the package id where it resolves back to the app, else the app's name.
* Resolving among the tiles alone would miss a package whose first app is
* hidden (no tile) and so still opens on the package id.
*
* A real render inside a `MemoryRouter`, as `HomeAppsStrip.tilesAreLinks-12305`.
*/

import '@testing-library/jest-dom/vitest';
import { describe, it, expect, afterEach } from 'vitest';
import React from 'react';
import { render, screen, cleanup } from '@testing-library/react';
import { MemoryRouter } from 'react-router-dom';
import { HomeAppsStrip } from '../HomeAppsStrip';

const R6_APP = { name: 'r6_app', label: 'R6 App', _packageId: 'com.qa.r6nav' };
const R6_BOARD = { name: 'r6_board', label: 'R6 Board', _packageId: 'com.qa.r6nav' };
const LEAD_SETTINGS = { name: 'lead_settings', label: 'Lead Settings', hidden: true, _packageId: 'com.qa.lead' };
const LEAD_APP = { name: 'lead_app', label: 'Lead App', _packageId: 'com.qa.lead' };
const SOLO = { name: 'solo', label: 'Solo', _packageId: 'com.qa.solo' };

/** The metadata app list; the tiles are its visible apps, as Home passes them. */
const ROUTE_APPS = [R6_APP, R6_BOARD, LEAD_SETTINGS, LEAD_APP, SOLO];
const TILES = [R6_APP, R6_BOARD, LEAD_APP, SOLO];

afterEach(() => cleanup());

function renderStrip() {
render(
<MemoryRouter initialEntries={['/home']}>
<HomeAppsStrip apps={TILES} routeApps={ROUTE_APPS} favorites={[]} onBrowseMarketplace={() => {}} isAdmin={false} />
</MemoryRouter>,
);
}

describe('HomeAppsStrip tiles open the app they name (objectstack-ai/objectstack#29024)', () => {
it('a package\'s second app links by its name; the first keeps its package id', () => {
renderStrip();
expect(screen.getByTestId('app-tile-r6_board')).toHaveAttribute('href', '/apps/r6_board');
expect(screen.getByTestId('app-tile-r6_app')).toHaveAttribute('href', '/apps/com.qa.r6nav');
});

it('a visible app behind its package\'s hidden first app links by its name', () => {
renderStrip();
expect(screen.queryByTestId('app-tile-lead_settings')).toBeNull();
expect(screen.getByTestId('app-tile-lead_app')).toHaveAttribute('href', '/apps/lead_app');
});

it('an app alone in its package keeps its package-id address', () => {
renderStrip();
expect(screen.getByTestId('app-tile-solo')).toHaveAttribute('href', '/apps/com.qa.solo');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ function renderStrip(
<LocationProbe />
<HomeAppsStrip
apps={apps}
routeApps={apps}
favorites={[]}
onBrowseMarketplace={() => {}}
isAdmin={false}
Expand Down
10 changes: 8 additions & 2 deletions ui/packages/app-shell/src/layout/AppHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ import type { BreadcrumbItem as BreadcrumbItemType } from '@object-ui/types';
import { useAuth, getUserInitials } from '@object-ui/auth';
import { useMetadata } from '../providers/MetadataProvider.js';
import { useBundledReads } from '../providers/bundledReads.js';
import { resolveKeyedI18nLabel, preferLocal, matchAppBySegment, appRouteSegment, appStudioRoutePath } from '../utils/index.js';
import { resolveKeyedI18nLabel, preferLocal, matchAppBySegment, appStudioRoutePath } from '../utils/index.js';
import { appAddressSegment } from '../utils/appRoute.js';
import { getIcon } from '../utils/getIcon.js';
import { useNavigationContext } from '../context/NavigationContext.js';
import { useCommandPalette, useCommandPaletteProviderMounted } from '../context/CommandPaletteProvider.js';
Expand Down Expand Up @@ -1290,6 +1291,11 @@ export function AppHeader({
* next to business apps — Personal Settings, etc. The `account`
* app is represented by the explicit Profile link above, so it
* is filtered out here to avoid a duplicate (dead) entry.
*
* Each entry links to the app's one address (`appAddressSegment`),
* never its bare package id: a hidden app that shares its package
* with the package's first app is reached by its name alone, and
* the package id would open that first app instead.
*/}
{(metadataApps || [])
.filter((a: any) => a.active !== false && a.hidden === true && a.name !== 'account')
Expand All @@ -1299,7 +1305,7 @@ export function AppHeader({
return (
<DropdownMenuItem
key={`hidden_app_${app.name}`}
onClick={() => leaveTo(`/apps/${appRouteSegment(app) ?? app.name}`)}
onClick={() => leaveTo(`/apps/${appAddressSegment(metadataApps, app)}`)}
className="cursor-pointer"
>
<AppIcon className="mr-2 h-4 w-4" />
Expand Down
3 changes: 2 additions & 1 deletion ui/packages/app-shell/src/layout/AppSwitcher.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import {
import { ChevronDown, Check, Eye, Home, LayoutGrid, Pencil, Settings } from 'lucide-react';
import { useMetadata } from '../providers/MetadataProvider.js';
import { resolveKeyedI18nLabel, matchAppBySegment, appRouteSegment } from '../utils/index.js';
import { appAddressSegment } from '../utils/appRoute.js';
import { useObjectTranslation, useObjectLabel } from '@object-ui/i18n';
import { useHomePath } from '../hooks/useHomePath.js';
import { useLauncherApps } from '../hooks/useLauncherApps.js';
Expand Down Expand Up @@ -166,7 +167,7 @@ export function AppSwitcher({ activeAppName, onAppChange, designInStudioPath, st
return (
<DropdownMenuItem
key={app.name}
onClick={() => onAppChange(appRouteSegment(app) ?? app.name)}
onClick={() => onAppChange(appAddressSegment(apps, app) ?? app.name)}
className="flex items-center gap-2.5 py-2"
data-testid={`app-switcher-row-${app.name}`}
>
Expand Down
Loading
Loading