Skip to content

Commit d258167

Browse files
hotlongCopilot
andcommitted
feat(console): land on cloud_control when control-plane App is present (PR-C)
Replace stock app-shell RootRedirect (always /home) with CloudAwareRootRedirect, which inspects the loaded metadata and: - prefers /apps/cloud_control when that App is registered (apps/cloud's control-plane experience) - otherwise falls back to /home (apps/objectos and other hosts) This keeps a single Console bundle shared across both control plane and per-project runtime — no VITE env var baked in — and gives apps/cloud users a one-click landing on the Cloud Control App right after login. Verified end-to-end: GET / -> /_console/ -> AuthGuard -> /_account/login -> session cookie -> /_console/apps/cloud_control/dashboard/system_overview Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 576bbe5 commit d258167

2 files changed

Lines changed: 41 additions & 2 deletions

File tree

apps/console/src/App.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import {
1515
ConsoleShell,
1616
ConnectedShell,
1717
RequireOrganization,
18-
RootRedirect,
1918
SystemRedirect,
2019
LoadingFallback,
2120
DefaultHomeLayout,
@@ -25,6 +24,7 @@ import {
2524
DefaultAppContent,
2625
} from '@object-ui/app-shell';
2726
import { AccountLoginRedirect } from './components/AccountLoginRedirect';
27+
import { CloudAwareRootRedirect } from './components/CloudAwareRootRedirect';
2828
import {
2929
gotoAccountLogin,
3030
gotoAccountRegister,
@@ -106,7 +106,7 @@ export function App() {
106106
<DefaultAppContent />
107107
</ProtectedRoute>
108108
} />
109-
<Route path="/" element={<ConnectedShell><RootRedirect /></ConnectedShell>} />
109+
<Route path="/" element={<ConnectedShell><CloudAwareRootRedirect /></ConnectedShell>} />
110110
<Route path="*" element={<Navigate to="/" replace />} />
111111
</Routes>
112112
</ConsoleShell>
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.
2+
3+
/**
4+
* CloudAwareRootRedirect — element for `<Route path="/" />`.
5+
*
6+
* Replaces app-shell's stock `RootRedirect` (which always sends to
7+
* `/home`). The same Console bundle is served by both apps/cloud
8+
* (control plane) and apps/objectos (per-project runtime); we want
9+
* each to land on the most useful App for that host without baking
10+
* a Vite env var into the build.
11+
*
12+
* Strategy: inspect the loaded metadata `apps` list and prefer a
13+
* cloud-control App when present (apps/cloud). Otherwise fall back
14+
* to `/home`, preserving the legacy behaviour for apps/objectos.
15+
*
16+
* Preference order:
17+
* 1. `cloud_control` — apps/cloud's control plane App
18+
* 2. `setup` — apps/cloud second-best fallback
19+
* 3. `/home` — original RootRedirect behaviour
20+
*/
21+
22+
import { Navigate } from 'react-router-dom';
23+
import { useMetadata, LoadingFallback } from '@object-ui/app-shell';
24+
25+
const PREFERRED_APPS = ['cloud_control'];
26+
27+
export function CloudAwareRootRedirect() {
28+
const { apps, loading } = useMetadata();
29+
if (loading) return <LoadingFallback />;
30+
31+
const appNames = new Set((apps ?? []).map((a: any) => a?.name).filter(Boolean));
32+
for (const candidate of PREFERRED_APPS) {
33+
if (appNames.has(candidate)) {
34+
return <Navigate to={`/apps/${candidate}`} replace />;
35+
}
36+
}
37+
38+
return <Navigate to="/home" replace />;
39+
}

0 commit comments

Comments
 (0)