Skip to content

Commit b8a5d41

Browse files
xuyushun441-sysos-zhuangclaude
authored
fix(routing): sweep remaining app-entry links onto package-id segment (ADR-0048) (#1719)
Follow-up to the home-page fix (#1717): - AppManagementPage "Open app" button opens /apps/<packageId> (app._packageId ?? app.name), not /apps/<name>. - AppContent current-app sub-routes/redirects (metadata/package redirect, record-form baseUrl) build against the URL's own appName segment instead of activeApp.name, so a /apps/<packageId>/ URL keeps its segment. requestedAppMissing uses matchAppBySegment so a package-id URL isn't flagged as a missing app. Verified in the browser: System > Apps > Open Showcase > /apps/com.example.showcase/showcase_project (app loads). Co-authored-by: Jack Zhuang <277994282+os-zhuang@users.noreply.github.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 94ef99e commit b8a5d41

3 files changed

Lines changed: 29 additions & 7 deletions

File tree

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
"@object-ui/app-shell": patch
3+
"@object-ui/console": patch
4+
---
5+
6+
ADR-0048: finish sweeping app-entry links onto the canonical package-id route
7+
segment (follow-up to the home-page fix).
8+
9+
- `AppManagementPage` (System → Apps) "Open app" button now opens
10+
`/apps/<packageId>` (`app._packageId ?? app.name`) instead of `/apps/<name>`.
11+
- `AppContent` current-app sub-routes/redirects (the `metadata/package`
12+
`component/developer/packages` redirect, and the record-form `baseUrl`) now
13+
build against the URL's own `appName` segment instead of `activeApp.name`, so a
14+
`/apps/<packageId>/…` URL keeps its package-id segment instead of flipping to
15+
the name form. `requestedAppMissing` (preview-drafts) now resolves the segment
16+
via `matchAppBySegment` so a package-id URL isn't treated as a missing app.

apps/console/src/pages/system/AppManagementPage.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,9 @@ export function AppManagementPage() {
226226
size="icon"
227227
title="Open app"
228228
aria-label={`Open ${app.label || app.name}`}
229-
onClick={() => navigate(`/apps/${app.name}`)}
229+
// ADR-0048 — open via the canonical package-id route segment
230+
// (falls back to name for runtime apps without a package id).
231+
onClick={() => navigate(`/apps/${app._packageId ?? app.name}`)}
230232
>
231233
<ExternalLink className="h-4 w-4" />
232234
</Button>

packages/app-shell/src/console/AppContent.tsx

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -184,18 +184,22 @@ export function AppContent({ extraRoutes, extraRoutesNoApp }: AppContentProps =
184184
// silently preview the WRONG app; treat the request as "not ready" instead
185185
// and let the preview-specific empty state below say so.
186186
const requestedAppMissing =
187-
previewDrafts && !!appName && !apps.some((a: any) => a.name === appName);
187+
previewDrafts && !!appName && !matchAppBySegment(apps, appName);
188188

189189
useEffect(() => {
190190
if (!activeApp?.name) return;
191-
const packageMetadataPath = `/apps/${activeApp.name}/metadata/package`;
191+
// ADR-0048 — build against the URL's own segment (`appName`, which may be the
192+
// package id) so the match works and the redirect keeps the same segment;
193+
// `activeApp.name` would flip a `/apps/<packageId>/…` URL to the name form.
194+
const seg = appName ?? activeApp.name;
195+
const packageMetadataPath = `/apps/${seg}/metadata/package`;
192196
if (
193197
location.pathname === packageMetadataPath ||
194198
location.pathname.startsWith(`${packageMetadataPath}/`)
195199
) {
196-
navigate(`/apps/${activeApp.name}/component/developer/packages`, { replace: true });
200+
navigate(`/apps/${seg}/component/developer/packages`, { replace: true });
197201
}
198-
}, [activeApp?.name, location.pathname, navigate]);
202+
}, [activeApp?.name, appName, location.pathname, navigate]);
199203

200204
const [isDialogOpen, setIsDialogOpen] = useState(false);
201205
const [editingRecord, setEditingRecord] = useState<any>(null);
@@ -331,7 +335,7 @@ export function AppContent({ extraRoutes, extraRoutesNoApp }: AppContentProps =
331335
// preserved for any object without the flag.
332336
const target = resolveRecordFormTarget({
333337
objectDef: currentObjectDef as any,
334-
baseUrl: activeApp?.name ? `/apps/${activeApp.name}` : '',
338+
baseUrl: appName ? `/apps/${appName}` : (activeApp?.name ? `/apps/${activeApp.name}` : ''),
335339
record,
336340
});
337341
if (target.kind === 'page') {
@@ -470,7 +474,7 @@ export function AppContent({ extraRoutes, extraRoutesNoApp }: AppContentProps =
470474
score 16; declaration order breaks the tie). */}
471475
<Route
472476
path="metadata/package/*"
473-
element={<Navigate to={`/apps/${activeApp.name}/component/developer/packages`} replace />}
477+
element={<Navigate to={`/apps/${appName ?? activeApp.name}/component/developer/packages`} replace />}
474478
/>
475479
<Route path="metadata">
476480
<Route index element={<MetadataDirectoryPage />} />

0 commit comments

Comments
 (0)