Skip to content

Commit c31701a

Browse files
committed
fix(app-shell): launcher surfaces narrow the app list by the user's /me/apps answer
Home's tiles, the app switcher menu and the app:launcher block listed GET /meta/app, which still serves an app a permission set hides (tabPermissions: hidden); the hide is applied only in GET /me/apps. A LauncherAppsProvider, mounted in the console's ConsolePermissionsScope, reads /me/apps once per user and useLauncherApps narrows each surface's list by its app names. No provider, a 404 or a failed read narrows nothing. Claude-Session: https://claude.ai/code/session_01JQwxbYwBbR8jCpWPE5Kosz Co-authored-by: Claude <noreply@anthropic.com>
1 parent 0b78a20 commit c31701a

8 files changed

Lines changed: 278 additions & 15 deletions

File tree

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
'@object-ui/app-shell': patch
3+
'@object-ui/console': patch
4+
---
5+
6+
fix(app-shell): Home, the app switcher and the `app:launcher` block no longer offer an app the user's permission sets hide
7+
8+
Clause-②: no
9+
Metadata-protocol: none
10+
11+
A permission set's `tabPermissions: { APP: 'hidden' }` hides an app from the member's launcher. The server applies that hide in one place, `GET /api/v1/me/apps`, and the console never read it: Home's tiles, the app switcher's menu and the `app:launcher` page block all listed `GET /api/v1/meta/app`, which still serves the hidden app because a hidden app keeps opening from a direct URL. So the member saw, and could open, the tile their admin had hidden.
12+
13+
What changes:
14+
15+
- The console reads `GET /api/v1/me/apps` once per user, beside its `/auth/me/permissions` read, and every launcher surface narrows its `/meta/app` list by that answer's app names. The tiles keep the labels, icons and publish state `/meta/app` serves.
16+
- An app the answer was not asked about is not hidden by it: an app that is installed or published after the read stays on the launcher, and the console asks again.
17+
- Home waits for the first answer, as it waits for the app list, so a hidden tile is never drawn and then removed.
18+
- A deployment without the security plugin answers `404` there; the launcher then lists every app the user can open, as before. Any other failure does the same and says so once on the browser console.
19+
- A hidden app still opens from its URL, and the switcher still names it while the user is in it. `default_off` is not a hide and changes nothing.
20+
21+
What to do: nothing. A permission set that already hides an app now hides it on Home, in the switcher and in launcher blocks.

‎ui/apps/console/src/AppContent.tsx‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
import { lazy, Suspense, useMemo, type ReactNode } from 'react';
1313
import { Route, useParams, useLocation, Navigate } from 'react-router-dom';
14-
import { DefaultAppContent, ENVIRONMENT_SCOPE_QUERY, LoadingScreen, useAdapter } from '@object-ui/app-shell';
14+
import { DefaultAppContent, ENVIRONMENT_SCOPE_QUERY, LauncherAppsProvider, LoadingScreen, useAdapter } from '@object-ui/app-shell';
1515
import { AdapterCtx } from '@object-ui/react';
1616
import { MePermissionsProvider, ServerReadScope } from '@object-ui/permissions';
1717
import { createAuthenticatedFetch } from '@object-ui/auth';
@@ -406,7 +406,13 @@ export function ConsolePermissionsScope({ children }: { children: ReactNode }) {
406406
// error + retry affordance all along.
407407
errorFallback={(err, retry) => <LoadingScreen error={err.message} onRetry={retry} />}
408408
>
409-
{children}
409+
{/* objectstack#26838 — the apps a launcher offers (Home's tiles, the app
410+
switcher, the `app:launcher` block) are the `/me/apps` answer, which
411+
drops an app the user's permission sets hide. One read for Home and
412+
every app, so this common ancestor holds it, beside the answer above. */}
413+
<LauncherAppsProvider endpoint={`${serverUrl}/api/v1/me/apps`} fetcher={authFetch}>
414+
{children}
415+
</LauncherAppsProvider>
410416
</MePermissionsProvider>
411417
);
412418
}

‎ui/packages/app-shell/src/console/home/HomePage.tsx‎

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import { RecoveryPasswordReminder } from './RecoveryPasswordReminder.js';
3838
import { HomeActionCenter, HomeContinue, HomeActivity, HomePendingDraftsRow, type RecentItemContext } from './HomeRail.js';
3939
import { resolveI18nLabel } from '@objectstack/spec/ui';
4040
import { useHomeInbox } from '../../hooks/useHomeInbox.js';
41+
import { useLauncherApps } from '../../hooks/useLauncherApps.js';
4142
import { useNavigationContext } from '../../context/NavigationContext.js';
4243
import {
4344
appRouteSegment,
@@ -415,6 +416,12 @@ export function HomePage() {
415416
});
416417

417418
const activeApps = filterActiveApps(apps);
419+
// The apps the tiles and the System Settings link offer: the active list
420+
// narrowed by the user's `/me/apps` answer, so an app a permission set hides
421+
// draws no tile (objectstack#26838). The other readings below — the host
422+
// app, a recent row's app label — keep the full list: a hidden app still
423+
// opens, so a link into it or a label for it is still true.
424+
const launcher = useLauncherApps(apps);
418425

419426
/**
420427
* Which app hosts the app-independent pages this page links into — the
@@ -445,8 +452,8 @@ export function HomePage() {
445452
* user can open, exactly where its tile used to be drawn.
446453
*/
447454
const setupPath = resolveSetupAppPath(activeApps);
448-
const setupApp = activeApps.find((app) => `/apps/${appRouteSegment(app)}` === setupPath);
449-
const launcherApps = setupApp ? activeApps.filter((app) => app !== setupApp) : activeApps;
455+
const setupApp = launcher.apps.find((app) => `/apps/${appRouteSegment(app)}` === setupPath);
456+
const launcherApps = setupApp ? launcher.apps.filter((app) => app !== setupApp) : launcher.apps;
450457
// When each tile's app was last open — the recent-items store's newest entry
451458
// inside it (objectui#12601; the reading is `lastOpenedByApp`'s).
452459
const lastOpened = lastOpenedByApp(launcherApps, recentItems);
@@ -527,8 +534,9 @@ export function HomePage() {
527534
// the verdict still in flight drops the admin entries and adds them back a
528535
// moment later. `isResolved` is true the instant `isAdmin` is, so an admin the
529536
// session already identifies waits nothing; this only holds the frame that
530-
// would otherwise be built on a guess.
531-
if (loading || !isAdminResolved) {
537+
// would otherwise be built on a guess. The first `/me/apps` read joins it
538+
// too, so a hidden app's tile is never drawn and then taken away.
539+
if (loading || !isAdminResolved || launcher.pending) {
532540
return (
533541
<div className="flex flex-1 items-center justify-center py-20">
534542
<div className="text-muted-foreground">{t('home.loading', { defaultValue: 'Loading…' })}</div>

‎ui/packages/app-shell/src/hooks/index.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@ export {
6363
} from './useUrlOverlay.js';
6464
export { useTenancyPosture } from './useTenancyPosture.js';
6565
export { useHomePath } from './useHomePath.js';
66+
export {
67+
LauncherAppsProvider,
68+
useLauncherApps,
69+
type LauncherApps,
70+
type LauncherAppsProviderProps,
71+
} from './useLauncherApps.js';
6672
export { useTrackRouteAsRecent, type UseTrackRouteAsRecentOptions } from './useTrackRouteAsRecent.js';
6773
export {
6874
sanitizeChatMessagesForCache,
Lines changed: 212 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,212 @@
1+
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
2+
3+
/**
4+
* `useLauncherApps` — the apps a launcher surface offers, as the SERVER filters
5+
* them for this user (objectstack#26838).
6+
*
7+
* `GET /api/v1/meta/app` serves every app the caller may open, routing
8+
* included: a permission set's `tabPermissions: { <app>: 'hidden' }` does not
9+
* withhold an app there, and must not — a hidden app keeps opening from a
10+
* direct URL (UI visibility, not access control). The hide is applied in one
11+
* place, `GET /api/v1/me/apps`, which merges the caller's sets (most visible
12+
* wins) and drops the hidden ones. Home read the first list and drew a tile
13+
* for an app the member's set hides; the app switcher and the `app:launcher`
14+
* page block read the same list and offered it too.
15+
*
16+
* So every launcher surface narrows its `/meta/app` list through this hook,
17+
* and the hook through ONE read of `/me/apps` per user, held by
18+
* {@link LauncherAppsProvider}. Three surfaces, one answer: they cannot
19+
* disagree about which app is offered.
20+
*
21+
* What the answer narrows, and what it leaves:
22+
*
23+
* - The list keeps `/meta/app`'s entries — their labels, icons, package ids
24+
* and publish state are that route's. `/me/apps` contributes NAMES only.
25+
* - An app the answer was never asked about is not hidden by it. The provider
26+
* records the active app names it asked with; an app that arrives later (an
27+
* install, a publish) passes until the re-read it triggers lands, rather
28+
* than vanishing from the launcher it was just installed into.
29+
* - No provider mounted, a `404` (no security plugin serves the route), or a
30+
* failed read: nothing narrows, and the surface shows the `/meta/app` list
31+
* as it always did. That is the server's own posture — `/me/apps` fails open
32+
* without the security plugin — and the same "cosmetic, never fail-closed"
33+
* one the console's other personal reads take. A failure other than `404`
34+
* says so once on the console.
35+
* - `pending` is true only while the FIRST read is out. Home waits on it, so a
36+
* hidden tile is never drawn and then taken away; a re-read keeps serving
37+
* the answer it replaces.
38+
*
39+
* `default_off` is not read here: it is not a hide.
40+
*
41+
* @module
42+
*/
43+
44+
import * as React from 'react';
45+
import { createContext, useContext, useEffect, useRef, useState } from 'react';
46+
import { createAuthenticatedFetch, useAuth } from '@object-ui/auth';
47+
import { useMetadata } from '../providers/MetadataProvider.js';
48+
import { filterActiveApps } from '../utils/appRoute.js';
49+
import { resolveRuntimeApiBase } from './storageUsageEndpoint.js';
50+
51+
type LauncherAppLike = { name?: unknown } & Record<string, unknown>;
52+
53+
/** One `/me/apps` answer, and the app names it speaks for. */
54+
interface LauncherAnswer {
55+
/** The app names `/me/apps` listed. */
56+
served: ReadonlySet<string>;
57+
/** The active `/meta/app` names when the read went out. */
58+
asked: ReadonlySet<string>;
59+
}
60+
61+
type LauncherAppsState =
62+
| { status: 'idle' }
63+
| { status: 'pending' }
64+
| { status: 'ready'; answer: LauncherAnswer }
65+
| { status: 'unavailable' };
66+
67+
const LauncherAppsContext = createContext<LauncherAppsState | null>(null);
68+
69+
/** The provider's state, and the user it belongs to. */
70+
interface HeldAnswer {
71+
owner: string | null;
72+
state: LauncherAppsState;
73+
}
74+
75+
const NOTHING_HELD: HeldAnswer = { owner: null, state: { status: 'idle' } };
76+
77+
/** A non-2xx answer, kept apart so `404` (route not served) reads as absence. */
78+
class LauncherAppsReadError extends Error {
79+
constructor(readonly httpStatus: number) {
80+
super(`GET /me/apps returned ${httpStatus}`);
81+
this.name = 'LauncherAppsReadError';
82+
}
83+
}
84+
85+
async function readServedAppNames(url: string, doFetch: typeof fetch): Promise<Set<string>> {
86+
const res = await doFetch(url, {
87+
method: 'GET',
88+
headers: { Accept: 'application/json' },
89+
credentials: 'include',
90+
});
91+
if (!res.ok) throw new LauncherAppsReadError(res.status);
92+
const body = (await res.json()) as { apps?: unknown } | null;
93+
if (!Array.isArray(body?.apps)) throw new Error('GET /me/apps answered without an `apps` array');
94+
const names = new Set<string>();
95+
for (const app of body.apps as Array<{ name?: unknown } | null>) {
96+
if (typeof app?.name === 'string') names.add(app.name);
97+
}
98+
return names;
99+
}
100+
101+
function activeAppNames(apps: readonly LauncherAppLike[] | null | undefined): string[] {
102+
const names = new Set<string>();
103+
for (const app of filterActiveApps(apps)) {
104+
if (typeof app?.name === 'string') names.add(app.name);
105+
}
106+
return [...names].sort();
107+
}
108+
109+
export interface LauncherAppsProviderProps {
110+
children?: React.ReactNode;
111+
/** Defaults to `{VITE_SERVER_URL}/api/v1/me/apps`. */
112+
endpoint?: string;
113+
/**
114+
* Defaults to a fresh `createAuthenticatedFetch()` per read: the console's
115+
* `/api/v1/*` lane carries a Bearer token and no session cookie.
116+
*/
117+
fetcher?: typeof fetch;
118+
}
119+
120+
/**
121+
* Holds the signed-in user's `/me/apps` answer for every launcher surface
122+
* below it. Mount it once, where Home and the apps share an ancestor — the
123+
* console mounts it beside the `/auth/me/permissions` provider.
124+
*
125+
* Reads when there is a user and an app list to narrow, and again when the
126+
* app list gains a name the held answer was not asked about.
127+
*/
128+
export function LauncherAppsProvider({ children, endpoint, fetcher }: LauncherAppsProviderProps) {
129+
const { user } = useAuth();
130+
const { apps, loading } = useMetadata();
131+
const owner = user?.id != null ? String(user.id) : null;
132+
// The effect keys on the names' VALUE, never on the list's identity.
133+
const namesKey = JSON.stringify(activeAppNames(apps as LauncherAppLike[] | undefined));
134+
135+
const [held, setHeld] = useState<HeldAnswer>(NOTHING_HELD);
136+
// The effect's reading of the current answer, without keying on it.
137+
const heldRef = useRef<HeldAnswer>(NOTHING_HELD);
138+
// Owners whose server answered `404`: the route is not served, so the same
139+
// question is not asked again for them.
140+
const notServed = useRef(new Set<string>());
141+
142+
useEffect(() => {
143+
const names = JSON.parse(namesKey) as string[];
144+
const publish = (next: HeldAnswer) => {
145+
heldRef.current = next;
146+
setHeld(next);
147+
};
148+
if (!owner || loading || names.length === 0 || notServed.current.has(owner)) return;
149+
const current = heldRef.current.owner === owner ? heldRef.current.state : null;
150+
const answer = current?.status === 'ready' ? current.answer : null;
151+
if (answer && names.every((name) => answer.asked.has(name))) return;
152+
153+
let cancelled = false;
154+
const asked = new Set(names);
155+
if (!current || current.status === 'idle') publish({ owner, state: { status: 'pending' } });
156+
const url = endpoint ?? `${resolveRuntimeApiBase()}/me/apps`;
157+
readServedAppNames(url, fetcher ?? createAuthenticatedFetch())
158+
.then((served) => {
159+
if (cancelled) return;
160+
publish({ owner, state: { status: 'ready', answer: { served, asked } } });
161+
})
162+
.catch((err: unknown) => {
163+
if (cancelled) return;
164+
if (err instanceof LauncherAppsReadError && err.httpStatus === 404) {
165+
notServed.current.add(owner);
166+
} else {
167+
console.warn(
168+
'[app-shell] Could not read the apps your permission sets show (`GET /me/apps`); ' +
169+
'the launcher lists every app you can open instead:',
170+
err,
171+
);
172+
}
173+
// A failed re-read keeps the answer it would have replaced.
174+
publish({ owner, state: answer ? { status: 'ready', answer } : { status: 'unavailable' } });
175+
});
176+
return () => {
177+
cancelled = true;
178+
};
179+
}, [owner, loading, namesKey, endpoint, fetcher]);
180+
181+
const state: LauncherAppsState = held.owner === owner ? held.state : { status: 'idle' };
182+
return <LauncherAppsContext.Provider value={state}>{children}</LauncherAppsContext.Provider>;
183+
}
184+
185+
export interface LauncherApps<T> {
186+
/** The apps to offer: `filterActiveApps(apps)`, narrowed by `/me/apps`. */
187+
apps: T[];
188+
/** The first `/me/apps` read is still out; nothing is narrowed yet. */
189+
pending: boolean;
190+
}
191+
192+
/**
193+
* The apps a launcher surface offers: `filterActiveApps(apps)`, minus every
194+
* app the user's `/me/apps` answer was asked about and did not list. Outside
195+
* a {@link LauncherAppsProvider}, or when the read is absent or failed, that
196+
* is `filterActiveApps(apps)` unchanged.
197+
*/
198+
export function useLauncherApps<T extends LauncherAppLike>(
199+
apps: readonly T[] | null | undefined,
200+
): LauncherApps<T> {
201+
const state = useContext(LauncherAppsContext);
202+
const openable = filterActiveApps(apps);
203+
if (state?.status !== 'ready') return { apps: openable, pending: state?.status === 'pending' };
204+
const { served, asked } = state.answer;
205+
return {
206+
apps: openable.filter((app) => {
207+
const name = app?.name;
208+
return typeof name !== 'string' || served.has(name) || !asked.has(name);
209+
}),
210+
pending: false,
211+
};
212+
}

‎ui/packages/app-shell/src/index.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,10 @@ export {
237237
useResponsiveSidebar,
238238
useActionModal,
239239
useHomePath,
240+
LauncherAppsProvider,
241+
useLauncherApps,
240242
} from './hooks/index.js';
241-
export type { FavoriteItem } from './hooks/index.js';
243+
export type { FavoriteItem, LauncherApps, LauncherAppsProviderProps } from './hooks/index.js';
242244

243245
// Context providers
244246
export {

‎ui/packages/app-shell/src/layout/AppSwitcher.tsx‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import { useMetadata } from '../providers/MetadataProvider.js';
3737
import { resolveKeyedI18nLabel, matchAppBySegment, appRouteSegment } from '../utils/index.js';
3838
import { useObjectTranslation, useObjectLabel } from '@object-ui/i18n';
3939
import { useHomePath } from '../hooks/useHomePath.js';
40+
import { useLauncherApps } from '../hooks/useLauncherApps.js';
4041
import { SETUP_APP_NAME, SETUP_APP_PACKAGE_ID } from '../console/ConsoleShell.js';
4142
import { GO_HOME_SHORTCUT, shortcutKeycaps } from '../chrome/advertisedShortcuts.js';
4243
import { isSingleAppSwitcherHidden } from '../runtime-config.js';
@@ -83,7 +84,12 @@ export function AppSwitcher({ activeAppName, onAppChange, designInStudioPath }:
8384
// this list is already permitted. Filtering it here would hide a builder's own
8485
// in-progress app from the builder. Pinned by
8586
// `__tests__/AppSwitcher.publishState.test.tsx`.
86-
const activeApps = apps.filter((a: any) => a.active !== false && a.hidden !== true);
87+
//
88+
// An app the user's permission sets hide (`tabPermissions: hidden`) is not
89+
// offered either: the menu offers what Home's tiles offer, narrowed by the
90+
// `/me/apps` answer (objectstack#26838). The pill below still names such an app when the user
91+
// is in it — it opens from a direct URL, so it is where they are.
92+
const { apps: activeApps } = useLauncherApps(apps);
8793
// ADR-0048 (A) — route segment may be a package id; match by it (name fallback).
8894
const activeApp = matchAppBySegment(activeApps, activeAppName) || matchAppBySegment(apps.filter((a: any) => a.active !== false), activeAppName) || activeApps[0];
8995

‎ui/packages/app-shell/src/views/app-launcher-renderer.tsx‎

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,11 @@
4040
* eagerly (`app` is in its `EAGER_TYPES`, i.e. `GET /api/v1/meta/app` on
4141
* mount). That is the SAME read the top-bar `AppSwitcher` and the Home page
4242
* make, and the openable-apps filter is the shared `filterActiveApps` helper
43-
* rather than a second copy of the `active`/`hidden` rule. This is the ruling's
44-
* "no external data-source dependency" claim, discharged: the block issues no
45-
* request of its own and reaches no adapter.
43+
* rather than a second copy of the `active`/`hidden` rule, narrowed by
44+
* `useLauncherApps` — the user's `/me/apps` answer, which the console's one
45+
* `LauncherAppsProvider` reads for Home, the switcher and this block alike.
46+
* This is the ruling's "no external data-source dependency" claim, discharged:
47+
* the block issues no request of its own and reaches no adapter.
4648
*
4749
* The grid itself is `HomeAppsStrip` — the console's existing launcher, already
4850
* the answer to "how does this product draw a wall of apps" — so an authored
@@ -82,13 +84,12 @@
8284
*/
8385

8486
import * as React from 'react';
85-
import { useMemo } from 'react';
8687
import { ComponentRegistry } from '@object-ui/core';
8788
import { useMetadata } from '@object-ui/react';
8889
import { useObjectTranslation } from '@object-ui/i18n';
8990
import { HomeAppsStrip } from '../console/home/HomeAppsStrip.js';
9091
import { useFavorites } from '../hooks/useFavorites.js';
91-
import { filterActiveApps } from '../utils/index.js';
92+
import { useLauncherApps } from '../hooks/useLauncherApps.js';
9293

9394
/** Keep the designer's own data attributes on the wrapper, drop the rest. */
9495
const splitDesigner = (props: Record<string, any>) => {
@@ -113,8 +114,9 @@ export const AppLauncherRenderer: React.FC<AppLauncherRendererProps> = ({
113114

114115
// The openable set, through the SHARED predicate — `active !== false &&
115116
// hidden !== true`. Two copies of "an app the user can open" is precisely
116-
// the dialect `filterActiveApps` exists to prevent.
117-
const openable = useMemo(() => filterActiveApps(apps as any[]), [apps]);
117+
// the dialect `filterActiveApps` exists to prevent. Narrowed, as Home's own
118+
// tiles are, by the user's `/me/apps` answer (objectstack#26838).
119+
const { apps: openable } = useLauncherApps(apps as any[]);
118120

119121
return (
120122
<nav

0 commit comments

Comments
 (0)